File tree Expand file tree Collapse file tree 8 files changed +115
-3
lines changed Expand file tree Collapse file tree 8 files changed +115
-3
lines changed Original file line number Diff line number Diff line change
1
+ export * from "./input" ;
2
+ export * from "./input.types" ;
Original file line number Diff line number Diff line change
1
+ import clsx from "clsx" ;
2
+ import { InputFieldProps } from "./input.types" ;
3
+
4
+ export function Input ( {
5
+ errorMessage,
6
+ hasError = ! ! errorMessage ,
7
+ icon,
8
+ disabled,
9
+ className,
10
+ ...props
11
+ } : InputFieldProps ) {
12
+ return (
13
+ < div className = "rustlanges-input__container" >
14
+ < div
15
+ className = { clsx (
16
+ "rustlanges-input" ,
17
+ hasError && "rustlanges-input--error" ,
18
+ className
19
+ ) }
20
+ >
21
+ { icon && < span className = "rustlanges-input__icon" > { icon } </ span > }
22
+ < input
23
+ disabled = { disabled }
24
+ className = "rustlanges-input__inner"
25
+ { ...props }
26
+ />
27
+ </ div >
28
+ { hasError && errorMessage && (
29
+ < span className = "rustlanges-input__error" > { errorMessage } </ span >
30
+ ) }
31
+ </ div >
32
+ ) ;
33
+ }
Original file line number Diff line number Diff line change
1
+ import { InputHTMLAttributes , ReactNode } from "react" ;
2
+
3
+ export interface InputFieldProps extends InputHTMLAttributes < HTMLInputElement > {
4
+ hasError ?: boolean ;
5
+ errorMessage ?: string ;
6
+ icon ?: ReactNode ;
7
+ }
Original file line number Diff line number Diff line change @@ -5,6 +5,7 @@ export * from "./components/contact-form";
5
5
export * from "./components/chip" ;
6
6
export * from "./components/tag" ;
7
7
export * from "./components/flap" ;
8
+ export * from "./components/input" ;
8
9
export * from "./components/level" ;
9
10
export * from "./components/avatar" ;
10
11
export * from "./components/collaborators" ;
Original file line number Diff line number Diff line change 5
5
Github ,
6
6
Tag ,
7
7
Telegram ,
8
+ Input ,
9
+ Location ,
8
10
Flap ,
9
11
Chip ,
10
12
Level ,
@@ -524,6 +526,31 @@ export function App() {
524
526
</ div >
525
527
</ div >
526
528
</ ShowComponent >
529
+ < ShowComponent
530
+ title = "Input"
531
+ propsDef = { {
532
+ placeholder : {
533
+ type : "string" ,
534
+ default : "Input" ,
535
+ } ,
536
+ disabled : {
537
+ type : "boolean" ,
538
+ default : false ,
539
+ } ,
540
+ hasError : {
541
+ type : "boolean" ,
542
+ default : false ,
543
+ } ,
544
+ errorMessage : {
545
+ type : "string" ,
546
+ default : "Error" ,
547
+ } ,
548
+ } }
549
+ component = { Input }
550
+ />
551
+ < ShowComponent title = "Input With Icon" >
552
+ < Input icon = { < Location /> } placeholder = "Input" />
553
+ </ ShowComponent >
527
554
< ShowComponent title = "Input Search" >
528
555
< div className = "flex min-h-60 w-full flex-wrap justify-evenly gap-40 p-5" >
529
556
< InputSearch
Original file line number Diff line number Diff line change 6
6
@import "./components/collaborators.css" ;
7
7
@import "./components/dropdown.css" ;
8
8
@import "./components/flap.css" ;
9
+ @import "./components/input.css" ;
9
10
@import "./components/level.css" ;
10
11
@import "./components/radio.css" ;
11
12
@import "./components/tag.css" ;
Original file line number Diff line number Diff line change 1
1
@layer components {
2
-
3
-
4
2
.rustlanges-input-search-container {
5
3
@apply relative flex h-fit w-full;
6
-
4
+
7
5
svg {
8
6
@apply text-gray-600 dark:text-gray-400;
9
7
}
Original file line number Diff line number Diff line change
1
+ @layer components {
2
+ .rustlanges-input {
3
+ @apply flex items-center gap-2 rounded-xl px-[10px ] py-3 transition-colors;
4
+ @apply bg-light border-1 border-black text-black hover:bg-neutral-100;
5
+ @apply dark:bg-neutral-950 dark:text-white dark:hover:bg-neutral-900;
6
+
7
+ & : has (> : active ),
8
+ & : has (> : focus ) {
9
+ @apply border-primary-500;
10
+ }
11
+
12
+ @variant has-disabled {
13
+ @apply cursor-not-allowed border-neutral-400 bg-neutral-100 text-neutral-600;
14
+ @apply dark:bg-neutral-900 dark:text-neutral-400;
15
+ }
16
+ }
17
+
18
+ .rustlanges-input--error {
19
+ @apply border-error-600;
20
+ }
21
+
22
+ .rustlanges-input__container {
23
+ @apply flex flex-col gap-1;
24
+ }
25
+
26
+ .rustlanges-input__error {
27
+ @apply text-error-800 dark:text-error-300 mt-1 text-sm;
28
+ }
29
+
30
+ .rustlanges-input__inner {
31
+ @apply w-full bg-transparent outline-none;
32
+ @apply placeholder:text-neutral-600 dark:placeholder:text-neutral-400;
33
+ @apply disabled:pointer-events-none disabled:placeholder:text-neutral-400 dark:disabled:placeholder:text-neutral-600;
34
+ }
35
+
36
+ .rustlanges-input__icon {
37
+ @apply text-neutral-600;
38
+
39
+ & : has (+ : disabled ) {
40
+ @apply text-neutral-400;
41
+ }
42
+ }
43
+ }
You can’t perform that action at this time.
0 commit comments