Skip to content

Commit bf61341

Browse files
committedApr 8, 2021
feat: design-system (#7)
chore(deps-dev): bump @storybook/addon-essentials (#16) Bumps [@storybook/addon-essentials](https://github.com/storybookjs/storybook/tree/HEAD/addons/essentials) from 6.2.0-rc.7 to 6.2.2. - [Release notes](https://github.com/storybookjs/storybook/releases) - [Changelog](https://github.com/storybookjs/storybook/blob/v6.2.2/CHANGELOG.md) - [Commits](https://github.com/storybookjs/storybook/commits/v6.2.2/addons/essentials) Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> chore(deps): bump react-intl from 5.13.5 to 5.15.7 (#15) Bumps [react-intl](https://github.com/formatjs/formatjs) from 5.13.5 to 5.15.7. - [Release notes](https://github.com/formatjs/formatjs/releases) - [Commits](https://github.com/formatjs/formatjs/compare/react-intl@5.13.5...react-intl@5.15.7) Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> chore(deps-dev): bump eslint-plugin-react from 7.22.0 to 7.23.1 (#11) Bumps [eslint-plugin-react](https://github.com/yannickcr/eslint-plugin-react) from 7.22.0 to 7.23.1. - [Release notes](https://github.com/yannickcr/eslint-plugin-react/releases) - [Changelog](https://github.com/yannickcr/eslint-plugin-react/blob/master/CHANGELOG.md) - [Commits](jsx-eslint/eslint-plugin-react@v7.22.0...v7.23.1) Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> chore(deps-dev): bump husky from 5.2.0 to 6.0.0 (#12) Bumps [husky](https://github.com/typicode/husky) from 5.2.0 to 6.0.0. - [Release notes](https://github.com/typicode/husky/releases) - [Commits](typicode/husky@v5.2.0...v6.0.0) Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> chore(deps-dev): bump @testing-library/jest-dom from 5.11.9 to 5.11.10 (#14) Bumps [@testing-library/jest-dom](https://github.com/testing-library/jest-dom) from 5.11.9 to 5.11.10. - [Release notes](https://github.com/testing-library/jest-dom/releases) - [Changelog](https://github.com/testing-library/jest-dom/blob/main/CHANGELOG.md) - [Commits](testing-library/jest-dom@v5.11.9...v5.11.10) Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> chore(deps): bump next from 10.0.9 to 10.1.3 (#17) Bumps [next](https://github.com/vercel/next.js) from 10.0.9 to 10.1.3. - [Release notes](https://github.com/vercel/next.js/releases) - [Changelog](https://github.com/vercel/next.js/blob/canary/release.js) - [Commits](vercel/next.js@v10.0.9...v10.1.3) Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> chore(deps-dev): bump @testing-library/react-hooks from 5.1.0 to 5.1.1 (#21) Bumps [@testing-library/react-hooks](https://github.com/testing-library/react-hooks-testing-library) from 5.1.0 to 5.1.1. - [Release notes](https://github.com/testing-library/react-hooks-testing-library/releases) - [Changelog](https://github.com/testing-library/react-hooks-testing-library/blob/master/CHANGELOG.md) - [Commits](testing-library/react-hooks-testing-library@v5.1.0...v5.1.1) Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> chore(deps-dev): bump @typescript-eslint/parser from 4.18.0 to 4.20.0 (#22) Bumps [@typescript-eslint/parser](https://github.com/typescript-eslint/typescript-eslint/tree/HEAD/packages/parser) from 4.18.0 to 4.20.0. - [Release notes](https://github.com/typescript-eslint/typescript-eslint/releases) - [Changelog](https://github.com/typescript-eslint/typescript-eslint/blob/master/packages/parser/CHANGELOG.md) - [Commits](https://github.com/typescript-eslint/typescript-eslint/commits/v4.20.0/packages/parser) Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> chore(deps-dev): bump @types/node from 14.14.35 to 14.14.37 (#20) Bumps [@types/node](https://github.com/DefinitelyTyped/DefinitelyTyped/tree/HEAD/types/node) from 14.14.35 to 14.14.37. - [Release notes](https://github.com/DefinitelyTyped/DefinitelyTyped/releases) - [Commits](https://github.com/DefinitelyTyped/DefinitelyTyped/commits/HEAD/types/node) Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> chore(deps-dev): bump eslint from 7.22.0 to 7.23.0 (#18) Bumps [eslint](https://github.com/eslint/eslint) from 7.22.0 to 7.23.0. - [Release notes](https://github.com/eslint/eslint/releases) - [Changelog](https://github.com/eslint/eslint/blob/master/CHANGELOG.md) - [Commits](eslint/eslint@v7.22.0...v7.23.0) Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> chore(deps-dev): bump postcss from 8.2.8 to 8.2.9 (#26) Bumps [postcss](https://github.com/postcss/postcss) from 8.2.8 to 8.2.9. - [Release notes](https://github.com/postcss/postcss/releases) - [Changelog](https://github.com/postcss/postcss/blob/main/CHANGELOG.md) - [Commits](postcss/postcss@8.2.8...8.2.9) Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> chore(deps-dev): bump @testing-library/cypress from 7.0.4 to 7.0.5 (#25) Bumps [@testing-library/cypress](https://github.com/kentcdodds/cypress-testing-library) from 7.0.4 to 7.0.5. - [Release notes](https://github.com/kentcdodds/cypress-testing-library/releases) - [Changelog](https://github.com/testing-library/cypress-testing-library/blob/master/CHANGELOG.md) - [Commits](testing-library/cypress-testing-library@v7.0.4...v7.0.5) Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> chore(deps-dev): bump @commitlint/config-conventional (#23) Bumps [@commitlint/config-conventional](https://github.com/conventional-changelog/commitlint) from 12.0.1 to 12.1.1. - [Release notes](https://github.com/conventional-changelog/commitlint/releases) - [Changelog](https://github.com/conventional-changelog/commitlint/blob/master/CHANGELOG.md) - [Commits](conventional-changelog/commitlint@v12.0.1...v12.1.1) Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> chore(deps-dev): bump @typescript-eslint/eslint-plugin (#19) Bumps [@typescript-eslint/eslint-plugin](https://github.com/typescript-eslint/typescript-eslint/tree/HEAD/packages/eslint-plugin) from 4.18.0 to 4.20.0. - [Release notes](https://github.com/typescript-eslint/typescript-eslint/releases) - [Changelog](https://github.com/typescript-eslint/typescript-eslint/blob/master/packages/eslint-plugin/CHANGELOG.md) - [Commits](https://github.com/typescript-eslint/typescript-eslint/commits/v4.20.0/packages/eslint-plugin) Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> chore(deps-dev): bump @types/jest from 26.0.21 to 26.0.22 (#24) Bumps [@types/jest](https://github.com/DefinitelyTyped/DefinitelyTyped/tree/HEAD/types/jest) from 26.0.21 to 26.0.22. - [Release notes](https://github.com/DefinitelyTyped/DefinitelyTyped/releases) - [Commits](https://github.com/DefinitelyTyped/DefinitelyTyped/commits/HEAD/types/jest) Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> chore(deps-dev): bump @testing-library/react from 11.2.5 to 11.2.6 (#31) Bumps [@testing-library/react](https://github.com/testing-library/react-testing-library) from 11.2.5 to 11.2.6. - [Release notes](https://github.com/testing-library/react-testing-library/releases) - [Changelog](https://github.com/testing-library/react-testing-library/blob/master/CHANGELOG.md) - [Commits](testing-library/react-testing-library@v11.2.5...v11.2.6) Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> chore(deps-dev): bump @storybook/react from 6.2.0-rc.7 to 6.2.3 (#30) Bumps [@storybook/react](https://github.com/storybookjs/storybook/tree/HEAD/app/react) from 6.2.0-rc.7 to 6.2.3. - [Release notes](https://github.com/storybookjs/storybook/releases) - [Changelog](https://github.com/storybookjs/storybook/blob/v6.2.3/CHANGELOG.md) - [Commits](https://github.com/storybookjs/storybook/commits/v6.2.3/app/react) Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> chore(deps): bump react and react-dom (#29) Bumps [react](https://github.com/facebook/react/tree/HEAD/packages/react) and [react-dom](https://github.com/facebook/react/tree/HEAD/packages/react-dom). These dependencies needed to be updated together. Updates `react` from 17.0.1 to 17.0.2 - [Release notes](https://github.com/facebook/react/releases) - [Changelog](https://github.com/facebook/react/blob/master/CHANGELOG.md) - [Commits](https://github.com/facebook/react/commits/v17.0.2/packages/react) Updates `react-dom` from 17.0.1 to 17.0.2 - [Release notes](https://github.com/facebook/react/releases) - [Changelog](https://github.com/facebook/react/blob/master/CHANGELOG.md) - [Commits](https://github.com/facebook/react/commits/v17.0.2/packages/react-dom) Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> chore(deps-dev): bump @commitlint/cli from 12.0.1 to 12.1.1 (#27) Bumps [@commitlint/cli](https://github.com/conventional-changelog/commitlint) from 12.0.1 to 12.1.1. - [Release notes](https://github.com/conventional-changelog/commitlint/releases) - [Changelog](https://github.com/conventional-changelog/commitlint/blob/master/CHANGELOG.md) - [Commits](conventional-changelog/commitlint@v12.0.1...v12.1.1) Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> chore(deps-dev): bump @storybook/addon-essentials from 6.2.2 to 6.2.3 (#28) Bumps [@storybook/addon-essentials](https://github.com/storybookjs/storybook/tree/HEAD/addons/essentials) from 6.2.2 to 6.2.3. - [Release notes](https://github.com/storybookjs/storybook/releases) - [Changelog](https://github.com/storybookjs/storybook/blob/v6.2.3/CHANGELOG.md) - [Commits](https://github.com/storybookjs/storybook/commits/v6.2.3/addons/essentials) Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> chore(deps-dev): bump @typescript-eslint/eslint-plugin (#32) Bumps [@typescript-eslint/eslint-plugin](https://github.com/typescript-eslint/typescript-eslint/tree/HEAD/packages/eslint-plugin) from 4.20.0 to 4.21.0. - [Release notes](https://github.com/typescript-eslint/typescript-eslint/releases) - [Changelog](https://github.com/typescript-eslint/typescript-eslint/blob/master/packages/eslint-plugin/CHANGELOG.md) - [Commits](https://github.com/typescript-eslint/typescript-eslint/commits/v4.21.0/packages/eslint-plugin) Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> chore(deps-dev): bump @storybook/addon-storyshots (#33) Bumps [@storybook/addon-storyshots](https://github.com/storybookjs/storybook/tree/HEAD/addons/storyshots/storyshots-core) from 6.2.0-rc.7 to 6.2.3. - [Release notes](https://github.com/storybookjs/storybook/releases) - [Changelog](https://github.com/storybookjs/storybook/blob/v6.2.3/CHANGELOG.md) - [Commits](https://github.com/storybookjs/storybook/commits/v6.2.3/addons/storyshots/storyshots-core) Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> chore(deps-dev): bump @typescript-eslint/parser from 4.20.0 to 4.21.0 (#34) Bumps [@typescript-eslint/parser](https://github.com/typescript-eslint/typescript-eslint/tree/HEAD/packages/parser) from 4.20.0 to 4.21.0. - [Release notes](https://github.com/typescript-eslint/typescript-eslint/releases) - [Changelog](https://github.com/typescript-eslint/typescript-eslint/blob/master/packages/parser/CHANGELOG.md) - [Commits](https://github.com/typescript-eslint/typescript-eslint/commits/v4.21.0/packages/parser) Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> chore(deps-dev): bump @babel/core from 7.13.10 to 7.13.14 (#35) Bumps [@babel/core](https://github.com/babel/babel/tree/HEAD/packages/babel-core) from 7.13.10 to 7.13.14. - [Release notes](https://github.com/babel/babel/releases) - [Changelog](https://github.com/babel/babel/blob/main/CHANGELOG.md) - [Commits](https://github.com/babel/babel/commits/v7.13.14/packages/babel-core) Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> chore: webpack 5 and perf
1 parent d28489d commit bf61341

25 files changed

+7463
-1556
lines changed
 

‎.eslintrc.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@
4646
"react/require-default-props": 0,
4747
"react/prop-types": 0,
4848
"react/react-in-jsx-scope": 0,
49-
"react/jsx-props-no-spreading": [1, { "exceptions": ["Component", "svg"] }],
49+
"react/jsx-props-no-spreading": [1, { "html": "ignore", "exceptions": ["Component"] }],
5050
"arrow-parens": 0,
5151
"no-undef": 0,
5252
"no-console": 1,

‎.github/workflows/tests.yml

+3-10
Original file line numberDiff line numberDiff line change
@@ -96,20 +96,13 @@ jobs:
9696
- name: Install
9797
run: yarn install
9898

99-
- name: Create URL
100-
run: |
101-
repository=`echo ${GITHUB_REPOSITORY} | sed 's/.*\///g' | tr [:upper:] [:lower:]`
102-
branch=`echo ${GITHUB_REF} | sed 's/.*\///g' | tr [:upper:] [:lower:]`
103-
owner=`echo ${GITHUB_REPOSITORY} | sed 's/\/.*//g' | tr [:upper:] [:lower:]`
104-
URL="https://${repository}-git-${branch}-${owner}.vercel.app"
105-
echo "CYPRESS_baseUrl=${URL}" >> $GITHUB_ENV
106-
echo ${{ github.event.deployment.id }}
107-
10899
- name: Cypress run
109100
uses: cypress-io/github-action@v2
110101
with:
102+
build: yarn build
111103
install: false
112-
wait-on: ${{ env.CYPRESS_baseUrl }}/api/healthcheck
104+
start: yarn start
105+
wait-on: 'http://localhost:3000'
113106
wait-on-timeout: 120
114107

115108
- name: Store Artifact

‎.storybook/main.js

+15
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
module.exports = {
2+
stories: ['../design-system/**/*.stories.mdx', '../design-system/**/*.stories.@(js|jsx|ts|tsx)'],
3+
addons: [
4+
'@storybook/addon-storyshots',
5+
'@storybook/addon-essentials',
6+
{
7+
name: '@storybook/addon-postcss',
8+
options: {
9+
postcssLoaderOptions: {
10+
implementation: require('postcss'),
11+
},
12+
},
13+
},
14+
],
15+
};

‎.storybook/preview.js

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
import 'tailwindcss/tailwind.css';
2+
3+
export const parameters = {
4+
actions: { argTypesRegex: '^on[A-Z].*' },
5+
};

‎CHANGELOG.md

+7-3
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,14 @@
22

33
All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines.
44

5-
## 1.1.0 (2021-03-21)
5+
## 1.2.0 (2021-03-22)
6+
7+
### Features
68

9+
- design-system ([#7](https://github.com/FabienGreard/front-end-rocks-boilerplate/issues/7)) ([cc4c825](https://github.com/FabienGreard/front-end-rocks-boilerplate/commit/cc4c8259c1afff4b60350a1a4b7eb7dec43cfdda))
10+
11+
## 1.1.0 (2021-03-21)
712

813
### Features
914

10-
* pwa support ! ([62c3f95](https://github.com/FabienGreard/front-end-rocks-boilerplate/commit/62c3f9556f39fa11668b22efc48be598f8943f5f))
11-
* standard-version ([c87898a](https://github.com/FabienGreard/front-end-rocks-boilerplate/commit/c87898aa82c8d43b2409c118bf9f5c092b22666f))
15+
- pwa support ([#6](https://github.com/FabienGreard/front-end-rocks-boilerplate/issues/6)) ([d28489d](https://github.com/FabienGreard/front-end-rocks-boilerplate/commit/d28489d7d5b28bafb474bab38c6e87ee411c003b))

‎README.md

+16-3
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,19 @@
33

44
# front-end-rocks-boilerplate
55

6-
This is an opiniated boilerplate with rocking tools for front-end development
6+
This is an opinionated boilerplate with rocking tools for front-end development.
7+
8+
## Values
9+
10+
This boilerplate aims to provide a way to start a new project with everything from testing to ci/cd out of the box.
11+
12+
Keeping the dependencies up to date is a priority.
13+
14+
You should, with this boilerplate only focus on coding rocking react components! Nothing else!
715

816
## Installation
917

10-
Start by cloning this repositories then use either `yarn install` or `npm install` to download the dependencies.
18+
Start by cloning this repository, then use either `yarn install` or `npm install` to download the dependencies.
1119

1220
## Getting Started
1321

@@ -36,11 +44,12 @@ Open [http://localhost:3000](http://localhost:3000) with your browser to see the
3644
| test | jest --silent | Launch test |
3745
| coverage | jest --coverage --silent | Generate a coverage from test |
3846
| e2e | cypress run --headless | Launch e2e test |
39-
| prepare | husky install | This is need from husky to set up the project |
47+
| storybook | start-storybook -p 6006 | Launch storybook (design-system) |
4048
| bump:patch | standard-version --release-as patch --no-verify | v.0.0.0 => v.0.0.1 |
4149
| bump:minor | standard-version --release-as minor --no-verify | v.0.0.0 => v.0.1.0 |
4250
| bump:major | standard-version --release-as major --no-verify | v.0.0.0 => v.1.0.0 |
4351
| clear | node scripts/clear.js | clear node_modules and \*lock |
52+
| prepare | husky install | This is need from husky to set up the project |
4453

4554
## Acknowledgement
4655

@@ -51,6 +60,7 @@ This project is build with :
5160
- [Typescript](https://www.typescriptlang.org/)
5261
- [react-intl](https://formatjs.io/)
5362
- [Jest](https://jestjs.io/)
63+
- [storybook](https://storybook.js.org/)
5464
- [Cypress](https://www.cypress.io/)
5565
- [Prettier](https://prettier.io/)
5666
- [Eslint](https://eslint.org/)
@@ -63,6 +73,9 @@ This project is build with :
6373

6474
This project use [testing-library](https://testing-library.com/) for both unit test and e2e.
6575

76+
- [react](https://testing-library.com/docs/react-testing-library/intro)
77+
- [cypress](https://testing-library.com/docs/cypress-testing-library/intro)
78+
- [jest-dom](https://github.com/testing-library/jest-dom)
6679
- [react-hooks](https://react-hooks-testing-library.com/)
6780

6881
## Git Commit Convention

‎babel.config.js

+1-2
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,7 @@ module.exports = {
55
{
66
'preset-env': {
77
useBuiltIns: false,
8-
targets:
9-
'Edge >= 83, Firefox >= 78, FirefoxAndroid >= 78, Chrome >= 80, ChromeAndroid >= 80, Opera >= 67, OperaMobile >= 67, Safari >= 13.1, iOS >= 13.4',
8+
targets: 'last 2 versions, not dead, >0.2%, not IE 11',
109
},
1110
},
1211
],
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,21 @@
1-
import Head from 'next/head';
1+
import NextHead from 'next/head';
22

33
import { SEO } from 'utils/constant';
44

5-
interface HeaderProps {
5+
interface Props {
66
title?: string;
77
description?: string;
88
}
99

10-
export default function Header({ title = SEO.title, description = SEO.description }: HeaderProps) {
10+
export default function Head({ title = SEO.title, description = SEO.description }: Props) {
1111
return (
12-
<Head>
12+
<NextHead>
1313
<title>{title}</title>
1414
<meta name="description" content={description} />
1515
<link rel="icon" href="/favicon.ico" />
1616
<link rel="manifest" href="/manifest.json" />
1717
<meta name="theme-color" content="#fff" />
1818
<link rel="apple-touch-icon" href="/images/192.png" />
19-
</Head>
19+
</NextHead>
2020
);
2121
}

‎components/Link.tsx

+17
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
import { ComponentType } from 'react';
2+
import Link from 'next/link';
3+
4+
export const withLink = <T extends Object>(Component: ComponentType<T>) => ({
5+
href,
6+
locale,
7+
...props
8+
}: T & { href: string; locale?: string }) => (
9+
<Link href={href} locale={locale} passHref>
10+
{/* eslint-disable-next-line jsx-a11y/anchor-is-valid */}
11+
<a className="outline-none">
12+
<Component {...((props as unknown) as T)} />
13+
</a>
14+
</Link>
15+
);
16+
17+
export default Link;

‎components/__tests__/Header.test.tsx ‎components/__tests__/Head.test.tsx

+4-4
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,24 @@
11
import { render } from '@testing-library/react';
2-
import Header from 'components/Header';
2+
import Head from 'components/Head';
33

44
import { SEO } from 'utils/constant';
55

66
describe('Header', () => {
77
test('Should had default values', () => {
8-
render(<Header />);
8+
render(<Head />);
99

1010
expect(document.title).toEqual(SEO.title);
1111
expect((document.head.querySelector('meta[name=description]') as HTMLMetaElement).content).toEqual(SEO.description);
1212
});
1313

1414
test('Should set a custom document title', () => {
15-
render(<Header title="New document title" />);
15+
render(<Head title="New document title" />);
1616

1717
expect(document.title).toEqual('New document title');
1818
});
1919

2020
test('Should set a custom meta description', () => {
21-
render(<Header description="New description meta" />);
21+
render(<Head description="New description meta" />);
2222

2323
expect((document.head.querySelector('meta[name=description]') as HTMLMetaElement).content).toEqual(
2424
'New description meta',

‎components/__tests__/Link.test.tsx

+20
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
import { render } from '@testing-library/react';
2+
import Link, { withLink } from 'components/Link';
3+
4+
describe('Link', () => {
5+
test('Should render a Link element', () => {
6+
const { getByText } = render(<Link href="/">link</Link>);
7+
8+
expect(getByText('link')).toBeInTheDocument();
9+
expect(getByText('link')).toHaveAttribute('href', '/');
10+
});
11+
12+
test('Should render a Link element', () => {
13+
const TitleWithLink = withLink(() => <h1>title</h1>);
14+
15+
const { getByText, container } = render(<TitleWithLink href="/" />);
16+
17+
expect(getByText('title')).toBeInTheDocument();
18+
expect(container.querySelector('a')).toHaveAttribute('href', '/');
19+
});
20+
});

‎design-system/Button.stories.tsx

+44
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
// also exported from '@storybook/react' if you can deal with breaking changes in 6.1
2+
import { Story, Meta } from '@storybook/react/types-6-0';
3+
4+
import { Button, ButtonProps } from './Button';
5+
6+
export default {
7+
title: 'Example/Button',
8+
component: Button,
9+
argTypes: {
10+
backgroundColor: { control: 'color' },
11+
size: {
12+
control: {
13+
type: 'select',
14+
options: ['small', 'medium', 'large'],
15+
},
16+
},
17+
},
18+
} as Meta;
19+
20+
// eslint-disable-next-line react/jsx-props-no-spreading
21+
const Template: Story<ButtonProps> = args => <Button {...args} />;
22+
23+
export const Primary = Template.bind({});
24+
Primary.args = {
25+
primary: true,
26+
label: 'Button',
27+
};
28+
29+
export const Secondary = Template.bind({});
30+
Secondary.args = {
31+
label: 'Button',
32+
};
33+
34+
export const Large = Template.bind({});
35+
Large.args = {
36+
size: 'large',
37+
label: 'Button',
38+
};
39+
40+
export const Small = Template.bind({});
41+
Small.args = {
42+
size: 'small',
43+
label: 'Button',
44+
};

‎design-system/Button.tsx

+56
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
export interface ButtonProps {
2+
/**
3+
* Is this the principal call to action on the page?
4+
*/
5+
primary?: boolean;
6+
/**
7+
* What background color to use
8+
*/
9+
backgroundColor?: string;
10+
/**
11+
* How large should the button be?
12+
*/
13+
size?: 'small' | 'medium' | 'large';
14+
/**
15+
* Button contents
16+
*/
17+
label: string;
18+
/**
19+
* Optional click handler
20+
*/
21+
onClick?: () => void;
22+
}
23+
24+
/**
25+
* Primary UI component for user interaction
26+
*/
27+
export const Button: React.FC<ButtonProps> = ({
28+
primary = false,
29+
size = 'medium',
30+
backgroundColor,
31+
label,
32+
...props
33+
}) => {
34+
const BASE_BUTTON = 'uppercase tracking-wider box-border';
35+
const PRIMARY_BUTTON = `${BASE_BUTTON} bg-blue-200 border border-blue-200 text-white focus:outline-none focus:bg-blue-400 focus:border-blue-400 hover:bg-blue-400 hover:border-blue-400`;
36+
const SECONDARY_BUTTON = `${BASE_BUTTON} border border-gray-200 text-black focus:outline-none focus:border-gray-400 hover:border-gray-400`;
37+
38+
const SIZE_BUTTON = {
39+
small: 'rounded-sm text-sm px-2 py-1',
40+
medium: 'rounded-md text-md px-3 py-2',
41+
large: 'rounded-lg text-lg px-4 py-3',
42+
};
43+
44+
return (
45+
<button
46+
type="button"
47+
className={`${primary ? PRIMARY_BUTTON : SECONDARY_BUTTON} ${SIZE_BUTTON[size]}`}
48+
style={{ backgroundColor }}
49+
{...props}
50+
>
51+
{label}
52+
</button>
53+
);
54+
};
55+
56+
export default Button;
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
// Jest Snapshot v1, https://goo.gl/fbAQLP
2+
3+
exports[`Storyshots Example/Button Large 1`] = `
4+
<button
5+
className="uppercase tracking-wider box-border border border-gray-200 text-black focus:outline-none focus:border-gray-400 hover:border-gray-400 rounded-lg text-lg px-4 py-3"
6+
style={
7+
Object {
8+
"backgroundColor": undefined,
9+
}
10+
}
11+
type="button"
12+
>
13+
Button
14+
</button>
15+
`;
16+
17+
exports[`Storyshots Example/Button Primary 1`] = `
18+
<button
19+
className="uppercase tracking-wider box-border bg-blue-200 border border-blue-200 text-white focus:outline-none focus:bg-blue-400 focus:border-blue-400 hover:bg-blue-400 hover:border-blue-400 rounded-md text-md px-3 py-2"
20+
style={
21+
Object {
22+
"backgroundColor": undefined,
23+
}
24+
}
25+
type="button"
26+
>
27+
Button
28+
</button>
29+
`;
30+
31+
exports[`Storyshots Example/Button Secondary 1`] = `
32+
<button
33+
className="uppercase tracking-wider box-border border border-gray-200 text-black focus:outline-none focus:border-gray-400 hover:border-gray-400 rounded-md text-md px-3 py-2"
34+
style={
35+
Object {
36+
"backgroundColor": undefined,
37+
}
38+
}
39+
type="button"
40+
>
41+
Button
42+
</button>
43+
`;
44+
45+
exports[`Storyshots Example/Button Small 1`] = `
46+
<button
47+
className="uppercase tracking-wider box-border border border-gray-200 text-black focus:outline-none focus:border-gray-400 hover:border-gray-400 rounded-sm text-sm px-2 py-1"
48+
style={
49+
Object {
50+
"backgroundColor": undefined,
51+
}
52+
}
53+
type="button"
54+
>
55+
Button
56+
</button>
57+
`;
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
import initStoryshots from '@storybook/addon-storyshots';
2+
3+
initStoryshots();

1 commit comments

Comments
 (1)
Please sign in to comment.