-
Notifications
You must be signed in to change notification settings - Fork 4
feat: #246 new v5 EmptyData #267
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
Merged
Merged
Changes from all commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
ccea558
feat: init empty-data component
nurm717123 fd3148e
chore: remove unused import and fix export declaration
nurm717123 fd96e32
chore: remove unused description
nurm717123 88021f4
Merge branch 'main' of https://github.com/reapit/elements into 246-em…
nurm717123 e29fd65
chore: update fixed height to use defined variable recommended by des…
nurm717123 3a2f328
Merge branch 'main' of https://github.com/reapit/elements into 246-em…
nurm717123 d00ad95
resolve feedback: rename component, use h4 and p, adjust style for sm…
nurm717123 90761fe
resolve feedback: revert heading to p
nurm717123 53c1c49
Merge branch 'main' of https://github.com/reapit/elements into 246-em…
nurm717123 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
25 changes: 25 additions & 0 deletions
25
src/components/empty-data/__tests__/__snapshots__/empty-data.test.tsx.snap
This file contains hidden or 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 @@ | ||
// Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html | ||
|
||
exports[`EmptyData > should render default component properly and match snapshot 1`] = ` | ||
<DocumentFragment> | ||
<div | ||
class="mocked-styled-3 el-empty-data" | ||
> | ||
<p | ||
class="mocked-styled-0 el-empty-data-description" | ||
> | ||
Description | ||
</p> | ||
<p | ||
class="mocked-styled-1 el-empty-data-secondary-description" | ||
> | ||
Secondary Description | ||
</p> | ||
<button | ||
class="mocked-styled-2 el-empty-data-action-button" | ||
> | ||
Action Button Text | ||
</button> | ||
</div> | ||
</DocumentFragment> | ||
`; |
This file contains hidden or 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 { render } from '@testing-library/react' | ||
import { EmptyData } from '..' | ||
|
||
describe('EmptyData', () => { | ||
it('should render default component properly and match snapshot', () => { | ||
const { asFragment } = render( | ||
<EmptyData> | ||
<EmptyData.Description>Description</EmptyData.Description> | ||
<EmptyData.SecondaryDescription>Secondary Description</EmptyData.SecondaryDescription> | ||
<EmptyData.ActionButton onClick={console.log}>Action Button Text</EmptyData.ActionButton> | ||
</EmptyData>, | ||
) | ||
expect(asFragment()).toMatchSnapshot() | ||
}) | ||
}) |
This file contains hidden or 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,32 @@ | ||
import { Meta, Canvas, Controls, Description } from '@storybook/blocks' | ||
import { RenderHtmlMarkup } from '../../storybook/render-html-markup' | ||
import * as EmptyDataStories from './empty-data.stories' | ||
|
||
<Meta of={EmptyDataStories} /> | ||
|
||
|
||
# Empty Data | ||
|
||
<Description of={EmptyDataStories.Default} /> | ||
|
||
<Controls /> | ||
|
||
## Default | ||
|
||
<Canvas of={EmptyDataStories.Default} /> | ||
|
||
<RenderHtmlMarkup of={EmptyDataStories.Default} /> | ||
|
||
## Description Only | ||
|
||
<Canvas of={EmptyDataStories.DescriptionOnly} /> | ||
|
||
<RenderHtmlMarkup of={EmptyDataStories.DescriptionOnly} /> | ||
|
||
|
||
## Action Only | ||
|
||
<Canvas of={EmptyDataStories.ActionOnly} /> | ||
|
||
<RenderHtmlMarkup of={EmptyDataStories.ActionOnly} /> | ||
|
This file contains hidden or 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,49 @@ | ||
import type { Meta, StoryObj } from '@storybook/react' | ||
import { EmptyData } from './empty-data' | ||
|
||
const meta: Meta<typeof EmptyData> = { | ||
title: 'Components/Empty Data', | ||
} | ||
|
||
export default meta | ||
type Story = StoryObj<typeof EmptyData> | ||
|
||
/** | ||
* The EmptyData component is designed to emphasize that current section of the page | ||
* has empty data, but could possibly have different content when there is data available. | ||
* | ||
* There are three variants available for the EmptyData component: | ||
* Default (full version), Description Only, and Action Only. | ||
* See the examples below for more details of the usage. | ||
*/ | ||
export const Default: Story = { | ||
render() { | ||
return ( | ||
<EmptyData> | ||
<EmptyData.Description>No items found</EmptyData.Description> | ||
<EmptyData.SecondaryDescription>Secondary text</EmptyData.SecondaryDescription> | ||
<EmptyData.ActionButton onClick={console.log}>Add Item</EmptyData.ActionButton> | ||
</EmptyData> | ||
) | ||
}, | ||
} | ||
|
||
export const DescriptionOnly: Story = { | ||
render() { | ||
return ( | ||
<EmptyData> | ||
<EmptyData.Description>No items found</EmptyData.Description> | ||
<EmptyData.SecondaryDescription>Secondary text</EmptyData.SecondaryDescription> | ||
</EmptyData> | ||
) | ||
}, | ||
} | ||
export const ActionOnly: Story = { | ||
render() { | ||
return ( | ||
<EmptyData> | ||
<EmptyData.ActionButton onClick={console.log}>Action</EmptyData.ActionButton> | ||
</EmptyData> | ||
) | ||
}, | ||
} |
This file contains hidden or 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,17 @@ | ||
import type { HTMLAttributes } from 'react' | ||
import { ElEmptyData, ElEmptyDataActionButton, ElEmptyDataDescription, ElEmptyDataSecondaryDescription } from './styles' | ||
import type React from 'react' | ||
|
||
type EmptyDataFC = React.FC<HTMLAttributes<HTMLDivElement>> & { | ||
Description: typeof ElEmptyDataDescription | ||
SecondaryDescription: typeof ElEmptyDataSecondaryDescription | ||
ActionButton: typeof ElEmptyDataActionButton | ||
} | ||
|
||
const EmptyData: EmptyDataFC = ({ children, ...props }) => <ElEmptyData {...props}>{children}</ElEmptyData> | ||
|
||
EmptyData.Description = ElEmptyDataDescription | ||
EmptyData.SecondaryDescription = ElEmptyDataSecondaryDescription | ||
EmptyData.ActionButton = ElEmptyDataActionButton | ||
|
||
export { EmptyData } |
This file contains hidden or 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 * from './empty-data' | ||
export * from './styles' |
This file contains hidden or 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,52 @@ | ||
import { styled } from '@linaria/react' | ||
|
||
export const ElEmptyDataDescription = styled.p` | ||
color: var(--text-primary); | ||
font-size: var(--font-size-base); | ||
font-weight: var(--font-weight-regular); | ||
line-height: var(--line-height-base); | ||
letter-spacing: var(--letter-spacing-base); | ||
text-align: center; | ||
` | ||
|
||
export const ElEmptyDataSecondaryDescription = styled.p` | ||
color: var(--text-secondary); | ||
font-size: var(--font-size-sm,); | ||
font-weight: var(--font-weight-regular,); | ||
line-height: var(--line-height-sm,); | ||
letter-spacing: var(--letter-spacing-sm); | ||
text-align: center; | ||
` | ||
|
||
export const ElEmptyDataActionButton = styled.button` | ||
color: var(--text-action); | ||
font-size: var(--font-size-sm); | ||
font-weight: var(--font-weight-medium); | ||
line-height: var(--line-height-sm); | ||
letter-spacing: var(--letter-spacing-sm); | ||
|
||
text-align: center; | ||
border: none; | ||
background: none; | ||
cursor: pointer; | ||
` | ||
|
||
export const ElEmptyData = styled.div` | ||
display: flex; | ||
flex-direction: column; | ||
justify-content: center; | ||
align-items: center; | ||
nurm717123 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
width: 100%; | ||
height: var(--size-40); | ||
padding: var(--spacing-6); | ||
border-radius: var(--corner-lg); | ||
background: var(--fill-default-lightest); | ||
|
||
${ElEmptyDataSecondaryDescription} + ${ElEmptyDataActionButton} { | ||
margin-top: var(--spacing-1); | ||
} | ||
|
||
& * { | ||
font-family: var(--font-family); | ||
} | ||
` |
This file contains hidden or 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
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.