-
Notifications
You must be signed in to change notification settings - Fork 65
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Co-authored-by: Brooke Scarlett Yalof <brooke.yalof@mongodb.com>
- Loading branch information
Showing
9 changed files
with
109 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,5 @@ | ||
--- | ||
'@leafygreen-ui/skeleton-loader': minor | ||
--- | ||
|
||
Adds `CodeSkeleton` |
15 changes: 15 additions & 0 deletions
15
packages/skeleton-loader/src/CodeSkeleton/CodeSkeleton.spec.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,15 @@ | ||
import React from 'react'; | ||
import { render } from '@testing-library/react'; | ||
import { axe } from 'jest-axe'; | ||
|
||
import { CodeSkeleton } from './CodeSkeleton'; | ||
|
||
describe('packages/skeleton-loader/CodeSkeleton', () => { | ||
describe('a11y', () => { | ||
test('does not have basic accessibility issues', async () => { | ||
const { container } = render(<CodeSkeleton />); | ||
const results = await axe(container); | ||
expect(results).toHaveNoViolations(); | ||
}); | ||
}); | ||
}); |
25 changes: 25 additions & 0 deletions
25
packages/skeleton-loader/src/CodeSkeleton/CodeSkeleton.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,25 @@ | ||
import React from 'react'; | ||
import { StoryFn } from '@storybook/react'; | ||
|
||
import { storybookArgTypes } from '@leafygreen-ui/lib'; | ||
|
||
import { CodeSkeleton } from '..'; | ||
|
||
export default { | ||
title: 'Components/SkeletonLoader', | ||
component: CodeSkeleton, | ||
argTypes: { | ||
darkMode: storybookArgTypes.darkMode, | ||
}, | ||
decorators: [ | ||
(Story: StoryFn) => ( | ||
<div style={{ width: 700 }}> | ||
<Story /> | ||
</div> | ||
), | ||
], | ||
}; | ||
|
||
export const Code: StoryFn<typeof CodeSkeleton> = props => ( | ||
<CodeSkeleton {...props} /> | ||
); |
19 changes: 19 additions & 0 deletions
19
packages/skeleton-loader/src/CodeSkeleton/CodeSkeleton.styles.ts
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,19 @@ | ||
import { css } from '@leafygreen-ui/emotion'; | ||
import { spacing } from '@leafygreen-ui/tokens'; | ||
|
||
export const rootStyles = css` | ||
width: 100%; | ||
display: grid; | ||
row-gap: ${spacing[3]}px; | ||
grid-template-columns: 75px 1fr 75px; | ||
`; | ||
|
||
export const lineStyles = css` | ||
&:nth-child(even) { | ||
grid-column: 2 / -1; | ||
} | ||
&:nth-child(odd) { | ||
grid-column: 1 / span 2; | ||
} | ||
`; |
30 changes: 30 additions & 0 deletions
30
packages/skeleton-loader/src/CodeSkeleton/CodeSkeleton.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,30 @@ | ||
import React from 'react'; | ||
|
||
import { cx } from '@leafygreen-ui/emotion'; | ||
import LeafyGreenProvider, { | ||
useDarkMode, | ||
} from '@leafygreen-ui/leafygreen-provider'; | ||
|
||
import { Skeleton } from '..'; | ||
|
||
import { lineStyles, rootStyles } from './CodeSkeleton.styles'; | ||
import { CodeSkeletonProps } from '.'; | ||
|
||
export function CodeSkeleton({ | ||
darkMode: darkModeProp, | ||
className, | ||
...rest | ||
}: CodeSkeletonProps) { | ||
const { darkMode } = useDarkMode(darkModeProp); | ||
return ( | ||
<LeafyGreenProvider darkMode={darkMode}> | ||
<div {...rest} className={cx(rootStyles, className)} aria-busy> | ||
<Skeleton size="small" className={lineStyles} /> | ||
<Skeleton size="small" className={lineStyles} /> | ||
<Skeleton size="small" className={lineStyles} /> | ||
</div> | ||
</LeafyGreenProvider> | ||
); | ||
} | ||
|
||
CodeSkeleton.displayName = 'CodeSkeleton'; |
5 changes: 5 additions & 0 deletions
5
packages/skeleton-loader/src/CodeSkeleton/CodeSkeleton.types.ts
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,5 @@ | ||
import { DarkModeProps, HTMLElementProps } from '@leafygreen-ui/lib'; | ||
|
||
export interface CodeSkeletonProps | ||
extends DarkModeProps, | ||
HTMLElementProps<'div'> {} |
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 { CodeSkeleton } from './CodeSkeleton'; | ||
export { type CodeSkeletonProps } from './CodeSkeleton.types'; |
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