Skip to content

Commit

Permalink
feat(Toolbar): create new component
Browse files Browse the repository at this point in the history
  • Loading branch information
kradio3 committed Feb 27, 2017
1 parent 582ed05 commit 388452d
Show file tree
Hide file tree
Showing 7 changed files with 87 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/Layout/Content.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ const Content = ({
fixedToolbar,
...otherProps
}) => {
const classes = classnames({ 'mdc-toolbar-fixed-adjust': fixedToolbar }, className);
const classes = classnames({ 'mdc-toolbar__fixed-adjust': fixedToolbar }, className);
return React.createElement(component || 'main', {
className: classes,
...otherProps,
Expand Down
1 change: 1 addition & 0 deletions src/Layout/index.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import '@material/layout-grid/dist/mdc.layout-grid.min.css';
import '@material/toolbar/dist/mdc.toolbar.css';

export { default as Grid } from './Grid';
export { default as Cell } from './Cell';
Expand Down
30 changes: 30 additions & 0 deletions src/Toolbar/Toolbar.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
import React, { PropTypes } from 'react';
import classnames from 'classnames';

const ROOT = 'mdc-toolbar';
const FIXED = `${ROOT}--fixed`;

const propTypes = {
className: PropTypes.string,
children: PropTypes.node,
fixedToolbar: PropTypes.bool,
};

const Toolbar = ({
className,
fixedToolbar,
children,
...otherProps
}) => (
<header
className={classnames(ROOT, {
[FIXED]: fixedToolbar,
}, className)}
{...otherProps}
>
{children}
</header>
);
Toolbar.propTypes = propTypes;
export default Toolbar;

24 changes: 24 additions & 0 deletions src/Toolbar/ToolbarSection.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
import React, { PropTypes } from 'react';
import classnames from 'classnames';
import isDefined from '../utils/isDefined';

const propTypes = {
className: PropTypes.string,
children: PropTypes.node,
align: PropTypes.oneOf(['start', 'end']),
};

const ROOT = 'mdc-toolbar__section';

const ToolbarSection = ({ className, align, children, ...otherProps }) => (
<section
className={classnames(ROOT, {
[`${ROOT}--align-${align}`]: isDefined(align),
}, className)} {...otherProps}
>
{children}
</section>
);
ToolbarSection.propTypes = propTypes;
export default ToolbarSection;

25 changes: 25 additions & 0 deletions src/Toolbar/ToolbarTitle.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
import React, { PropTypes } from 'react';
import classnames from 'classnames';

const ROOT = 'mdc-toolbar__title';

const propTypes = {
className: PropTypes.string,
children: PropTypes.node,
};

const ToolbarTitle = ({
className,
children,
...otherProps
}) => (
<span
className={classnames(ROOT, className)}
{...otherProps}
>
{children}
</span>
);
ToolbarTitle.propTypes = propTypes;
export default ToolbarTitle;

5 changes: 5 additions & 0 deletions src/Toolbar/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import '@material/toolbar/dist/mdc.toolbar.css';

export { default as Toolbar } from './Toolbar';
export { default as ToolbarSection } from './ToolbarSection';
export { default as ToolbarTitle } from './ToolbarTitle';
1 change: 1 addition & 0 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,3 +13,4 @@ export { default as Icon } from './Icon';
export { Drawer, DrawerSpacer, Navigation, DrawerHeader, DrawerHeaderContent, DrawerContent } from './Drawer';
export { Grid, Cell, Layout, Content } from './Layout';
export { default as Snackbar } from './Snackbar';
export { Toolbar, ToolbarSection, ToolbarTitle } from './Toolbar';

0 comments on commit 388452d

Please sign in to comment.