Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(store-ui): Add Skeleton Atom #911

Merged
merged 7 commits into from
Sep 13, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions packages/store-ui/src/atoms/Skeleton/Skeleton.test.tsx
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')
})
})
18 changes: 18 additions & 0 deletions packages/store-ui/src/atoms/Skeleton/Skeleton.tsx
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 },
lariciamota marked this conversation as resolved.
Show resolved Hide resolved
ref
) {
return <div ref={ref} data-store-skeleton data-testid={testId} {...props} />
})

export default Skeleton
2 changes: 2 additions & 0 deletions packages/store-ui/src/atoms/Skeleton/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
export { default } from './Skeleton'
export type { SkeletonProps } from './Skeleton'
18 changes: 18 additions & 0 deletions packages/store-ui/src/atoms/Skeleton/stories/Skeleton.mdx
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 packages/store-ui/src/atoms/Skeleton/stories/Skeleton.stories.tsx
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,
},
},
}
3 changes: 3 additions & 0 deletions packages/store-ui/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,9 @@ export type { SliderProps } from './atoms/Slider'
export { default as List } from './atoms/List'
export type { ListProps } from './atoms/List'

export { default as Skeleton } from './atoms/Skeleton'
export type { SkeletonProps } from './atoms/Skeleton'

// Molecules
export { default as Bullets } from './molecules/Bullets'
export type { BulletsProps } from './molecules/Bullets'
Expand Down
1 change: 1 addition & 0 deletions themes/theme-b2c-tailwind/src/atoms/index.css
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,4 @@
@import "./overlay.css";
@import "./badge.css";
@import "./slider.css";
@import "./skeleton.css";
3 changes: 3 additions & 0 deletions themes/theme-b2c-tailwind/src/atoms/skeleton.css
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;
}
1 change: 1 addition & 0 deletions themes/theme-b2c-tailwind/src/index.css
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";