refactor(nav): add class prop to BackButton, remove mb-4 from topbar contexts
Some checks failed
CI / Unit & Component Tests (push) Failing after 2m41s
CI / OCR Service Tests (push) Successful in 37s
CI / Backend Unit Tests (push) Has been cancelled
CI / Unit & Component Tests (pull_request) Failing after 2m44s
CI / OCR Service Tests (pull_request) Successful in 32s
CI / Backend Unit Tests (pull_request) Failing after 2m51s

- BackButton now accepts a `class` prop (default 'mb-4') so callers can
  override spacing; resolves hardcoded margin in flex-row topbar snippets
- documents/[id]/edit and enrich/[id] pass class="" to suppress the margin
- Replace weak className unit test with class-prop behaviour tests
- Add [data-hydrated] comment in E2E spec explaining what emits the attribute

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
Marcel
2026-04-22 11:16:49 +02:00
parent 6c99c6a670
commit 367dcc66f2
5 changed files with 16 additions and 5 deletions

View File

@@ -1,11 +1,12 @@
<script lang="ts">
import { m } from '$lib/paraglide/messages.js';
let { class: cls = 'mb-4' }: { class?: string } = $props();
</script>
<button
type="button"
onclick={() => history.back()}
class="group mb-4 inline-flex min-h-[44px] items-center text-xs font-bold tracking-widest text-ink-2 uppercase transition-colors outline-none hover:text-ink focus-visible:ring-2 focus-visible:ring-focus-ring"
class="group {cls} inline-flex min-h-[44px] items-center text-xs font-bold tracking-widest text-ink-2 uppercase transition-colors outline-none hover:text-ink focus-visible:ring-2 focus-visible:ring-focus-ring"
>
<svg
class="mr-2 h-4 w-4 transform transition-transform group-hover:-translate-x-1"

View File

@@ -21,9 +21,16 @@ describe('BackButton', () => {
backSpy.mockRestore();
});
it('has min-h-[44px] for touch target compliance', async () => {
it('applies mb-4 by default', async () => {
render(BackButton);
const btn = document.querySelector('button');
expect(btn?.className).toContain('min-h-[44px]');
expect(btn?.className).toContain('mb-4');
});
it('applies custom class prop instead of default', async () => {
render(BackButton, { props: { class: 'mr-3 md:hidden' } });
const btn = document.querySelector('button');
expect(btn?.className).toContain('mr-3');
expect(btn?.className).not.toContain('mb-4');
});
});