Skip to content

Commit 2f5f2dc

Browse files
committed
feat(ui): unify graphite theme and semantic colors
1 parent 8f49127 commit 2f5f2dc

99 files changed

Lines changed: 830 additions & 658 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

‎AGENTS.md‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,11 @@ Tauri-based cross-platform SQL database GUI client with Vue 3 + TypeScript front
88

99
**Before adding or changing client UI, read [DESIGN.md](DESIGN.md).** It is the canonical client design specification; feature design documents describe behavior within that system.
1010

11-
- Preserve SQLKit's existing **blue primary**, light/dark/system themes, compact desktop workspace, and shared shadcn-vue/Radix Vue components. Learn restraint and semantic color ownership from console-serverlessinsight; do not copy its violet brand or monochrome primary buttons.
11+
- Preserve SQLKit's existing **blue primary**, light/dark/system themes, compact desktop workspace, and shared shadcn-vue/Radix Vue components. Keep semantic color ownership consistent and retain SQLKit's blue brand and primary actions.
1212
- Use neutral surfaces, typography, spacing, and borders for hierarchy. Keep accent areas scarce (roughly 10% of application chrome); use at most one solid primary action per operation context. Secondary toolbar actions stay neutral.
1313
- Colors have fixed roles: `primary` = primary actions/interaction; `success` = actual success/connected/completed; `destructive` = errors/destructive actions. Ordinary information, counts, boolean values, database properties, and file formats are neutral. Do not assign a color to each feature or add a separate AI palette.
1414
- Reuse semantic CSS tokens from `src/assets/index.css` and their `uno.config.ts` mappings. Do not add palette classes or literal colors for existing UI semantics. `accent` is a neutral interaction surface, not a second brand color.
15-
- `warning` and `info` are **not currently registered** semantic colors. Any new semantic token must include light/dark definitions, necessary foreground pairs, UnoCSS mappings, shared variants where needed, contrast verification, and a DESIGN.md update in the same change.
15+
- `warning` is registered with light/dark foreground, muted-background, and border pairs; `info` is **not registered**. Use `primary-text` and `destructive-text` for readable colored text, reserving the corresponding base tokens for solid actions. Any new semantic token must include light/dark definitions, necessary foreground pairs, UnoCSS mappings, shared variants where needed, contrast verification, and a DESIGN.md update in the same change.
1616
- Non-interactive badges explicitly use `outline`/`secondary` by default; status colors require real state and accompanying text or icons. Syntax highlighting, data charts, diffs, and small vendor logos have the bounded exceptions documented in DESIGN.md.
1717
- Provide visible keyboard focus, accessible icon-button names, loading/empty/error states, readable contrast, and localized copy. Reuse runtime platform detection for shortcuts and native window behavior.
1818
- Existing hardcoded colors and component defaults are migration debt, not permission to repeat them. Distinguish documented targets from implemented behavior, and verify the affected themes, window sizes, and interactions when changing UI.

‎DESIGN.md‎

Lines changed: 58 additions & 53 deletions
Large diffs are not rendered by default.

‎eslint.config.js‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ export default antfu({
2323
'**/dist/**',
2424
'**/node_modules/**',
2525
'**/.tauri/**',
26+
'.impeccable/hook.cache.json',
2627
'AGENTS.md',
2728
'docs/**',
2829
'src-tauri/gen/**',

‎src/__tests__/dataGridPaging.test.ts‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -92,13 +92,13 @@ describe('paged result grid', () => {
9292
const firstRow = wrapper.get('[data-index="0"]')
9393
firstRow.findComponent({ name: 'Checkbox' }).vm.$emit('update:checked', true)
9494
await wrapper.vm.$nextTick()
95-
expect(wrapper.get('[data-index="0"]').classes()).toContain('bg-primary/[0.08]')
95+
expect(wrapper.get('[data-index="0"]').classes()).toContain('bg-selection')
9696
const scroller = wrapper.find('.overflow-auto').element as HTMLDivElement
9797
scroller.scrollTop = 320
9898
wrapper.findComponent({ name: 'PaginationControls' }).vm.$emit('pageChange', 2)
9999
await wrapper.vm.$nextTick()
100100
expect(scroller.scrollTop).toBe(0)
101-
expect(wrapper.get('[data-index="0"]').classes()).not.toContain('bg-primary/[0.08]')
101+
expect(wrapper.get('[data-index="0"]').classes()).not.toContain('bg-selection')
102102
expect(wrapper.get('[data-index="0"]').text()).toContain('135')
103103
})
104104

‎src/__tests__/theme.test.ts‎

Lines changed: 117 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,117 @@
1+
/** @jest-environment jsdom */
2+
import { readFileSync } from 'node:fs'
3+
import { join } from 'node:path'
4+
import { applyEditorTheme } from '@/composables/editorTheme'
5+
6+
const css = readFileSync(join(__dirname, '../assets/index.css'), 'utf8')
7+
const parseTokens = (block: string) => Object.fromEntries(
8+
[...block.matchAll(/--([\w-]+): ([^;]+);/g)].map(([, name, value]) => [name, value]),
9+
)
10+
const themes = {
11+
light: parseTokens(css.slice(css.indexOf('{') + 1, css.indexOf('}'))),
12+
dark: parseTokens(css.match(/\.dark \{([^}]+)\}/)![1]),
13+
}
14+
15+
const luminance = (hsl: string) => {
16+
const [h, s, l] = hsl.match(/[\d.]+/g)!.map(Number)
17+
const saturation = s / 100
18+
const light = l / 100
19+
const chroma = (1 - Math.abs(2 * light - 1)) * saturation
20+
const x = chroma * (1 - Math.abs((h / 60) % 2 - 1))
21+
const m = light - chroma / 2
22+
const channels = [
23+
[chroma, x, 0],
24+
[x, chroma, 0],
25+
[0, chroma, x],
26+
[0, x, chroma],
27+
[x, 0, chroma],
28+
[chroma, 0, x],
29+
][Math.floor(h / 60) % 6]
30+
return channels.map(value => value + m)
31+
.map(value => value <= 0.04045 ? value / 12.92 : ((value + 0.055) / 1.055) ** 2.4)
32+
.reduce((sum, value, index) => sum + value * [0.2126, 0.7152, 0.0722][index], 0)
33+
}
34+
35+
const contrast = (a: string, b: string) => {
36+
const values = [luminance(a), luminance(b)].sort((a, b) => a - b)
37+
return (values[1] + 0.05) / (values[0] + 0.05)
38+
}
39+
40+
describe.each(['light', 'dark'] as const)('%s theme', (name) => {
41+
const tokens = themes[name]
42+
43+
it.each(['background', 'chrome', 'card', 'popover', 'accent', 'selection'])(
44+
'keeps normal and supporting text readable on %s',
45+
(surface) => {
46+
;['foreground', 'muted-foreground', 'primary-text', 'destructive-text'].forEach((text) => {
47+
expect(contrast(tokens[text], tokens[surface])).toBeGreaterThanOrEqual(4.5)
48+
})
49+
},
50+
)
51+
52+
it.each(['primary', 'destructive', 'success', 'warning'])(
53+
'provides a readable foreground on solid %s',
54+
(role) => {
55+
expect(contrast(tokens[`${role}-foreground`], tokens[role])).toBeGreaterThanOrEqual(4.5)
56+
},
57+
)
58+
59+
it.each(['success', 'warning', 'destructive'])(
60+
'keeps %s feedback readable on its subdued surface',
61+
(role) => {
62+
const text = role === 'destructive' ? 'destructive-text' : role
63+
expect(contrast(tokens[text], tokens[`${role}-muted`])).toBeGreaterThanOrEqual(4.5)
64+
},
65+
)
66+
67+
it.each(['keyword', 'string', 'number', 'comment'])(
68+
'keeps SQL %s tokens readable',
69+
(token) => {
70+
expect(contrast(tokens[`syntax-${token}`], tokens.background)).toBeGreaterThanOrEqual(4.5)
71+
},
72+
)
73+
})
74+
75+
describe('monaco theme integration', () => {
76+
const monaco = { editor: { defineTheme: jest.fn(), setTheme: jest.fn() } }
77+
const applyTheme = (dark: boolean) => {
78+
document.documentElement.removeAttribute('style')
79+
Object.entries(dark ? themes.dark : themes.light).forEach(([key, value]) => {
80+
document.documentElement.style.setProperty(`--${key}`, value)
81+
})
82+
return applyEditorTheme(monaco as unknown as Parameters<typeof applyEditorTheme>[0], dark)
83+
}
84+
85+
afterEach(() => {
86+
document.documentElement.removeAttribute('style')
87+
jest.clearAllMocks()
88+
})
89+
90+
it('coordinates editor, gutter and completion surfaces with the active dark tokens', () => {
91+
expect(applyTheme(true)).toBe('sqlkit-dark')
92+
expect(monaco.editor.defineTheme).toHaveBeenCalledWith('sqlkit-dark', expect.objectContaining({
93+
base: 'vs-dark',
94+
inherit: true,
95+
colors: expect.objectContaining({
96+
'editor.background': '#16181c',
97+
'editorGutter.background': '#16181c',
98+
'editor.foreground': '#e4e7ec',
99+
'editorSuggestWidget.background': '#23262c',
100+
'editorSuggestWidget.selectedBackground': '#263750',
101+
}),
102+
}))
103+
expect(monaco.editor.setTheme).toHaveBeenLastCalledWith('sqlkit-dark')
104+
})
105+
106+
it('rebuilds from the current CSS values when appearance switches in either direction', () => {
107+
applyTheme(true)
108+
applyTheme(false)
109+
expect(monaco.editor.defineTheme).toHaveBeenLastCalledWith('sqlkit-light', expect.objectContaining({
110+
base: 'vs',
111+
colors: expect.objectContaining({ 'editor.background': '#ffffff' }),
112+
}))
113+
expect(monaco.editor.setTheme).toHaveBeenLastCalledWith('sqlkit-light')
114+
applyTheme(true)
115+
expect(monaco.editor.setTheme).toHaveBeenLastCalledWith('sqlkit-dark')
116+
})
117+
})

‎src/assets/index.css‎

Lines changed: 69 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
1-
:root {
1+
:root,
2+
.theme-preview.light {
3+
color-scheme: light;
24
--background: 0 0% 100%;
35
--foreground: 222.2 84% 4.9%;
46
--card: 0 0% 100%;
@@ -10,55 +12,84 @@
1012
--secondary: 210 40% 96.1%;
1113
--secondary-foreground: 222.2 47.4% 11.2%;
1214
--muted: 210 40% 96.1%;
13-
--muted-foreground: 215.4 16.3% 46.9%;
15+
--muted-foreground: 213.33 16.82% 41.96%;
1416
--accent: 210 40% 96.1%;
1517
--accent-foreground: 222.2 47.4% 11.2%;
16-
--destructive: 0 84.2% 60.2%;
17-
--destructive-foreground: 210 40% 98%;
18-
--success: 142.1 70.6% 35.5%;
19-
--success-foreground: 0 0% 100%;
20-
--success-muted: 138 76% 95%;
21-
--success-border: 140 58% 85%;
18+
--destructive: 0.00 73.71% 41.76%;
19+
--destructive-foreground: 0.00 0.00% 100.00%;
20+
--success: 142.43 71.81% 29.22%;
21+
--success-foreground: 0.00 0.00% 100.00%;
22+
--success-muted: 138.46 76.47% 96.67%;
23+
--success-border: 141.00 78.95% 85.10%;
2224
--border: 214.3 31.8% 91.4%;
23-
--input: 214.3 31.8% 80%;
24-
--ring: 220 13% 60%;
25+
--input: 213.75 13.91% 54.90%;
26+
--ring: 215.38 16.32% 46.86%;
2527
--radius: 0.5rem;
2628
--chart-1: 12 76% 61%;
2729
--chart-2: 173 58% 39%;
2830
--chart-3: 197 37% 24%;
2931
--chart-4: 43 74% 66%;
3032
--chart-5: 27 87% 67%;
33+
--chrome: 210.00 40.00% 98.04%;
34+
--primary-text: 224.28 76.33% 48.04%;
35+
--selection: 220.00 100.00% 95.29%;
36+
--destructive-text: 0.00 73.71% 41.76%;
37+
--destructive-muted: 0.00 85.71% 97.25%;
38+
--destructive-border: 0.00 96.30% 89.41%;
39+
--warning: 35.65 100.00% 27.06%;
40+
--warning-foreground: 0.00 0.00% 100.00%;
41+
--warning-muted: 39.00 100.00% 96.08%;
42+
--warning-border: 39.10 67.94% 74.31%;
43+
--syntax-keyword: 224.28 76.33% 48.04%;
44+
--syntax-string: 23.16 60.64% 36.86%;
45+
--syntax-number: 270.65 39.66% 45.49%;
46+
--syntax-comment: 98.18 12.09% 35.69%;
3147
}
3248

3349
.dark {
34-
--background: 222.2 84% 4.9%;
35-
--foreground: 210 40% 98%;
36-
--card: 222.2 47% 8%;
37-
--card-foreground: 210 40% 98%;
38-
--popover: 222.2 47% 8%;
39-
--popover-foreground: 210 40% 98%;
40-
--primary: 217.2 91.2% 45%;
41-
--primary-foreground: 0 0% 100%;
42-
--secondary: 217.2 32.6% 16%;
43-
--secondary-foreground: 210 40% 98%;
44-
--muted: 217.2 32.6% 16%;
45-
--muted-foreground: 215 20.2% 65.1%;
46-
--accent: 217.2 32.6% 17.5%;
47-
--accent-foreground: 210 40% 98%;
48-
--destructive: 0 62.8% 30.6%;
49-
--destructive-foreground: 210 40% 98%;
50-
--success: 142.1 70% 45%;
51-
--success-foreground: 0 0% 100%;
52-
--success-muted: 142 35% 16%;
53-
--success-border: 142 30% 25%;
54-
--border: 217.2 32.6% 17.5%;
55-
--input: 217.2 32.6% 28%;
56-
--ring: 212.7 26.8% 68%;
50+
color-scheme: dark;
51+
--background: 220.00 12.00% 9.80%;
52+
--foreground: 217.50 17.39% 90.98%;
53+
--card: 220.00 11.39% 15.49%;
54+
--card-foreground: 217.50 17.39% 90.98%;
55+
--popover: 220.00 11.39% 15.49%;
56+
--popover-foreground: 217.50 17.39% 90.98%;
57+
--primary: 221.21 83.19% 53.33%;
58+
--primary-foreground: 0.00 0.00% 100.00%;
59+
--secondary: 220.00 11.39% 15.49%;
60+
--secondary-foreground: 217.50 17.39% 90.98%;
61+
--muted: 220.00 11.39% 15.49%;
62+
--muted-foreground: 217.89 11.80% 68.43%;
63+
--accent: 216.92 13.13% 19.41%;
64+
--accent-foreground: 217.50 17.39% 90.98%;
65+
--destructive: 0.00 53.53% 47.25%;
66+
--destructive-foreground: 0.00 0.00% 100.00%;
67+
--success: 143.02 47.25% 64.31%;
68+
--success-foreground: 220.00 12.00% 9.80%;
69+
--success-muted: 148.42 22.89% 16.27%;
70+
--success-border: 141.67 23.08% 30.59%;
71+
--border: 217.50 13.33% 23.53%;
72+
--input: 215.56 11.79% 44.90%;
73+
--ring: 217.89 11.80% 68.43%;
5774
--chart-1: 220 70% 50%;
5875
--chart-2: 160 60% 45%;
5976
--chart-3: 30 80% 55%;
6077
--chart-4: 280 65% 60%;
6178
--chart-5: 340 75% 55%;
79+
--chrome: 217.50 12.50% 12.55%;
80+
--primary-text: 218.46 100.00% 77.06%;
81+
--selection: 215.71 35.59% 23.14%;
82+
--destructive-text: 4.82 81.16% 72.94%;
83+
--destructive-muted: 352.94 19.10% 17.45%;
84+
--destructive-border: 3.40 29.61% 35.10%;
85+
--warning: 36.61 79.73% 70.98%;
86+
--warning-foreground: 220.00 12.00% 9.80%;
87+
--warning-muted: 36.67 20.45% 17.25%;
88+
--warning-border: 37.36 32.12% 32.35%;
89+
--syntax-keyword: 218.46 100.00% 77.06%;
90+
--syntax-string: 26.40 47.77% 69.22%;
91+
--syntax-number: 264.49 51.58% 81.37%;
92+
--syntax-comment: 112.50 7.55% 58.43%;
6293
}
6394

6495
* {
@@ -99,7 +130,6 @@ button:not(:disabled),
99130
@supports not (border-width: 0.5px) {
100131
.border {
101132
border-width: 1px !important;
102-
opacity: 0.6;
103133
}
104134
}
105135

@@ -127,3 +157,8 @@ button:not(:disabled),
127157
scrollbar-width: thin;
128158
scrollbar-color: hsl(var(--muted-foreground) / 0.25) transparent;
129159
}
160+
161+
::selection {
162+
background-color: hsl(var(--selection));
163+
color: hsl(var(--foreground));
164+
}

‎src/components/DeviceReplaceDialog.vue‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -224,7 +224,7 @@ function handleOpenChange(open: boolean) {
224224
225225
.replace-error {
226226
font-size: 13px;
227-
color: hsl(var(--destructive));
227+
color: hsl(var(--destructive-text));
228228
margin-top: 8px;
229229
}
230230

‎src/components/SQLEditor.vue‎

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -269,15 +269,9 @@ defineExpose({ getValue, setValue, handleFormat })
269269
<style scoped>
270270
.sql-editor-wrapper {
271271
position: relative;
272-
border: 1px solid var(--border-color, #e5e7eb);
273-
border-radius: 0.375rem;
272+
border: 1px solid hsl(var(--border));
274273
overflow: hidden;
275-
background-color: var(--background-color, #ffffff);
276-
}
277-
278-
.dark .sql-editor-wrapper {
279-
--border-color: #374151;
280-
--background-color: #1e1e1e;
274+
background-color: hsl(var(--background));
281275
}
282276
283277
.sql-editor-container {

‎src/components/UpdateNotification.vue‎

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -123,24 +123,24 @@ const buttonsDisabled = computed(() =>
123123
<div v-if="hasError" class="px-5 pb-3">
124124
<div class="px-3 py-2.5 border border-destructive/30 rounded-lg bg-destructive/10 space-y-1.5">
125125
<div class="flex gap-2 items-start">
126-
<span class="i-carbon-warning text-destructive mt-0.5 shrink-0 h-4 w-4" />
126+
<span class="i-carbon-warning text-destructive-text mt-0.5 shrink-0 h-4 w-4" />
127127
<div class="flex-1 min-w-0">
128-
<p class="text-xs text-destructive font-semibold">
128+
<p class="text-xs text-destructive-text font-semibold">
129129
{{ t('updater.installFailed') }}
130130
</p>
131-
<p class="text-xs text-destructive/80 leading-relaxed mt-0.5 break-all">
131+
<p class="text-xs text-destructive-text leading-relaxed mt-0.5 break-all">
132132
{{ updateError }}
133133
</p>
134134
</div>
135135
<button
136-
class="text-destructive/60 shrink-0 transition-colors hover:text-destructive"
136+
class="text-destructive-text shrink-0 transition-colors hover:text-destructive-text"
137137
:aria-label="t('common.buttons.dismiss')"
138138
@click="clearError"
139139
>
140140
<span class="i-carbon-close h-3.5 w-3.5" />
141141
</button>
142142
</div>
143-
<p class="text-xs text-destructive/70 pl-6">
143+
<p class="text-xs text-destructive-text pl-6">
144144
{{ t('updater.installFailedHelp') }}
145145
</p>
146146
</div>
@@ -169,7 +169,7 @@ const buttonsDisabled = computed(() =>
169169
<Button
170170
variant="default"
171171
size="sm"
172-
class="text-white font-semibold min-w-[96px]"
172+
class="text-primary-foreground font-semibold min-w-[96px]"
173173
:class="{
174174
'opacity-50 cursor-not-allowed': buttonsDisabled,
175175
}"

0 commit comments

Comments
 (0)