11import { useState , useMemo } from "react" ;
22import {
33 theme ,
4- IconButton ,
54 DropdownMenu ,
65 DropdownMenuTrigger ,
76 DropdownMenuContent ,
@@ -12,7 +11,6 @@ import {
1211 SmallToggleButton ,
1312 SmallIconButton ,
1413 Box ,
15- Text ,
1614 Label ,
1715 Grid ,
1816 useSortable ,
@@ -21,6 +19,9 @@ import {
2119 InputField ,
2220 DialogTitle ,
2321 Tooltip ,
22+ SectionTitleButton ,
23+ SectionTitle ,
24+ SectionTitleLabel ,
2425} from "@webstudio-is/design-system" ;
2526import {
2627 EyeClosedIcon ,
@@ -37,6 +38,7 @@ import { newScrollAnimations } from "./new-scroll-animations";
3738import { newViewAnimations } from "./new-view-animations" ;
3839import { useIds } from "~/shared/form-utils" ;
3940import { AnimationPanelContent } from "./animation-panel-content" ;
41+ import { CollapsibleSectionRoot } from "~/builder/shared/collapsible-section" ;
4042
4143const newAnimationsPerType : {
4244 scroll : ScrollAnimation [ ] ;
@@ -93,66 +95,76 @@ export const AnimationsSelect = ({
9395 } ;
9496
9597 return (
96- < Grid gap = { 1 } align = { "center" } css = { { gridTemplateColumns : "1fr auto" } } >
97- < Label htmlFor = { fieldIds . addAnimation } >
98- < Text variant = { "titles" } > Animations</ Text >
99- </ Label >
100-
101- < DropdownMenu >
102- < DropdownMenuTrigger asChild >
103- < IconButton id = { fieldIds . addAnimation } >
104- < PlusIcon />
105- </ IconButton >
106- </ DropdownMenuTrigger >
107- < DropdownMenuContent
108- sideOffset = { Number . parseFloat ( rawTheme . spacing [ 5 ] ) }
109- css = { { width : theme . spacing [ 25 ] } }
110- >
111- { newAnimations . map ( ( animation , index ) => (
112- < DropdownMenuItem
113- key = { index }
114- onSelect = { ( ) => {
115- handleChange (
116- {
117- ...value ,
118- animations : value . animations . concat ( animation ) ,
119- } ,
120- false
121- ) ;
122- } }
123- onFocus = { ( ) => setNewAnimationHint ( animation . description ) }
124- onBlur = { ( ) => setNewAnimationHint ( undefined ) }
125- >
126- { animation . name }
127- </ DropdownMenuItem >
128- ) ) }
98+ < CollapsibleSectionRoot
99+ isOpen
100+ fullWidth
101+ trigger = {
102+ < SectionTitle
103+ collapsible = { false }
104+ suffix = {
105+ < DropdownMenu >
106+ < DropdownMenuTrigger asChild >
107+ < SectionTitleButton
108+ prefix = { < PlusIcon /> }
109+ tabIndex = { 0 }
110+ id = { fieldIds . addAnimation }
111+ />
112+ </ DropdownMenuTrigger >
113+ < DropdownMenuContent
114+ sideOffset = { Number . parseFloat ( rawTheme . spacing [ 5 ] ) }
115+ css = { { width : theme . spacing [ 25 ] } }
116+ >
117+ { newAnimations . map ( ( animation , index ) => (
118+ < DropdownMenuItem
119+ key = { index }
120+ onSelect = { ( ) => {
121+ handleChange (
122+ {
123+ ...value ,
124+ animations : value . animations . concat ( animation ) ,
125+ } ,
126+ false
127+ ) ;
128+ } }
129+ onFocus = { ( ) => setNewAnimationHint ( animation . description ) }
130+ onBlur = { ( ) => setNewAnimationHint ( undefined ) }
131+ >
132+ { animation . name }
133+ </ DropdownMenuItem >
134+ ) ) }
129135
130- < DropdownMenuSeparator />
136+ < DropdownMenuSeparator />
131137
132- < DropdownMenuItem css = { { display : "grid" } } hint >
133- { newAnimations . map ( ( { description } , index ) => (
134- < Box
135- css = { {
136- gridColumn : "1" ,
137- gridRow : "1" ,
138- visibility : "hidden" ,
139- } }
140- key = { index }
141- >
142- { description }
143- </ Box >
144- ) ) }
145- < Box
146- css = { {
147- gridColumn : "1" ,
148- gridRow : "1" ,
149- } }
150- >
151- { newAnimationHint ?? "Add new or select existing animation" }
152- </ Box >
153- </ DropdownMenuItem >
154- </ DropdownMenuContent >
155- </ DropdownMenu >
138+ < DropdownMenuItem css = { { display : "grid" } } hint >
139+ { newAnimations . map ( ( { description } , index ) => (
140+ < Box
141+ css = { {
142+ gridColumn : "1" ,
143+ gridRow : "1" ,
144+ visibility : "hidden" ,
145+ } }
146+ key = { index }
147+ >
148+ { description }
149+ </ Box >
150+ ) ) }
151+ < Box
152+ css = { {
153+ gridColumn : "1" ,
154+ gridRow : "1" ,
155+ } }
156+ >
157+ { newAnimationHint ?? "Add new or select existing animation" }
158+ </ Box >
159+ </ DropdownMenuItem >
160+ </ DropdownMenuContent >
161+ </ DropdownMenu >
162+ }
163+ >
164+ < SectionTitleLabel > Animations</ SectionTitleLabel >
165+ </ SectionTitle >
166+ }
167+ >
156168 < CssValueListArrowFocus dragItemId = { dragItemId } >
157169 < Grid gap = { 1 } css = { { gridColumn : "span 2" } } ref = { sortableRefCallback } >
158170 { value . animations . map ( ( animation , index ) => {
@@ -286,6 +298,6 @@ export const AnimationsSelect = ({
286298 { placementIndicator }
287299 </ Grid >
288300 </ CssValueListArrowFocus >
289- </ Grid >
301+ </ CollapsibleSectionRoot >
290302 ) ;
291303} ;
0 commit comments