Skip to content

Commit

Permalink
fix(Skeleton): mark .Rect as deprecated (#1586)
Browse files Browse the repository at this point in the history
- typing a subcomponent that is self-referential is sort of weird
- instead, suggest people not do that (and clarify the docs to indicate preference)
- add new snapshots
  • Loading branch information
booc0mtaco authored Apr 6, 2023
1 parent 7291c6a commit 405f81b
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 2 deletions.
14 changes: 14 additions & 0 deletions src/components/Skeleton/Skeleton.stories.tsx
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { BADGE } from '@geometricpanda/storybook-addon-badges';
import type { StoryObj, Meta } from '@storybook/react';
import React from 'react';

Expand Down Expand Up @@ -29,6 +30,19 @@ export const Default: StoryObj<Args> = {
},
};

export const Rect: StoryObj<Args> = {
args: {
width: 50,
height: 50,
},
parameters: {
badges: [BADGE.DEPRECATED],
},
render: (args) => {
return <Skeleton.Rect {...args} />;
},
};

export const Circle: StoryObj<React.ComponentProps<typeof Skeleton.Circle>> = {
args: {
width: 100,
Expand Down
5 changes: 3 additions & 2 deletions src/components/Skeleton/Skeleton.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,9 @@ type SkeletonProps = BaseProps & {
*
* For text, Use `Skeleton.Text` and specify the height and the width (for example in 'ch' units).
*
* For circular objects, use `Skeleton.Circle' and specify the width (which is the same as the height).
* For circular objects, use `Skeleton.Circle` and specify the width (which is the same as the height).
*
* For all other objects, use `Skeleton.Rect` (or just `Skeleton`) and specify the width and height.
* For rectangular objects, just use `Skeleton` and specify the width and height.
*/
export const Skeleton = ({
className,
Expand Down Expand Up @@ -107,5 +107,6 @@ const CircleSkeleton = ({
};

Skeleton.Text = TextSkeleton;
/** @deprecated Use `Skeleton` instead */
Skeleton.Rect = Skeleton;
Skeleton.Circle = CircleSkeleton;
8 changes: 8 additions & 0 deletions src/components/Skeleton/__snapshots__/Skeleton.test.ts.snap
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,14 @@ exports[`<Skeleton /> Default story renders snapshot 1`] = `
/>
`;

exports[`<Skeleton /> Rect story renders snapshot 1`] = `
<div
aria-hidden="true"
class="skeleton skeleton--is-animating"
style="width: 50px; height: 50px;"
/>
`;

exports[`<Skeleton /> Text story renders snapshot 1`] = `
<div
aria-hidden="true"
Expand Down

0 comments on commit 405f81b

Please sign in to comment.