File tree Expand file tree Collapse file tree 5 files changed +93
-0
lines changed
packages/vue-primitives/src/separator Expand file tree Collapse file tree 5 files changed +93
-0
lines changed Original file line number Diff line number Diff line change 1+ import type { PrimitiveProps } from '~/primitive/index.ts'
2+
3+ export interface SeparatorProps extends PrimitiveProps {
4+ /**
5+ * Either `vertical` or `horizontal`. Defaults to `horizontal`.
6+ */
7+ orientation ?: 'vertical' | 'horizontal'
8+ /**
9+ * Whether or not the component is purely decorative. When true, accessibility-related attributes
10+ * are updated so that that the rendered element is removed from the accessibility tree.
11+ */
12+ decorative ?: boolean
13+ }
Original file line number Diff line number Diff line change 1+ <script setup lang="ts">
2+ import type { SeparatorProps } from ' ./Separator.ts'
3+ import { Primitive } from ' ~/primitive/index.ts'
4+
5+ defineOptions ({
6+ name: ' Separator' ,
7+ })
8+
9+ withDefaults (defineProps <SeparatorProps >(), {
10+ orientation: ' horizontal' ,
11+ })
12+ </script >
13+
14+ <template >
15+ <Primitive
16+ :as =" as"
17+ :as-child =" asChild"
18+ :data-orientation =" orientation"
19+ v-bind =" {
20+ ...(
21+ decorative ? {
22+ role: 'none',
23+ } : {
24+ 'aria-orientation': orientation === 'vertical' ? orientation : undefined,
25+ 'role': 'separator',
26+ }
27+ ),
28+ }"
29+ >
30+ <slot />
31+ </Primitive >
32+ </template >
Original file line number Diff line number Diff line change 1+ export { default as Separator } from './Separator.vue'
2+ export type { SeparatorProps } from './Separator.ts'
Original file line number Diff line number Diff line change 1+ import { Separator } from '../index.ts'
2+ import './styles.css'
3+
4+ export default { title : 'Components/Separator' }
5+
6+ export function Styled ( ) {
7+ return (
8+ < >
9+ < h1 > Horizontal</ h1 >
10+ < p > The following separator is horizontal and has semantic meaning.</ p >
11+ < Separator class = "separator_root" orientation = "horizontal" />
12+ < p >
13+ The following separator is horizontal and is purely decorative. Assistive technology will
14+ ignore this element.
15+ </ p >
16+ < Separator class = "separator_root" orientation = "horizontal" decorative />
17+
18+ < h1 > Vertical</ h1 >
19+ < div style = { { display : 'flex' , alignItems : 'center' } } >
20+ < p > The following separator is vertical and has semantic meaning.</ p >
21+ < Separator class = "separator_root" orientation = "vertical" />
22+ < p >
23+ The following separator is vertical and is purely decorative. Assistive technology will
24+ ignore this element.
25+ </ p >
26+ < Separator class = "separator_root" orientation = "vertical" decorative />
27+ </ div >
28+ </ >
29+ )
30+ }
Original file line number Diff line number Diff line change 1+ .separator_root {
2+ border : none;
3+ background-color : red;
4+
5+ & [data-orientation = "horizontal" ] {
6+ height : 1px ;
7+ width : 100% ;
8+ margin : 20px 0 ;
9+ }
10+
11+ & [data-orientation = "vertical" ] {
12+ height : 100px ;
13+ width : 1px ;
14+ margin : 0 20px ;
15+ }
16+ }
You can’t perform that action at this time.
0 commit comments