@@ -598,17 +598,75 @@ export const RenameCssVariableDialog = ({
598598 ) ;
599599} ;
600600
601- export const DeleteUnusedCssVariablesDialog = ( ) => {
602- const open = useStore ( $isDeleteUnusedCssVariablesDialogOpen ) ;
601+ const DeleteUnusedCssVariablesDialogContent = ( {
602+ onClose,
603+ } : {
604+ onClose : ( ) => void ;
605+ } ) => {
603606 const unusedVariables = useStore ( $unusedCssVariables ) ;
607+ // Convert Set to Array for display
608+ const unusedVariablesArray = Array . from ( unusedVariables ) ;
604609
610+ return (
611+ < Flex gap = "3" direction = "column" css = { { padding : theme . panel . padding } } >
612+ { unusedVariablesArray . length === 0 ? (
613+ < Text > There are no unused CSS variables to delete.</ Text >
614+ ) : (
615+ < >
616+ < Text >
617+ Delete { unusedVariablesArray . length } unused CSS{ " " }
618+ { unusedVariablesArray . length === 1 ? "variable" : "variables" } from
619+ the project?
620+ </ Text >
621+ < Text
622+ variant = "mono"
623+ css = { {
624+ maxHeight : 200 ,
625+ overflowY : "auto" ,
626+ backgroundColor : theme . colors . backgroundPanel ,
627+ borderRadius : theme . borderRadius [ 4 ] ,
628+ wordBreak : "break-word" ,
629+ } }
630+ >
631+ { unusedVariablesArray . join ( ", " ) }
632+ </ Text >
633+ </ >
634+ ) }
635+ < Flex direction = "rowReverse" gap = "2" >
636+ { unusedVariablesArray . length > 0 && (
637+ < Button
638+ color = "destructive"
639+ onClick = { ( ) => {
640+ const deletedCount = deleteUnusedCssVariables ( ) ;
641+ onClose ( ) ;
642+ if ( deletedCount === 0 ) {
643+ toast . info ( "No unused CSS variables to delete" ) ;
644+ } else {
645+ toast . success (
646+ `Deleted ${ deletedCount } unused CSS ${ deletedCount === 1 ? "variable" : "variables" } `
647+ ) ;
648+ }
649+ } }
650+ >
651+ Delete
652+ </ Button >
653+ ) }
654+ < DialogClose >
655+ < Button color = "ghost" >
656+ { unusedVariablesArray . length > 0 ? "Cancel" : "Close" }
657+ </ Button >
658+ </ DialogClose >
659+ </ Flex >
660+ </ Flex >
661+ ) ;
662+ } ;
663+
664+ export const DeleteUnusedCssVariablesDialog = ( ) => {
665+ const open = useStore ( $isDeleteUnusedCssVariablesDialogOpen ) ;
605666 const handleClose = ( ) => {
606667 $isDeleteUnusedCssVariablesDialogOpen . set ( false ) ;
607668 } ;
608669
609- // Convert Set to Array for display
610- const unusedVariablesArray = Array . from ( unusedVariables ) ;
611-
612670 return (
613671 < Dialog
614672 open = { open }
@@ -625,56 +683,7 @@ export const DeleteUnusedCssVariablesDialog = () => {
625683 } }
626684 >
627685 < DialogTitle > Delete unused CSS variables</ DialogTitle >
628- < Flex gap = "3" direction = "column" css = { { padding : theme . panel . padding } } >
629- { unusedVariablesArray . length === 0 ? (
630- < Text > There are no unused CSS variables to delete.</ Text >
631- ) : (
632- < >
633- < Text >
634- Delete { unusedVariablesArray . length } unused CSS{ " " }
635- { unusedVariablesArray . length === 1 ? "variable" : "variables" } { " " }
636- from the project?
637- </ Text >
638- < Text
639- variant = "mono"
640- css = { {
641- maxHeight : 200 ,
642- overflowY : "auto" ,
643- backgroundColor : theme . colors . backgroundPanel ,
644- borderRadius : theme . borderRadius [ 4 ] ,
645- wordBreak : "break-word" ,
646- } }
647- >
648- { unusedVariablesArray . join ( ", " ) }
649- </ Text >
650- </ >
651- ) }
652- < Flex direction = "rowReverse" gap = "2" >
653- { unusedVariablesArray . length > 0 && (
654- < Button
655- color = "destructive"
656- onClick = { ( ) => {
657- const deletedCount = deleteUnusedCssVariables ( ) ;
658- handleClose ( ) ;
659- if ( deletedCount === 0 ) {
660- toast . info ( "No unused CSS variables to delete" ) ;
661- } else {
662- toast . success (
663- `Deleted ${ deletedCount } unused CSS ${ deletedCount === 1 ? "variable" : "variables" } `
664- ) ;
665- }
666- } }
667- >
668- Delete
669- </ Button >
670- ) }
671- < DialogClose >
672- < Button color = "ghost" >
673- { unusedVariablesArray . length > 0 ? "Cancel" : "Close" }
674- </ Button >
675- </ DialogClose >
676- </ Flex >
677- </ Flex >
686+ < DeleteUnusedCssVariablesDialogContent onClose = { handleClose } />
678687 </ DialogContent >
679688 </ Dialog >
680689 ) ;
0 commit comments