diff --git a/package-lock.json b/package-lock.json index 106746377..cbd92b499 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1890,6 +1890,7 @@ }, "node_modules/@clack/prompts/node_modules/is-unicode-supported": { "version": "1.3.0", + "extraneous": true, "inBundle": true, "license": "MIT", "engines": { @@ -30526,7 +30527,6 @@ "license": "MIT", "dependencies": { "@spark-ui/internal-utils": "^6.3.8", - "@spark-ui/radio-group": "^6.3.8", "@spark-ui/visually-hidden": "^6.3.8", "class-variance-authority": "0.7.0" }, diff --git a/packages/components/skeleton/package.json b/packages/components/skeleton/package.json index e9d6e834f..90cb72dee 100644 --- a/packages/components/skeleton/package.json +++ b/packages/components/skeleton/package.json @@ -23,7 +23,6 @@ "build": "vite build" }, "dependencies": { - "@spark-ui/radio-group": "^6.3.8", "@spark-ui/internal-utils": "^6.3.8", "@spark-ui/visually-hidden": "^6.3.8", "class-variance-authority": "0.7.0" diff --git a/packages/components/skeleton/src/Skeleton.doc.mdx b/packages/components/skeleton/src/Skeleton.doc.mdx index a362ea875..023639ff0 100644 --- a/packages/components/skeleton/src/Skeleton.doc.mdx +++ b/packages/components/skeleton/src/Skeleton.doc.mdx @@ -30,10 +30,6 @@ import { Skeleton } from '@spark-ui/skeleton' of={Skeleton} description="A container for all Skeleton parts." subcomponents={{ - 'Skeleton.Group': { - of: Skeleton.Group, - description: 'A wrapper to group Skeleton components, for advanced layouts.', - }, 'Skeleton.Circle': { of: Skeleton.Circle, description: 'A specific Skeleton component, for circular content.', @@ -55,27 +51,20 @@ import { Skeleton } from '@spark-ui/skeleton' -### Size +### Sizing For `` component you can use `width|height` props to define the size. -For `` component you can use `size` prop to define the size. - -For `` component you can use `lines` prop to define the number of lines, which will be equivalent to size in this specific usecase. - - + -### Gap - -Use `gap` property to set gaps between group items, or lines. - - +For `` component you can use `size` prop to define the size. -### Alignment + -Use `alignment` property to set alignments for group items, or lines. +For `` component you can use `lines` prop to define the number of lines, which will +be equivalent to size in this specific usecase. To handle spacing between these lines, use `gap` specific prop. - + ### Animation @@ -85,11 +74,11 @@ Use `isAnimated` prop display an animation on your `` content. ## Advanced usage -### Group +### Composing layouts -For advanced `` layouts you can group items to fit your specific needs. You can then define gaps, direction and alignment properties for this group, using dedicated properties `gap`, `direction` and `alignment`. +For specific needs you may want to build an entire layout using skeleton items (eg. cards, ...). You may then simply add your own solution (such as a specific markup using flexbox or grid CSS modules) in your implementation. - + ## Accessibility diff --git a/packages/components/skeleton/src/Skeleton.stories.tsx b/packages/components/skeleton/src/Skeleton.stories.tsx index f73aa782c..d3cfdd204 100644 --- a/packages/components/skeleton/src/Skeleton.stories.tsx +++ b/packages/components/skeleton/src/Skeleton.stories.tsx @@ -1,10 +1,7 @@ import { StoryLabel } from '@docs/helpers/StoryLabel' -import { RadioGroup } from '@spark-ui/radio-group' import { Meta, StoryFn } from '@storybook/react' -import { useState } from 'react' import { Skeleton } from '.' -import { SkeletonGroupProps } from './SkeletonGroup' const meta: Meta = { title: 'Experimental/Skeleton', @@ -14,140 +11,57 @@ const meta: Meta = { export default meta export const Default: StoryFn = _args => ( - + ) -export const Size: StoryFn = _args => ( -
-
- - - - - -
- -
- - - - - -
- -
- - - - - -
-
+export const CircleSize: StoryFn = _args => ( + + + ) -const gaps: ExcludeNull[] = ['sm', 'md', 'lg', 'xl', '2xl', '3xl'] -export const Gap: StoryFn = _args => { - return ( -
- {gaps.map(gap => ( -
- {gap} - - - -
- ))} -
- ) -} - -const alignments: ExcludeNull[] = ['start', 'center', 'end'] -export const Alignment: StoryFn = _args => ( -
- {alignments.map(alignment => ( -
- {alignment} - - - -
- ))} -
+export const RectangleSize: StoryFn = _args => ( + + + ) -export const Group: StoryFn = _args => { - const [alignment, setAlignment] = useState('start') - - return ( -
- setAlignment(value as SkeletonGroupProps['align'])} - > - Start - Center - End - - -
-
- with direction `row` (default) - - - - - - - -
- -
- with direction `column` - - - - - - - -
-
- -
- with specific gaps - - - - - - - - - -
-
- ) -} +export const LineSize: StoryFn = _args => ( + + + +) export const Animation: StoryFn = _args => (
with animation (default) - +
without animation - +
) + +export const Layout: StoryFn = _args => ( + +
+ + +
+ + + + +
+) diff --git a/packages/components/skeleton/src/Skeleton.styles.ts b/packages/components/skeleton/src/Skeleton.styles.ts index 9841376b0..f04efed94 100644 --- a/packages/components/skeleton/src/Skeleton.styles.ts +++ b/packages/components/skeleton/src/Skeleton.styles.ts @@ -1,6 +1,6 @@ import { cva, VariantProps } from 'class-variance-authority' -export const skeletonStyles = cva(['flex flex-row !flex-wrap'], { +export const skeletonStyles = cva([], { variants: { isAnimated: { true: [ diff --git a/packages/components/skeleton/src/Skeleton.tsx b/packages/components/skeleton/src/Skeleton.tsx index f15736975..af52d1df1 100644 --- a/packages/components/skeleton/src/Skeleton.tsx +++ b/packages/components/skeleton/src/Skeleton.tsx @@ -2,12 +2,8 @@ import { VisuallyHidden } from '@spark-ui/visually-hidden' import { ComponentPropsWithoutRef, forwardRef, PropsWithChildren } from 'react' import { type SkeletonStyleProps, skeletonStyles } from './Skeleton.styles' -import { SkeletonGroup, type SkeletonGroupProps } from './SkeletonGroup' -export interface SkeletonProps - extends ComponentPropsWithoutRef<'div'>, - SkeletonStyleProps, - SkeletonGroupProps { +export interface SkeletonProps extends ComponentPropsWithoutRef<'div'>, SkeletonStyleProps { /** * Displays an animated light effect. * @default true @@ -21,7 +17,7 @@ export interface SkeletonProps export const Skeleton = forwardRef>( ({ isAnimated = true, label, className, children, ...rest }, forwardedRef) => ( - {label}} - + ) ) diff --git a/packages/components/skeleton/src/SkeletonGroup.styles.ts b/packages/components/skeleton/src/SkeletonGroup.styles.ts deleted file mode 100644 index 58b109aa8..000000000 --- a/packages/components/skeleton/src/SkeletonGroup.styles.ts +++ /dev/null @@ -1,29 +0,0 @@ -import { cva, VariantProps } from 'class-variance-authority' - -export const skeletonGroupStyles = cva(['flex flex-nowrap flex-auto'], { - variants: { - gap: { - sm: 'gap-sm', - md: 'gap-md', - lg: 'gap-lg', - xl: 'gap-xl', - '2xl': 'gap-2xl', - '3xl': 'gap-3xl', - }, - direction: { - row: 'flex-row', - column: 'flex-col', - }, - align: { - start: 'items-start', - center: 'items-center', - end: 'items-end', - }, - }, - defaultVariants: { - direction: 'row', - align: 'start', - }, -}) - -export type SkeletonGroupStyleProps = ExcludeNull> diff --git a/packages/components/skeleton/src/SkeletonGroup.tsx b/packages/components/skeleton/src/SkeletonGroup.tsx deleted file mode 100644 index f159d8132..000000000 --- a/packages/components/skeleton/src/SkeletonGroup.tsx +++ /dev/null @@ -1,37 +0,0 @@ -import { ComponentPropsWithoutRef, forwardRef, PropsWithChildren } from 'react' - -import { type SkeletonGroupStyleProps, skeletonGroupStyles } from './SkeletonGroup.styles' - -export interface SkeletonGroupProps - extends ComponentPropsWithoutRef<'div'>, - SkeletonGroupStyleProps { - /** - * Sets the main axis direction. - * @default row - */ - direction?: 'row' | 'column' - /** - * Sets the default alignement. - * @default start - */ - align?: 'start' | 'center' | 'end' - /** - * Sets the gaps between group items. - */ - gap?: 'sm' | 'md' | 'lg' | 'xl' | '2xl' | '3xl' -} - -export const SkeletonGroup = forwardRef>( - ({ gap, direction = 'row', align = 'start', className, children, ...rest }, forwardedRef) => ( -
- {children} -
- ) -) - -SkeletonGroup.displayName = 'Skeleton.Group' diff --git a/packages/components/skeleton/src/SkeletonItem.styles.ts b/packages/components/skeleton/src/SkeletonItem.styles.ts index a7a1f448e..bea28fff1 100644 --- a/packages/components/skeleton/src/SkeletonItem.styles.ts +++ b/packages/components/skeleton/src/SkeletonItem.styles.ts @@ -3,9 +3,9 @@ import { cva, VariantProps } from 'class-variance-authority' export const skeletonItemStyles = cva(['bg-neutral/dim-4', 'min-h-lg min-w-lg'], { variants: { shape: { - line: ['flex', 'w-full [&:last-child:not(:first-child)]:w-5/6', 'rounded-lg'], - rectangle: ['flex', 'rounded-sm'], - circle: ['inline-flex flex-none', 'rounded-full'], + line: ['w-full [&:last-child:not(:first-child)]:w-5/6', 'rounded-lg'], + rectangle: ['rounded-sm'], + circle: ['flex-none', 'rounded-full'], }, }, defaultVariants: { @@ -15,11 +15,6 @@ export const skeletonItemStyles = cva(['bg-neutral/dim-4', 'min-h-lg min-w-lg'], export const skeletonLineStyles = cva(['flex flex-col', 'w-full'], { variants: { - align: { - start: 'items-start', - center: 'items-center', - end: 'items-end', - }, gap: { sm: 'gap-sm', md: 'gap-md', @@ -30,7 +25,7 @@ export const skeletonLineStyles = cva(['flex flex-col', 'w-full'], { }, }, defaultVariants: { - align: 'start', + gap: 'md', }, }) diff --git a/packages/components/skeleton/src/SkeletonItem.tsx b/packages/components/skeleton/src/SkeletonItem.tsx index 4b62f8451..6bcc581ca 100644 --- a/packages/components/skeleton/src/SkeletonItem.tsx +++ b/packages/components/skeleton/src/SkeletonItem.tsx @@ -15,11 +15,6 @@ export type SkeletonRectangleProps = Omit & { export type SkeletonCircleProps = Omit & { size: string | number } export type SkeletonLineProps = Omit & { lines?: number - /** - * Sets the default alignement. - * @default start - */ - align?: 'start' | 'center' | 'end' /** * Sets the gaps between group items. */ @@ -75,14 +70,13 @@ export const SkeletonCircle = ({ size, ...rest }: SkeletonCircleProps) => ( export const SkeletonLine = ({ lines = 1, gap: gapProp, - align = 'start', className, ...rest }: SkeletonLineProps) => { const gap = gapProp || 'md' return ( -
+
{[...new Array(lines)].map((_, index) => ( ))} diff --git a/packages/components/skeleton/src/index.ts b/packages/components/skeleton/src/index.ts index 4ec2ca1a0..5b8c76e47 100644 --- a/packages/components/skeleton/src/index.ts +++ b/packages/components/skeleton/src/index.ts @@ -1,5 +1,4 @@ import { Skeleton as Root } from './Skeleton' -import { SkeletonGroup as Group } from './SkeletonGroup' import { SkeletonCircle as Circle, SkeletonLine as Line, @@ -10,16 +9,13 @@ export const Skeleton: typeof Root & { Circle: typeof Circle Line: typeof Line Rectangle: typeof Rectangle - Group: typeof Group } = Object.assign(Root, { Circle, Line, Rectangle, - Group, }) Skeleton.displayName = 'Skeleton' -Group.displayName = 'Skeleton.Group' Line.displayName = 'Skeleton.Line' Circle.displayName = 'Skeleton.Circle' Rectangle.displayName = 'Skeleton.Rectangle'