fix(ui): real heading structure and a nav landmark for the sidebar (#1751)
CardTitle and EmptyTitle take an as prop (default h2) and render through component :is, so card and empty-state titles are headings; Section passes as="h2" under the page's h1. The sidebar menu list now sits in <nav aria-label="Sections">.
This commit is contained in:
4 files changed
+26
-12
No files matched your search
@@ -28,7 +28,8 @@ watch(() => route.path, () => { if (isMobile.value) setOpenMobile(false); });
|
||||
|
||||
<template>
|
||||
<SidebarGroup>
|
||||
<SidebarMenu aria-label="Sections">
|
||||
<nav aria-label="Sections">
|
||||
<SidebarMenu>
|
||||
<SidebarMenuItem v-for="entry in links" :key="entry.path">
|
||||
<SidebarMenuButton as-child :tooltip="entry.label" :is-active="activePath === entry.path" class="max-md:h-11">
|
||||
<RouterLink :to="entry.path" :aria-current="activePath === entry.path ? 'page' : undefined">
|
||||
@@ -38,5 +39,6 @@ watch(() => route.path, () => { if (isMobile.value) setOpenMobile(false); });
|
||||
</SidebarMenuButton>
|
||||
</SidebarMenuItem>
|
||||
</SidebarMenu>
|
||||
</nav>
|
||||
</SidebarGroup>
|
||||
</template>
|
||||
@@ -2,13 +2,19 @@
|
||||
import type { HTMLAttributes } from "vue";
|
||||
import { cn } from "@/lib/utils";
|
||||
|
||||
const props = defineProps<{
|
||||
class?: HTMLAttributes["class"];
|
||||
}>();
|
||||
const props = withDefaults(
|
||||
defineProps<{
|
||||
class?: HTMLAttributes["class"];
|
||||
/** The heading level, so pages keep a real heading structure. */
|
||||
as?: string;
|
||||
}>(),
|
||||
{ as: "h2" },
|
||||
);
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<div
|
||||
<component
|
||||
:is="props.as"
|
||||
data-slot="card-title"
|
||||
:class="
|
||||
cn(
|
||||
@@ -18,5 +24,5 @@ const props = defineProps<{
|
||||
"
|
||||
>
|
||||
<slot />
|
||||
</div>
|
||||
</component>
|
||||
</template>
|
||||
@@ -2,18 +2,24 @@
|
||||
import type { HTMLAttributes } from "vue";
|
||||
import { cn } from "@/lib/utils";
|
||||
|
||||
const props = defineProps<{
|
||||
class?: HTMLAttributes["class"];
|
||||
}>();
|
||||
const props = withDefaults(
|
||||
defineProps<{
|
||||
class?: HTMLAttributes["class"];
|
||||
/** The heading level, so pages keep a real heading structure. */
|
||||
as?: string;
|
||||
}>(),
|
||||
{ as: "h2" },
|
||||
);
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<div
|
||||
<component
|
||||
:is="props.as"
|
||||
data-slot="empty-title"
|
||||
:class="
|
||||
cn('text-label font-medium tracking-tight cn-font-heading', props.class)
|
||||
"
|
||||
>
|
||||
<slot />
|
||||
</div>
|
||||
</component>
|
||||
</template>
|
||||
@@ -28,7 +28,7 @@ const props = defineProps<{
|
||||
<template>
|
||||
<Card :class="cn('mb-4', props.edited && 'ring-primary/60', props.class)">
|
||||
<CardHeader v-if="title || description || $slots.action">
|
||||
<CardTitle v-if="title">{{ title }}</CardTitle>
|
||||
<CardTitle v-if="title" as="h2">{{ title }}</CardTitle>
|
||||
<CardDescription v-if="description">{{ description }}</CardDescription>
|
||||
<CardAction v-if="$slots.action"><slot name="action" /></CardAction>
|
||||
</CardHeader>
|
||||
|
||||
Reference in new issue
Block a user