-
-
Notifications
You must be signed in to change notification settings - Fork 9.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #26481 from storybookjs/feat/addon-panel-empty-state
UI: Improve empty state of addon panel (cherry picked from commit ccc04e5)
- Loading branch information
Showing
11 changed files
with
258 additions
and
139 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
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
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
51 changes: 51 additions & 0 deletions
51
code/ui/components/src/components/tabs/EmptyTabContent.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,51 @@ | ||
import React from 'react'; | ||
import { EmptyTabContent } from './EmptyTabContent'; | ||
import { DocumentIcon } from '@storybook/icons'; | ||
import { Link } from '@storybook/components'; | ||
import type { Meta, StoryObj } from '@storybook/react'; | ||
|
||
export default { | ||
component: EmptyTabContent, | ||
parameters: { | ||
layout: 'centered', | ||
}, | ||
tags: ['autodocs'], | ||
} satisfies Meta<typeof EmptyTabContent>; | ||
|
||
type Story = StoryObj<typeof EmptyTabContent>; | ||
|
||
export const OnlyTitle: Story = { | ||
args: { | ||
title: 'Nothing found', | ||
}, | ||
}; | ||
|
||
export const TitleAndDescription: Story = { | ||
args: { | ||
title: 'Nothing found', | ||
description: 'Sorry, there is nothing to display here.', | ||
}, | ||
}; | ||
|
||
export const TitleAndFooter: Story = { | ||
args: { | ||
title: 'Nothing found', | ||
footer: ( | ||
<Link href="foo" withArrow> | ||
<DocumentIcon /> See the docs | ||
</Link> | ||
), | ||
}, | ||
}; | ||
|
||
export const TitleDescriptionAndFooter: Story = { | ||
args: { | ||
title: 'Nothing found', | ||
description: 'Sorry, there is nothing to display here.', | ||
footer: ( | ||
<Link href="foo" withArrow> | ||
<DocumentIcon /> See the docs | ||
</Link> | ||
), | ||
}, | ||
}; |
52 changes: 52 additions & 0 deletions
52
code/ui/components/src/components/tabs/EmptyTabContent.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,52 @@ | ||
import React from 'react'; | ||
import { styled } from '@storybook/theming'; | ||
|
||
const Wrapper = styled.div(({ theme }) => ({ | ||
height: '100%', | ||
display: 'flex', | ||
padding: 30, | ||
alignItems: 'center', | ||
justifyContent: 'center', | ||
flexDirection: 'column', | ||
gap: 15, | ||
background: theme.background.content, | ||
})); | ||
|
||
const Content = styled.div({ | ||
display: 'flex', | ||
flexDirection: 'column', | ||
gap: 4, | ||
maxWidth: 415, | ||
}); | ||
|
||
const Title = styled.div(({ theme }) => ({ | ||
fontWeight: theme.typography.weight.bold, | ||
fontSize: theme.typography.size.s2 - 1, | ||
textAlign: 'center', | ||
color: theme.textColor, | ||
})); | ||
|
||
const Description = styled.div(({ theme }) => ({ | ||
fontWeight: theme.typography.weight.regular, | ||
fontSize: theme.typography.size.s2 - 1, | ||
textAlign: 'center', | ||
color: theme.textMutedColor, | ||
})); | ||
|
||
interface Props { | ||
title: React.ReactNode; | ||
description?: React.ReactNode; | ||
footer?: React.ReactNode; | ||
} | ||
|
||
export const EmptyTabContent = ({ title, description, footer }: Props) => { | ||
return ( | ||
<Wrapper> | ||
<Content> | ||
<Title>{title}</Title> | ||
{description && <Description>{description}</Description>} | ||
</Content> | ||
{footer} | ||
</Wrapper> | ||
); | ||
}; |
Oops, something went wrong.