From 33512707126584fda03c5f9c0008bdf3a174064b Mon Sep 17 00:00:00 2001 From: EmNudge <24513691+EmNudge@users.noreply.github.com> Date: Wed, 4 Feb 2026 09:23:53 -0500 Subject: [PATCH] Migrate hardcoded CSS values to design tokens --- src/components/EasySearch.vue | 43 +++++++------------ src/components/Header.vue | 7 +-- src/components/Loader.vue | 4 +- .../advanced-search/AdvancedSearch.vue | 14 +++--- src/components/advanced-search/BoxContent.vue | 24 ++++++++--- src/components/advanced-search/BoxSet.vue | 6 +-- src/components/advanced-search/Button.vue | 13 +++--- src/components/advanced-search/Dropdown.vue | 5 ++- .../table-container/InfoContainer.vue | 10 ++--- src/components/table-container/ResultsRow.vue | 2 +- .../table-container/info-tables/Encoding.vue | 11 ++--- .../info-tables/HtmlEntities.vue | 6 +-- .../info-tables/Properties.vue | 8 ++-- src/lib/components/forms/Input.vue | 3 ++ src/lib/components/overlay/Modal.vue | 2 +- src/styles/base.css | 21 +++++---- src/styles/tokens.css | 20 +++++++++ 17 files changed, 114 insertions(+), 85 deletions(-) diff --git a/src/components/EasySearch.vue b/src/components/EasySearch.vue index c4149e7..137e2cb 100644 --- a/src/components/EasySearch.vue +++ b/src/components/EasySearch.vue @@ -2,6 +2,7 @@ import { ref, onMounted, onUnmounted } from "vue"; import { easySearch, isCommandPaletteOpen } from "$stores"; import { debounce } from "$utils/debounce"; +import Input from "$lib/components/forms/Input.vue"; interface Props { onSearch?: () => void; @@ -10,7 +11,7 @@ interface Props { const props = defineProps(); const error = ref(""); -const inputEl = ref(null); +const inputEl = ref | null>(null); const search = debounce(() => props.onSearch?.(), 100); @@ -37,10 +38,15 @@ function trySearch() { search(); } +function getInputElement() { + return inputEl.value?.$el?.querySelector("input") as HTMLInputElement | null; +} + function handleKeyDown(e: KeyboardEvent) { if (isCommandPaletteOpen.value) return; - const inputIsFocused = document.activeElement === inputEl.value; + const input = getInputElement(); + const inputIsFocused = document.activeElement === input; if (inputIsFocused) return; if (e.key.length > 1 || /\p{C}/u.test(e.key)) return; @@ -51,7 +57,7 @@ function handleKeyDown(e: KeyboardEvent) { return; } - inputEl.value?.focus(); + input?.focus(); } onMounted(() => { @@ -76,39 +82,20 @@ function handleSubmit(e: Event) { diff --git a/src/components/Header.vue b/src/components/Header.vue index 445eb46..f443021 100644 --- a/src/components/Header.vue +++ b/src/components/Header.vue @@ -28,7 +28,7 @@ header { display: flex; justify-content: space-between; max-width: 600px; - margin: 20px auto; + margin: var(--space-5) auto; display: flex; align-items: center; } @@ -42,7 +42,7 @@ button { cursor: pointer; margin: 0; z-index: 2; - padding: 10px 20px; + padding: var(--space-3) var(--space-5); } .active { color: var(--hsl-bg); @@ -50,6 +50,7 @@ button { transition: 0.25s; } button:focus { - border: 1px solid var(--hsl); + outline: var(--border-width-2) solid var(--color-border-focus); + outline-offset: var(--border-width-2); } diff --git a/src/components/Loader.vue b/src/components/Loader.vue index 4765865..50432a6 100644 --- a/src/components/Loader.vue +++ b/src/components/Loader.vue @@ -34,11 +34,11 @@ const chars = computed(() => Array.from(str.value)); diff --git a/src/components/advanced-search/BoxContent.vue b/src/components/advanced-search/BoxContent.vue index cf1b4de..83e9d3a 100644 --- a/src/components/advanced-search/BoxContent.vue +++ b/src/components/advanced-search/BoxContent.vue @@ -54,33 +54,43 @@ function handleDataChange(data: any) {
- + diff --git a/src/components/advanced-search/BoxSet.vue b/src/components/advanced-search/BoxSet.vue index 6647ccf..8cab5fe 100644 --- a/src/components/advanced-search/BoxSet.vue +++ b/src/components/advanced-search/BoxSet.vue @@ -55,13 +55,13 @@ function handleDataChange(data: any) { diff --git a/src/components/advanced-search/Button.vue b/src/components/advanced-search/Button.vue index 7321e24..bd7f9c9 100644 --- a/src/components/advanced-search/Button.vue +++ b/src/components/advanced-search/Button.vue @@ -27,15 +27,18 @@ const btnClass = computed(() => ["styled", props.disabled && "disabled"].filter( diff --git a/src/components/table-container/info-tables/HtmlEntities.vue b/src/components/table-container/info-tables/HtmlEntities.vue index 5dc22b1..4175f28 100644 --- a/src/components/table-container/info-tables/HtmlEntities.vue +++ b/src/components/table-container/info-tables/HtmlEntities.vue @@ -39,15 +39,15 @@ th { text-align: left; color: var(--primary-text); font-weight: 400; - padding-bottom: 6px; + padding-bottom: var(--space-2); } tbody tr:nth-child(odd) { background-color: var(--bg-offset); } td { - padding: 6px; + padding: var(--space-2); } td:first-child { - padding-right: 30px; + padding-right: var(--space-8); } diff --git a/src/components/table-container/info-tables/Properties.vue b/src/components/table-container/info-tables/Properties.vue index 69ed913..b045794 100644 --- a/src/components/table-container/info-tables/Properties.vue +++ b/src/components/table-container/info-tables/Properties.vue @@ -17,7 +17,7 @@ const props = defineProps(); diff --git a/src/lib/components/forms/Input.vue b/src/lib/components/forms/Input.vue index 7797315..b167e50 100644 --- a/src/lib/components/forms/Input.vue +++ b/src/lib/components/forms/Input.vue @@ -83,6 +83,9 @@ function handleInput(e: Event) { gap: var(--space-1); width: auto; } +.input-wrapper:has(.input--full-width) { + width: 100%; +} .input { margin: 0; padding: var(--space-2) var(--space-4); diff --git a/src/lib/components/overlay/Modal.vue b/src/lib/components/overlay/Modal.vue index f334fd1..060794c 100644 --- a/src/lib/components/overlay/Modal.vue +++ b/src/lib/components/overlay/Modal.vue @@ -64,7 +64,7 @@ watch( .modal-backdrop { position: fixed; inset: 0; - background: rgba(0, 0, 0, 0.5); + background: var(--color-backdrop); display: flex; align-items: flex-start; justify-content: center; diff --git a/src/styles/base.css b/src/styles/base.css index df37d6f..6da1479 100644 --- a/src/styles/base.css +++ b/src/styles/base.css @@ -32,7 +32,7 @@ body { } a { - color: rgb(0, 100, 200); + color: var(--color-link); text-decoration: none; transition: var(--transition-colors); } @@ -42,7 +42,7 @@ a:hover { } a:visited { - color: rgb(0, 80, 160); + color: var(--color-link-visited); } label { @@ -70,7 +70,7 @@ input::placeholder { } input:disabled { - color: #ccc; + color: var(--color-text-tertiary); opacity: 0.6; } @@ -80,23 +80,24 @@ input[type="range"] { button { color: var(--color-text); - background-color: #f4f4f4; + background-color: var(--color-bg-offset); outline: none; cursor: pointer; } button:disabled { - color: #999; + color: var(--color-text-tertiary); cursor: not-allowed; opacity: 0.6; } button:not(:disabled):active { - background-color: #ddd; + background-color: var(--color-bg-active); } button:focus { - border-color: #666; + outline: var(--border-width-2) solid var(--color-border-focus); + outline-offset: var(--border-width-2); } /* ========================================== @@ -127,10 +128,12 @@ button.underline-btn { border-radius: var(--radius-base); } -.styled:hover:not(:disabled) { +button.styled:hover:not(:disabled), +select.styled:hover:not(:disabled) { filter: brightness(0.95); } -.styled:active:not(:disabled) { +button.styled:active:not(:disabled), +select.styled:active:not(:disabled) { transform: scale(0.98); } diff --git a/src/styles/tokens.css b/src/styles/tokens.css index 55a7fae..76be3a8 100644 --- a/src/styles/tokens.css +++ b/src/styles/tokens.css @@ -59,6 +59,16 @@ --color-border-focus: #a5b5ff; --color-border-error: var(--color-error); + /* Link Colors */ + --color-link: hsl(210, 100%, 40%); + --color-link-visited: hsl(210, 100%, 32%); + + /* Backdrop Colors */ + --color-backdrop: rgba(0, 0, 0, 0.5); + + /* Active/Selected State */ + --color-bg-active: rgba(128, 128, 128, 0.1); + /* Shadow Colors */ --color-shadow: rgba(0, 0, 0, 0.09); --color-shadow-elevated: rgba(0, 0, 0, 0.12); @@ -254,6 +264,11 @@ --color-shadow: rgba(0, 0, 0, 0.43); --color-shadow-elevated: rgba(0, 0, 0, 0.6); + --color-link: hsl(210, 80%, 60%); + --color-link-visited: hsl(210, 70%, 52%); + --color-backdrop: rgba(0, 0, 0, 0.7); + --color-bg-active: rgba(128, 128, 128, 0.15); + /* Adjusted state colors for dark mode */ --color-success: hsl(140, 50%, 55%); --color-success-bg: hsl(140, 40%, 20%); @@ -298,6 +313,11 @@ --color-shadow: rgba(0, 0, 0, 0.43); --color-shadow-elevated: rgba(0, 0, 0, 0.6); + --color-link: hsl(210, 80%, 60%); + --color-link-visited: hsl(210, 70%, 52%); + --color-backdrop: rgba(0, 0, 0, 0.7); + --color-bg-active: rgba(128, 128, 128, 0.15); + --color-success: hsl(140, 50%, 55%); --color-success-bg: hsl(140, 40%, 20%); --color-success-border: hsl(140, 50%, 50%);