Skip to content

Commit e9f9d37

Browse files
feat: add new separator component and fix typo in status banner message
- Add a new separator component to the kit-headless package. - Fix a typo in the status banner message, changing "Production Readty" to "Production Ready".
1 parent 2d43fb1 commit e9f9d37

File tree

3 files changed

+59
-1
lines changed

3 files changed

+59
-1
lines changed

apps/website/src/routes/docs/_components/status-banner/status-banner.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ function getMessageByStatus(status?: ComponentStatus) {
1717
case ComponentStatus.Ready:
1818
return (
1919
<>
20-
This component is <strong>Production Readty</strong>
20+
This component is <strong>Production Ready</strong>
2121
</>
2222
);
2323
case ComponentStatus.Beta:
Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
import { component$, HTMLAttributes, useComputed$ } from '@builder.io/qwik';
2+
3+
const ORIENTATIONS = ['horizontal', 'vertical'] as const;
4+
5+
type Orientation = (typeof ORIENTATIONS)[number];
6+
7+
export interface SeparatorProps extends HTMLAttributes<HTMLElement> {
8+
/**
9+
* Either `vertical` or `horizontal`. Defaults to `horizontal`.
10+
*/
11+
orientation?: Orientation;
12+
/**
13+
* If true, accessibility-related attributes
14+
* are updated so that that the element is not included in the accessibility tree.
15+
*/
16+
decorative?: boolean;
17+
}
18+
19+
export const Separator = component$(
20+
({
21+
orientation: orientationProp = 'horizontal',
22+
decorative,
23+
...props
24+
}: SeparatorProps) => {
25+
const orientation = useComputed$(() => {
26+
if (ORIENTATIONS.includes(orientationProp)) {
27+
return orientationProp;
28+
}
29+
30+
console.warn(
31+
`Invalid prop 'orientation' of value '${orientationProp}' supplied to 'separator',
32+
expected one of:
33+
- horizontal
34+
- vertical
35+
36+
Defaulting to 'horizontal'.`
37+
);
38+
return 'horizontal';
39+
});
40+
41+
// `aria-orientation` defaults to `horizontal` so we only need it if `orientation` is vertical
42+
const ariaOrientation = useComputed$(() =>
43+
orientation.value === 'vertical' ? orientation : undefined
44+
);
45+
46+
const semanticProps = useComputed$(() =>
47+
decorative
48+
? { role: 'none' }
49+
: {
50+
role: 'separator',
51+
'aria-orientation': ariaOrientation
52+
}
53+
);
54+
55+
return <div data-orientation={orientation} {...semanticProps} {...props} />;
56+
}
57+
);

packages/kit-headless/src/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ export * from './components/tooltip/tooltip';
2121
export * as Checkbox from './components/checkbox/checkbox';
2222
export * as CheckboxProps from './components/checkbox/checkbox';
2323
export * from './components/select';
24+
export * from './components/separator/separator';
2425
export * from './components/slider';
2526
export * from './components/breadcrumb';
2627
export * from './components/navigation-bar/navigation-bar';

0 commit comments

Comments
 (0)