Skip to content

Commit

Permalink
fix(Select): component doesn't have stretch prop
Browse files Browse the repository at this point in the history
  • Loading branch information
lesha1201 committed May 7, 2019
1 parent 4aab9e0 commit ab21679
Show file tree
Hide file tree
Showing 9 changed files with 19 additions and 10 deletions.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion src/components/Input/Input.theme.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ const name = 'input';

const [InputTag, themeInput] = createThemeTag(name, ({ COLORS, SIZES }: *): * => ({
root: props => ({
width: props.width ? `${props.width}rem` : props.stretch ? '100%' : '172px',
width: props.width ? `${props.width}rem` : props.stretch ? '100%' : SIZES.FIELD_WIDTH,
outline: 'none',
paddingLeft: props.hasLeftIcon ? '36px' : '8px',
paddingRight: props.hasRightIcon || (props.type === 'number' && !props.hideNumberArrows) ? '48px' : '16px',
Expand Down
3 changes: 3 additions & 0 deletions src/components/Select/Select.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@ type SelectProps = {|
components?: Object,
className?: string,
formatOptionLabel?: Function,
/** when stretch is true, width is 100% */
stretch?: boolean,
|};

type SelectPropsFromHOCs = {|
Expand Down Expand Up @@ -94,6 +96,7 @@ class Select extends React.Component<SelectProps & SelectPropsFromHOCs> {
static components = components;
static defaultProps = {
withPortal: true,
stretch: true,
};

onChange = (option: Object) => {
Expand Down
2 changes: 1 addition & 1 deletion src/components/Select/Select.stories.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ export default (asStory) => {
.add('common', () => (
<Column>
<StateContainer value={ null }>
<Select name="name" placeholder="Select an option" options={ OPTIONS } />
<Select name="name" placeholder="Select an option" options={ OPTIONS } stretch={ false } />
</StateContainer>
<StateContainer value={ OPTIONS[1].value }>
<Select name="name" placeholder="Select an option" options={ OPTIONS } clearable />
Expand Down
3 changes: 3 additions & 0 deletions src/components/Select/Select.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ describe('<Select />', () => {
const hasError = false;
const loading = false;
const disabled = true;
const stretch = true;
const components = {};

const wrapper = mount(
Expand All @@ -29,6 +30,7 @@ describe('<Select />', () => {
loading={ loading }
disabled={ disabled }
components={ components }
stretch={ stretch }
/>
</EightBaseBoostProvider>,
);
Expand All @@ -54,6 +56,7 @@ describe('<Select />', () => {
expect(passedStyledProps).toEqual({
hasError,
'aria-busy': String(loading),
stretch,
});
});
});
14 changes: 8 additions & 6 deletions src/components/Select/Select.theme.js
Original file line number Diff line number Diff line change
@@ -1,14 +1,18 @@
// @flow
import { createThemeTag } from '../../theme/createThemeTag';


const name = 'select';

const [SelectTag, themeSelect] = createThemeTag(name, {
const [SelectTag, themeSelect] = createThemeTag(name, ({ SIZES }) => ({
root: {
width: '100%',
width: SIZES.FIELD_WIDTH,
},
});
modifiers: {
stretch: {
width: '100%',
},
},
}));

const [SelectChevron, themeChevron] = createThemeTag(`${name}Chevron`, {
root: {
Expand All @@ -17,11 +21,9 @@ const [SelectChevron, themeChevron] = createThemeTag(`${name}Chevron`, {
},
});


const theme = {
...themeSelect,
...themeChevron,
};

export { SelectTag, SelectChevron, theme };

3 changes: 1 addition & 2 deletions src/components/SelectField/SelectField.stories.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ export default (asStory) => {
.add('common', () => (
<Column>
<StateContainer value={ null } withForm>
<SelectField label="Select" name="name" placeholder="Select an option" options={ OPTIONS } />
<SelectField label="Stretch = false" name="name" placeholder="Select an option" options={ OPTIONS } stretch={ false } />
</StateContainer>
<StateContainer value={ OPTIONS[1].value } withForm>
<SelectField label="Clearable select" name="name" placeholder="Select an option" options={ OPTIONS } clearable />
Expand All @@ -29,4 +29,3 @@ export default (asStory) => {
));
});
};

2 changes: 2 additions & 0 deletions src/theme/sizes.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,8 @@ const SIZES = {

SUBTITLE_2: '1.2rem',
SUBTITLE_2_LH: '2.1rem',

FIELD_WIDTH: '172px',
};

export {
Expand Down

0 comments on commit ab21679

Please sign in to comment.