Skip to content

Commit 32900dc

Browse files
committed
fix: address CodeRabbit review comments
- Localise OG image metadata with $t() instead of hardcoded strings - Track PNG loading per-logo with a Set to prevent race conditions - Add safe fallback for empty accentColors array
1 parent b4b5630 commit 32900dc

File tree

2 files changed

+9
-7
lines changed

2 files changed

+9
-7
lines changed

app/components/Brand/Customize.vue

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,8 @@ const customLogoRef = useTemplateRef('customLogoRef')
99
const activeAccentId = computed(() => customAccent.value ?? selectedAccentColor.value ?? 'sky')
1010
const activeAccentColor = computed(() => {
1111
const match = accentColors.value.find(c => c.id === activeAccentId.value)
12-
return match?.value ?? accentColors.value[0]!.value
12+
const fallback = accentColors.value[0]?.value ?? 'oklch(0.787 0.128 230.318)'
13+
return match?.value ?? fallback
1314
})
1415
1516
function getCustomSvgString(): string {

app/pages/brand.vue

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,8 @@ useSeoMeta({
1010
1111
defineOgImageComponent('Default', {
1212
primaryColor: '#51c8fc',
13-
title: 'npmx brand',
14-
description: 'logos, colors, typography, and usage guidelines',
13+
title: $t('brand.title'),
14+
description: $t('brand.meta_description'),
1515
})
1616
1717
const { convert, download: downloadPng } = useSvgToPng()
@@ -71,16 +71,17 @@ const dontsItems = [
7171
() => $t('brand.usage.dont_rotate'),
7272
]
7373
74-
const pngLoading = ref<string | null>(null)
74+
const pngLoading = ref(new Set<string>())
7575
7676
async function handlePngDownload(logo: (typeof logos)[number]) {
77-
pngLoading.value = logo.src
77+
if (pngLoading.value.has(logo.src)) return
78+
pngLoading.value.add(logo.src)
7879
try {
7980
const blob = await convert(logo.src, logo.width, logo.height)
8081
const filename = logo.src.replace(/^\//, '').replace('.svg', '.png')
8182
downloadPng(blob, filename)
8283
} finally {
83-
pngLoading.value = null
84+
pngLoading.value.delete(logo.src)
8485
}
8586
}
8687
</script>
@@ -167,7 +168,7 @@ async function handlePngDownload(logo: (typeof logos)[number]) {
167168
size="sm"
168169
classicon="i-lucide:download"
169170
:aria-label="$t('brand.logos.download_png_aria', { name: logo.name() })"
170-
:disabled="pngLoading === logo.src"
171+
:disabled="pngLoading.has(logo.src)"
171172
@click="handlePngDownload(logo)"
172173
>
173174
{{ $t('brand.logos.download_png') }}

0 commit comments

Comments
 (0)