Skip to content

Commit a4fe3fe

Browse files
committed
style(sql): move editor gutter, syntax greys and active line to semantic tokens
1 parent 74a539e commit a4fe3fe

1 file changed

Lines changed: 11 additions & 19 deletions

File tree

frontend/src/components/pages/sql/sql-editor.tsx

Lines changed: 11 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -121,8 +121,6 @@ function useIsDarkMode(): boolean {
121121
// muted gutter line numbers. CodeMirror themes are plain CSS, so registry
122122
// custom properties can be referenced directly and stay live.
123123
function editorChrome(mode: 'light' | 'dark'): Extension {
124-
const gutter = mode === 'dark' ? 'var(--color-grey-600)' : 'var(--color-grey-400)';
125-
const gutterActive = mode === 'dark' ? 'var(--color-grey-400)' : 'var(--color-grey-600)';
126124
return EditorView.theme(
127125
{
128126
'&': { backgroundColor: 'transparent', height: '100%', fontSize: '13px' },
@@ -132,24 +130,18 @@ function editorChrome(mode: 'light' | 'dark'): Extension {
132130
lineHeight: '21px',
133131
},
134132
'.cm-content': { padding: '12px 0' },
135-
'.cm-gutters': { backgroundColor: 'transparent', border: 'none', color: gutter },
136-
'.cm-activeLineGutter': { backgroundColor: 'transparent', color: gutterActive },
137-
'.cm-activeLine': {
138-
backgroundColor: mode === 'dark' ? 'rgba(255, 255, 255, 0.04)' : 'rgba(0, 0, 0, 0.03)',
139-
},
133+
'.cm-gutters': { backgroundColor: 'transparent', border: 'none', color: 'var(--color-muted-foreground)' },
134+
'.cm-activeLineGutter': { backgroundColor: 'transparent', color: 'var(--color-foreground)' },
135+
'.cm-activeLine': { backgroundColor: 'var(--color-surface-default-hover)' },
140136
},
141137
{ dark: mode === 'dark' }
142138
);
143139
}
144140

145141
// SQL syntax palette mapped onto the Lezer highlight tags the SQL grammar
146-
// emits. Hued tokens use theme-adaptive semantic tokens; only the grey
147-
// comment/identifier shades vary by mode.
148-
function sqlHighlight(mode: 'light' | 'dark'): Extension {
149-
const grey =
150-
mode === 'dark'
151-
? { comment: 'var(--color-grey-400)', id: 'var(--color-grey-100)' }
152-
: { comment: 'var(--color-grey-600)', id: 'var(--color-grey-900)' };
142+
// emits, entirely from theme-adaptive semantic tokens so it tracks light/dark
143+
// without per-mode values.
144+
function sqlHighlight(): Extension {
153145
return syntaxHighlighting(
154146
HighlightStyle.define([
155147
{ tag: tags.keyword, color: 'var(--color-secondary)', fontWeight: 'bold' },
@@ -159,18 +151,18 @@ function sqlHighlight(mode: 'light' | 'dark'): Extension {
159151
},
160152
{ tag: [tags.string, tags.special(tags.string)], color: 'var(--color-success)' },
161153
{ tag: tags.number, color: 'var(--color-warning)' },
162-
{ tag: tags.comment, color: grey.comment, fontStyle: 'italic' },
154+
{ tag: tags.comment, color: 'var(--color-muted-foreground)', fontStyle: 'italic' },
163155
{
164156
tag: [tags.operator, tags.punctuation, tags.separator, tags.paren, tags.brace, tags.squareBracket],
165-
color: 'var(--color-grey-500)',
157+
color: 'var(--color-muted-foreground)',
166158
},
167-
{ tag: tags.name, color: grey.id },
159+
{ tag: tags.name, color: 'var(--color-foreground)' },
168160
])
169161
);
170162
}
171163

172-
const LIGHT_THEME: Extension = [editorChrome('light'), sqlHighlight('light')];
173-
const DARK_THEME: Extension = [editorChrome('dark'), sqlHighlight('dark')];
164+
const LIGHT_THEME: Extension = [editorChrome('light'), sqlHighlight()];
165+
const DARK_THEME: Extension = [editorChrome('dark'), sqlHighlight()];
174166

175167
function tableNamespace(table: TableRef): SQLNamespace {
176168
return {

0 commit comments

Comments
 (0)