Skip to content

Commit 3beb39f

Browse files
0xKurthussmartinez
authored andcommitted
Add disabled input (#126)
add disabled input
1 parent f418d06 commit 3beb39f

File tree

3 files changed

+17
-3
lines changed

3 files changed

+17
-3
lines changed

packages/ui/src/components/Form/Form.stories.tsx

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,17 @@ const fields: FormField[] = [
1414
component: "Input",
1515
placeholder: "your cool round name",
1616
},
17-
17+
{
18+
field: {
19+
name: "disabledField",
20+
label: "Disabled input",
21+
className: "border-grey-300",
22+
validation: { stringValidation: { minLength: 7 } },
23+
},
24+
component: "Input",
25+
placeholder: "This field is disabled",
26+
disabled: true,
27+
},
1828
{
1929
field: {
2030
name: "roundDescription",

packages/ui/src/types/form/fieldTypes.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import { FieldArrayProps, MetricsProps } from "@/components/Form";
22
import { FileUploadProps } from "@/primitives/FileUpload";
33
import { SelectProps } from "@/primitives/Select";
4+
import { InputProps } from "@/ui-shadcn/input";
45

56
import { Markdown } from "../markdown";
67

@@ -49,7 +50,7 @@ export interface BaseField {
4950
className?: string;
5051
}
5152

52-
export interface InputField {
53+
export interface InputField extends InputProps {
5354
field: BaseField;
5455
component: "Input";
5556
type?: string;

packages/ui/src/ui-shadcn/input.tsx

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,14 +5,17 @@ import { cn } from "@/lib/utils";
55
export interface InputProps extends React.InputHTMLAttributes<HTMLInputElement> {}
66

77
const Input = React.forwardRef<HTMLInputElement, InputProps>(
8-
({ className, type, ...props }, ref) => {
8+
({ className, type, disabled, ...props }, ref) => {
99
return (
1010
<input
1111
type={type}
1212
className={cn(
1313
"flex h-10 w-full rounded-md border border-grey-100 bg-white px-3 py-2 text-sm ring-offset-white file:border-0 file:bg-transparent file:text-sm file:font-medium file:text-black placeholder:text-grey-900 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-black focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50 dark:border-black dark:bg-black dark:ring-offset-black dark:file:text-grey-50 dark:placeholder:text-grey-500 dark:focus-visible:ring-grey-100",
14+
disabled &&
15+
"flex cursor-not-allowed gap-2 rounded-md bg-grey-100 px-3 py-2 font-normal text-grey-500",
1416
className,
1517
)}
18+
disabled={disabled}
1619
ref={ref}
1720
{...props}
1821
/>

0 commit comments

Comments
 (0)