-
Notifications
You must be signed in to change notification settings - Fork 2
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 #50 from auung/feature/component-stories-4
feat(packages|components): add stories for input, label, pagination, and popover components
- Loading branch information
Showing
10 changed files
with
447 additions
and
1 deletion.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,94 @@ | ||
import type { Meta, StoryObj } from "@storybook/react" | ||
import { Input, InputProps } from "./input" | ||
import { LuPlus } from "react-icons/lu" | ||
|
||
const meta: Meta<typeof Input> = { | ||
title: "Components/Input", | ||
component: Input, | ||
parameters: { | ||
layout: "centered", | ||
}, | ||
args: { | ||
placeholder: "Username...", | ||
disabled: false, | ||
unstyled: false, | ||
}, | ||
argTypes: { | ||
label: { | ||
type: "string", | ||
}, | ||
placeholder: { | ||
type: "string", | ||
}, | ||
startIcon: { | ||
table: { | ||
disable: true, | ||
}, | ||
}, | ||
endIcon: { | ||
table: { | ||
disable: true, | ||
}, | ||
}, | ||
classNames: { | ||
table: { | ||
disable: true, | ||
}, | ||
}, | ||
}, | ||
} | ||
|
||
export default meta | ||
type Story = StoryObj<typeof Input> | ||
|
||
const InputTemplate = (args: InputProps) => { | ||
return <Input className="w-80" {...args} /> | ||
} | ||
|
||
const InputWithIcons = (args: InputProps) => { | ||
return ( | ||
<div className="flex flex-col gap-2"> | ||
<Input className="w-80" {...args} endIcon={undefined} /> | ||
<Input className="w-80" {...args} startIcon={undefined} /> | ||
<Input className="w-80" {...args} /> | ||
</div> | ||
) | ||
} | ||
|
||
export const Default: Story = { | ||
render: InputTemplate, | ||
} | ||
|
||
export const WithIcon: Story = { | ||
render: InputWithIcons, | ||
args: { | ||
startIcon: <LuPlus />, | ||
endIcon: <LuPlus />, | ||
}, | ||
} | ||
|
||
export const WithFloatingLabel: Story = { | ||
render: InputTemplate, | ||
args: { | ||
placeholder: "", | ||
label: "Username", | ||
}, | ||
} | ||
|
||
export const WithFloatingLabelAndIcon: Story = { | ||
render: InputWithIcons, | ||
args: { | ||
placeholder: "", | ||
label: "Username", | ||
startIcon: <LuPlus />, | ||
endIcon: <LuPlus />, | ||
}, | ||
} | ||
|
||
export const Unstyled: Story = { | ||
render: InputTemplate, | ||
args: { | ||
unstyled: true, | ||
classNames: { input: "indent-2 py-1" }, | ||
}, | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
import type { Meta, StoryObj } from "@storybook/react" | ||
import { Label, LabelProps } from "./label" | ||
import { Button } from "@mijn-ui/react-button" | ||
|
||
const meta: Meta<typeof Label> = { | ||
title: "Components/Label", | ||
component: Label, | ||
parameters: { | ||
layout: "centered", | ||
}, | ||
args: { | ||
unstyled: false, | ||
}, | ||
} | ||
|
||
export default meta | ||
type Story = StoryObj<typeof Label> | ||
|
||
const LabelTemplate = (args: LabelProps) => { | ||
return ( | ||
<div className="flex flex-col gap-2"> | ||
<Label htmlFor="comment" {...args}> | ||
Feedback | ||
</Label> | ||
<textarea | ||
id="comment" | ||
name="comment" | ||
className={ | ||
args.unstyled | ||
? "indent-2" | ||
: "border-input placeholder:text-muted-text focus-visible:ring-ring flex min-h-[80px] w-full rounded-md border bg-transparent px-3 py-2 text-sm focus-visible:outline-none focus-visible:ring-2 disabled:cursor-not-allowed disabled:opacity-50" | ||
} | ||
placeholder="Enter your feedback ..." | ||
></textarea> | ||
<Button | ||
unstyled={args.unstyled} | ||
className={args.unstyled ? "bg-accent w-full py-2" : ""} | ||
> | ||
Submit | ||
</Button> | ||
</div> | ||
) | ||
} | ||
|
||
export const Default: Story = { | ||
render: LabelTemplate, | ||
} | ||
|
||
export const Unstyled: Story = { | ||
render: LabelTemplate, | ||
args: { | ||
unstyled: true, | ||
}, | ||
} |
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
104 changes: 104 additions & 0 deletions
104
packages/components/pagination/src/pagination.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,104 @@ | ||
import type { Meta, StoryObj } from "@storybook/react" | ||
import { | ||
Pagination, | ||
PaginationProps, | ||
PaginationContent, | ||
PaginationList, | ||
PaginationNextButton, | ||
PaginationNextEllipsis, | ||
PaginationPreviousButton, | ||
PaginationPreviousEllipsis, | ||
} from "./pagination" | ||
import { LuChevronLeft, LuChevronRight } from "react-icons/lu" | ||
import React from "react" | ||
|
||
const meta: Meta<typeof Pagination> = { | ||
title: "Components/Pagination", | ||
component: Pagination, | ||
parameters: { | ||
layout: "centered", | ||
}, | ||
args: { | ||
currentPage: 7, | ||
itemsPerPage: 10, | ||
totalPages: 160, | ||
unstyled: false, | ||
}, | ||
argTypes: { | ||
children: { | ||
table: { | ||
disable: true, | ||
}, | ||
}, | ||
}, | ||
} | ||
|
||
export default meta | ||
type Story = StoryObj<typeof Pagination> | ||
|
||
const PaginationTemplate = (args: PaginationProps) => { | ||
const [currentPage, setCurrentPage] = React.useState(args.currentPage) | ||
|
||
return ( | ||
<Pagination | ||
totalPages={args.totalPages} | ||
currentPage={currentPage} | ||
itemsPerPage={args.itemsPerPage} | ||
onChangePage={setCurrentPage} | ||
unstyled={args.unstyled} | ||
> | ||
<PaginationContent> | ||
<PaginationPreviousButton className="h-9 sm:h-10"> | ||
<LuChevronLeft className="size-4" /> | ||
<span className="hidden sm:inline">Previous</span> | ||
</PaginationPreviousButton> | ||
<PaginationPreviousEllipsis /> | ||
<PaginationList className="[&>li>button]:size-9 sm:[&>li>button]:size-10" /> | ||
<PaginationNextEllipsis className="[&>svg]:size-3.5 sm:[&>svg]:size-4" /> | ||
<PaginationNextButton className="h-9 sm:h-10"> | ||
<span className="hidden sm:inline">Next</span> | ||
<LuChevronRight className="size-4" /> | ||
</PaginationNextButton> | ||
</PaginationContent> | ||
</Pagination> | ||
) | ||
} | ||
|
||
const PaginationUnstyled = (args: PaginationProps) => { | ||
const [currentPage, setCurrentPage] = React.useState(args.currentPage) | ||
|
||
return ( | ||
<Pagination | ||
totalPages={args.totalPages} | ||
currentPage={currentPage} | ||
itemsPerPage={args.itemsPerPage} | ||
onChangePage={setCurrentPage} | ||
unstyled={args.unstyled} | ||
> | ||
<PaginationContent className="flex items-center gap-2"> | ||
<PaginationPreviousButton className="flex h-9 items-center gap-2 sm:h-10"> | ||
<LuChevronLeft className="size-4" /> | ||
<span className="hidden sm:inline">Previous</span> | ||
</PaginationPreviousButton> | ||
<PaginationPreviousEllipsis /> | ||
<PaginationList className="flex items-center gap-2 [&>li>button]:size-9 sm:[&>li>button]:size-10" /> | ||
<PaginationNextEllipsis className="[&>svg]:size-3.5 sm:[&>svg]:size-4" /> | ||
<PaginationNextButton className="flex h-9 items-center gap-2 sm:h-10"> | ||
<span className="hidden sm:inline">Next</span> | ||
<LuChevronRight className="size-4" /> | ||
</PaginationNextButton> | ||
</PaginationContent> | ||
</Pagination> | ||
) | ||
} | ||
|
||
export const Default: Story = { | ||
render: (args: PaginationProps) => <PaginationTemplate {...args} />, | ||
} | ||
|
||
export const Unstyled: Story = { | ||
render: (args: PaginationProps) => <PaginationUnstyled {...args} />, | ||
args: { | ||
unstyled: true, | ||
}, | ||
} |
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.
3a0f64d
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.
Deploy preview for mijn-ui-react ready!
✅ Preview
https://mijn-ui-react-btprnsw0c-htla380s-projects.vercel.app
Built with commit 3a0f64d.
This pull request is being automatically deployed with vercel-action