Skip to content

Commit

Permalink
feat: updates and working with next.js (#43)
Browse files Browse the repository at this point in the history
* 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
wahidrahim committed Nov 25, 2022
1 parent 460f5dc commit 8eb39cf
Show file tree
Hide file tree
Showing 15 changed files with 162 additions and 29 deletions.
41 changes: 36 additions & 5 deletions package-lock.json

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

7 changes: 5 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,9 @@
},
"dependencies": {
"@tippyjs/react": "^4.2.5",
"country-region-data": "^2.6.0",
"focus-visible": "^5.2.0",
"lodash": "^4.17.21",
"moment": "^2.29.1",
"react-day-picker": "^7.4.10",
"react-dropzone": "^14.2.3",
Expand All @@ -55,6 +57,7 @@
"@svgr/cli": "^5.5.0",
"@svgr/webpack": "^5.5.0",
"@types/jest": "^26.0.24",
"@types/lodash": "^4.14.186",
"@types/node": "^16.3.0",
"@types/react-select": "^4.0.17",
"@types/react-table": "^7.7.2",
Expand Down Expand Up @@ -88,7 +91,7 @@
"webpack-cli": "^4.9.1"
},
"peerDependencies": {
"react": "^17.0.2",
"react-dom": "^17.0.2"
"react": "17 - 18",
"react-dom": "17 - 18"
}
}
23 changes: 23 additions & 0 deletions src/components/CountrySelector/CountrySelector.stories.tsx
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'],
};
34 changes: 34 additions & 0 deletions src/components/CountrySelector/CountrySelector.tsx
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} />;
}
1 change: 1 addition & 0 deletions src/components/CountrySelector/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export * from './CountrySelector';
7 changes: 5 additions & 2 deletions src/components/Input/Input.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ export type InputProps = {
isDivisible?: boolean;
inputRef?: any;
readOnly?: boolean;
width?: string;
};

export type InputWrapperProps = GridProps & {
Expand All @@ -56,6 +57,7 @@ const InputWrapper = styled(Grid)<InputWrapperProps>(
border: (theme.INPUT || { border: 0 }).border,
borderRadius: (theme.INPUT || { borderRadius: 0 }).borderRadius,
transition: (theme.INPUT || { transition: 'unset' }).transition,
width: '100%',
...(error
? {
borderColor: theme.COLOR.danger2,
Expand Down Expand Up @@ -116,6 +118,7 @@ export const Input = forwardRef<HTMLInputElement, InputProps>(
disabled,
readOnly,
iconPosition,
width = 'fit-content',
...props
} = inputProps;

Expand Down Expand Up @@ -155,8 +158,8 @@ export const Input = forwardRef<HTMLInputElement, InputProps>(

return (
<Flex
width="fit-content"
variant="basic"
width={width}
variant="raw"
align={labelPosition === LablePosition.Left ? 'center' : 'start'}
dir={labelPosition === LablePosition.Left ? 'row' : 'column'}
margin={margin}
Expand Down
2 changes: 1 addition & 1 deletion src/components/Radio/Radio.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ export const Radio = (props: Props) => {
<Text
margin="0 5px"
as="span"
variant="b3"
variant="b1"
color={disabled ? 'gray2' : 'highlightText'}
>
{label}
Expand Down
32 changes: 17 additions & 15 deletions src/components/Select/Select.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -60,23 +60,25 @@ const DropdownIndicator = (props: DropdownIndicatorProps) => {
);
};

const Option = ({ children, ...props }: SelectOptionProps) => (
<components.Option {...props} isDisabled>
{!props.selectProps.noIcon && (
<Icon
variant="basic"
icon={polyIcons.Image}
size="22px"
color="gray3"
margin="0 9px -5px 0"
/>
)}
{children}
{/* {oProps.isDisabled && oProps.selectProps.disabledOptionText && (
const Option = ({ children, ...props }: SelectOptionProps) => {
return (
<components.Option {...props} isDisabled>
{!props.selectProps.noIcon && (
<Icon
variant="basic"
icon={props.data.icon || polyIcons.Image}
size="22px"
color="gray3"
margin="0 9px -5px 0"
/>
)}
{children}
{/* {oProps.isDisabled && oProps.selectProps.disabledOptionText && (
<Tooltip>{oProps.selectProps.disabledOptionText}</Tooltip>
)} */}
</components.Option>
);
</components.Option>
);
};

export const Select = ({
margin,
Expand Down
1 change: 1 addition & 0 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ export * from './components/Tooltip';
export * from './components/DropZone';
// export * from './components/TextArea';
// export * from './components/TextCopy'; // (tx hash)
export * from './components/CountrySelector';

// CONTAINERS
export * from './components/Box';
Expand Down
6 changes: 3 additions & 3 deletions src/theme/definitions/launchpad.ts
Original file line number Diff line number Diff line change
Expand Up @@ -238,7 +238,7 @@ export const ICON: Record<IconVariant, CSSPropertiesExtended> = {
},
circle: {
fill: COLOR.brandMain,
backgroundColor: COLOR.brandMain,
backgroundColor: COLOR.brandLightest,
borderRadius: '50%',
},
};
Expand Down Expand Up @@ -343,7 +343,7 @@ export const BUTTON: Record<ButtonVariant, CSSPropertiesExtended> = {
fontWeight: 'inherit',
fontSize: 'inherit',
letterSpacing: 'inherit',
color: 'inherit',
color: COLOR.brandMain,
background: 'transparent',
cursor: 'pointer',
},
Expand Down Expand Up @@ -556,7 +556,7 @@ export const SELECT: any = {
control: (styles: any, state: any) => ({
...styles,
backgroundColor: state.selectProps.readonly ? COLOR.gray5 : COLOR.light,
borderRadius: RADIUS.m,
borderRadius: RADIUS.s,
...(state.selectProps.isDisabled
? {
borderColor: COLOR.gray5,
Expand Down
3 changes: 3 additions & 0 deletions src/theme/icons/svg/camera-front-variant.svg
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
13 changes: 13 additions & 0 deletions src/theme/icons/svg/canada.svg
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 3 additions & 0 deletions src/theme/icons/svg/email-check-outline.svg
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
15 changes: 15 additions & 0 deletions src/theme/icons/svg/united-states.svg
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 2 additions & 1 deletion src/theme/types.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { CSSProperties } from 'react';
import { CSSProperties, ReactNode } from 'react';

export type CSSPropertiesExtended = CSSProperties & Record<string, any>;

Expand All @@ -21,6 +21,7 @@ export const propValueMap: Record<string, string> = {
export type OptionType = {
value: string;
label: string;
icon?: ReactNode;
};

export type Gap = 'xs' | 's' | 'm' | 'l' | 'xl' | 'xxl' | 'xxxl';

0 comments on commit 8eb39cf

Please sign in to comment.