File tree Expand file tree Collapse file tree 11 files changed +68
-1
lines changed
apps/builder/app/builder/features/style-panel Expand file tree Collapse file tree 11 files changed +68
-1
lines changed Original file line number Diff line number Diff line change @@ -27,6 +27,9 @@ export const ColorControl = ({ property }: { property: StyleProperty }) => {
2727 onChange = { ( styleValue ) => setValue ( styleValue , { isEphemeral : true } ) }
2828 onChangeComplete = { setValue }
2929 onAbort = { ( ) => deleteProperty ( property , { isEphemeral : true } ) }
30+ onReset = { ( ) => {
31+ deleteProperty ( property ) ;
32+ } }
3033 />
3134 ) ;
3235} ;
Original file line number Diff line number Diff line change @@ -55,6 +55,10 @@ export const TextControl = ({ property }: { property: StyleProperty }) => {
5555 onAbort = { ( ) => {
5656 deleteProperty ( property , { isEphemeral : true } ) ;
5757 } }
58+ onReset = { ( ) => {
59+ setIntermediateValue ( undefined ) ;
60+ deleteProperty ( property ) ;
61+ } }
5862 />
5963 ) ;
6064} ;
Original file line number Diff line number Diff line change @@ -84,6 +84,13 @@ export const BorderColor = () => {
8484 }
8585 batch . publish ( { isEphemeral : true } ) ;
8686 } }
87+ onReset = { ( ) => {
88+ const batch = createBatchUpdate ( ) ;
89+ for ( const property of properties ) {
90+ batch . deleteProperty ( property ) ;
91+ }
92+ batch . publish ( ) ;
93+ } }
8794 />
8895 </ div >
8996 </ PropertyValueTooltip >
Original file line number Diff line number Diff line change @@ -183,6 +183,10 @@ const GapInput = ({
183183 onAbort = { ( ) => {
184184 onPreviewChange ( ) ;
185185 } }
186+ onReset = { ( ) => {
187+ onIntermediateChange ( undefined ) ;
188+ onReset ( ) ;
189+ } }
186190 />
187191 </ Box >
188192 ) ;
Original file line number Diff line number Diff line change @@ -77,8 +77,8 @@ const Input = ({
7777 batch . publish ( { isEphemeral : true } ) ;
7878 } }
7979 onChangeComplete = { ( { value } ) => {
80- const batch = createBatchUpdate ( ) ;
8180 setIntermediateValue ( undefined ) ;
81+ const batch = createBatchUpdate ( ) ;
8282 for ( const property of activeProperties ) {
8383 batch . setProperty ( property ) ( value ) ;
8484 }
@@ -90,6 +90,15 @@ const Input = ({
9090 batch . deleteProperty ( property ) ;
9191 batch . publish ( { isEphemeral : true } ) ;
9292 } }
93+ onReset = { ( ) => {
94+ setIntermediateValue ( undefined ) ;
95+ const batch = createBatchUpdate ( ) ;
96+ for ( const property of activeProperties ) {
97+ batch . deleteProperty ( property ) ;
98+ }
99+ batch . publish ( ) ;
100+ onClosePopover ( ) ;
101+ } }
93102 />
94103 ) ;
95104} ;
Original file line number Diff line number Diff line change @@ -127,6 +127,9 @@ export const ScalePanelContent = () => {
127127 }
128128 } }
129129 onAbort = { ( ) => deleteProperty ( property , { isEphemeral : true } ) }
130+ onReset = { ( ) => {
131+ deleteProperty ( property ) ;
132+ } }
130133 />
131134 </ Grid >
132135 < Grid
@@ -168,6 +171,9 @@ export const ScalePanelContent = () => {
168171 }
169172 } }
170173 onAbort = { ( ) => deleteProperty ( property , { isEphemeral : true } ) }
174+ onReset = { ( ) => {
175+ deleteProperty ( property ) ;
176+ } }
171177 />
172178 </ Grid >
173179 < Grid
@@ -205,6 +211,9 @@ export const ScalePanelContent = () => {
205211 }
206212 } }
207213 onAbort = { ( ) => deleteProperty ( property , { isEphemeral : true } ) }
214+ onReset = { ( ) => {
215+ deleteProperty ( property ) ;
216+ } }
208217 />
209218 </ Grid >
210219 </ Flex >
Original file line number Diff line number Diff line change @@ -169,6 +169,7 @@ const ColorPickerPopoverContent = ({
169169type ColorPickerProps = {
170170 onChange : ( value : StyleValue ) => void ;
171171 onChangeComplete : ( value : StyleValue ) => void ;
172+ onReset : ( ) => void ;
172173 onAbort : ( ) => void ;
173174 value : StyleValue ;
174175 currentColor : StyleValue ;
@@ -243,6 +244,7 @@ export const ColorPicker = ({
243244 onChange,
244245 onChangeComplete,
245246 onAbort,
247+ onReset,
246248} : ColorPickerProps ) => {
247249 const [ intermediateValue , setIntermediateValue ] = useState <
248250 StyleValue | IntermediateStyleValue
@@ -326,6 +328,10 @@ export const ColorPicker = ({
326328 onChange ( invalidValue ) ;
327329 } }
328330 onAbort = { onAbort }
331+ onReset = { ( ) => {
332+ setIntermediateValue ( undefined ) ;
333+ onReset ( ) ;
334+ } }
329335 />
330336 ) ;
331337} ;
Original file line number Diff line number Diff line change @@ -11,6 +11,7 @@ type CssValueInputContainerProps = {
1111 | "onChange"
1212 | "onHighlight"
1313 | "onChangeComplete"
14+ | "onReset"
1415 | "onAbort"
1516 | "intermediateValue"
1617> ;
@@ -56,6 +57,9 @@ export const CssValueInputContainer = ({
5657 onAbort = { ( ) => {
5758 deleteProperty ( property , { isEphemeral : true } ) ;
5859 } }
60+ onReset = { ( ) => {
61+ deleteProperty ( property ) ;
62+ } }
5963 />
6064 ) ;
6165} ;
Original file line number Diff line number Diff line change @@ -47,6 +47,9 @@ export const WithKeywords = () => {
4747 onAbort = { ( ) => {
4848 action ( "onAbort" ) ( ) ;
4949 } }
50+ onReset = { ( ) => {
51+ action ( "onReset" ) ( ) ;
52+ } }
5053 />
5154 ) ;
5255} ;
@@ -91,6 +94,9 @@ export const WithIcons = () => {
9194 onAbort = { ( ) => {
9295 action ( "onAbort" ) ( ) ;
9396 } }
97+ onReset = { ( ) => {
98+ action ( "onReset" ) ( ) ;
99+ } }
94100 />
95101 ) ;
96102} ;
@@ -134,6 +140,9 @@ export const WithUnits = () => {
134140 onAbort = { ( ) => {
135141 action ( "onAbort" ) ( ) ;
136142 } }
143+ onReset = { ( ) => {
144+ action ( "onReset" ) ( ) ;
145+ } }
137146 />
138147 < InputField
139148 readOnly
Original file line number Diff line number Diff line change @@ -267,6 +267,7 @@ type CssValueInputProps = Pick<
267267 onChangeComplete : ( event : ChangeCompleteEvent ) => void ;
268268 onHighlight : ( value : StyleValue | undefined ) => void ;
269269 onAbort : ( ) => void ;
270+ onReset : ( ) => void ;
270271 icon ?: ReactNode ;
271272 showSuffix ?: boolean ;
272273} ;
@@ -337,6 +338,7 @@ export const CssValueInput = ({
337338 getOptions = ( ) => [ ] ,
338339 onHighlight,
339340 onAbort,
341+ onReset,
340342 disabled,
341343 [ "aria-disabled" ] : ariaDisabled ,
342344 fieldSizing,
@@ -376,6 +378,13 @@ export const CssValueInput = ({
376378 const { value } = event ;
377379 const defaultProps = { altKey : false , shiftKey : false } ;
378380
381+ // We are resetting by setting the value to an empty string
382+ if ( value . type === "intermediate" && value . value === "" ) {
383+ closeMenu ( ) ;
384+ onReset ( ) ;
385+ return ;
386+ }
387+
379388 if ( value . type !== "intermediate" && value . type !== "invalid" ) {
380389 // The value might be valid but not selected from the combo menu. Close the menu.
381390 closeMenu ( ) ;
You can’t perform that action at this time.
0 commit comments