Skip to content

Commit ec0dba1

Browse files
refactor(input): move component and story file from tailwind folder
1 parent b621f93 commit ec0dba1

File tree

5 files changed

+29
-52
lines changed

5 files changed

+29
-52
lines changed

src/components/MeetupList.tsx

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,8 @@ import { trackCustomEvent } from "@/lib/utils/matomo"
1111

1212
import meetups from "@/data/community-meetups.json"
1313

14-
import Input from "../../tailwind/ui/Input"
15-
1614
import { Flex } from "./ui/flex"
15+
import Input from "./ui/input"
1716
import InlineLink, { BaseLink } from "./ui/Link"
1817

1918
export interface Meetup {

src/components/Staking/WithdrawalCredentials.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,10 @@ import Translation from "@/components/Translation"
77

88
import { trackCustomEvent } from "@/lib/utils/matomo"
99

10-
import Input from "../../../tailwind/ui/Input"
1110
import { Alert, AlertContent } from "../ui/alert"
1211
import { Button } from "../ui/buttons/Button"
1312
import { Flex } from "../ui/flex"
13+
import Input from "../ui/input"
1414
import { Spinner } from "../ui/spinner"
1515

1616
interface Validator {

tailwind/ui/__stories__/Input.stories.tsx renamed to src/components/ui/__stories__/Input.stories.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
import type { Meta, StoryObj } from "@storybook/react/*"
22

3-
import { VStack } from "../../../src/components/ui/flex"
4-
import Input from "../Input"
3+
import { VStack } from "../flex"
4+
import Input from "../input"
55

66
const meta = {
7-
title: "Atoms / Form / ShadCN Input",
7+
title: "Atoms / Form / Input",
88
component: Input,
99
} satisfies Meta<typeof Input>
1010

src/components/ui/input.tsx

Lines changed: 24 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,33 @@
11
import * as React from "react"
2+
import { cva, type VariantProps } from "class-variance-authority"
23

34
import { cn } from "@/lib/utils/cn"
45

5-
const Input = React.forwardRef<HTMLInputElement, React.ComponentProps<"input">>(
6-
({ className, type, ...props }, ref) => {
6+
const inputVariants = cva(
7+
"rounded border border-body placeholder:text-disabled hover:not-disabled:border-primary-hover focus-visible:outline focus-visible:outline-primary-hover focus-visible:outline-[3px] focus-visible:-outline-offset-2 disabled:cursor-not-allowed disabled:border-disabled bg-background",
8+
{
9+
variants: {
10+
size: {
11+
md: "p-2",
12+
sm: "p-1 text-sm",
13+
},
14+
},
15+
defaultVariants: {
16+
size: "md",
17+
},
18+
}
19+
)
20+
21+
export interface InputProps
22+
extends Omit<React.InputHTMLAttributes<HTMLInputElement>, "size">,
23+
VariantProps<typeof inputVariants> {}
24+
25+
const Input = React.forwardRef<HTMLInputElement, InputProps>(
26+
({ className, type, size, ...props }, ref) => {
727
return (
828
<input
929
type={type}
10-
className={cn(
11-
"border-input file:text-foreground placeholder:text-muted-foreground focus-visible:ring-ring flex h-10 w-full rounded-md border bg-background px-3 py-2 text-base ring-offset-background file:border-0 file:bg-transparent file:text-sm file:font-medium focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50 md:text-sm",
12-
className
13-
)}
30+
className={cn(inputVariants({ size, className }))}
1431
ref={ref}
1532
{...props}
1633
/>
@@ -19,4 +36,4 @@ const Input = React.forwardRef<HTMLInputElement, React.ComponentProps<"input">>(
1936
)
2037
Input.displayName = "Input"
2138

22-
export { Input }
39+
export default Input

tailwind/ui/Input.tsx

Lines changed: 0 additions & 39 deletions
This file was deleted.

0 commit comments

Comments
 (0)