@@ -431,6 +431,14 @@ def create(cls, *children, **props) -> Component:
431431 return super ().create (tag = "chevron_down" , class_name = cls_name , ** props )
432432
433433
434+ SLIDE_DOWN = Var (
435+ r'keyframes({ from: { height: 0 }, to: { height: "var(--radix-accordion-content-height)" } })'
436+ )
437+ SLIDE_UP = Var (
438+ r'keyframes({ from: { height: "var(--radix-accordion-content-height)" }, to: { height: 0 } })'
439+ )
440+
441+
434442class AccordionContent (AccordionComponent ):
435443 """An accordion component."""
436444
@@ -464,44 +472,17 @@ def create(cls, *children, **props) -> Component:
464472
465473 return super ().create (* children , class_name = cls_name , ** props )
466474
467- def add_custom_code (self ) -> list [str ]:
468- """Add custom code to the component.
469-
470- Returns:
471- The custom code of the component.
472- """
473- return [
474- """
475- const slideDown = keyframes`
476- from {
477- height: 0;
478- }
479- to {
480- height: var(--radix-accordion-content-height);
481- }
482- `
483- const slideUp = keyframes`
484- from {
485- height: var(--radix-accordion-content-height);
486- }
487- to {
488- height: 0;
489- }
490- `
491- """
492- ]
493-
494475 def add_style (self ) -> dict [str , Any ] | None :
495476 """Add style to the component.
496477
497478 Returns:
498479 The style of the component.
499480 """
500- slide_down = Var ( "slideDown" ) .to (str ) + Var .create (
481+ slide_down = SLIDE_DOWN .to (str ) + Var .create (
501482 " var(--animation-duration) var(--animation-easing)" ,
502483 )
503484
504- slide_up = Var ( "slideUp" ) .to (str ) + Var .create (
485+ slide_up = SLIDE_UP .to (str ) + Var .create (
505486 " var(--animation-duration) var(--animation-easing)" ,
506487 )
507488
0 commit comments