Skip to content

Commit

Permalink
Flexbox layout support for DropdownMenuWrapper component
Browse files Browse the repository at this point in the history
  • Loading branch information
cheton committed Mar 7, 2018
1 parent f8a08a4 commit e0ca29f
Show file tree
Hide file tree
Showing 9 changed files with 32 additions and 10 deletions.
1 change: 1 addition & 0 deletions README.md
Expand Up @@ -266,6 +266,7 @@ rootCloseEvent | One of:<br/>'click'<br/>'mousedown' | | Which event when fired
Name | Type | Default | Description
:--- | :--- | :------ | :----------
componentClass | element | div | A custom element for this component.
flex | boolean | false | Whether to use the flexbox layout.
open | boolean | false | Whether or not the dropdown is visible.
pullRight | boolean | false | Align the menu to the right side of the dropdown toggle.
onClose | function(event) | | A callback fired when the dropdown menu closes.
Expand Down
10 changes: 9 additions & 1 deletion dist/react-dropdown.css

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion dist/react-dropdown.min.css

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions docs/bundle.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion docs/index.html
Expand Up @@ -11,5 +11,5 @@
</head>
<body>
<div id="container"></div>
<script type="text/javascript" src="bundle.js?ea95ce0687334d9ae53a"></script></body>
<script type="text/javascript" src="bundle.js?9eba4931e2a85e8221fc"></script></body>
</html>
5 changes: 3 additions & 2 deletions examples/DropdownMenuWrapper.jsx
Expand Up @@ -13,8 +13,8 @@ export default () => (
style={{ width: '100%' }}
>
<Dropdown.Toggle title="Custom range" />
<Dropdown.MenuWrapper>
<Dropdown.Menu>
<Dropdown.MenuWrapper flex>
<Dropdown.Menu style={{ flex: '1 0 0' }}>
<MenuItem eventKey="1d">
Last 24 hours
</MenuItem>
Expand All @@ -33,6 +33,7 @@ export default () => (
</Dropdown.Menu>
<div
style={{
flex: '0 0 auto',
display: 'inline-block',
padding: 12,
borderLeft: '1px solid #ddd',
Expand Down
2 changes: 1 addition & 1 deletion package.json
@@ -1,6 +1,6 @@
{
"name": "@trendmicro/react-dropdown",
"version": "1.2.0",
"version": "1.2.1",
"description": "React Dropdown component",
"main": "lib/index.js",
"files": [
Expand Down
10 changes: 9 additions & 1 deletion src/DropdownMenuWrapper.jsx
Expand Up @@ -18,6 +18,8 @@ class DropdownMenuWrapper extends PureComponent {
PropTypes.func
]),

flex: PropTypes.bool,

// Dropdown
open: PropTypes.bool,
pullRight: PropTypes.bool,
Expand All @@ -32,6 +34,8 @@ class DropdownMenuWrapper extends PureComponent {
static defaultProps = {
componentClass: 'div',

flex: false,

// Dropdown
open: false,
pullRight: false
Expand Down Expand Up @@ -72,6 +76,7 @@ class DropdownMenuWrapper extends PureComponent {
const {
componentType, // eslint-disable-line
componentClass: Component,
flex,
open,
pullRight,
onClose,
Expand All @@ -90,7 +95,10 @@ class DropdownMenuWrapper extends PureComponent {
>
<Component
{...props}
className={cx(className, styles.dropdownMenuWrapper)}
className={cx(className, {
[styles.dropdownMenuWrapper]: true,
[styles.flex]: !!flex
})}
>
{React.Children.map(children, child => {
if (!React.isValidElement(child)) {
Expand Down
4 changes: 4 additions & 0 deletions src/dropdown-menu-wrapper.styl
Expand Up @@ -17,6 +17,10 @@
display: block;
}

.dropdown.open > .dropdown-menu-wrapper.flex {
display: flex;
}

.dropdown.open > .dropdown-menu-wrapper > .dropdown-menu {
display: inline-block;
border: 0;
Expand Down

0 comments on commit e0ca29f

Please sign in to comment.