-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #3 from cupton15/dev
Dev
- Loading branch information
Showing
12 changed files
with
446 additions
and
102 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
/* eslint-disable react/jsx-props-no-spreading */ | ||
import React from 'react'; | ||
import { useFormContext } from 'react-hook-form'; | ||
import { ReactComponent as Chevron } from '../../chevron-down-solid.svg'; | ||
|
||
type SelectProps = { | ||
id: string; | ||
name: string; | ||
children: React.ReactNode; | ||
}; | ||
|
||
export default function Select({ | ||
id, | ||
name, | ||
children, | ||
}: SelectProps): JSX.Element { | ||
const { register } = useFormContext(); | ||
const formattedName = name.replace(/([A-Z])/g, ' $1').toLowerCase(); | ||
return ( | ||
<div className="relative"> | ||
<label htmlFor={id} className="sr-only"> | ||
{`Select an ${formattedName}`} | ||
</label> | ||
<Chevron className="w-6 h-6 absolute right-2 top-3" fill="currentColor" /> | ||
<select | ||
id={id} | ||
{...register(name)} | ||
className="focus:border-blue-500 focus:ring-1 focus:ring-blue-500 focus:outline-none w-full border border-gray-200 rounded-md p-2 bg-white appearance-none" | ||
> | ||
{children} | ||
</select> | ||
</div> | ||
); | ||
} |
Oops, something went wrong.