Skip to content

Commit

Permalink
fix: optimize code
Browse files Browse the repository at this point in the history
  • Loading branch information
rgah2107 committed May 4, 2020
1 parent 00a6c9a commit 31ec5f9
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 18 deletions.
4 changes: 2 additions & 2 deletions src/components/VisualPicker/index.d.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { ReactNode, ComponentType } from 'react';
import { BaseProps } from '../types';
import { BaseProps, VisualPickerSize } from '../types';

type Value = string[] | string;

Expand All @@ -13,7 +13,7 @@ export interface VisualPickerProps extends BaseProps {
error?: ReactNode;
children?: ReactNode;
multiple?: boolean;
size?: string;
size?: VisualPickerSize;
}

declare const VisualPicker: React.ComponentType<VisualPickerProps>;
Expand Down
18 changes: 2 additions & 16 deletions src/components/VisualPickerOption/styled/content.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
import styled from 'styled-components';
import attachThemeAttrs from '../../../styles/helpers/attachThemeAttrs';

const sizeMap = { large: '210px', medium: '142px', small: '100px' };
const StyledContent = attachThemeAttrs(styled.span)`
height: 142px;
height: ${props => sizeMap[props.size] || '142px'};
width: 100%;
border-radius: 22px;
box-shadow: ${props => props.shadows.shadow_4};
Expand All @@ -13,21 +14,6 @@ const StyledContent = attachThemeAttrs(styled.span)`
justify-content: center;
align-items: center;
position: relative;
${props =>
props.size === 'large' &&
`
height: 210px;
`};
${props =>
props.size === 'medium' &&
`
height: 142px;
`};
${props =>
props.size === 'small' &&
`
height: 100px;
`};
`;

export default StyledContent;
1 change: 1 addition & 0 deletions src/components/types.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ export type ButtonIconVariant =
| 'border-filled'
| 'border-inverse'
| 'inverse';
export type VisualPickerSize = 'small' | 'medium' | 'large';

export type IconPosition = 'left' | 'right';

Expand Down

0 comments on commit 31ec5f9

Please sign in to comment.