@@ -123,10 +123,42 @@ function setPreview(values: Values): void {
123123 ) ;
124124}
125125
126+ function doInputsExist ( ) {
127+ const getTrackColor = getColorInput1 ( attribute ) ;
128+ const getThumbColor = getColorInput2 ( attribute ) ;
129+
130+ const doColorInputsExist = getTrackColor . value && getThumbColor . value ;
131+
132+ const trackCheckBox = getCheckbox ( `${ attribute } -track` ) ;
133+ const getTrackRadius = getRadiusInput ( `${ attribute } -track` ) ;
134+
135+ const doesTrackRadiusInputExists = trackCheckBox . checked
136+ ? getTrackRadius . value !== ''
137+ : true ;
138+
139+ const thumbCheckBox = getCheckbox ( `${ attribute } -thumb` ) ;
140+ const getThumbRadius = getRadiusInput ( `${ attribute } -thumb` ) ;
141+
142+ const doesThumbRadiusInputExists = thumbCheckBox . checked
143+ ? getThumbRadius . value !== ''
144+ : true ;
145+
146+ if (
147+ doColorInputsExist &&
148+ doesTrackRadiusInputExists &&
149+ doesThumbRadiusInputExists
150+ )
151+ return true ;
152+
153+ showPopup ( "Couldn't Copy Code" , 'Some input value may be missing' , 'error' ) ;
154+ return false ;
155+ }
156+
126157function copyHandler ( ) {
127158 const previewElement = document . getElementById (
128159 'preview-range'
129160 ) as HTMLInputElement ;
161+ if ( doInputsExist ( ) === false ) return ;
130162 copyCSSCodeToClipboard ( attribute , previewElement ) ;
131163 showPopup (
132164 'Code Copied' ,
@@ -254,6 +286,7 @@ getValues();
254286// Tailwind codecopy handler
255287function tailwindHandler ( ) {
256288 const element = document . querySelector ( '#preview-range' ) as HTMLInputElement ;
289+ if ( doInputsExist ( ) === false ) return ;
257290 copyTailwindCodeToClipboard ( attribute , element ) ;
258291 showPopup (
259292 'Tailwind Code Copied' ,
0 commit comments