Skip to content

Commit

Permalink
feat: add select input component prop size
Browse files Browse the repository at this point in the history
  • Loading branch information
yvmunayev committed Oct 8, 2022
1 parent e010800 commit 1db36b3
Show file tree
Hide file tree
Showing 3 changed files with 42 additions and 4 deletions.
1 change: 1 addition & 0 deletions src/components/Select/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ export interface SelectProps extends BaseProps {
hideLabel?: boolean;
tabIndex?: number | string;
variant?: 'default' | 'shaded';
size?: 'small' | 'medium' | 'large';
}

declare const Select: React.ComponentType<SelectProps>;
Expand Down
5 changes: 5 additions & 0 deletions src/components/Select/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ class Select extends Component {
hideLabel,
tabIndex,
variant,
size,
} = this.props;

return (
Expand All @@ -93,6 +94,7 @@ class Select extends Component {
disabled={disabled}
variant={variant}
ref={this.selectRef}
size={size}
>
<Options options={options} />
</StyledSelect>
Expand Down Expand Up @@ -157,6 +159,8 @@ Select.propTypes = {
/** The variant changes the appearance of the Select. Accepted variants include default
* and shaded. This value defaults to default. */
variant: PropTypes.oneOf(['default', 'shaded']),
/** The size of the input. Valid values are small, medium, and large. */
size: PropTypes.oneOf(['small', 'medium', 'large']),
};

Select.defaultProps = {
Expand All @@ -179,6 +183,7 @@ Select.defaultProps = {
hideLabel: false,
tabIndex: undefined,
variant: 'default',
size: 'medium',
};

export default withReduxForm(Select);
40 changes: 36 additions & 4 deletions src/components/Select/styled/select.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,11 @@ import styled from 'styled-components';
import attachThemeAttrs from '../../../styles/helpers/attachThemeAttrs';
import { BORDER_RADIUS_2 } from '../../../styles/borderRadius';
import { PADDING_MEDIUM } from '../../../styles/paddings';
import { FONT_SIZE_TEXT_LARGE } from '../../../styles/fontSizes';
import {
FONT_SIZE_TEXT_LARGE,
FONT_SIZE_HEADING_MEDIUM,
FONT_SIZE_TEXT_MEDIUM,
} from '../../../styles/fontSizes';

const StyledSelect = attachThemeAttrs(styled.select)`
font: inherit;
Expand All @@ -21,6 +25,24 @@ const StyledSelect = attachThemeAttrs(styled.select)`
transition: all 0.1s linear;
box-sizing: border-box;
${props =>
props.size === 'large' &&
`
// padding: 0 1.2rem;
line-height: 3.275rem;
font-size: ${FONT_SIZE_HEADING_MEDIUM};
height: 3.4rem;
`};
${props =>
props.size === 'small' &&
`
// padding: 0 0.8rem;
line-height: 1.775rem;
font-size: ${FONT_SIZE_TEXT_MEDIUM};
height: 1.9rem;
`};
&::-ms-expand {
display: none;
}
Expand All @@ -33,7 +55,17 @@ const StyledSelect = attachThemeAttrs(styled.select)`
padding-right: 1.7375rem;
border: 0.125rem ${props => props.palette.brand.main} solid;
box-shadow: ${props => props.shadows.brand};
line-height: 2rem;
${props =>
props.size === 'large' &&
`
// padding: 0 1.125rem;
`};
${props =>
props.size === 'small' &&
`
// padding: 0 0.75rem;
`};
}
&[disabled] {
Expand All @@ -48,8 +80,8 @@ const StyledSelect = attachThemeAttrs(styled.select)`
box-shadow: none;
background-color: ${props => props.palette.action.active};
border: 0.0626rem ${props => props.palette.border.divider} solid;
padding-left: ${PADDING_MEDIUM};
padding-right: 1.8rem;
// padding-left: ${PADDING_MEDIUM};
// padding-right: 1.8rem;
}
}
Expand Down

0 comments on commit 1db36b3

Please sign in to comment.