Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 15 additions & 13 deletions src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -639,19 +639,21 @@ interface ProjectWallaceJSON {

const domainInput = document.getElementById('url-input');
if (domainInput) {
domainInput.addEventListener('input', (evt) => {
if (evt.currentTarget instanceof HTMLSelectElement) {
const url = evt.currentTarget.value.replace(/[./]+/g, '.');
fetch(`/design-tokens/${url}.json`)
.then((response) => response.json())
.then((json: ProjectWallaceJSON) => {
const colors = Object.entries(json.Color).map(([name, { $value }]) => ({
name,
color: $value,
}));

setPresetColors(colors);
});
domainInput.addEventListener('input', async (event) => {
if (event.currentTarget instanceof HTMLSelectElement) {
const url = event.currentTarget.value.replace(/[./]+/g, '.');
if (url) {
const response = await fetch(`/design-tokens/${url}.json`)
const json = await response.json() as ProjectWallaceJSON
const colors = Object.entries(json.Color).map(([name, { $value }]) => ({
name,
color: $value,
}));

setPresetColors(colors);
} else {
setPresetColors(radixColors)
}
}
});
}
Expand Down
Loading