-
Notifications
You must be signed in to change notification settings - Fork 63
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(store-ui): Add Skeleton Atom (#911)
* Add skeleton atom * Move animation to theme * Import tailwind utilities * Update test * Use only 1 div * Update story * Extend HTMLDivElement
- Loading branch information
1 parent
a1dd489
commit ef25cde
Showing
9 changed files
with
80 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
import { render } from '@testing-library/react' | ||
import React from 'react' | ||
|
||
import Skeleton from './Skeleton' | ||
|
||
describe('Skeleton', () => { | ||
it('`data-store-skeleton` is present', () => { | ||
const { getByTestId } = render(<Skeleton testId="store-skeleton" />) | ||
const skeleton = getByTestId('store-skeleton') | ||
|
||
expect(skeleton).toHaveAttribute('data-store-skeleton') | ||
}) | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
import React, { forwardRef } from 'react' | ||
import type { HTMLAttributes } from 'react' | ||
|
||
export interface SkeletonProps extends HTMLAttributes<HTMLDivElement> { | ||
/** | ||
* ID to find this component in testing tools (e.g.: cypress, testing library, and jest). | ||
*/ | ||
testId?: string | ||
} | ||
|
||
const Skeleton = forwardRef<HTMLDivElement, SkeletonProps>(function Skeleton( | ||
{ testId = 'store-skeleton', ...props }, | ||
ref | ||
) { | ||
return <div ref={ref} data-store-skeleton data-testid={testId} {...props} /> | ||
}) | ||
|
||
export default Skeleton |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
export { default } from './Skeleton' | ||
export type { SkeletonProps } from './Skeleton' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
import { Story, Canvas, ArgsTable } from '@storybook/addon-docs' | ||
import Skeleton from '../Skeleton' | ||
|
||
# Skeleton | ||
|
||
<Canvas> | ||
<Story id="atoms-skeleton--skeleton" /> | ||
</Canvas> | ||
|
||
## Props | ||
|
||
<ArgsTable of={Skeleton} /> | ||
|
||
## CSS Selectors | ||
|
||
```css | ||
[data-store-skeleton] {} | ||
``` |
21 changes: 21 additions & 0 deletions
21
packages/store-ui/src/atoms/Skeleton/stories/Skeleton.stories.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
import type { Story } from '@storybook/react' | ||
import React from 'react' | ||
|
||
import type { SkeletonProps } from '../Skeleton' | ||
import Component from '../Skeleton' | ||
import mdx from './Skeleton.mdx' | ||
|
||
const SkeletonTemplate: Story<SkeletonProps> = ({ testId, ...props }) => ( | ||
<Component testId={testId} {...props} /> | ||
) | ||
|
||
export const Skeleton = SkeletonTemplate.bind({}) | ||
|
||
export default { | ||
title: 'Atoms/Skeleton', | ||
parameters: { | ||
docs: { | ||
page: mdx, | ||
}, | ||
}, | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,3 +7,4 @@ | |
@import "./overlay.css"; | ||
@import "./badge.css"; | ||
@import "./slider.css"; | ||
@import "./skeleton.css"; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
[data-store-skeleton] { | ||
@apply animate-pulse rounded bg-gray-400 h-14 w-96; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,3 @@ | ||
@import "./atoms/index.css"; | ||
@import "./molecules/index.css"; | ||
@import "./utils/utilities.css"; |