-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: updates and working with next.js (#43)
* feat: add email-check-outline icon * fix: circle icons bg * feat: add CameraFrontVariant icon * fix: make input wrapper without padding * feat: add canada and usa icons * fix: select component icons * feat: country-selector component * fix: country-selector props * fix: border radius on select component * fix: add width prop to inputs * fix: inline button color * fix: radio font variant * chore: remove react from dev dep * chore: package-lock update
- Loading branch information
1 parent
460f5dc
commit 8eb39cf
Showing
15 changed files
with
162 additions
and
29 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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
23 changes: 23 additions & 0 deletions
23
src/components/CountrySelector/CountrySelector.stories.tsx
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,23 @@ | ||
import { ComponentProps } from 'react'; | ||
import { Story } from '@storybook/react'; | ||
import { CountrySelector } from './CountrySelector'; | ||
|
||
const Template: Story<ComponentProps<typeof CountrySelector>> = (props) => ( | ||
<CountrySelector {...props} /> | ||
); | ||
|
||
export default { | ||
title: 'Polyblocks/CountrySelector', | ||
component: CountrySelector, | ||
}; | ||
|
||
export const Basic = Template.bind({}); | ||
Basic.args = { | ||
label: 'Select country', | ||
}; | ||
|
||
export const CertainCountries = Template.bind({}); | ||
CertainCountries.args = { | ||
label: 'Select country', | ||
countries: ['Canada', 'United States'], | ||
}; |
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 @@ | ||
import { allCountries, countryNames } from 'country-region-data'; | ||
import { isEmpty } from 'lodash'; | ||
import { ComponentProps } from 'react'; | ||
import { polyIcons } from '../../theme'; | ||
import { Select } from '../Select'; | ||
|
||
const countryOptions = allCountries.map(([country]) => { | ||
const countryIcon = country.replace(/\W/gi, ''); | ||
|
||
return { | ||
// NOTE: country icon name must match with country name from 'country-region-data' package | ||
// @ts-ignore | ||
icon: polyIcons[countryIcon], | ||
value: country, | ||
label: country, | ||
}; | ||
}); | ||
|
||
type CountrySelectProps = Omit< | ||
ComponentProps<typeof Select>, | ||
'variant' | 'options' | ||
> & { | ||
countries?: typeof countryNames; | ||
}; | ||
|
||
export function CountrySelector(props: CountrySelectProps) { | ||
const { countries, ...selectProps } = props; | ||
|
||
const options = isEmpty(countries) | ||
? countryOptions | ||
: countryOptions.filter((option) => countries?.includes(option.value)); | ||
|
||
return <Select {...selectProps} variant="basic" options={options} />; | ||
} |
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 @@ | ||
export * from './CountrySelector'; |
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
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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