-
-
Notifications
You must be signed in to change notification settings - Fork 113
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: add prop size to VisualPicker component #1527
feat: add prop size to VisualPicker component #1527
Conversation
@@ -13,6 +13,7 @@ export interface VisualPickerProps extends BaseProps { | |||
error?: ReactNode; | |||
children?: ReactNode; | |||
multiple?: boolean; | |||
size?: string; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
be more specific here like:
size?: 'small' | 'medium' | 'large';
props.size === 'small' && | ||
` | ||
height: 100px; | ||
`}; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
here you can use a map like:
const sizeMap = {
large: '210px',
medium: '142px',
small: '100px',
};
and then:
height: ${props => sizeMap[props.size] || 142px}
and thus avoid all conditionals
@rgah2107 let's add 2 examples more with the new sizes on the component |
const StyledContent = attachThemeAttrs(styled.span)` | ||
height: 142px; | ||
height: ${props => sizeMap[props.size] || '142px'}; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
size is always defined because in defaultProps you put medium
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@yvmunayev
I think we need do a fallback to || '142px'
since the user can pass a wrong size value and the component should render nicely
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@rgah2107 check here, I'm wrong and if necessary put:
height: ${props => sizeMap[props.size] || '142px'};
@rgah2107 we need to have the same width and the height on the different variants for example: |
we need to have the same width and the height on the different variants
height: 142px; | ||
width: 100%; | ||
height: ${props => sizeMap[props.size]}; | ||
width: ${props => sizeMap[props.size]}; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
here we need to do a fallback to a default size since the user can pass a wrong size where sizeMap[props.size]
will return undefined
fix: #1519
Changes proposed in this PR:
add prop size to VisualPicker component
I have followed (at least) the PR section of the contributing guide.
@nexxtway/react-rainbow