Skip to content

Commit

Permalink
feat: boilerplate for select component
Browse files Browse the repository at this point in the history
  • Loading branch information
vickonrails committed Apr 7, 2021
1 parent d272760 commit dce8e2f
Show file tree
Hide file tree
Showing 4 changed files with 37 additions and 2 deletions.
16 changes: 14 additions & 2 deletions example/src/App.tsx
Expand Up @@ -7,11 +7,19 @@ import {
theme,
ThemeProps,
Input,
ISelectOptions,
Select,
Radio
// RadioGroup
} from 'avocado-ui'
import 'avocado-ui/dist/index.css'

const genderOptions: ISelectOptions[] = [
{ value: 'male', displayText: 'Male' },
{ value: 'female', displayText: 'Female' },
{ value: 'other', displayText: 'Other' }
]

const customTheme: ThemeProps = {
...theme,
colors: {
Expand Down Expand Up @@ -142,16 +150,20 @@ const App = () => {
Male
</Radio>

<Radio value='female' name='gender'>
<Radio value='male' name='gender'>
Female
</Radio>

<input />
{/* </RadioGroup> */}
<Select
placeholder='Select an option'
selectOptions={genderOptions}
/>
<Button loading={formLoading}>Submit</Button>
</form>
</div>
</div>
{}
</ThemeProvider>
)
}
Expand Down
1 change: 1 addition & 0 deletions src/components/index.ts
Expand Up @@ -2,3 +2,4 @@ export * from './button'
export * from './theme/theme-provider/provider'
export * from './input'
export * from './radio'
export * from './select'
1 change: 1 addition & 0 deletions src/components/select/index.ts
@@ -0,0 +1 @@
export * from './select'
21 changes: 21 additions & 0 deletions src/components/select/select.tsx
@@ -0,0 +1,21 @@
import React, { FC, HTMLAttributes } from 'react'

const Select: FC<Select> = ({ selectOptions, ...props }) => {
return (
<select {...props}>
{selectOptions.map((option) => (
<option key={option.value} value={option.value}>
{option.displayText}
</option>
))}
</select>
)
}

export type ISelectOptions = { value: string; displayText: string }

interface Select extends HTMLAttributes<HTMLSelectElement> {
selectOptions: ISelectOptions[]
}

export { Select }

0 comments on commit dce8e2f

Please sign in to comment.