-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add empty state component (#179)
* feat: add empty state component * chore: deprecate old empty state component * docs: update empty state docs
- Loading branch information
Showing
7 changed files
with
166 additions
and
19 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
53 changes: 53 additions & 0 deletions
53
packages/raystack/v1/components/emptystate/emptystate.module.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,53 @@ | ||
.emptyState { | ||
padding: var(--rs-space-9) var(--rs-space-5); | ||
width: 100%; | ||
height: 100%; | ||
text-align: center; | ||
} | ||
|
||
.iconContainer { | ||
position: relative; | ||
z-index: 2; | ||
} | ||
|
||
.icon { | ||
height: 32px; | ||
width: 32px; | ||
padding: var(--rs-space-3); | ||
box-sizing: content-box; | ||
border: 1px solid var(--rs-color-border-base-primary); | ||
background-color: var(--rs-color-background-base-secondary); | ||
border-radius: var(--rs-radius-4); | ||
color: var(--rs-color-text-base-secondary); | ||
box-shadow: 0px 1px 4px 0px rgba(0, 0, 0, 0.08), | ||
0px -3px 0px 0px rgba(0, 0, 0, 0.03) inset; | ||
} | ||
|
||
.icon > svg { | ||
fill: currentColor; | ||
height: 100%; | ||
width: 100%; | ||
} | ||
|
||
.icon::before { | ||
content: ""; | ||
position: absolute; | ||
height: 100%; | ||
width: 100%; | ||
top: -10px; | ||
left: calc(50% - 15px); | ||
border: inherit; | ||
border-radius: inherit; | ||
background-color: inherit; | ||
z-index: -10; | ||
transform: rotate(-42deg); | ||
box-shadow: 0px -1.5px 0px 0px rgba(0, 0, 0, 0.02) inset; | ||
} | ||
|
||
.headerText { | ||
max-width: 360px; | ||
} | ||
|
||
.subHeaderText { | ||
max-width: 288px; | ||
} |
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,70 @@ | ||
import { cva } from "class-variance-authority"; | ||
import styles from "./emptystate.module.css"; | ||
const emptystate = cva(styles.emptystate); | ||
import { Flex } from "../flex"; | ||
import { Text } from "../text"; | ||
import clsx from "clsx"; | ||
|
||
type classNameKeys = | ||
| "container" | ||
| "iconContainer" | ||
| "icon" | ||
| "heading" | ||
| "subHeading"; | ||
|
||
interface EmptystateProps { | ||
icon: React.ReactNode; | ||
heading?: React.ReactNode; | ||
subHeading?: React.ReactNode; | ||
primaryAction?: React.ReactNode; | ||
secondaryAction?: React.ReactNode; | ||
classNames?: Partial<Record<classNameKeys, string>>; | ||
} | ||
|
||
export const EmptyState = ({ | ||
icon, | ||
heading, | ||
subHeading, | ||
primaryAction, | ||
secondaryAction, | ||
classNames, | ||
}: EmptystateProps) => { | ||
return ( | ||
<Flex | ||
direction="column" | ||
align="center" | ||
gap="medium" | ||
className={clsx(styles.emptyState, classNames?.container)} | ||
> | ||
<div className={clsx(styles.iconContainer, classNames?.iconContainer)}> | ||
<div className={clsx(styles.icon, classNames?.icon)}>{icon}</div> | ||
</div> | ||
|
||
<Flex direction="column" gap="small" align="center"> | ||
{heading && ( | ||
<Text | ||
size={5} | ||
weight={500} | ||
className={clsx(styles.headerText, classNames?.heading)} | ||
> | ||
{heading} | ||
</Text> | ||
)} | ||
|
||
{subHeading && ( | ||
<Text | ||
size={4} | ||
weight={400} | ||
className={clsx(styles.subHeaderText, classNames?.subHeading)} | ||
> | ||
{subHeading} | ||
</Text> | ||
)} | ||
</Flex> | ||
|
||
{primaryAction} | ||
|
||
{secondaryAction} | ||
</Flex> | ||
); | ||
}; |
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 @@ | ||
export { EmptyState } from "./emptystate"; |
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