forked from appsmithorg/appsmith
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore: Move smaller Entity Explorer components into ADS (appsmithorg#…
- Loading branch information
Showing
28 changed files
with
406 additions
and
138 deletions.
There are no files selected for viewing
35 changes: 35 additions & 0 deletions
35
packages/design-system/ads/src/Templates/EntityExplorer/EmptyState/EmptyState.mdx
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,35 @@ | ||
import { Canvas, Meta } from "@storybook/blocks"; | ||
|
||
import * as EmptyStateStories from "./EmptyState.stories"; | ||
|
||
<Meta of={EmptyStateStories} /> | ||
|
||
# Empty State | ||
|
||
A placeholder for when there is no data to display. It can be used to guide users on what to do next. | ||
|
||
## Anatomy | ||
|
||
icon: The icon of the file type or the entity type that is being displayed. | ||
|
||
description: The details of the empty state. It should be a short and clear message. | ||
|
||
button: A button that can be used to trigger an action. This is optional. | ||
|
||
### Default implementation | ||
|
||
Below is the default implementation of the Empty State component. It does not have a button. | ||
|
||
<Canvas of={EmptyStateStories.Basic} /> | ||
|
||
### With Button | ||
|
||
Button kind can be supplied. If no kind is supplied, default is "secondary". | ||
|
||
<Canvas of={EmptyStateStories.WithButton} /> | ||
|
||
### With Button but no onClick is supplied | ||
|
||
onClick is optional. If not supplied, the button will not be shown. | ||
|
||
<Canvas of={EmptyStateStories.WithButtonWithoutOnClick} /> |
54 changes: 54 additions & 0 deletions
54
packages/design-system/ads/src/Templates/EntityExplorer/EmptyState/EmptyState.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,54 @@ | ||
/* eslint-disable no-console */ | ||
import React from "react"; | ||
import type { Meta, StoryObj } from "@storybook/react"; | ||
|
||
import { EmptyState, type EmptyStateProps } from "."; | ||
|
||
const meta: Meta<typeof EmptyState> = { | ||
title: "ADS/Templates/Entity Explorer/Empty State", | ||
component: EmptyState, | ||
}; | ||
|
||
export default meta; | ||
|
||
const Template = (props: EmptyStateProps) => { | ||
const { button, description, icon } = props; | ||
|
||
return ( | ||
<EmptyState | ||
{...{ | ||
description, | ||
icon, | ||
button, | ||
}} | ||
/> | ||
); | ||
}; | ||
|
||
export const Basic = Template.bind({}) as StoryObj; | ||
|
||
Basic.args = { | ||
description: "No data available", | ||
icon: "folder-line", | ||
}; | ||
|
||
export const WithButton = Template.bind({}) as StoryObj; | ||
|
||
WithButton.args = { | ||
description: "No data available", | ||
icon: "file-line", | ||
button: { | ||
text: "Add new", | ||
onClick: () => console.log("Add clicked"), | ||
}, | ||
}; | ||
|
||
export const WithButtonWithoutOnClick = Template.bind({}) as StoryObj; | ||
|
||
WithButtonWithoutOnClick.args = { | ||
description: "No data available", | ||
icon: "file-line", | ||
button: { | ||
text: "Add new", | ||
}, | ||
}; |
48 changes: 48 additions & 0 deletions
48
packages/design-system/ads/src/Templates/EntityExplorer/EmptyState/EmptyState.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,48 @@ | ||
import React from "react"; | ||
import { Button, Flex, Icon, Text } from "../../.."; | ||
import type { EmptyStateProps } from "./EmptyState.types"; | ||
|
||
const EmptyState = ({ button, description, icon }: EmptyStateProps) => { | ||
return ( | ||
<Flex | ||
alignItems={"center"} | ||
flexDirection="column" | ||
gap="spaces-4" | ||
justifyContent={"center"} | ||
px="spaces-3" | ||
py="spaces-7" | ||
> | ||
<Flex | ||
alignItems="center" | ||
backgroundColor="var(--ads-v2-color-bg-subtle)" | ||
borderRadius="var(--ads-v2-border-radius)" | ||
height="var(--ads-v2-spaces-11)" | ||
justifyContent="center" | ||
padding="spaces-3" | ||
width="var(--ads-v2-spaces-11)" | ||
> | ||
<Icon name={icon} size="lg" /> | ||
</Flex> | ||
<Text | ||
className="text-center" | ||
color="var(--ads-v2-color-fg)" | ||
kind="heading-xs" | ||
> | ||
{description} | ||
</Text> | ||
{button && button.onClick ? ( | ||
<Button | ||
className={button.className} | ||
data-testid={button.testId} | ||
kind={button.kind || "secondary"} | ||
onClick={button.onClick} | ||
size="sm" | ||
> | ||
{button.text} | ||
</Button> | ||
) : null} | ||
</Flex> | ||
); | ||
}; | ||
|
||
export { EmptyState }; |
13 changes: 13 additions & 0 deletions
13
packages/design-system/ads/src/Templates/EntityExplorer/EmptyState/EmptyState.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,13 @@ | ||
import { type IconNames, type ButtonKind } from "../../.."; | ||
|
||
export interface EmptyStateProps { | ||
icon: IconNames; | ||
description: string; | ||
button?: { | ||
text: string; | ||
onClick?: () => void; | ||
kind?: Extract<ButtonKind, "primary" | "secondary">; | ||
className?: string; | ||
testId?: string; | ||
}; | ||
} |
2 changes: 2 additions & 0 deletions
2
packages/design-system/ads/src/Templates/EntityExplorer/EmptyState/index.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,2 @@ | ||
export { EmptyState } from "./EmptyState"; | ||
export * from "./EmptyState.types"; |
4 changes: 4 additions & 0 deletions
4
...-system/ads/src/Templates/EntityExplorer/ExplorerContainer/ExplorerContainer.constants.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,4 @@ | ||
export const ExplorerContainerBorder = { | ||
STANDARD: "1px solid var(--ads-v2-color-border)", | ||
NONE: "", | ||
}; |
54 changes: 54 additions & 0 deletions
54
...n-system/ads/src/Templates/EntityExplorer/ExplorerContainer/ExplorerContainer.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,54 @@ | ||
/* eslint-disable no-console */ | ||
import React from "react"; | ||
import type { Meta, StoryObj } from "@storybook/react"; | ||
|
||
import { type ExplorerContainerProps, ExplorerContainer } from "."; | ||
|
||
import { SearchAndAdd } from ".."; | ||
import { Flex } from "../../../Flex"; | ||
|
||
const meta: Meta<typeof ExplorerContainer> = { | ||
title: "ADS/Templates/Entity Explorer/Container", | ||
component: ExplorerContainer, | ||
argTypes: { | ||
borderRight: { | ||
options: ["STANDARD", "NONE"], | ||
control: { type: "select" }, | ||
}, | ||
}, | ||
}; | ||
|
||
export default meta; | ||
|
||
const Template = (props: ExplorerContainerProps) => { | ||
const { borderRight, children, className, height, width } = props; | ||
|
||
return ( | ||
<ExplorerContainer | ||
{...{ | ||
children, | ||
width, | ||
height, | ||
className, | ||
borderRight, | ||
}} | ||
/> | ||
); | ||
}; | ||
|
||
export const Basic = Template.bind({}) as StoryObj; | ||
|
||
const Children = () => { | ||
return ( | ||
<Flex flexDirection="column" p="spaces-2"> | ||
<SearchAndAdd showAddButton={false} /> | ||
</Flex> | ||
); | ||
}; | ||
|
||
Basic.args = { | ||
children: <Children />, | ||
borderRight: "STANDARD", | ||
height: "300px", | ||
width: "255px", | ||
}; |
18 changes: 18 additions & 0 deletions
18
...es/design-system/ads/src/Templates/EntityExplorer/ExplorerContainer/ExplorerContainer.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,18 @@ | ||
import React from "react"; | ||
import { ExplorerContainerBorder, Flex } from "../../.."; | ||
import type { ExplorerContainerProps } from "./ExplorerContainer.types"; | ||
|
||
export const ExplorerContainer = (props: ExplorerContainerProps) => { | ||
return ( | ||
<Flex | ||
borderRight={ExplorerContainerBorder[props.borderRight]} | ||
className={`relative ${props.className}`} | ||
flexDirection="column" | ||
height={props.height} | ||
overflow="hidden" | ||
width={props.width} | ||
> | ||
{props.children} | ||
</Flex> | ||
); | ||
}; |
10 changes: 10 additions & 0 deletions
10
...sign-system/ads/src/Templates/EntityExplorer/ExplorerContainer/ExplorerContainer.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,10 @@ | ||
import { type ReactNode } from "react"; | ||
import type { ExplorerContainerBorder } from "./ExplorerContainer.constants"; | ||
|
||
export interface ExplorerContainerProps { | ||
children: ReactNode | ReactNode[]; | ||
borderRight: keyof typeof ExplorerContainerBorder; | ||
className?: string; | ||
width?: string | number; | ||
height?: string | number; | ||
} |
3 changes: 3 additions & 0 deletions
3
packages/design-system/ads/src/Templates/EntityExplorer/ExplorerContainer/index.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,3 @@ | ||
export { ExplorerContainer } from "./ExplorerContainer"; | ||
export * from "./ExplorerContainer.types"; | ||
export { ExplorerContainerBorder } from "./ExplorerContainer.constants"; |
16 changes: 16 additions & 0 deletions
16
...ign-system/ads/src/Templates/EntityExplorer/NoSearchResults/NoSearchResults.mdx
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,16 @@ | ||
import { Canvas, Meta } from "@storybook/blocks"; | ||
|
||
import * as NoSearchResultStories from "./NoSearchResults.stories"; | ||
|
||
<Meta of={NoSearchResultStories} /> | ||
|
||
# No Search Results | ||
|
||
A placeholder for when there are no search results to display. It can be used to guide users on what to do next. | ||
What you get is an ADS styled message from this component. | ||
|
||
### Default implementation | ||
|
||
Below is the default implementation | ||
|
||
<Canvas of={NoSearchResultStories.Basic} /> |
24 changes: 24 additions & 0 deletions
24
...esign-system/ads/src/Templates/EntityExplorer/NoSearchResults/NoSearchResults.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,24 @@ | ||
/* eslint-disable no-console */ | ||
import React from "react"; | ||
import type { Meta, StoryObj } from "@storybook/react"; | ||
|
||
import { NoSearchResults, type NoSearchResultsProps } from "."; | ||
|
||
const meta: Meta<typeof NoSearchResults> = { | ||
title: "ADS/Templates/Entity Explorer/No Search Results", | ||
component: NoSearchResults, | ||
}; | ||
|
||
export default meta; | ||
|
||
const Template = (props: NoSearchResultsProps) => { | ||
const { text } = props; | ||
|
||
return <NoSearchResults text={text} />; | ||
}; | ||
|
||
export const Basic = Template.bind({}) as StoryObj; | ||
|
||
Basic.args = { | ||
text: "No files found", | ||
}; |
17 changes: 17 additions & 0 deletions
17
packages/design-system/ads/src/Templates/EntityExplorer/NoSearchResults/NoSearchResults.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,17 @@ | ||
import React from "react"; | ||
import { Text } from "../../.."; | ||
import type { NoSearchResultsProps } from "./NoSearchResults.types"; | ||
|
||
const NoSearchResults = ({ text }: NoSearchResultsProps) => { | ||
return ( | ||
<Text | ||
className="font-normal text-center" | ||
color="var(--ads-v2-color-fg-muted)" | ||
kind="body-s" | ||
> | ||
{text} | ||
</Text> | ||
); | ||
}; | ||
|
||
export { NoSearchResults }; |
3 changes: 3 additions & 0 deletions
3
...s/design-system/ads/src/Templates/EntityExplorer/NoSearchResults/NoSearchResults.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,3 @@ | ||
export interface NoSearchResultsProps { | ||
text: string; | ||
} |
2 changes: 2 additions & 0 deletions
2
packages/design-system/ads/src/Templates/EntityExplorer/NoSearchResults/index.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,2 @@ | ||
export { NoSearchResults } from "./NoSearchResults"; | ||
export * from "./NoSearchResults.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
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
Oops, something went wrong.