Skip to content

Commit 165c864

Browse files
author
Bart Veneman
committed
fix: make URL preset work and apply fallback
1 parent 83909f8 commit 165c864

File tree

1 file changed

+15
-13
lines changed

1 file changed

+15
-13
lines changed

src/main.ts

Lines changed: 15 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -639,19 +639,21 @@ interface ProjectWallaceJSON {
639639

640640
const domainInput = document.getElementById('url-input');
641641
if (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
}

0 commit comments

Comments
 (0)