Skip to content

Commit 00218e8

Browse files
authored
Merge branch 'main' into feat/switch
2 parents b53613c + a9c651a commit 00218e8

File tree

48 files changed

+1130
-2
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

48 files changed

+1130
-2
lines changed

.changeset/evil-hands-obey.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
---
2+
"@skeletonlabs/skeleton-common": minor
3+
"@skeletonlabs/skeleton-svelte": minor
4+
"@skeletonlabs/skeleton-react": minor
5+
"@skeletonlabs/skeleton": patch
6+
---
7+
8+
feat: progress-linear
9+
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
import { defineSkeletonClasses } from '../internal/define-skeleton-classes.js' with { type: 'macro' };
2+
3+
export const classesProgressLinear = defineSkeletonClasses({
4+
root: [
5+
// Common
6+
'items-center justify-center gap-2',
7+
// Horizontal Orientation
8+
'data-[orientation=horizontal]:flex data-[orientation=horizontal]:flex-row data-[orientation=horizontal]:w-full',
9+
// Vertical Orientation
10+
'data-[orientation=vertical]:inline-flex data-[orientation=vertical]:flex-col'
11+
],
12+
label: 'whitespace-nowrap',
13+
track: [
14+
// Common
15+
'bg-surface-200-800 rounded-base overflow-hidden',
16+
// Horizontal Orientation
17+
'data-[orientation=horizontal]:w-full data-[orientation=horizontal]:h-2',
18+
// Vertical Orientation
19+
'data-[orientation=vertical]:w-2 data-[orientation=vertical]:h-[100px]'
20+
],
21+
range: [
22+
// Common
23+
'h-full bg-surface-950-50 rounded-base',
24+
// Horizontal Orientation
25+
'data-[orientation=horizontal]:transition-[width] data-[orientation=horizontal]:data-[state=indeterminate]:animate-progress-indeterminate-horz',
26+
// Vertical Orientation
27+
'data-[orientation=vertical]:transition-[height] data-[orientation=vertical]:data-[state=indeterminate]:animate-progress-indeterminate-vert'
28+
]
29+
});

packages/skeleton-common/src/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
export * from './themes';
22
export * from './classes/accordion';
33
export * from './classes/avatar';
4+
export * from './classes/progress-linear';
45
export * from './classes/rating-group';
56
export * from './classes/switch';
67
export * from './classes/tabs';
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
import { useContext, type ComponentProps } from 'react';
2+
import { mergeProps } from '@zag-js/react';
3+
import { classesProgressLinear } from '@skeletonlabs/skeleton-common';
4+
import { ProgressLinearRootContext } from '../modules/root-context';
5+
import type { PropsWithElement } from '@/internal/props-with-element';
6+
7+
export interface ProgressLinearLabelProps extends PropsWithElement, ComponentProps<'div'> {}
8+
9+
export default function (props: ProgressLinearLabelProps) {
10+
const rootContext = useContext(ProgressLinearRootContext);
11+
12+
const { element, children, ...restAttributes } = props;
13+
14+
const attributes = mergeProps(rootContext.api.getLabelProps(), { className: classesProgressLinear.label }, restAttributes);
15+
16+
return element ? element({ attributes }) : <div {...attributes}>{children}</div>;
17+
}
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
import { useContext, type ComponentProps } from 'react';
2+
import { mergeProps } from '@zag-js/react';
3+
import { classesProgressLinear } from '@skeletonlabs/skeleton-common';
4+
import { ProgressLinearRootContext } from '../modules/root-context';
5+
import type { PropsWithElement } from '@/internal/props-with-element';
6+
7+
export interface ProgressLinearRangeProps extends PropsWithElement, Omit<ComponentProps<'div'>, 'children'> {}
8+
9+
export default function (props: ProgressLinearRangeProps) {
10+
const rootContext = useContext(ProgressLinearRootContext);
11+
12+
const { element, ...restAttributes } = props;
13+
14+
const attributes = mergeProps(rootContext.api.getRangeProps(), { className: classesProgressLinear.range }, restAttributes);
15+
16+
return element ? element({ attributes }) : <div {...attributes} />;
17+
}
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
import { useContext, type ReactNode } from 'react';
2+
import { ProgressLinearRootContext, type ProgressLinearRootContextType } from '../modules/root-context';
3+
4+
export interface ProgressLinearRootContextProps {
5+
children: (context: ProgressLinearRootContextType) => ReactNode;
6+
}
7+
8+
export default function (props: ProgressLinearRootContextProps) {
9+
const rootContext = useContext(ProgressLinearRootContext);
10+
11+
return props.children(rootContext);
12+
}
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
import { useId, type ComponentProps } from 'react';
2+
import { mergeProps, normalizeProps, useMachine } from '@zag-js/react';
3+
import { splitProps, machine, connect, type Props } from '@zag-js/progress';
4+
import { classesProgressLinear } from '@skeletonlabs/skeleton-common';
5+
import { ProgressLinearRootContext } from '../modules/root-context';
6+
import type { PropsWithElement } from '@/internal/props-with-element';
7+
8+
export interface ProgressLinearRootProps
9+
extends PropsWithElement,
10+
Omit<Props, 'id'>,
11+
Omit<ComponentProps<'div'>, 'id' | 'dir' | 'defaultValue'> {}
12+
13+
export default function (props: ProgressLinearRootProps) {
14+
const [machineProps, componentProps] = splitProps(props);
15+
const { element, children, ...restAttributes } = componentProps;
16+
17+
const service = useMachine(machine, {
18+
id: useId(),
19+
...machineProps
20+
});
21+
const api = connect(service, normalizeProps);
22+
23+
const attributes = mergeProps(
24+
api.getRootProps(),
25+
{
26+
className: classesProgressLinear.root
27+
},
28+
restAttributes
29+
);
30+
31+
return (
32+
<ProgressLinearRootContext.Provider value={{ api }}>
33+
{element ? element({ attributes }) : <div {...attributes}>{children}</div>}
34+
</ProgressLinearRootContext.Provider>
35+
);
36+
}
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
import { useContext, type ComponentProps } from 'react';
2+
import { mergeProps } from '@zag-js/react';
3+
import { classesProgressLinear } from '@skeletonlabs/skeleton-common';
4+
import { ProgressLinearRootContext } from '../modules/root-context';
5+
import type { PropsWithElement } from '@/internal/props-with-element';
6+
7+
export interface ProgressLinearTrackProps extends PropsWithElement, ComponentProps<'div'> {}
8+
9+
export default function (props: ProgressLinearTrackProps) {
10+
const rootContext = useContext(ProgressLinearRootContext);
11+
12+
const { element, children, ...restAttributes } = props;
13+
14+
const attributes = mergeProps(rootContext.api.getTrackProps(), { className: classesProgressLinear.track }, restAttributes);
15+
16+
return element ? element({ attributes }) : <div {...attributes}>{children}</div>;
17+
}
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
export { ProgressLinear } from './modules/anatomy';
2+
export type { ProgressLinearRootProps } from './anatomy/root';
3+
export type { ProgressLinearRootContextProps } from './anatomy/root-context';
4+
export type { ProgressLinearLabelProps } from './anatomy/label';
5+
export type { ProgressLinearTrackProps } from './anatomy/track';
6+
export type { ProgressLinearRangeProps } from './anatomy/range';
7+
export type { ProgressLinearRootContextType as ProgressLinearRootContext } from './modules/root-context';
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
import Root from '../anatomy/root';
2+
import RootContext from '../anatomy/root-context';
3+
import Label from '../anatomy/label';
4+
import Track from '../anatomy/track';
5+
import Range from '../anatomy/range';
6+
7+
export const ProgressLinear = Object.assign(Root, {
8+
Context: RootContext,
9+
Label: Label,
10+
Track: Track,
11+
Range: Range
12+
});

0 commit comments

Comments
 (0)