Skip to content

Commit

Permalink
Merge pull request #21 from acm-ucr/darsh175223/create-input
Browse files Browse the repository at this point in the history
Added the email input field
  • Loading branch information
shahdivyank authored Oct 29, 2024
2 parents 0dce829 + 250260b commit 633c358
Show file tree
Hide file tree
Showing 6 changed files with 105 additions and 7 deletions.
23 changes: 23 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
},
"dependencies": {
"@radix-ui/react-alert-dialog": "^1.1.2",
"@radix-ui/react-label": "^2.1.0",
"@radix-ui/react-slot": "^1.1.0",
"@tanstack/react-query": "^5.53.3",
"class-variance-authority": "^0.7.0",
Expand Down
11 changes: 6 additions & 5 deletions src/components/applications/application.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import Textarea from "@/components/global/inputs/textarea";
import Select from "@/components/global/inputs/select";
import Text from "@/components/global/inputs/text";
import { Questions } from "@/types/questions";
import Input from "@/components/global/inputs/input";

interface props {
title: string;
Expand All @@ -26,14 +27,14 @@ const Application = ({ title, questions }: props) => {
}}
/>

<Text
<Input
meta={{
type: "text",
title: "Email",
placeholder: "Enter an Email",
placeholder: "Enter your email",
value: "",
type: "text",
maxLength: 250,
value: "SAMPLE EMAIL",
disabled: true,
disabled: false,
}}
/>

Expand Down
20 changes: 18 additions & 2 deletions src/components/global/inputs/input.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,21 @@
const Input = () => {
return <div>Input</div>;
import { Input as ShadCNInput } from "@/components/ui/input";
import { Label } from "@/components/ui/label";
import { TextInput } from "@/types/questions";

const Input = ({ meta }: { meta: TextInput }) => {
const { title, placeholder, value, type } = meta;

return (
<div className="grid w-full max-w-sm items-center gap-3">
<Label htmlFor={title}>{title}</Label>
<ShadCNInput
type={type}
id={title}
placeholder={placeholder}
value={value}
/>
</div>
);
};

export default Input;
31 changes: 31 additions & 0 deletions src/components/ui/input.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
import * as React from "react";

import { cn } from "@/lib/utils";

export interface InputProps
extends React.InputHTMLAttributes<HTMLInputElement> {
meta?: {
title: string;
placeholder: string;
value?: string;
};
}

const Input = React.forwardRef<HTMLInputElement, InputProps>(
({ className, type, ...props }, ref) => {
return (
<input
type={type}
className={cn(
"flex h-10 w-full rounded-md border border-input bg-background px-3 py-2 text-sm ring-offset-background file:border-0 file:bg-transparent file:text-sm file:font-medium file:text-foreground placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50",
className,
)}
ref={ref}
{...props}
/>
);
},
);
Input.displayName = "Input";

export { Input };
26 changes: 26 additions & 0 deletions src/components/ui/label.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
"use client";

import * as React from "react";
import * as LabelPrimitive from "@radix-ui/react-label";
import { cva, type VariantProps } from "class-variance-authority";

import { cn } from "@/lib/utils";

const labelVariants = cva(
"text-sm font-medium leading-none peer-disabled:cursor-not-allowed peer-disabled:opacity-70",
);

const Label = React.forwardRef<
React.ElementRef<typeof LabelPrimitive.Root>,
React.ComponentPropsWithoutRef<typeof LabelPrimitive.Root> &
VariantProps<typeof labelVariants>
>(({ className, ...props }, ref) => (
<LabelPrimitive.Root
ref={ref}
className={cn(labelVariants(), className)}
{...props}
/>
));
Label.displayName = LabelPrimitive.Root.displayName;

export { Label };

0 comments on commit 633c358

Please sign in to comment.