11use pgml_components:: { component, Component } ;
22use sailfish:: TemplateOnce ;
33
4+ use crate :: components:: stimulus:: StimulusAction ;
5+ use crate :: types:: CustomOption ;
6+
47#[ derive( TemplateOnce ) ]
58#[ template( path ="cards/rgb/template.html" ) ]
69pub struct Rgb {
710value : Component ,
8- active : bool ,
911link : Option < String > ,
12+ link_action : CustomOption < StimulusAction > ,
13+ controller_classes : Vec < String > ,
14+ card_classes : Vec < String > ,
15+ body_classes : Vec < String > ,
1016}
1117
1218impl Default for Rgb {
@@ -19,20 +25,44 @@ impl Rgb {
1925pub fn new ( value : Component ) ->Rgb {
2026Rgb {
2127 value,
22- active : false ,
2328link : None ,
29+ link_action : CustomOption :: default ( ) ,
30+ controller_classes : vec ! [ ] ,
31+ card_classes : vec ! [ ] ,
32+ body_classes : vec ! [ ] ,
2433}
2534}
2635
2736pub fn active ( mut self ) ->Self {
28- self . active =true ;
37+ self . card_classes . push ( "active" . into ( ) ) ;
38+ self . card_classes . push ( "main-gradient-border-card-1" . into ( ) ) ;
39+ self
40+ }
41+
42+ pub fn is_active ( mut self , active : bool ) ->Self {
43+ if active{
44+ self . card_classes . push ( "active" . into ( ) ) ;
45+ self . card_classes . push ( "main-gradient-border-card-1" . into ( ) ) ;
46+ }
47+
2948self
3049}
3150
3251pub fn link ( mut self , link : & str ) ->Self {
3352self . link =Some ( link. to_string ( ) ) ;
3453self
3554}
55+
56+ pub fn link_action ( mut self , action : StimulusAction ) ->Self {
57+ self . link_action = action. into ( ) ;
58+ self
59+ }
60+
61+ pub fn h_100 ( mut self ) ->Self {
62+ self . controller_classes . push ( "h-100" . into ( ) ) ;
63+ self . card_classes . push ( "h-100" . into ( ) ) ;
64+ self
65+ }
3666}
3767
3868component ! ( Rgb ) ;