Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rename LayoutCenter to Center and CardList to Grid #146

Merged
merged 2 commits into from
Sep 11, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
67 changes: 34 additions & 33 deletions src/demo/pages/DemoContainer.jsx

Large diffs are not rendered by default.

12 changes: 6 additions & 6 deletions src/demo/pages/navigation.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,8 @@ export default [
{
items: [
{
link: '#layout-components-card-list',
title: 'Card List',
},
{
link: '#layout-components-centered-layout',
title: 'Centered Layout',
link: '#layout-components-center',
title: 'Center',
},
{
link: '#layout-components-cta',
Expand All @@ -39,6 +35,10 @@ export default [
link: '#layout-components-form-layout',
title: 'Form Layout',
},
{
link: '#layout-components-grid',
title: 'Grid',
},
{
link: '#layout-components-list',
title: 'List',
Expand Down
3 changes: 0 additions & 3 deletions src/lib/components/layout/CardList/_theme.scss

This file was deleted.

1 change: 0 additions & 1 deletion src/lib/components/layout/CardList/index.js

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,21 +1,21 @@
import PropTypes from 'prop-types';
import React from 'react';
import styles from './LayoutCenter.scss';
import styles from './Center.scss';

const LayoutCenter = (props) => (
export const Center = (props) => (
<div className={styles.root}>
<div>
{props.children}
</div>
</div>
);

LayoutCenter.defaultProps = {
Center.defaultProps = {
children: null,
};

LayoutCenter.propTypes = {
Center.propTypes = {
children: PropTypes.node,
};

export default LayoutCenter;
export default Center;
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,4 @@
justify-content: center;
width: 100%;
height: 100%;
min-height: 100vh;
}
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
import React from 'react';
import { shallow } from 'enzyme';
import { shallowToJson } from 'enzyme-to-json';
import LayoutCenter from '..';
import { Center } from '../Center';

describe('rendering', () => {
it('renders correctly', () => {
const tree = shallow(<LayoutCenter />);
const tree = shallow(<Center />);

expect(shallowToJson(tree)).toMatchSnapshot();
});

it('renders correctly with children', () => {
const tree = shallow(<LayoutCenter><div>test</div></LayoutCenter>);
const tree = shallow(<Center><div>test</div></Center>);

expect(shallowToJson(tree)).toMatchSnapshot();
});
Expand Down
1 change: 1 addition & 0 deletions src/lib/components/layout/Center/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export { default } from './Center';
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import flattenChildren from 'react-keyed-flatten-children';
import PropTypes from 'prop-types';
import React from 'react';
import styles from './CardList.scss';
import styles from './Grid.scss';

const CardList = (props) => {
export const Grid = (props) => {
const {
children,
id,
Expand All @@ -25,22 +25,20 @@ const CardList = (props) => {
return null;
}

return React.cloneElement(child, {
inList: true,
});
return React.cloneElement(child);
})}
</div>
);
};

CardList.defaultProps = {
Grid.defaultProps = {
children: null,
id: undefined,
};

CardList.propTypes = {
Grid.propTypes = {
children: PropTypes.node,
id: PropTypes.string,
};

export default CardList;
export default Grid;
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,11 @@
display: grid;
grid-template-columns: 1fr;
grid-template-rows: auto;
grid-gap: $card-list-grid-gap;
grid-gap: $grid-gap;
margin-bottom: $layout-common-bottom-spacing;

@include breakpoint-up(sm) {
grid-template-columns: repeat(auto-fit, minmax($card-list-card-min-width, $card-list-card-max-width));
grid-template-columns: repeat(auto-fit, minmax($grid-item-min-width, $grid-item-max-width));
justify-content: start;
}
}
Original file line number Diff line number Diff line change
@@ -1,34 +1,34 @@
import React from 'react';
import { shallow } from 'enzyme';
import { Card } from '../../../ui/Card/Card';
import CardList from '../CardList';
import { Grid } from '../Grid';

describe('rendering', () => {
it('renders correctly with no children', () => {
const tree = shallow((
<CardList />
<Grid />
));

expect(tree).toMatchSnapshot();
});

it('renders correctly with a single child', () => {
const tree = shallow((
<CardList>
<Grid>
<Card>content</Card>
</CardList>
</Grid>
));

expect(tree).toMatchSnapshot();
});

it('renders correctly with multiple children', () => {
const tree = shallow((
<CardList>
<Grid>
<Card>content 1</Card>
<Card>content 2</Card>
<Card>content 3</Card>
</CardList>
</Grid>
));

expect(tree).toMatchSnapshot();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ exports[`rendering renders correctly with a single child 1`] = `
<Card
dense={false}
disabled={false}
inList={true}
key=".0"
raised={false}
type={null}
Expand All @@ -25,7 +24,6 @@ exports[`rendering renders correctly with multiple children 1`] = `
<Card
dense={false}
disabled={false}
inList={true}
key=".0"
raised={false}
type={null}
Expand All @@ -36,7 +34,6 @@ exports[`rendering renders correctly with multiple children 1`] = `
<Card
dense={false}
disabled={false}
inList={true}
key=".1"
raised={false}
type={null}
Expand All @@ -47,7 +44,6 @@ exports[`rendering renders correctly with multiple children 1`] = `
<Card
dense={false}
disabled={false}
inList={true}
key=".2"
raised={false}
type={null}
Expand Down
3 changes: 3 additions & 0 deletions src/lib/components/layout/Grid/_theme.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
$grid-item-min-width: var(--rui-grid-item-min-width);
$grid-item-max-width: var(--rui-grid-item-max-width);
$grid-gap: var(--rui-grid-gap);
1 change: 1 addition & 0 deletions src/lib/components/layout/Grid/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export { default } from './Grid';
1 change: 0 additions & 1 deletion src/lib/components/layout/LayoutCenter/index.js

This file was deleted.

9 changes: 0 additions & 9 deletions src/lib/components/ui/Card/Card.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ export const Card = (props) => {
dense,
disabled,
id,
inList,
raised,
type,
variant,
Expand Down Expand Up @@ -48,11 +47,6 @@ export const Card = (props) => {
disabledClass = styles.isDisabled;
}

let inListClass = '';
if (inList) {
inListClass = styles.isInList;
}

let raisedClass = '';
if (raised) {
raisedClass = styles.isRaised;
Expand All @@ -66,7 +60,6 @@ export const Card = (props) => {
${variantClass}
${denseClass}
${disabledClass}
${inListClass}
${raisedClass}
`).trim()}
id={id}
Expand All @@ -80,7 +73,6 @@ Card.defaultProps = {
dense: false,
disabled: false,
id: undefined,
inList: false,
raised: false,
type: null,
variant: 'flat',
Expand All @@ -91,7 +83,6 @@ Card.propTypes = {
dense: PropTypes.bool,
disabled: PropTypes.bool,
id: PropTypes.string,
inList: PropTypes.bool,
raised: PropTypes.bool,
type: PropTypes.oneOf(['success', 'warning', 'error', 'help', 'info', 'note']),
variant: PropTypes.oneOf(['flat', 'bordered']),
Expand Down
4 changes: 0 additions & 4 deletions src/lib/components/ui/Card/Card.scss
Original file line number Diff line number Diff line change
Expand Up @@ -56,10 +56,6 @@
background-color: map-get($card-disabled, background-color);
}

.isInList {
max-width: $card-in-list-max-width;
}

.isRaised {
box-shadow: map-get($card-raised, box-shadow);
}
Expand Down
2 changes: 0 additions & 2 deletions src/lib/components/ui/Card/_theme.scss
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,6 @@ $card-disabled: (
opacity: var(--rui-card-disabled-opacity),
);

$card-in-list-max-width: var(--rui-card-in-list-max-width);

$card-raised: (
box-shadow: var(--rui-card-raised-box-shadow),
);
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,6 @@ exports[`rendering renders correctly raised 1`] = `
isVariantFlat



isRaised"
>
<p>
Expand All @@ -61,7 +60,6 @@ exports[`rendering renders correctly with all props 1`] = `
isVariantBordered
isDense
isDisabled

isRaised"
id="custom-id"
>
Expand Down
50 changes: 31 additions & 19 deletions src/lib/index.js
Original file line number Diff line number Diff line change
@@ -1,20 +1,30 @@
// Layout components
export { default as CardList } from './components/layout/CardList';
export { default as LayoutCenter } from './components/layout/LayoutCenter';
export { CTA } from './components/layout/CTA';
export { CTACenter } from './components/layout/CTA';
export { CTAEnd } from './components/layout/CTA';
export { CTAStart } from './components/layout/CTA';
export { FormLayout } from './components/layout/FormLayout';
export { FormLayoutCustomField } from './components/layout/FormLayout';
export { List } from './components/layout/List';
export { ListItem } from './components/layout/List';
export { Media } from './components/layout/Media';
export { MediaBody } from './components/layout/Media';
export { MediaObject } from './components/layout/Media';
export { Toolbar } from './components/layout/Toolbar';
export { ToolbarGroup } from './components/layout/Toolbar';
export { ToolbarItem } from './components/layout/Toolbar';
export { default as Center } from './components/layout/Center';
export {
CTA,
CTACenter,
CTAEnd,
CTAStart,
} from './components/layout/CTA';
export {
FormLayout,
FormLayoutCustomField,
} from './components/layout/FormLayout';
export { default as Grid } from './components/layout/Grid';
export {
List,
ListItem,
} from './components/layout/List';
export {
Media,
MediaBody,
MediaObject,
} from './components/layout/Media';
export {
Toolbar,
ToolbarGroup,
ToolbarItem,
} from './components/layout/Toolbar';

// Screens
export { default as ForgotPassword } from './components/screens/Login/ForgotPassword';
Expand All @@ -26,9 +36,11 @@ export { default as Alert } from './components/ui/Alert';
export { default as Badge } from './components/ui/Badge';
export { default as Button } from './components/ui/Button';
export { default as ButtonGroup } from './components/ui/ButtonGroup';
export { Card } from './components/ui/Card';
export { CardBody } from './components/ui/Card';
export { CardFooter } from './components/ui/Card';
export {
Card,
CardBody,
CardFooter,
} from './components/ui/Card';
export { default as CheckboxField } from './components/ui/CheckboxField';
export { default as Modal } from './components/ui/Modal';
export { default as MultipleSelectField } from './components/ui/MultipleSelectField';
Expand Down
Loading