File tree Expand file tree Collapse file tree 10 files changed +123
-5
lines changed Expand file tree Collapse file tree 10 files changed +123
-5
lines changed Original file line number Diff line number Diff line change @@ -49,6 +49,10 @@ export const componentConfig: {
4949 name : "dialog" ,
5050 filePath : "packages/ui/Dialog/Dialog.tsx" ,
5151 } ,
52+ input : {
53+ name : "input" ,
54+ filePath : "packages/ui/Input.tsx" ,
55+ } ,
5256 menu : {
5357 name : "menu" ,
5458 filePath : "packages/ui/Menu/Menu.tsx" ,
@@ -200,6 +204,18 @@ export const componentConfig: {
200204 filePath : "preview/components/input-style-default.tsx" ,
201205 preview : lazy ( ( ) => import ( "@/preview/components/input-style-default" ) ) ,
202206 } ,
207+ "input-style-with-label" : {
208+ name : "input-style-with-label" ,
209+ filePath : "preview/components/input-style-with-label.tsx" ,
210+ preview : lazy (
211+ ( ) => import ( "@/preview/components/input-style-with-label" )
212+ ) ,
213+ } ,
214+ "input-style-error" : {
215+ name : "input-style-error" ,
216+ filePath : "preview/components/input-style-error.tsx" ,
217+ preview : lazy ( ( ) => import ( "@/preview/components/input-style-error" ) ) ,
218+ } ,
203219 "menu-style-default" : {
204220 name : "menu-style-default" ,
205221 filePath : "preview/components/menu-style-default.tsx" ,
Original file line number Diff line number Diff line change 11---
22title : Input
33description : This pretty input makes your users want to type stuff! ⌨️
4- lastUpdated : 08 Oct , 2024
4+ lastUpdated : 04 Mar , 2024
55---
66
7- ### Default
7+ <ComponentShowcase name = " input-style-default" />
8+ <br />
9+ <br />
10+
11+ ## Installation
812
9- <hr />
13+ #### 1. Copy the code 👇 into your project:
14+
15+ <ComponentSource name = " input" />
16+ <br />
1017<br />
18+
19+ ## Examples
20+
21+ ### Default
22+
1123<ComponentShowcase name = " input-style-default" />
24+ <br />
25+ <br />
26+
27+ ### With label
28+
29+ <ComponentShowcase name = " input-style-with-label" />
30+ <br />
31+ <br />
32+
33+ ### Error
34+
35+ <ComponentShowcase name = " input-style-error" />
36+ <br />
Original file line number Diff line number Diff line change 1515 "@radix-ui/react-checkbox" : " ^1.1.4" ,
1616 "@radix-ui/react-dialog" : " ^1.1.2" ,
1717 "@radix-ui/react-dropdown-menu" : " ^2.1.2" ,
18+ "@radix-ui/react-label" : " ^2.1.2" ,
1819 "@radix-ui/react-radio-group" : " ^1.2.3" ,
1920 "@radix-ui/react-select" : " ^2.1.6" ,
2021 "@radix-ui/react-switch" : " ^1.1.3" ,
Original file line number Diff line number Diff line change 1- export * from "./Input" ;
21export * from "./Textarea" ;
32export * from "./Checkbox" ;
43export * from "./Radio" ;
Original file line number Diff line number Diff line change @@ -10,11 +10,16 @@ export const Input: React.FC<InputProps> = ({
1010 className = "" ,
1111 ...props
1212} ) => {
13+ console . log ( props ) ;
1314 return (
1415 < input
1516 type = { type }
1617 placeholder = { placeholder }
17- className = { `px-4 py-2 w-full border-2 border-black shadow-md transition focus:outline-none focus:shadow-xs ${ className } ` }
18+ className = { `px-4 py-2 w-full border-2 border-black shadow-md transition focus:outline-none focus:shadow-xs ${
19+ props [ "aria-invalid" ]
20+ ? "border-red-500 text-red-500 shadow-xs shadow-red-600"
21+ : ""
22+ } ${ className } `}
1823 { ...props }
1924 />
2025 ) ;
Original file line number Diff line number Diff line change 1+ import * as React from "react" ;
2+ import * as LabelPrimitive from "@radix-ui/react-label" ;
3+ import { cva } from "class-variance-authority" ;
4+
5+ import { cn } from "@/lib/utils" ;
6+
7+ const labelVariants = cva (
8+ "leading-none peer-disabled:cursor-not-allowed peer-disabled:opacity-70"
9+ ) ;
10+
11+ const Label = ( {
12+ className,
13+ ...props
14+ } : React . ComponentProps < typeof LabelPrimitive . Root > ) => (
15+ < LabelPrimitive . Root className = { cn ( labelVariants ( ) , className ) } { ...props } />
16+ ) ;
17+
18+ export { Label } ;
Original file line number Diff line number Diff line change @@ -9,3 +9,5 @@ export * from "./Badges";
99export * from "./Tabs" ;
1010export * from "./Dialog" ;
1111export * from "./Menu" ;
12+ export * from "./Input" ;
13+ export * from "./Label" ;
Original file line number Diff line number Diff line change 1+ import { Input , Label } from "@/packages/ui" ;
2+
3+ export default function InputStyleError ( ) {
4+ return (
5+ < div className = "grid w-full max-w-sm items-center gap-1.5" >
6+ < Label htmlFor = "pokemon" > Favorite Pokemon</ Label >
7+ < Input
8+ type = "pokemon"
9+ id = "pokemon"
10+ placeholder = "Charmander"
11+ defaultValue = "Son Goku"
12+ aria-invalid
13+ />
14+ < p className = "text-sm text-red-500" > Please provide a valid pokemon!</ p >
15+ </ div >
16+ ) ;
17+ }
Original file line number Diff line number Diff line change 1+ import { Input , Label } from "@/packages/ui" ;
2+
3+ export default function InputStyleWithLabel ( ) {
4+ return (
5+ < div className = "grid w-full max-w-sm items-center gap-1.5" >
6+ < Label htmlFor = "pokemon" > Favorite Pokemon</ Label >
7+ < Input type = "pokemon" id = "pokemon" placeholder = "Charmander" />
8+ </ div >
9+ ) ;
10+ }
You can’t perform that action at this time.
0 commit comments