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 {
400400
401401 showChatbotAlert ( level , message ) {
402402 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+ }
407410 }
408411
409412 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 55pub mod checkbox;
66pub use checkbox:: Checkbox ;
77
8+ // src/components/inputs/labels
9+ pub mod labels;
10+
811// src/components/inputs/radio
912pub mod radio;
1013pub use radio:: Radio ;
Original file line number Diff line number Diff line change 11div [data-controller = " inputs-text-input" ] {
22 --bs-danger : #{$peach-shade-100 } ;
33
4- span .material-symbols-outlined {
4+ span .inputs-text-input-icon {
55 margin-left : -40px ;
66 color : #{$slate-shade-100 } ;
77
Original file line number Diff line number Diff line change 2626
2727 < % if let Some(icon) = icon { %>
2828 < span
29- class ="<%= icon_classes %> "
29+ class ="<%= icon_classes %> inputs-text-input-icon "
3030 data-action ="<%= icon_actions %> ">
3131 < %= icon %>
3232 </ span >
Original file line number Diff line number Diff line change 88< % use crate::components::inputs::select::{Select, Option}; %>
99< % use crate::components::inputs::{SwitchV2, Radio, Checkbox}; %>
1010< % use crate::components::cards::{Rgb, Secondary, Primary}; %>
11+ < % use crate::components::inputs::labels::WithTooltip; %>
1112
1213< div class ="container " data-controller ="pages-demo ">
1314 < div class ="py-5 ">
5960 </ div >
6061
6162 < div class ="py-5 ">
63+ < %
64+ let label = WithTooltip::new("Name".into())
65+ .tooltip("Your full name.")
66+ .icon("info");
67+ %>
68+
6269 < %+ Input::new()
63- .label("What is your name?" .into())
70+ .label(label .into())
6471 .icon("person")
6572 .placeholder("Enter your name")
6673 .name("name")
201208 </ div >
202209 </ div >
203210 </ 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 >
204223</ div >
Original file line number Diff line number Diff line change 2121@import " ../../src/components/icons/checkmark/checkmark.scss" ;
2222@import " ../../src/components/icons/twitter/twitter.scss" ;
2323@import " ../../src/components/inputs/checkbox/checkbox.scss" ;
24+ @import " ../../src/components/inputs/labels/with_tooltip/with_tooltip.scss" ;
2425@import " ../../src/components/inputs/radio/radio.scss" ;
2526@import " ../../src/components/inputs/range_group/range_group.scss" ;
2627@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