Skip to content

Commit f4c6916

Browse files
Adebesin-Cellclaude
andcommitted
fix: sync color picker swatches with preview background palette
The accent color picker was using the site's theme palette while the logo preview used the customizer's own dark/light toggle. This caused the neutral swatch to show white while the logo rendered black (or vice-versa). Now the picker derives its colors from the same palette as the preview, and the neutral swatch gets a visible border so it doesn't disappear against contrasting backgrounds. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent 7f07fcb commit f4c6916

File tree

1 file changed

+30
-6
lines changed

1 file changed

+30
-6
lines changed

app/components/Brand/Customize.vue

Lines changed: 30 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,42 @@
11
<script setup lang="ts">
22
import { ACCENT_COLORS, type AccentColorId } from '#shared/utils/constants'
33
4-
const { accentColors, selectedAccentColor } = useAccentColor()
4+
const { selectedAccentColor } = useAccentColor()
55
const { download: downloadBlob } = useSvgToPng()
6+
const { t } = useI18n()
67
78
const customAccent = ref<string | null>(null)
89
const customBgDark = ref(true)
910
const customLogoRef = useTemplateRef('customLogoRef')
1011
1112
const activeAccentId = computed(() => customAccent.value ?? selectedAccentColor.value ?? 'sky')
13+
14+
// Use the palette matching the preview background, not the site theme
15+
const previewPalette = computed(() => customBgDark.value ? ACCENT_COLORS.dark : ACCENT_COLORS.light)
16+
1217
const activeAccentColor = computed(() => {
13-
// Use light accent colors on light bg for proper contrast (e.g. neutral: dark on white, not white on white)
14-
const palette = customBgDark.value ? ACCENT_COLORS.dark : ACCENT_COLORS.light
15-
return palette[activeAccentId.value as AccentColorId] ?? palette.sky
18+
return previewPalette.value[activeAccentId.value as AccentColorId] ?? previewPalette.value.sky
1619
})
1720
21+
const accentColorLabels = computed<Record<AccentColorId, string>>(() => ({
22+
sky: t('settings.accent_colors.sky'),
23+
coral: t('settings.accent_colors.coral'),
24+
amber: t('settings.accent_colors.amber'),
25+
emerald: t('settings.accent_colors.emerald'),
26+
violet: t('settings.accent_colors.violet'),
27+
magenta: t('settings.accent_colors.magenta'),
28+
neutral: t('settings.clear_accent'),
29+
}))
30+
31+
// Color swatches match the preview background palette so the circles reflect what the logo will render
32+
const pickerColors = computed(() =>
33+
Object.entries(previewPalette.value).map(([id, value]) => ({
34+
id: id as AccentColorId,
35+
label: accentColorLabels.value[id as AccentColorId],
36+
value,
37+
})),
38+
)
39+
1840
function getCustomSvgString(): string {
1941
const el = customLogoRef.value?.$el as SVGElement | undefined
2042
if (!el) return ''
@@ -120,7 +142,7 @@ async function downloadCustomPng() {
120142
}}</span>
121143
<div class="flex items-center gap-1.5" role="radiogroup">
122144
<ButtonBase
123-
v-for="color in accentColors"
145+
v-for="color in pickerColors"
124146
:key="color.id"
125147
role="radio"
126148
:aria-checked="activeAccentId === color.id"
@@ -129,7 +151,9 @@ async function downloadCustomPng() {
129151
:class="
130152
activeAccentId === color.id
131153
? '!border-fg scale-110'
132-
: '!border-transparent hover:!border-border-hover'
154+
: color.id === 'neutral'
155+
? '!border-border hover:!border-border-hover'
156+
: '!border-transparent hover:!border-border-hover'
133157
"
134158
:style="{ backgroundColor: color.value }"
135159
@click="customAccent = color.id"

0 commit comments

Comments
 (0)