Skip to content

Commit

Permalink
fix(atoms): add stretch prop to the dropdown palte
Browse files Browse the repository at this point in the history
  • Loading branch information
ej9x committed Oct 3, 2018
1 parent d9069a9 commit e571581
Show file tree
Hide file tree
Showing 6 changed files with 378 additions and 258 deletions.
2 changes: 2 additions & 0 deletions src/atoms/Dropdown/Dropdown.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import { DropdownHead as Head } from './DropdownHead';
import { DropdownBody as Body } from './DropdownBody';
import { theme as dropdownHeadTheme } from './DropdownHead.theme';
import { theme as dropdownBodyTheme } from './DropdownBody.theme';
import { theme as dropdownPlateTheme } from './DropdownPlate.theme';

const Dropdown = {
Head,
Expand All @@ -15,6 +16,7 @@ const Dropdown = {
const theme = {
...dropdownHeadTheme,
...dropdownBodyTheme,
...dropdownPlateTheme,
};

export {
Expand Down
2 changes: 1 addition & 1 deletion src/atoms/Dropdown/DropdownBody.js
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ const DropdownBody = dropdownBodyEnhancer(

return stretch
? targetWidth
: width && `${width}rem`;
: width && `${width}px`;
}

getBodyChildren = () => {
Expand Down
4 changes: 2 additions & 2 deletions src/atoms/Dropdown/DropdownHead.theme.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ const theme = createTheme(name, {

const DropdownHeadTag = createStyledTag(name, {
cursor: 'pointer',
display: 'inline-flex',
display: 'flex',
flexWrap: 'nowrap',
height: 'auto',
width: 'auto',
Expand All @@ -25,7 +25,7 @@ const DropdownHeadTag = createStyledTag(name, {


const DropdownPopperTarget = createStyledTag(name, {
display: 'inline-flex',
display: 'flex',
width: '100%',
height: ' 100%',
});
Expand Down
11 changes: 8 additions & 3 deletions src/atoms/Dropdown/DropdownPlate.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,13 @@ import { compose, withStateHandlers, branch, setDisplayName } from 'recompose';
import { Manager } from 'react-popper';

import { DropdownContext } from './DropdownContext';
import { DropdownPlateTag } from './DropdownPlate.theme';

type DropdownControlledProps = {|
/** Open state of the dropdown */
isOpen: boolean,
/** When true then plate */
stretch?: boolean,
/** Callback to close dropdown */
onCloseDropdown?: () => void,
/** Callback to open dropdown */
Expand All @@ -20,6 +23,8 @@ type DropdownControlledProps = {|
type DropdownUncontroledProps = {|
/** Default opened state for the uncontorlled mode */
defaultOpen?: boolean,
/** When true then plate */
stretch?: boolean,
children: React$Node,
|}

Expand Down Expand Up @@ -81,7 +86,7 @@ const DropdownPlate = dropDownEnhancer(
getIgnoreClickOutsideClass = () => `ignore-react-onclickoutside-${this.instanceIndex}`;

render() {
const { children, onCloseDropdown, isOpen } = this.props;
const { children, onCloseDropdown, isOpen, ...rest } = this.props;

const contextData: DropdownContextData = {
isOpen,
Expand All @@ -93,11 +98,11 @@ const DropdownPlate = dropDownEnhancer(

return (
<DropdownContext.Provider value={ contextData }>
<div ref={ this.setDropdownRef }>
<DropdownPlateTag { ...rest } tag="div" ref={ this.setDropdownRef }>
<Manager tag={ false }>
{ children }
</Manager>
</div>
</DropdownPlateTag>
</DropdownContext.Provider>
);
}
Expand Down
23 changes: 23 additions & 0 deletions src/atoms/Dropdown/DropdownPlate.theme.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
// @flow

import { createStyledTag, createTheme } from '../../utils';

const name = 'dropdownHead';

const theme = createTheme(name, {
modifiers: {
stretch: {
height: '100%',
width: '100%',
},
},
defaults: {},
});

const DropdownPlateTag = createStyledTag(name, {});

export {
theme,
DropdownPlateTag,
};

Loading

0 comments on commit e571581

Please sign in to comment.