Skip to content
This repository has been archived by the owner on Feb 10, 2025. It is now read-only.

Commit

Permalink
add disabled input
Browse files Browse the repository at this point in the history
  • Loading branch information
0xKurt committed Jan 28, 2025
1 parent 4806b55 commit cf9a5a9
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 3 deletions.
12 changes: 11 additions & 1 deletion src/components/Form/Form.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,17 @@ const fields: FormField[] = [
component: "Input",
placeholder: "your cool round name",
},

{
field: {
name: "disabledField",
label: "Disabled input",
className: "border-grey-300",
validation: { stringValidation: { minLength: 7 } },
},
component: "Input",
placeholder: "This field is disabled",
disabled: true,
},
{
field: {
name: "roundDescription",
Expand Down
3 changes: 2 additions & 1 deletion src/types/form/fieldTypes.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { FieldArrayProps, MetricsProps } from "@/components/Form";
import { FileUploadProps } from "@/primitives/FileUpload";
import { SelectProps } from "@/primitives/Select";
import { InputProps } from "@/ui-shadcn/input";

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

Expand Down Expand Up @@ -49,7 +50,7 @@ export interface BaseField {
className?: string;
}

export interface InputField {
export interface InputField extends InputProps {
field: BaseField;
component: "Input";
type?: string;
Expand Down
5 changes: 4 additions & 1 deletion src/ui-shadcn/input.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,17 @@ import { cn } from "@/lib/utils";
export interface InputProps extends React.InputHTMLAttributes<HTMLInputElement> {}

const Input = React.forwardRef<HTMLInputElement, InputProps>(
({ className, type, ...props }, ref) => {
({ className, type, disabled, ...props }, ref) => {
return (
<input
type={type}
className={cn(
"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",
disabled &&
"flex cursor-not-allowed gap-2 rounded-md bg-grey-100 px-3 py-2 font-normal text-grey-500",
className,
)}
disabled={disabled}
ref={ref}
{...props}
/>
Expand Down

0 comments on commit cf9a5a9

Please sign in to comment.