File tree Expand file tree Collapse file tree 13 files changed +124
-18
lines changed Expand file tree Collapse file tree 13 files changed +124
-18
lines changed Original file line number Diff line number Diff line change @@ -400,10 +400,13 @@ export default class extends Controller {
400
400
401
401
showChatbotAlert ( level , message ) {
402
402
const toastElement = createToast ( message , level ) ;
403
- showToast ( toastElement , {
404
- autohide : true ,
405
- delay : 7000 ,
406
- } ) ;
403
+
404
+ if ( toastElement ) {
405
+ showToast ( toastElement , {
406
+ autohide : true ,
407
+ delay : 7000 ,
408
+ } ) ;
409
+ }
407
410
}
408
411
409
412
hideExampleQuestions ( ) {
Original file line number Diff line number Diff line change
1
+ // This file is automatically generated.
2
+ // You shouldn't modify it manually.
3
+
4
+ // src/components/inputs/labels/with_tooltip
5
+ pub mod with_tooltip;
6
+ pub use with_tooltip:: WithTooltip ;
Original file line number Diff line number Diff line change
1
+ use pgml_components:: { component, Component } ;
2
+ use sailfish:: TemplateOnce ;
3
+
4
+ #[ derive( TemplateOnce , Default ) ]
5
+ #[ template( path = "inputs/labels/with_tooltip/template.html" ) ]
6
+ pub struct WithTooltip {
7
+ component : Component ,
8
+ tooltip : String ,
9
+ icon : String ,
10
+ html : bool ,
11
+ }
12
+
13
+ impl WithTooltip {
14
+ pub fn new ( component : Component ) -> WithTooltip {
15
+ WithTooltip {
16
+ component,
17
+ tooltip : String :: new ( ) ,
18
+ icon : "info" . to_string ( ) ,
19
+ html : false ,
20
+ }
21
+ }
22
+
23
+ pub fn tooltip ( mut self , tooltip : impl ToString ) -> Self {
24
+ self . tooltip = tooltip. to_string ( ) ;
25
+ self
26
+ }
27
+
28
+ pub fn tooltip_text ( self , tooltip : impl ToString ) -> Self {
29
+ self . tooltip ( tooltip)
30
+ }
31
+
32
+ pub fn tooltip_html ( mut self , tooltip : impl ToString ) -> Self {
33
+ self . tooltip = tooltip. to_string ( ) ;
34
+ self . html = true ;
35
+ self
36
+ }
37
+
38
+ pub fn icon ( mut self , icon : impl ToString ) -> Self {
39
+ self . icon = icon. to_string ( ) ;
40
+ self
41
+ }
42
+ }
43
+
44
+ component ! ( WithTooltip ) ;
Original file line number Diff line number Diff line change
1
+ < span
2
+ data-controller ="inputs-labels-with-tooltip enable-tooltip "
3
+ class ="d-inline-flex gap-1 align-items-top "
4
+ >
5
+ < span > < %+ component %> </ span >
6
+ < span
7
+ data-bs-toggle ="tooltip "
8
+ data-bs-placement ="right "
9
+ data-bs-title ="<%- tooltip %> "
10
+ data-bs-html ="<%= html %> "
11
+ class ="material-symbols-outlined fw-bold "
12
+ >
13
+ < %= icon %>
14
+ </ span >
15
+ </ span >
Original file line number Diff line number Diff line change
1
+ span [data-controller = " inputs-labels-with-tooltip enable-tooltip" ] {
2
+ span [data-bs-toggle = " tooltip" ] {
3
+ color : #{$slate-tint-100 } ;
4
+ font-size : 1.2rem ;
5
+ }
6
+ }
Original file line number Diff line number Diff line change 5
5
pub mod checkbox;
6
6
pub use checkbox:: Checkbox ;
7
7
8
+ // src/components/inputs/labels
9
+ pub mod labels;
10
+
8
11
// src/components/inputs/radio
9
12
pub mod radio;
10
13
pub use radio:: Radio ;
Original file line number Diff line number Diff line change 1
1
div [data-controller = " inputs-text-input" ] {
2
2
--bs-danger : #{$peach-shade-100 } ;
3
3
4
- span .material-symbols-outlined {
4
+ span .inputs-text-input-icon {
5
5
margin-left : -40px ;
6
6
color : #{$slate-shade-100 } ;
7
7
Original file line number Diff line number Diff line change 26
26
27
27
< % if let Some(icon) = icon { %>
28
28
< span
29
- class ="<%= icon_classes %> "
29
+ class ="<%= icon_classes %> inputs-text-input-icon "
30
30
data-action ="<%= icon_actions %> ">
31
31
< %= icon %>
32
32
</ span >
Original file line number Diff line number Diff line change 8
8
< % use crate::components::inputs::select::{Select, Option}; %>
9
9
< % use crate::components::inputs::{SwitchV2, Radio, Checkbox}; %>
10
10
< % use crate::components::cards::{Rgb, Secondary, Primary}; %>
11
+ < % use crate::components::inputs::labels::WithTooltip; %>
11
12
12
13
< div class ="container " data-controller ="pages-demo ">
13
14
< div class ="py-5 ">
59
60
</ div >
60
61
61
62
< div class ="py-5 ">
63
+ < %
64
+ let label = WithTooltip::new("Name".into())
65
+ .tooltip("Your full name.")
66
+ .icon("info");
67
+ %>
68
+
62
69
< %+ Input::new()
63
- .label("What is your name?" .into())
70
+ .label(label .into())
64
71
.icon("person")
65
72
.placeholder("Enter your name")
66
73
.name("name")
201
208
</ div >
202
209
</ div >
203
210
</ div >
211
+
212
+ < div class ="py-5 ">
213
+ < %+ WithTooltip::new("Model".into())
214
+ .tooltip("A model is great, but two is better.")
215
+ .icon("help_outline") %>
216
+ </ div >
217
+
218
+ < div class ="py-5 ">
219
+ < %+ WithTooltip::new("Model".into())
220
+ .tooltip_html("A model is great< br > , but< br > two< br > is better.")
221
+ .icon("help_outline") %>
222
+ </ div >
204
223
</ div >
Original file line number Diff line number Diff line change 21
21
@import " ../../src/components/icons/checkmark/checkmark.scss" ;
22
22
@import " ../../src/components/icons/twitter/twitter.scss" ;
23
23
@import " ../../src/components/inputs/checkbox/checkbox.scss" ;
24
+ @import " ../../src/components/inputs/labels/with_tooltip/with_tooltip.scss" ;
24
25
@import " ../../src/components/inputs/radio/radio.scss" ;
25
26
@import " ../../src/components/inputs/range_group/range_group.scss" ;
26
27
@import " ../../src/components/inputs/range_group_v_2/range_group_v_2.scss" ;
You can’t perform that action at this time.
0 commit comments