Skip to content

Commit 775b5bf

Browse files
committed
feat: add AppLogo component
1 parent b2f330b commit 775b5bf

10 files changed

Lines changed: 80 additions & 50 deletions

File tree

app/components/AppHeader.vue

Lines changed: 4 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -95,18 +95,11 @@ onKeyStroke(
9595
<button
9696
v-if="!isSearchExpanded && !isOnHomePage"
9797
type="button"
98-
class="sm:hidden flex-shrink-0 inline-flex items-center gap-2 font-mono text-lg font-medium text-fg hover:text-fg transition-colors duration-200 focus-ring rounded"
98+
class="sm:hidden flex-shrink-0 inline-flex items-center gap-2 font-mono text-lg font-medium text-fg hover:text-fg transition-colors duration-200 rounded"
9999
:aria-label="$t('nav.tap_to_search')"
100100
@click="expandMobileSearch"
101101
>
102-
<img
103-
aria-hidden="true"
104-
:alt="$t('alt_logo')"
105-
src="/logo.svg"
106-
width="96"
107-
height="96"
108-
class="w-8 h-8 rounded-lg"
109-
/>
102+
<AppLogo class="w-8 h-8 rounded-lg" />
110103
<span class="i-carbon:search w-4 h-4 text-fg-subtle" aria-hidden="true" />
111104
</button>
112105

@@ -116,16 +109,9 @@ onKeyStroke(
116109
to="/"
117110
:aria-label="$t('header.home')"
118111
dir="ltr"
119-
class="inline-flex items-center gap-2 header-logo font-mono text-lg font-medium text-fg hover:text-fg transition-colors duration-200 focus-ring rounded"
112+
class="inline-flex items-center gap-2 header-logo font-mono text-lg font-medium text-fg hover:text-fg transition-colors duration-200 rounded"
120113
>
121-
<img
122-
aria-hidden="true"
123-
:alt="$t('alt_logo')"
124-
src="/logo.svg"
125-
width="96"
126-
height="96"
127-
class="w-8 h-8 rounded-lg"
128-
/>
114+
<AppLogo class="w-8 h-8 rounded-lg" />
129115
<span>npmx</span>
130116
</NuxtLink>
131117
</div>

app/components/AppLogo.vue

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
<script setup lang="ts">
2+
defineProps<{
3+
class?: string
4+
}>()
5+
</script>
6+
7+
<template>
8+
<svg
9+
aria-hidden="true"
10+
xmlns="http://www.w3.org/2000/svg"
11+
viewBox="0 0 512 512"
12+
width="96"
13+
height="96"
14+
:class="class"
15+
>
16+
<title>{{ $t('alt_logo') }}</title>
17+
<rect fill="var(--bg)" width="512" height="512" rx="64" />
18+
<rect fill="var(--fg)" x="110" y="310" width="60" height="60" />
19+
<text
20+
fill="var(--accent)"
21+
x="320"
22+
y="370"
23+
font-family="'Geist Mono',ui-monospace, SFMono-Regular, 'SF Mono', Menlo, Consolas, monospace"
24+
font-size="420"
25+
font-weight="500"
26+
text-anchor="middle"
27+
>
28+
<tspan>/</tspan>
29+
</text>
30+
</svg>
31+
</template>

app/pages/index.vue

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -59,14 +59,7 @@ defineOgImageComponent('Default', {
5959
dir="ltr"
6060
class="flex items-center justify-center gap-2 header-logo font-mono text-5xl sm:text-7xl md:text-8xl font-medium tracking-tight mb-4 motion-safe:animate-fade-in motion-safe:animate-fill-both"
6161
>
62-
<img
63-
aria-hidden="true"
64-
:alt="$t('alt_logo')"
65-
src="/logo.svg"
66-
width="48"
67-
height="48"
68-
class="w-12 h-12 sm:w-20 sm:h-20 md:w-24 md:h-24 rounded-2xl sm:rounded-3xl"
69-
/>
62+
<AppLogo class="w-12 h-12 sm:w-20 sm:h-20 md:w-24 md:h-24 rounded-2xl sm:rounded-3xl" />
7063
<span class="pb-4">npmx</span>
7164
</h1>
7265

public-dev/favicon.svg

Lines changed: 7 additions & 6 deletions
Loading

public-dev/logo.svg

Lines changed: 3 additions & 3 deletions
Loading

public-staging/favicon.svg

Lines changed: 7 additions & 6 deletions
Loading

public-staging/logo.svg

Lines changed: 3 additions & 3 deletions
Loading

public/favicon.svg

Lines changed: 6 additions & 5 deletions
Loading

public/logo.svg

Lines changed: 1 addition & 1 deletion
Loading

test/nuxt/a11y.spec.ts

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,7 @@ afterEach(() => {
6161
import {
6262
AppFooter,
6363
AppHeader,
64+
AppLogo,
6465
BaseCard,
6566
BuildEnvironment,
6667
CallToAction,
@@ -224,6 +225,22 @@ describe('component accessibility audits', () => {
224225
})
225226
})
226227

228+
describe('AppLogo', () => {
229+
it('should have no accessibility violations', async () => {
230+
const component = await mountSuspended(AppLogo)
231+
const results = await runAxe(component)
232+
expect(results.violations).toEqual([])
233+
})
234+
235+
it('should have no accessibility violations with custom class', async () => {
236+
const component = await mountSuspended(AppLogo, {
237+
props: { class: 'h-6 w-6 text-accent' },
238+
})
239+
const results = await runAxe(component)
240+
expect(results.violations).toEqual([])
241+
})
242+
})
243+
227244
describe('BaseCard', () => {
228245
it('should have no accessibility violations', async () => {
229246
const component = await mountSuspended(BaseCard, {

0 commit comments

Comments
 (0)