Skip to content

Commit bd6e828

Browse files
committed
Add nowrap option for Toolbar
1 parent 2acf00c commit bd6e828

File tree

5 files changed

+35
-7
lines changed

5 files changed

+35
-7
lines changed

src/demo/pages/DemoContainer.jsx

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -445,6 +445,27 @@ class DemoContainer extends React.Component {
445445
</Toolbar>
446446
)}
447447
/>
448+
<Documentation
449+
name="Toolbar with disabled wrapping"
450+
component={(
451+
<Toolbar justify="space-between" nowrap>
452+
<ToolbarGroup>
453+
<ToolbarItem>
454+
<Placeholder text="grouped item 1" />
455+
</ToolbarItem>
456+
<ToolbarItem>
457+
<Placeholder text="grouped item 2" />
458+
</ToolbarItem>
459+
<ToolbarItem>
460+
<Placeholder text="grouped item 3" />
461+
</ToolbarItem>
462+
</ToolbarGroup>
463+
<ToolbarItem>
464+
<Placeholder text="item A" />
465+
</ToolbarItem>
466+
</Toolbar>
467+
)}
468+
/>
448469
<Documentation
449470
name="Centered justification and alignment"
450471
component={(

src/lib/components/layout/Toolbar/Toolbar.jsx

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ const Toolbar = (props) => {
77
align,
88
children,
99
justify,
10+
nowrap,
1011
} = props;
1112

1213
const alignClass = (value) => {
@@ -45,6 +46,7 @@ const Toolbar = (props) => {
4546
<div
4647
className={[
4748
styles.toolbar,
49+
nowrap ? styles.isNowrap : null,
4850
alignClass(align),
4951
justifyClass(justify),
5052
].join(' ')}
@@ -57,6 +59,7 @@ const Toolbar = (props) => {
5759
Toolbar.defaultProps = {
5860
align: 'top',
5961
justify: 'start',
62+
nowrap: false,
6063
};
6164

6265
Toolbar.propTypes = {
@@ -66,6 +69,7 @@ Toolbar.propTypes = {
6669
PropTypes.node,
6770
]).isRequired,
6871
justify: PropTypes.oneOf(['start', 'center', 'end', 'space-between']),
72+
nowrap: PropTypes.bool,
6973
};
7074

7175
export default Toolbar;

src/lib/components/layout/Toolbar/Toolbar.scss

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
@import '../../../styles/tools/offset';
21
@import 'theme';
32

43
.toolbar,
@@ -16,8 +15,12 @@
1615
margin: $toolbar-spacing;
1716
}
1817

19-
.spacer {
20-
flex: 1 1 auto;
18+
.isNowrap {
19+
flex-wrap: nowrap;
20+
}
21+
22+
.isNowrap > .item {
23+
flex: 0 1 auto;
2124
}
2225

2326
.isAlignedToTop {

src/lib/components/layout/Toolbar/__tests__/Toolbar.test.jsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ describe('rendering', () => {
2727

2828
it('renders correctly with all props', () => {
2929
const tree = shallow((
30-
<Toolbar align="middle" justify="center">
30+
<Toolbar align="middle" justify="center" nowrap>
3131
<span>content</span>
3232
</Toolbar>
3333
));

src/lib/components/layout/Toolbar/__tests__/__snapshots__/Toolbar.test.jsx.snap

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
exports[`rendering renders correctly with a single child 1`] = `
44
<div
5-
className="toolbar isAlignedToTop isJustifiedToStart"
5+
className="toolbar isAlignedToTop isJustifiedToStart"
66
>
77
<span>
88
content
@@ -12,7 +12,7 @@ exports[`rendering renders correctly with a single child 1`] = `
1212

1313
exports[`rendering renders correctly with all props 1`] = `
1414
<div
15-
className="toolbar isAlignedToMiddle isJustifiedToCenter"
15+
className="toolbar isNowrap isAlignedToMiddle isJustifiedToCenter"
1616
>
1717
<span>
1818
content
@@ -22,7 +22,7 @@ exports[`rendering renders correctly with all props 1`] = `
2222

2323
exports[`rendering renders correctly with multiple children 1`] = `
2424
<div
25-
className="toolbar isAlignedToTop isJustifiedToStart"
25+
className="toolbar isAlignedToTop isJustifiedToStart"
2626
>
2727
<span>
2828
content 1

0 commit comments

Comments
 (0)