Skip to content

Commit

Permalink
Merge c6a9a30 into 39128ed
Browse files Browse the repository at this point in the history
  • Loading branch information
mukiienko committed Jul 8, 2019
2 parents 39128ed + c6a9a30 commit c76a0b5
Show file tree
Hide file tree
Showing 16 changed files with 87 additions and 44 deletions.
6 changes: 3 additions & 3 deletions src/components/Footer/Footer.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import React from 'react';
import PropTypes from 'prop-types';
import bem from 'bem';
import PageWidthRestrictor from '../PageWidthRestrictor';
import { BlockWidthRestrictor } from '../WidthRestrictor';
import styles from './Footer.scss';
import { LogoTextkernel } from '../Icon';

Expand All @@ -22,10 +22,10 @@ const Footer = props => {

return (
<footer {...rest} {...block(props)}>
<PageWidthRestrictor {...elem('wrapper', props)}>
<BlockWidthRestrictor {...elem('wrapper', props)}>
{copyright || tkCopyright}
<div {...elem('menu', props)}>{children}</div>
</PageWidthRestrictor>
</BlockWidthRestrictor>
</footer>
);
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,12 @@ exports[`Footer component that renders a copyright text on the left and optional
<footer
className="Footer"
>
<PageWidthRestrictor
<BlockWidthRestrictor
As="div"
className="Footer__wrapper"
>
<div
className="PageWidthRestrictor Footer__wrapper"
className="BlockWidthRestrictor Footer__wrapper"
>
<span>
© 2019
Expand Down Expand Up @@ -86,7 +86,7 @@ exports[`Footer component that renders a copyright text on the left and optional
This is a placeholder for children
</div>
</div>
</PageWidthRestrictor>
</BlockWidthRestrictor>
</footer>
</Footer>
`;
Expand All @@ -98,19 +98,19 @@ exports[`Footer component that renders a copyright text on the left and optional
<footer
className="Footer"
>
<PageWidthRestrictor
<BlockWidthRestrictor
As="div"
className="Footer__wrapper"
>
<div
className="PageWidthRestrictor Footer__wrapper"
className="BlockWidthRestrictor Footer__wrapper"
>
my special copyright
<div>
This is a placeholder for children
</div>
</div>
</PageWidthRestrictor>
</BlockWidthRestrictor>
</footer>
</Footer>
`;
6 changes: 3 additions & 3 deletions src/components/Header/Header.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import React from 'react';
import PropTypes from 'prop-types';
import bem from 'bem';
import PageWidthRestrictor from '../PageWidthRestrictor';
import { BlockWidthRestrictor } from '../WidthRestrictor';
import styles from './Header.scss';

const { block, elem } = bem({
Expand All @@ -26,10 +26,10 @@ const Header = props => {

return (
<header {...rest} {...block(props)}>
<PageWidthRestrictor {...elem('wrapper', props)}>
<BlockWidthRestrictor {...elem('wrapper', props)}>
{renderedLogo}
<div {...elem('menu', props)}>{children}</div>
</PageWidthRestrictor>
</BlockWidthRestrictor>
</header>
);
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,12 @@ exports[`Header component that renders a website header with a logo on the left
<header
className="Header"
>
<PageWidthRestrictor
<BlockWidthRestrictor
As="div"
className="Header__wrapper"
>
<div
className="PageWidthRestrictor Header__wrapper"
className="BlockWidthRestrictor Header__wrapper"
>
<a
className="Header__logo"
Expand Down Expand Up @@ -70,7 +70,7 @@ exports[`Header component that renders a website header with a logo on the left
This is a placeholder for children
</div>
</div>
</PageWidthRestrictor>
</BlockWidthRestrictor>
</header>
</Header>
`;
Expand All @@ -86,12 +86,12 @@ exports[`Header component that renders a website header with a logo on the left
<header
className="Header"
>
<PageWidthRestrictor
<BlockWidthRestrictor
As="div"
className="Header__wrapper"
>
<div
className="PageWidthRestrictor Header__wrapper"
className="BlockWidthRestrictor Header__wrapper"
>
<img
alt="our logo"
Expand All @@ -102,7 +102,7 @@ exports[`Header component that renders a website header with a logo on the left
This is a placeholder for children
</div>
</div>
</PageWidthRestrictor>
</BlockWidthRestrictor>
</header>
</Header>
`;
Expand All @@ -119,12 +119,12 @@ exports[`Header component that renders a website header with a logo on the left
<header
className="Header"
>
<PageWidthRestrictor
<BlockWidthRestrictor
As="div"
className="Header__wrapper"
>
<div
className="PageWidthRestrictor Header__wrapper"
className="BlockWidthRestrictor Header__wrapper"
>
<a
href="/"
Expand All @@ -138,7 +138,7 @@ exports[`Header component that renders a website header with a logo on the left
This is a placeholder for children
</div>
</div>
</PageWidthRestrictor>
</BlockWidthRestrictor>
</header>
</Header>
`;
6 changes: 3 additions & 3 deletions src/components/Navigation/NavBar/NavBar.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import React from 'react';
import PropTypes from 'prop-types';
import bem from 'bem';
import PageWidthRestrictor from '../../PageWidthRestrictor';
import { BlockWidthRestrictor } from '../../WidthRestrictor';
import styles from './NavBar.scss';

const { block, elem } = bem({
Expand All @@ -14,9 +14,9 @@ const NavBar = props => {

return (
<div {...rest} {...block(props)}>
<PageWidthRestrictor As="nav" {...elem('wrapper', props)}>
<BlockWidthRestrictor As="nav" {...elem('wrapper', props)}>
{children}
</PageWidthRestrictor>
</BlockWidthRestrictor>
</div>
);
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,12 @@ exports[`NavBar that renders a container for navigation should render correctly
<div
className="NavBar"
>
<PageWidthRestrictor
<BlockWidthRestrictor
As="nav"
className="NavBar__wrapper"
>
<nav
className="PageWidthRestrictor NavBar__wrapper"
className="BlockWidthRestrictor NavBar__wrapper"
>
<a
href="/"
Expand All @@ -23,7 +23,7 @@ exports[`NavBar that renders a container for navigation should render correctly
other
</a>
</nav>
</PageWidthRestrictor>
</BlockWidthRestrictor>
</div>
</NavBar>
`;
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
import React from 'react';
import PropTypes from 'prop-types';
import bem from 'bem';
import styles from './BlockWidthRestrictor.scss';

const { block } = bem({
name: 'BlockWidthRestrictor',
classnames: styles
});

const BlockWidthRestrictor = props => {
const { children, As, ...rest } = props;

return (
<As {...rest} {...block(props)}>
{children}
</As>
);
};

BlockWidthRestrictor.displayName = 'BlockWidthRestrictor';

BlockWidthRestrictor.propTypes = {
/** Node(s) to be rendered inside the container */
children: PropTypes.oneOfType([PropTypes.string, PropTypes.node]).isRequired,
/** HTML tag to be used to render the container */
As: PropTypes.string
};

BlockWidthRestrictor.defaultProps = {
As: 'div'
};

export default BlockWidthRestrictor;
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
@import '../../themes/oneui/oneui.scss';
@import '../../../themes/oneui/oneui.scss';

.PageWidthRestrictor {
.BlockWidthRestrictor {
min-width: var(--site-container-min-size);
max-width: var(--site-container-max-size);
padding: 0 var(--site-container-padding);
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export { default } from './BlockWidthRestrictor';
Original file line number Diff line number Diff line change
Expand Up @@ -12,23 +12,17 @@ const PageWidthRestrictor = props => {
const { children, As, ...rest } = props;

return (
<As {...rest} {...block(props)}>
<div {...rest} {...block(props)}>
{children}
</As>
</div>
);
};

PageWidthRestrictor.displayName = 'PageWidthRestrictor';

PageWidthRestrictor.propTypes = {
/** Node(s) to be rendered inside the container */
children: PropTypes.oneOfType([PropTypes.string, PropTypes.node]).isRequired,
/** HTML tag to be used to render the container */
As: PropTypes.string
};

PageWidthRestrictor.defaultProps = {
As: 'div'
children: PropTypes.oneOfType([PropTypes.string, PropTypes.node]).isRequired
};

export default PageWidthRestrictor;
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
@import '../../../themes/oneui/oneui.scss';

.PageWidthRestrictor {
min-width: calc(var(--site-container-min-size) + 2 * var(--site-container-padding));
}
File renamed without changes.
2 changes: 2 additions & 0 deletions src/components/WidthRestrictor/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
export { default as PageWidthRestrictor } from './PageWidthRestrictor';
export { default as BlockWidthRestrictor } from './BlockWidthRestrictor';
2 changes: 1 addition & 1 deletion src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ export { default as Link } from './components/Link';
export { List, ListItem, ListActions, JobResult } from './components/List';
export { default as LoadingSpinner } from './components/LoadingSpinner';
export { NavBar, NavItem } from './components/Navigation';
export { default as PageWidthRestrictor } from './components/PageWidthRestrictor';
export { PageWidthRestrictor, BlockWidthRestrictor } from './components/WidthRestrictor';
export { default as Pagination } from './components/Pagination';
export { default as ProgressBar } from './components/ProgressBar';
export { default as RadioButton } from './components/RadioButton';
Expand Down
15 changes: 11 additions & 4 deletions stories/PageWidthRestrictor.js → stories/WidthRestrictor.js
Original file line number Diff line number Diff line change
@@ -1,17 +1,24 @@
import React from 'react';
import { storiesOf } from '@storybook/react';
import { text, withKnobs } from '@storybook/addon-knobs';
import { PageWidthRestrictor } from '@textkernel/oneui';
import { PageWidthRestrictor, BlockWidthRestrictor } from '@textkernel/oneui';

storiesOf('PageWidthRestrictor', module)
storiesOf('WidthRestrictor', module)
.addDecorator(withKnobs)
.add('PageWidthRestrictor', () => (
<div style={{ backgroundColor: 'teal' }}>
<PageWidthRestrictor
<PageWidthRestrictor style={{ backgroundColor: 'darkturquoise' }}>
{text('Content', 'This is a placeholder for children')}
</PageWidthRestrictor>
</div>
))
.add('BlockWidthRestrictor', () => (
<div style={{ backgroundColor: 'teal' }}>
<BlockWidthRestrictor
As={text('Tag for component', 'div')}
style={{ backgroundColor: 'darkturquoise' }}
>
{text('Content', 'This is a placeholder for children')}
</PageWidthRestrictor>
</BlockWidthRestrictor>
</div>
));
2 changes: 1 addition & 1 deletion stories/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import './Link';
import './List';
import './LoadingSpinner';
import './Navigation';
import './PageWidthRestrictor';
import './WidthRestrictor';
import './Pagination';
import './ProgressBar';
import './RadioButton';
Expand Down

0 comments on commit c76a0b5

Please sign in to comment.