-
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.
feat(ui): add textfield and checkbox component
- Loading branch information
1 parent
5ae4552
commit 0a6f94f
Showing
11 changed files
with
209 additions
and
43 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
import { Checkbox, type CheckboxProps } from "@fellipeutaka/ui/checkbox"; | ||
import { Label } from "@fellipeutaka/ui/label"; | ||
import type { Meta, StoryObj } from "@storybook/react"; | ||
|
||
const meta: Meta<CheckboxProps> = { | ||
title: "Components/Checkbox", | ||
component: Checkbox, | ||
args: { | ||
disabled: false, | ||
}, | ||
}; | ||
|
||
export default meta; | ||
|
||
type Story = StoryObj<CheckboxProps>; | ||
|
||
export const Default: Story = {}; | ||
|
||
export const WithLabel: Story = { | ||
render(props) { | ||
return ( | ||
<div className="flex items-center gap-2"> | ||
<Checkbox {...props} id="terms" /> | ||
<Label htmlFor="terms">Accept terms and conditions</Label> | ||
</div> | ||
); | ||
}, | ||
}; | ||
|
||
export const Disabled: Story = { | ||
args: { | ||
disabled: 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,11 @@ | ||
# @fellipeutaka/ui | ||
|
||
## 2.1.0 | ||
|
||
### Minor Changes | ||
|
||
- add textfield and checkbox | ||
|
||
## 2.0.0 | ||
|
||
### Major Changes | ||
|
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
"use client"; | ||
|
||
import { forwardRef } from "react"; | ||
|
||
import { tv } from "@fellipeutaka/styles"; | ||
import { Root, Indicator } from "@radix-ui/react-checkbox"; | ||
import { Check } from "lucide-react"; | ||
|
||
export type { CheckboxProps } from "@radix-ui/react-checkbox"; | ||
|
||
export const CheckboxStyles = { | ||
Root: tv({ | ||
base: [ | ||
"border-input text-primary-foreground flex aspect-square w-5 appearance-none items-center justify-center rounded-sm border shadow outline-none transition", | ||
"disabled:cursor-not-allowed disabled:opacity-50", | ||
"data-[state=checked]:border-primary data-[state=checked]:bg-primary", | ||
"focus-visible:ring-input focus-visible:ring-offset-background focus-visible:ring-2 focus-visible:ring-offset-2", | ||
], | ||
}), | ||
}; | ||
|
||
export const Checkbox = forwardRef< | ||
React.ElementRef<typeof Root>, | ||
React.ComponentPropsWithoutRef<typeof Root> | ||
>(({ className, ...props }, ref) => ( | ||
<Root ref={ref} className={CheckboxStyles.Root({ className })} {...props}> | ||
<Indicator className="flex items-center justify-center text-current"> | ||
<Check className="h-4 w-4" /> | ||
</Indicator> | ||
</Root> | ||
)); | ||
Checkbox.displayName = "Checkbox"; |
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
Oops, something went wrong.