Skip to content

Commit 1d4dbd4

Browse files
authored
chore: change default accent color (#1678)
1 parent 7acb904 commit 1d4dbd4

File tree

4 files changed

+44
-37
lines changed

4 files changed

+44
-37
lines changed

app/assets/main.css

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -24,16 +24,17 @@
2424
--border-hover: oklch(0.371 0 0);
2525

2626
/* accent color, set by user from settings */
27-
--accent: var(--accent-color, oklch(1 0 0));
27+
--accent: var(--accent-color, oklch(0.787 0.128 230.318));
2828
--accent-muted: var(--accent-color, oklch(0.922 0 0));
2929

3030
/* accent colors */
31+
--swatch-sky: oklch(0.787 0.128 230.318);
3132
--swatch-coral: oklch(0.704 0.177 14.75);
3233
--swatch-amber: oklch(0.828 0.165 84.429);
3334
--swatch-emerald: oklch(0.792 0.153 166.95);
34-
--swatch-sky: oklch(0.787 0.128 230.318);
3535
--swatch-violet: oklch(0.78 0.148 286.067);
3636
--swatch-magenta: oklch(0.78 0.15 330);
37+
--swatch-neutral: oklch(1 0 0);
3738

3839
/* syntax highlighting colors */
3940
--syntax-fn: oklch(0.727 0.137 299.149);
@@ -94,16 +95,17 @@
9495
--border-subtle: oklch(0.922 0 0);
9596
--border-hover: oklch(0.715 0 0);
9697

97-
--accent: var(--accent-color, oklch(0.145 0 0));
98+
--accent: var(--accent-color, oklch(0.53 0.16 247.27));
9899
--accent-muted: var(--accent-color, oklch(0.205 0 0));
99100

100101
/* accent colors */
101-
--swatch-coral: oklch(0.7 0.19 14.75);
102-
--swatch-amber: oklch(0.8 0.25 84.429);
103-
--swatch-emerald: oklch(0.7 0.17 166.95);
104-
--swatch-sky: oklch(0.7 0.15 230.318);
105-
--swatch-violet: oklch(0.7 0.17 286.067);
106-
--swatch-magenta: oklch(0.75 0.18 330);
102+
--swatch-sky: oklch(0.53 0.16 247.27);
103+
--swatch-coral: oklch(0.56 0.17 10.75);
104+
--swatch-amber: oklch(0.58 0.18 46.34);
105+
--swatch-emerald: oklch(0.51 0.13 162.4);
106+
--swatch-violet: oklch(0.56 0.13 282.067);
107+
--swatch-magenta: oklch(0.56 0.14 325);
108+
--swatch-neutral: oklch(0.145 0 0);
107109

108110
--syntax-fn: oklch(0.502 0.188 294.988);
109111
--syntax-str: oklch(0.425 0.152 252);

app/components/Settings/AccentColorPicker.vue

Lines changed: 11 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ const { accentColors, selectedAccentColor, setAccentColor } = useAccentColor()
55
66
onPrehydrate(el => {
77
const settings = JSON.parse(localStorage.getItem('npmx-settings') || '{}')
8+
const defaultId = 'sky'
89
const id = settings.accentColorId
910
if (id) {
1011
const input = el.querySelector<HTMLInputElement>(`input[value="${id}"]`)
@@ -13,10 +14,12 @@ onPrehydrate(el => {
1314
input.setAttribute('checked', '')
1415
}
1516
// Remove checked from the server-default (clear button, value="")
16-
const clearInput = el.querySelector<HTMLInputElement>('input[value=""]')
17-
if (clearInput) {
18-
clearInput.checked = false
19-
clearInput.removeAttribute('checked')
17+
if (id !== defaultId) {
18+
const clearInput = el.querySelector<HTMLInputElement>(`input[value="${defaultId}"]`)
19+
if (clearInput) {
20+
clearInput.checked = false
21+
clearInput.removeAttribute('checked')
22+
}
2023
}
2124
}
2225
})
@@ -31,31 +34,19 @@ onPrehydrate(el => {
3134
v-for="color in accentColors"
3235
:key="color.id"
3336
class="size-6 rounded-full transition-transform duration-150 motion-safe:hover:scale-110 has-[:checked]:(ring-2 ring-fg ring-offset-2 ring-offset-bg-subtle) has-[:focus-visible]:(ring-2 ring-fg ring-offset-2 ring-offset-bg-subtle)"
37+
:class="color.id === 'neutral' ? 'flex items-center justify-center bg-fg' : ''"
3438
:style="{ backgroundColor: `var(--swatch-${color.id})` }"
3539
>
3640
<input
3741
type="radio"
3842
name="accent-color"
3943
class="sr-only"
4044
:value="color.id"
41-
:checked="selectedAccentColor === color.id"
42-
:aria-label="color.name"
45+
:checked="selectedAccentColor === color.id || (!selectedAccentColor && color.id === 'sky')"
46+
:aria-label="color.id === 'neutral' ? $t('settings.clear_accent') : color.name"
4347
@change="setAccentColor(color.id)"
4448
/>
45-
</label>
46-
<label
47-
class="size-6 rounded-full transition-transform duration-150 motion-safe:hover:scale-110 has-[:checked]:(ring-2 ring-fg ring-offset-2 ring-offset-bg-subtle) has-[:focus-visible]:(ring-2 ring-fg ring-offset-2 ring-offset-bg-subtle) flex items-center justify-center bg-fg"
48-
>
49-
<input
50-
type="radio"
51-
name="accent-color"
52-
class="sr-only"
53-
value=""
54-
:checked="selectedAccentColor === null"
55-
:aria-label="$t('settings.clear_accent')"
56-
@change="setAccentColor(null)"
57-
/>
58-
<span class="i-lucide:ban size-4 text-bg" aria-hidden="true" />
49+
<span v-if="color.id === 'neutral'" class="i-lucide:ban size-4 text-bg" aria-hidden="true" />
5950
</label>
6051
</fieldset>
6152
</template>

app/components/Settings/BgThemePicker.vue

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,22 @@ const { backgroundThemes, selectedBackgroundTheme, setBackgroundTheme } = useBac
33
44
onPrehydrate(el => {
55
const settings = JSON.parse(localStorage.getItem('npmx-settings') || '{}')
6+
const defaultId = 'neutral'
67
const id = settings.preferredBackgroundTheme
78
if (id) {
89
const input = el.querySelector<HTMLInputElement>(`input[value="${id}"]`)
910
if (input) {
1011
input.checked = true
1112
input.setAttribute('checked', '')
1213
}
14+
// Remove checked from the server-default (clear button, value="")
15+
if (id !== defaultId) {
16+
const clearInput = el.querySelector<HTMLInputElement>(`input[value="${defaultId}"]`)
17+
if (clearInput) {
18+
clearInput.checked = false
19+
clearInput.removeAttribute('checked')
20+
}
21+
}
1322
}
1423
})
1524
</script>
@@ -30,7 +39,10 @@ onPrehydrate(el => {
3039
name="background-theme"
3140
class="sr-only"
3241
:value="theme.id"
33-
:checked="selectedBackgroundTheme === theme.id"
42+
:checked="
43+
selectedBackgroundTheme === theme.id ||
44+
(!selectedBackgroundTheme && theme.id === 'neutral')
45+
"
3446
:aria-label="theme.name"
3547
@change="setBackgroundTheme(theme.id)"
3648
/>

shared/utils/constants.ts

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -49,20 +49,22 @@ export const LIKES_SCOPE = `repo:${dev.npmx.feed.like.$nsid}`
4949
// Theming
5050
export const ACCENT_COLORS = {
5151
light: {
52-
coral: 'oklch(0.70 0.19 14.75)',
53-
amber: 'oklch(0.8 0.25 84.429)',
54-
emerald: 'oklch(0.70 0.17 166.95)',
55-
sky: 'oklch(0.70 0.15 230.318)',
56-
violet: 'oklch(0.70 0.17 286.067)',
57-
magenta: 'oklch(0.75 0.18 330)',
52+
sky: 'oklch(0.53 0.16 247.27)',
53+
coral: 'oklch(0.56 0.17 10.75)',
54+
amber: 'oklch(0.58 0.18 46.34)',
55+
emerald: 'oklch(0.51 0.13 162.4)',
56+
violet: 'oklch(0.56 0.13 282.067)',
57+
magenta: 'oklch(0.56 0.14 325)',
58+
neutral: 'oklch(0.145 0 0)',
5859
},
5960
dark: {
61+
sky: 'oklch(0.787 0.128 230.318)',
6062
coral: 'oklch(0.704 0.177 14.75)',
6163
amber: 'oklch(0.828 0.165 84.429)',
6264
emerald: 'oklch(0.792 0.153 166.95)',
63-
sky: 'oklch(0.787 0.128 230.318)',
6465
violet: 'oklch(0.78 0.148 286.067)',
6566
magenta: 'oklch(0.78 0.15 330)',
67+
neutral: 'oklch(1 0 0)',
6668
},
6769
} as const
6870

0 commit comments

Comments
 (0)