File tree Expand file tree Collapse file tree 1 file changed +15
-13
lines changed
Expand file tree Collapse file tree 1 file changed +15
-13
lines changed Original file line number Diff line number Diff line change @@ -639,19 +639,21 @@ interface ProjectWallaceJSON {
639639
640640const domainInput = document . getElementById ( 'url-input' ) ;
641641if ( domainInput ) {
642- domainInput . addEventListener ( 'input' , ( evt ) => {
643- if ( evt . currentTarget instanceof HTMLSelectElement ) {
644- const url = evt . currentTarget . value . replace ( / [ . / ] + / g, '.' ) ;
645- fetch ( `/design-tokens/${ url } .json` )
646- . then ( ( response ) => response . json ( ) )
647- . then ( ( json : ProjectWallaceJSON ) => {
648- const colors = Object . entries ( json . Color ) . map ( ( [ name , { $value } ] ) => ( {
649- name,
650- color : $value ,
651- } ) ) ;
652-
653- setPresetColors ( colors ) ;
654- } ) ;
642+ domainInput . addEventListener ( 'input' , async ( event ) => {
643+ if ( event . currentTarget instanceof HTMLSelectElement ) {
644+ const url = event . currentTarget . value . replace ( / [ . / ] + / g, '.' ) ;
645+ if ( url ) {
646+ const response = await fetch ( `/design-tokens/${ url } .json` )
647+ const json = await response . json ( ) as ProjectWallaceJSON
648+ const colors = Object . entries ( json . Color ) . map ( ( [ name , { $value } ] ) => ( {
649+ name,
650+ color : $value ,
651+ } ) ) ;
652+
653+ setPresetColors ( colors ) ;
654+ } else {
655+ setPresetColors ( radixColors )
656+ }
655657 }
656658 } ) ;
657659}
You can’t perform that action at this time.
0 commit comments