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>
|
<template>
|
||||||
<SidebarGroup>
|
<SidebarGroup>
|
||||||
<SidebarMenu aria-label="Sections">
|
<nav aria-label="Sections">
|
||||||
|
<SidebarMenu>
|
||||||
<SidebarMenuItem v-for="entry in links" :key="entry.path">
|
<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">
|
<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">
|
<RouterLink :to="entry.path" :aria-current="activePath === entry.path ? 'page' : undefined">
|
||||||
@@ -38,5 +39,6 @@ watch(() => route.path, () => { if (isMobile.value) setOpenMobile(false); });
|
|||||||
</SidebarMenuButton>
|
</SidebarMenuButton>
|
||||||
</SidebarMenuItem>
|
</SidebarMenuItem>
|
||||||
</SidebarMenu>
|
</SidebarMenu>
|
||||||
|
</nav>
|
||||||
</SidebarGroup>
|
</SidebarGroup>
|
||||||
</template>
|
</template>
|
||||||
@@ -2,13 +2,19 @@
|
|||||||
import type { HTMLAttributes } from "vue";
|
import type { HTMLAttributes } from "vue";
|
||||||
import { cn } from "@/lib/utils";
|
import { cn } from "@/lib/utils";
|
||||||
|
|
||||||
const props = defineProps<{
|
const props = withDefaults(
|
||||||
class?: HTMLAttributes["class"];
|
defineProps<{
|
||||||
}>();
|
class?: HTMLAttributes["class"];
|
||||||
|
/** The heading level, so pages keep a real heading structure. */
|
||||||
|
as?: string;
|
||||||
|
}>(),
|
||||||
|
{ as: "h2" },
|
||||||
|
);
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
<div
|
<component
|
||||||
|
:is="props.as"
|
||||||
data-slot="card-title"
|
data-slot="card-title"
|
||||||
:class="
|
:class="
|
||||||
cn(
|
cn(
|
||||||
@@ -18,5 +24,5 @@ const props = defineProps<{
|
|||||||
"
|
"
|
||||||
>
|
>
|
||||||
<slot />
|
<slot />
|
||||||
</div>
|
</component>
|
||||||
</template>
|
</template>
|
||||||
@@ -2,18 +2,24 @@
|
|||||||
import type { HTMLAttributes } from "vue";
|
import type { HTMLAttributes } from "vue";
|
||||||
import { cn } from "@/lib/utils";
|
import { cn } from "@/lib/utils";
|
||||||
|
|
||||||
const props = defineProps<{
|
const props = withDefaults(
|
||||||
class?: HTMLAttributes["class"];
|
defineProps<{
|
||||||
}>();
|
class?: HTMLAttributes["class"];
|
||||||
|
/** The heading level, so pages keep a real heading structure. */
|
||||||
|
as?: string;
|
||||||
|
}>(),
|
||||||
|
{ as: "h2" },
|
||||||
|
);
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
<div
|
<component
|
||||||
|
:is="props.as"
|
||||||
data-slot="empty-title"
|
data-slot="empty-title"
|
||||||
:class="
|
:class="
|
||||||
cn('text-label font-medium tracking-tight cn-font-heading', props.class)
|
cn('text-label font-medium tracking-tight cn-font-heading', props.class)
|
||||||
"
|
"
|
||||||
>
|
>
|
||||||
<slot />
|
<slot />
|
||||||
</div>
|
</component>
|
||||||
</template>
|
</template>
|
||||||
@@ -28,7 +28,7 @@ const props = defineProps<{
|
|||||||
<template>
|
<template>
|
||||||
<Card :class="cn('mb-4', props.edited && 'ring-primary/60', props.class)">
|
<Card :class="cn('mb-4', props.edited && 'ring-primary/60', props.class)">
|
||||||
<CardHeader v-if="title || description || $slots.action">
|
<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>
|
<CardDescription v-if="description">{{ description }}</CardDescription>
|
||||||
<CardAction v-if="$slots.action"><slot name="action" /></CardAction>
|
<CardAction v-if="$slots.action"><slot name="action" /></CardAction>
|
||||||
</CardHeader>
|
</CardHeader>
|
||||||
|
|||||||
Reference in new issue
Block a user