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: {
49
49
name : "dialog" ,
50
50
filePath : "packages/ui/Dialog/Dialog.tsx" ,
51
51
} ,
52
+ input : {
53
+ name : "input" ,
54
+ filePath : "packages/ui/Input.tsx" ,
55
+ } ,
52
56
menu : {
53
57
name : "menu" ,
54
58
filePath : "packages/ui/Menu/Menu.tsx" ,
@@ -200,6 +204,18 @@ export const componentConfig: {
200
204
filePath : "preview/components/input-style-default.tsx" ,
201
205
preview : lazy ( ( ) => import ( "@/preview/components/input-style-default" ) ) ,
202
206
} ,
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
+ } ,
203
219
"menu-style-default" : {
204
220
name : "menu-style-default" ,
205
221
filePath : "preview/components/menu-style-default.tsx" ,
Original file line number Diff line number Diff line change 1
1
---
2
2
title : Input
3
3
description : This pretty input makes your users want to type stuff! ⌨️
4
- lastUpdated : 08 Oct , 2024
4
+ lastUpdated : 04 Mar , 2024
5
5
---
6
6
7
- ### Default
7
+ <ComponentShowcase name = " input-style-default" />
8
+ <br />
9
+ <br />
10
+
11
+ ## Installation
8
12
9
- <hr />
13
+ #### 1. Copy the code 👇 into your project:
14
+
15
+ <ComponentSource name = " input" />
16
+ <br />
10
17
<br />
18
+
19
+ ## Examples
20
+
21
+ ### Default
22
+
11
23
<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 15
15
"@radix-ui/react-checkbox" : " ^1.1.4" ,
16
16
"@radix-ui/react-dialog" : " ^1.1.2" ,
17
17
"@radix-ui/react-dropdown-menu" : " ^2.1.2" ,
18
+ "@radix-ui/react-label" : " ^2.1.2" ,
18
19
"@radix-ui/react-radio-group" : " ^1.2.3" ,
19
20
"@radix-ui/react-select" : " ^2.1.6" ,
20
21
"@radix-ui/react-switch" : " ^1.1.3" ,
Original file line number Diff line number Diff line change 1
- export * from "./Input" ;
2
1
export * from "./Textarea" ;
3
2
export * from "./Checkbox" ;
4
3
export * from "./Radio" ;
Original file line number Diff line number Diff line change @@ -10,11 +10,16 @@ export const Input: React.FC<InputProps> = ({
10
10
className = "" ,
11
11
...props
12
12
} ) => {
13
+ console . log ( props ) ;
13
14
return (
14
15
< input
15
16
type = { type }
16
17
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 } `}
18
23
{ ...props }
19
24
/>
20
25
) ;
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";
9
9
export * from "./Tabs" ;
10
10
export * from "./Dialog" ;
11
11
export * 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