Skip to content

Commit

Permalink
build(bundler): add all blocks to the rollup build
Browse files Browse the repository at this point in the history
BREAKING CHANGE: the "Block" suffix is removed from the names of all blocks
  • Loading branch information
ryanoglesby08 committed Jul 17, 2017
1 parent 8ade54a commit f3eb547
Show file tree
Hide file tree
Showing 24 changed files with 105 additions and 104 deletions.
4 changes: 2 additions & 2 deletions docs/src/js/blocks/HeadlineBlockExample.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import React from 'react';
import { HeadlineBlock } from 'telus-thorium-enriched/blocks';
import { Headline } from 'telus-thorium-enriched/blocks';

const HeadlineBlockExample = () => {
const props = {
Expand All @@ -8,7 +8,7 @@ const HeadlineBlockExample = () => {
};

return (
<HeadlineBlock {...props} />
<Headline {...props} />
);
};

Expand Down
4 changes: 2 additions & 2 deletions docs/src/js/blocks/OverviewBlockExample.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import React from 'react';
import { OverviewBlock } from 'telus-thorium-enriched/blocks';
import { Overview } from 'telus-thorium-enriched/blocks';

const OverviewBlockExample = () => {
const props = {
Expand All @@ -18,7 +18,7 @@ const OverviewBlockExample = () => {
};

return (
<OverviewBlock {...props} />
<Overview {...props} />
);
};

Expand Down
4 changes: 2 additions & 2 deletions docs/src/js/blocks/TitledTextBlockExample.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import React from 'react';
import { TitledTextBlock } from 'telus-thorium-enriched/blocks';
import { TitledText } from 'telus-thorium-enriched/blocks';

const TitledTextBlockExample = () => {
const props = {
Expand All @@ -17,7 +17,7 @@ const TitledTextBlockExample = () => {
};

return (
<TitledTextBlock {...props} />
<TitledText {...props} />
);
};

Expand Down
4 changes: 2 additions & 2 deletions docs/src/js/blocks/VideoBlockExample.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import React from 'react';
import { VideoBlock } from 'telus-thorium-enriched/blocks';
import { Video } from 'telus-thorium-enriched/blocks';

const VideoBlockExample = () => {
const props = {
Expand All @@ -9,7 +9,7 @@ const VideoBlockExample = () => {
};

return (
<VideoBlock {...props} />
<Video {...props} />
);
};

Expand Down
3 changes: 2 additions & 1 deletion enriched/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,8 @@
"build": "npm run clean && npm run build:lib && npm run build:umd && npm run build:umd:min",
"test": "jest",
"test:watch": "npm run test -- --watch",
"rollup": "rollup -c"
"test:u": "npm run test -- -u",
"rollup": "rollup -c && cp ./src/blocks/Headline/wave_header_default.png ./dist/"
},
"dependencies": {
"@telusdigital/redux-contentful": "^2.2.1",
Expand Down
3 changes: 2 additions & 1 deletion enriched/rollup.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@ export default {
],
sourceMap: true,

external: ['react', 'prop-types'],
external: ['react', 'prop-types', '@telusdigital/redux-contentful'],

plugins: [
resolve({
extensions: ['.js', '.jsx']
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,9 @@
import React from 'react';
import PropTypes from 'prop-types';

if (process.env.BROWSER) {
require('./headline.scss');
}
import './Headline.scss';

const HeadlineBlock = (props) => {
const Headline = (props) => {
const { eyebrow, title } = props;

return (
Expand All @@ -22,13 +20,13 @@ const HeadlineBlock = (props) => {
);
};

HeadlineBlock.propTypes = {
Headline.propTypes = {
title: PropTypes.string.isRequired,
eyebrow: PropTypes.string
};

HeadlineBlock.defaultProps = {
Headline.defaultProps = {
eyebrow: ''
};

export default HeadlineBlock;
export default Headline;
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
@import '~telus-thorium-core/scss/settings/variables';
@import '../../../../core/scss/settings/variables';

.headline-block__bg {
background-image: url('./wave_header_default.png');
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import React from 'react';
import { mount } from 'enzyme';
import { mountToJson } from 'enzyme-to-json';
import Headline from '../';
import Headline from '../Headline';

describe('Headline', () => {
const data = { eyebrow: 'Foo', title: 'Bar' };
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`Headline matches snapshot 1`] = `
<HeadlineBlock
<Headline
eyebrow="Foo"
title="Bar"
>
Expand Down Expand Up @@ -31,5 +31,5 @@ exports[`Headline matches snapshot 1`] = `
</div>
</div>
</div>
</HeadlineBlock>
</Headline>
`;
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import cx from 'classnames';
import CheckList from '../components/CheckList';
import TextTitleBodyButton from '../components/TextTitleBodyButton';

const OverviewBlock = (props) => {
const Overview = (props) => {
const { className, ctaLink, overviewTitle, overviewDescription, sideContent } = props;
const cls = cx(className);
const bodyContent = {
Expand All @@ -26,15 +26,15 @@ const OverviewBlock = (props) => {
);
};

OverviewBlock.propTypes = {
Overview.propTypes = {
className: PropTypes.string,
overviewTitle: PropTypes.string,
overviewDescription: PropTypes.string,
ctaLink: PropTypes.object,
sideContent: PropTypes.object
};

OverviewBlock.defaultProps = {
Overview.defaultProps = {
className: '',
overviewTitle: '',
overviewDescription: '',
Expand All @@ -49,4 +49,4 @@ OverviewBlock.defaultProps = {
}
};

export default OverviewBlock;
export default Overview;
38 changes: 38 additions & 0 deletions enriched/src/blocks/Overview/__tests__/Overview.spec.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
import React from 'react';
import { shallow } from 'enzyme';
import Overview from '../Overview';

describe('<Overview />', () => {
const props = {
className: 'class',
overviewTitle: 'title',
overviewDescription: 'description',
ctaLink: {
target: 'target',
href: 'href',
text: 'text'
},
sideContent: {
listTitle: 'title',
listItems: ['one', 'two']
}
};

const overview = shallow(<Overview {...props} />);

it('sets the classes from the className prop', () => {
expect(overview.hasClass('class')).toBeTruthy();
});

it('renders a textTitleBodyButton Component', () => {
expect(overview.find('TextTitleBodyButton')).toBeDefined();
expect(overview.find('TextTitleBodyButton').props().caption).toBe('title');
expect(overview.find('TextTitleBodyButton').props().description).toEqual('description');
});

it('renders a checklist Component', () => {
expect(overview.find('CheckList')).toBeDefined();
expect(overview.find('CheckList').props().listTitle).toBe('title');
expect(overview.find('CheckList').props().listItems).toEqual(['one', 'two']);
});
});
38 changes: 0 additions & 38 deletions enriched/src/blocks/OverviewBlock/__tests__/OverviewBlock.spec.jsx

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,11 +1,9 @@
import React, { Component } from 'react';
import PropTypes from 'prop-types';

if (process.env.BROWSER) {
require('./titledTextBlock.scss');
}
import './TitledText.scss';

class TitledTextBlock extends Component {
class TitledText extends Component {

render() {
const { title, content, titleHeadingClass } = this.props;
Expand All @@ -32,7 +30,7 @@ class TitledTextBlock extends Component {
}
}

TitledTextBlock.propTypes = {
TitledText.propTypes = {
title: PropTypes.string.isRequired,
content: PropTypes.arrayOf(PropTypes.shape({
title: PropTypes.string.isRequired,
Expand All @@ -41,8 +39,8 @@ TitledTextBlock.propTypes = {
titleHeadingClass: PropTypes.string
};

TitledTextBlock.defaultProps = {
TitledText.defaultProps = {
titleHeadingClass: 'heading-1'
};

export default TitledTextBlock;
export default TitledText;
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import React from 'react';
import { mount } from 'enzyme';
import { mountToJson } from 'enzyme-to-json';
import TitledTextBlock from '../';
import TitledText from '../TitledText';

describe('TextBlock Component', () => {
describe('TitledText', () => {
const data = {
title: 'Title1',
content: [
Expand All @@ -12,26 +12,26 @@ describe('TextBlock Component', () => {
};

it('matches snapshot', () => {
const wrapper = mount(<TitledTextBlock {...data} />);
const wrapper = mount(<TitledText {...data} />);
expect(mountToJson(wrapper)).toMatchSnapshot();
});

it('should render title with default class', () => {
const wrapper = mount(<TitledTextBlock {...data} />);
const wrapper = mount(<TitledText {...data} />);
const elem = wrapper.find('h1').first();
expect(elem.text()).toEqual('Title1');
expect(elem.hasClass('heading-1')).toBeTruthy();
});

it('should render title with specified class', () => {
const wrapper = mount(<TitledTextBlock {...data} titleHeadingClass="heading-2" />);
const wrapper = mount(<TitledText {...data} titleHeadingClass="heading-2" />);
const elem = wrapper.find('h1').first();
expect(elem.text()).toEqual('Title1');
expect(elem.hasClass('heading-2')).toBeTruthy();
});

it('should render content', () => {
const wrapper = mount(<TitledTextBlock {...data} />);
const wrapper = mount(<TitledText {...data} />);
expect(wrapper.find('h2').first().text()).toEqual('Small Title 1');
expect(wrapper.find('p').first().text()).toEqual('Small Text1');
});
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`TextBlock Component matches snapshot 1`] = `
<TitledTextBlock
exports[`TitledText matches snapshot 1`] = `
<TitledText
content={
Array [
Object {
Expand Down Expand Up @@ -46,5 +46,5 @@ exports[`TextBlock Component matches snapshot 1`] = `
</div>
</div>
</section>
</TitledTextBlock>
</TitledText>
`;
Original file line number Diff line number Diff line change
@@ -1,11 +1,9 @@
import React from 'react';
import PropTypes from 'prop-types';

if (process.env.BROWSER) {
require('./video-block.scss');
}
import './Video.scss';

const VideoBlock = (props) => {
const Video = (props) => {
const { caption, subtext, videoUrl } = props;

return (
Expand All @@ -27,16 +25,16 @@ const VideoBlock = (props) => {
);
};

VideoBlock.propTypes = {
Video.propTypes = {
caption: PropTypes.string,
subtext: PropTypes.string,
videoUrl: PropTypes.string
};

VideoBlock.defaultProps = {
Video.defaultProps = {
subtext: '',
caption: '',
videoUrl: ''
};

export default VideoBlock;
export default Video;
File renamed without changes.
Loading

0 comments on commit f3eb547

Please sign in to comment.