diff --git a/src/components/SelectComponent/SelectComponent.definitions.ts b/src/components/SelectComponent/SelectComponent.definitions.ts new file mode 100644 index 0000000..e6d0a7b --- /dev/null +++ b/src/components/SelectComponent/SelectComponent.definitions.ts @@ -0,0 +1,11 @@ +// definitions +import type { UseFormRegister } from "react-hook-form"; + +export interface SelectProps { + name: string; + // eslint-disable-next-line @typescript-eslint/no-explicit-any + register: UseFormRegister; + label: string; + options: string[]; + placeholder: string; +} diff --git a/src/components/SelectComponent/SelectComponent.module.css b/src/components/SelectComponent/SelectComponent.module.css new file mode 100644 index 0000000..73f0396 --- /dev/null +++ b/src/components/SelectComponent/SelectComponent.module.css @@ -0,0 +1,31 @@ +.selectWrapper { + position: relative; + width: 200px; /* Set the width as needed */ + display: flex; + flex-direction: column; +} + +.selectWrapper label { + font-weight: 700; + font-size: 14px; + margin-bottom: 2px; + color: red; +} + +.selectWrapper select { + width: 100%; + color: #999; + border-color: #999; + border-radius: 4px; + border-style: solid; + border-width: 2px; + font-size: 16px; + outline: none; + height: fit-content; + padding: 4px 8px; +} + +/* Style the placeholder option */ +.selectWrapper select::placeholder { + color: #999; /* Adjust placeholder color as needed */ +} diff --git a/src/components/SelectComponent/SelectComponent.tsx b/src/components/SelectComponent/SelectComponent.tsx new file mode 100644 index 0000000..4e12a60 --- /dev/null +++ b/src/components/SelectComponent/SelectComponent.tsx @@ -0,0 +1,29 @@ +import style from "./SelectComponent.module.css"; +import type { ReactElement } from "react"; +import type { SelectProps } from "./SelectComponent.definitions.tsx"; + +const Select = ({ + name, + register, + label, + placeholder, + options, +}: SelectProps): ReactElement => { + return ( +
+
+ {label && } + +
+
+ ); +}; + +export default Select; diff --git a/src/components/SelectComponent/tests/ButtonComponent.test.tsx b/src/components/SelectComponent/tests/ButtonComponent.test.tsx new file mode 100644 index 0000000..1b2ba95 --- /dev/null +++ b/src/components/SelectComponent/tests/ButtonComponent.test.tsx @@ -0,0 +1,21 @@ +import Select from "../SelectComponent"; +import { render } from "@testing-library/react"; + +describe("SelectComponent Tests", () => { + test("Test Select component to render", () => { + const options = ["Option 1", "Option 2", "Option 3"]; + + // Mock register function + const mockRegister = jest.fn(); + + render( +