-
Notifications
You must be signed in to change notification settings - Fork 13
Refactor: Component Divider #203
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
Draft
b1ink0
wants to merge
1
commit into
develop
Choose a base branch
from
feat/update-component-divider
base: develop
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Changes from all commits
Commits
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
178 changes: 178 additions & 0 deletions
178
packages/frappe-ui-react/src/components/divider/divider.stories.tsx
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,178 @@ | ||
| import type { Meta, StoryObj } from "@storybook/react-vite"; | ||
| import { ChevronDown } from "lucide-react"; | ||
|
|
||
| import Divider from "./divider"; | ||
| import { Button } from "../button"; | ||
| import { Badge } from "../badge"; | ||
|
|
||
| const meta: Meta<typeof Divider> = { | ||
| title: "Components/Divider", | ||
| component: Divider, | ||
| parameters: { docs: { source: { type: "dynamic" } }, layout: "centered" }, | ||
| tags: ["autodocs"], | ||
| argTypes: { | ||
| orientation: { | ||
| control: { type: "select" }, | ||
| options: ["horizontal", "vertical"], | ||
| description: "Orientation of the divider", | ||
| }, | ||
| slot: { | ||
| control: false, | ||
| description: "Element to render in the divider slot", | ||
| }, | ||
| position: { | ||
| control: { type: "select" }, | ||
| options: ["start", "center", "end"], | ||
| description: "Position of the slot element", | ||
| }, | ||
| padding: { | ||
| control: "number", | ||
| description: "Padding around the divider in pixels", | ||
| }, | ||
| flexItem: { | ||
| control: "boolean", | ||
| description: "If true, adapts to flex container", | ||
| }, | ||
| className: { | ||
| control: "text", | ||
| description: "Additional CSS classes to apply to the divider", | ||
| }, | ||
| }, | ||
| }; | ||
|
|
||
| export default meta; | ||
| type Story = StoryObj<typeof Divider>; | ||
|
|
||
| export const Horizontal: Story = { | ||
| render: (args) => ( | ||
| <div className="w-80"> | ||
| <p className="text-sm text-ink-gray-7">Content above</p> | ||
| <Divider {...args} /> | ||
| <p className="text-sm text-ink-gray-7">Content below</p> | ||
| </div> | ||
| ), | ||
| args: { | ||
| orientation: "horizontal", | ||
| padding: 16, | ||
| }, | ||
| }; | ||
|
|
||
| export const Vertical: Story = { | ||
| render: (args) => ( | ||
| <div className="flex items-center h-16"> | ||
| <span className="text-sm text-ink-gray-7">Left</span> | ||
| <Divider {...args} /> | ||
| <span className="text-sm text-ink-gray-7">Right</span> | ||
| </div> | ||
| ), | ||
| args: { | ||
| orientation: "vertical", | ||
| flexItem: true, | ||
| padding: 16, | ||
| }, | ||
| }; | ||
|
|
||
| export const WithSlot: Story = { | ||
| render: (args) => ( | ||
| <div className="w-80"> | ||
| <p className="text-sm text-ink-gray-7">Content above</p> | ||
| <Divider {...args} /> | ||
| <p className="text-sm text-ink-gray-7">Content below</p> | ||
| </div> | ||
| ), | ||
| args: { | ||
| orientation: "horizontal", | ||
| position: "center", | ||
| padding: 6, | ||
| slot: () => <Button label="Load More" size="sm" variant="outline" />, | ||
| }, | ||
| }; | ||
|
|
||
| export const SlotPositionsHorizontal: Story = { | ||
| render: () => ( | ||
| <div className="flex flex-col gap-14 w-80"> | ||
| <Divider | ||
| orientation="horizontal" | ||
| position="start" | ||
| slot={() => <Button label="Start" size="sm" variant="outline" />} | ||
| /> | ||
| <Divider | ||
| orientation="horizontal" | ||
| position="center" | ||
| slot={() => <Button label="Center" size="sm" variant="outline" />} | ||
| /> | ||
| <Divider | ||
| orientation="horizontal" | ||
| position="end" | ||
| slot={() => <Button label="End" size="sm" variant="outline" />} | ||
| /> | ||
| </div> | ||
| ), | ||
| }; | ||
|
|
||
| export const SlotPositionsVertical: Story = { | ||
| render: () => ( | ||
| <div className="flex items-center gap-20 h-48"> | ||
| <Divider | ||
| orientation="vertical" | ||
| position="start" | ||
| flexItem | ||
| slot={() => <Button label="Start" size="sm" variant="outline" />} | ||
| /> | ||
| <Divider | ||
| orientation="vertical" | ||
| position="center" | ||
| flexItem | ||
| slot={() => <Button label="Center" size="sm" variant="outline" />} | ||
| /> | ||
| <Divider | ||
| orientation="vertical" | ||
| position="end" | ||
| flexItem | ||
| slot={() => <Button label="End" size="sm" variant="outline" />} | ||
| /> | ||
| </div> | ||
| ), | ||
| }; | ||
|
|
||
| export const Timeline: Story = { | ||
| render: () => ( | ||
| <div className="w-125 flex flex-col gap-8 items-center"> | ||
| <Divider | ||
| position="start" | ||
| slot={() => <Badge label="Jun" size="lg" variant="outline" />} | ||
| /> | ||
| <Divider | ||
| position="start" | ||
| slot={() => ( | ||
| <Badge label="Today 2 hours ago" size="lg" variant="outline" /> | ||
| )} | ||
| /> | ||
| <Divider | ||
| position="center" | ||
| slot={() => ( | ||
| <Button | ||
| label="Today" | ||
| size="sm" | ||
| variant="outline" | ||
| iconRight={() => <ChevronDown className="w-4 h-4" />} | ||
| /> | ||
| )} | ||
| /> | ||
| <Divider | ||
| position="start" | ||
| slot={() => <Badge label="New messages" size="lg" theme="blue" />} | ||
| /> | ||
| <div className="w-80 flex flex-col gap-8 items-center"> | ||
| <Divider | ||
| position="start" | ||
| slot={() => <Button label="Continue" size="sm" variant="outline" />} | ||
| /> | ||
| <Divider | ||
| position="center" | ||
| slot={() => <Button icon="message-circle" variant="ghost" />} | ||
| /> | ||
| </div> | ||
| </div> | ||
| ), | ||
| }; |
99 changes: 53 additions & 46 deletions
99
packages/frappe-ui-react/src/components/divider/divider.tsx
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
Oops, something went wrong.
Oops, something went wrong.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The
slotfunction is called without any arguments, but the type signature suggests it could acceptargs?: any. This is inconsistent with the type definition. Either remove the parameter from the type definition, or if arguments are needed in the future, pass them here consistently.