Skip to content

Commit

Permalink
Merge pull request #121 from uselagoon/vulnerable-packages/breaking-c…
Browse files Browse the repository at this point in the history
…hanges/storybook

update packages, re-init storybook
  • Loading branch information
tobybellwood authored Apr 26, 2023
2 parents 9ef9e4e + 7c1e8fb commit d702673
Show file tree
Hide file tree
Showing 26 changed files with 5,094 additions and 7,815 deletions.
3 changes: 1 addition & 2 deletions .eslintrc.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
const path = require('path');

module.exports = {
extends: ['next'],
extends: ['next', 'plugin:storybook/recommended'],
rules: {
'import/no-anonymous-default-export': 'off',
'react/no-unescaped-entities': 'off',
Expand Down
14 changes: 14 additions & 0 deletions .storybook/main.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import type { StorybookConfig } from '@storybook/nextjs';

const config: StorybookConfig = {
stories: ['../src/**/*.mdx', '../src/**/*.stories.@(js|jsx|ts|tsx)'],
addons: ['@storybook/addon-links', '@storybook/addon-essentials', '@storybook/addon-interactions'],
framework: {
name: '@storybook/nextjs',
options: {},
},
docs: {
autodocs: 'tag',
},
};
export default config;
15 changes: 15 additions & 0 deletions .storybook/preview.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import type { Preview } from '@storybook/react';

const preview: Preview = {
parameters: {
actions: { argTypesRegex: '^on[A-Z].*' },
controls: {
matchers: {
color: /(background|color)$/i,
date: /Date$/,
},
},
},
};

export default preview;
72 changes: 37 additions & 35 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,97 +11,99 @@
"build": "next build src",
"start": "NODE_ENV=production node server.js",
"generateTourHash": "node tourHash.js",
"storybook": "start-storybook -s ./src -p 6006",
"build-storybook": "build-storybook -s ./src",
"storybook": "storybook dev -p 6006",
"build-storybook": "storybook build",
"serve-storybook": "storybook-server -s ./src",
"format": "yarn prettier --write .",
"format-check": "yarn prettier --c ."
},
"dependencies": {
"@apollo/react-hooks": "^3.1.5",
"@emotion/core": "^10.0.28",
"@emotion/styled": "^10.0.27",
"@emotion/core": "^11.0.0",
"@emotion/styled": "^11.10.6",
"apollo-cache-inmemory": "^1.3.9",
"apollo-client": "^2.4.5",
"apollo-link": "^1.2.3",
"apollo-link-error": "^1.1.1",
"apollo-link-http": "^1.5.5",
"apollo-link-ws": "^1.0.10",
"babel-plugin-styled-components": "^2.0.7",
"babel-plugin-styled-components": "^2.1.1",
"colors": "^1.4.0",
"core-js": "^3.30.1",
"crypto-js": "^4.1.1",
"d3": "^5.15.0",
"d3": "^7.8.4",
"date-fns": "^2.9.0",
"dotenv-extended": "^2.2.0",
"eslint": "^8.35.0",
"eslint-config-next": "^13.2.3",
"eslint-config-next": "^13.3.0",
"express": "^4.18.1",
"framer-motion": "^10.2.4",
"framer-motion": "^10.12.3",
"git-up": "^7.0.0",
"git-url-parse": "13.1.0",
"graphql": "^14.5.8",
"graphql-tag": "^2.10.0",
"isomorphic-unfetch": "^2.1.1",
"isomorphic-unfetch": "^4.0.2",
"moment": "^2.22.2",
"moment-duration-format": "^2.2.2",
"next": "12",
"nprogress": "^0.2.0",
"object-hash": "^3.0.0",
"parse-url": "^8.1.0",
"postcss-nested": "^3.0.0",
"ramda": "^0.25.0",
"postcss-nested": "^6.0.1",
"ramda": "^0.29.0",
"react": "18.2.0",
"react-apollo": "^2.1.11",
"react-beautiful-dnd": "^13.0.0",
"react-copy-to-clipboard": "^5.0.1",
"react-dom": "18.2.0",
"react-hexgrid": "^1.0.3",
"react-highlight-words": "^0.14.0",
"react-hexgrid": "1.0.4",
"react-highlight-words": "^0.20.0",
"react-joyride": "^2.5.3",
"react-loading-skeleton": "^3.2.0",
"react-markdown": "^6.0.0",
"react-loading-skeleton": "^3.2.1",
"react-markdown": "^8.0.7",
"react-modal": "^3.8.1",
"react-nice-dates": "^1.0.2",
"react-select": "5.7.0",
"react-nice-dates": "^3.1.0",
"react-select": "5.7.2",
"react-typekit": "^1.1.3",
"recompose": "^0.30.0",
"resize-observer-polyfill": "^1.5.1",
"styled-components": "^5.3.6",
"subscriptions-transport-ws": "^0.11.0",
"svg-inline-loader": "^0.8.0",
"webpack": "5.75.0"
"webpack": "5.79.0"
},
"devDependencies": {
"@babel/core": "^7.7.4",
"@storybook/addon-a11y": "^5.3.0",
"@storybook/addon-actions": "^5.3.0",
"@storybook/addon-docs": "^5.3.0",
"@storybook/addon-knobs": "^5.3.0",
"@storybook/addon-links": "^5.3.0",
"@storybook/addon-viewport": "^5.3.0",
"@storybook/addons": "^5.3.0",
"@storybook/core": "^5.3.0",
"@storybook/react": "^5.3.0",
"@storybook/addon-essentials": "^7.0.5",
"@storybook/addon-interactions": "^7.0.5",
"@storybook/addon-links": "^7.0.5",
"@storybook/blocks": "^7.0.5",
"@storybook/nextjs": "^7.0.5",
"@storybook/react": "^7.0.5",
"@storybook/testing-library": "^0.0.14-next.2",
"@types/core-js": "^2.5.5",
"@trivago/prettier-plugin-sort-imports": "^4.1.1",
"@types/git-url-parse": "^9.0.1",
"@types/react": "^18.0.28",
"@types/react": "^18.0.37",
"@types/react-dom": "^18.0.11",
"@types/react-highlight-words": "^0.16.4",
"@types/recompose": "^0.30.10",
"@types/styled-components": "^5.1.26",
"@typescript-eslint/eslint-plugin": "^5.54.0",
"@typescript-eslint/parser": "^5.54.0",
"@typescript-eslint/eslint-plugin": "^5.59.0",
"@typescript-eslint/parser": "^5.59.0",
"apollo-link-schema": "^1.2.4",
"babel-loader": "^8.0.6",
"babel-plugin-macros": "^2.7.1",
"chromatic": "^5.6.2",
"babel-loader": "^9.1.2",
"babel-plugin-macros": "^3.1.0",
"chromatic": "^6.17.3",
"eslint-plugin-storybook": "^0.6.11",
"faker": "^4.1.0",
"prettier": "^2.8.7",
"prop-types": "^15.7.2",
"react-is": "^16.12.0",
"react-is": "^18.2.0",
"regenerator-runtime": "^0.13.3",
"require-context.macro": "^1.2.2",
"typescript": "^4.9.5"
"storybook": "^7.0.5",
"typescript": "^5.0.4"
},
"postcss": {
"plugins": {
Expand Down
3 changes: 1 addition & 2 deletions src/components/AddTask/logic.js
Original file line number Diff line number Diff line change
Expand Up @@ -60,8 +60,7 @@ const withOptions = withProps(({ pageEnvironment }) => {
options = [...options, ...advancedTasks];

// Remove tasks that are blocklisted.
options = R.reject(option => R.contains(option.value, publicRuntimeConfig.LAGOON_UI_TASK_BLOCKLIST), options);

options = R.reject(option => R.includes(option.value, publicRuntimeConfig.LAGOON_UI_TASK_BLOCKLIST), options);
// Currently all tasks require the environment to have a 'cli' service,
// but this can be made dynamic if that changes.
// if (
Expand Down
2 changes: 0 additions & 2 deletions src/components/Honeycomb/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@ import React, { useEffect, useState } from 'react';
import { GridGenerator, HexGrid, Hexagon, Layout, Text } from 'react-hexgrid';

import ProblemsByProject from 'components/ProblemsByProject';
import { ErrorNoHeader } from 'pages/_error';
import { LoadingPageNoHeader } from 'pages/_loading';
import * as R from 'ramda';

const config = {
Expand Down
46 changes: 46 additions & 0 deletions src/stories/Button.stories.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
import type { Meta, StoryObj } from '@storybook/react';

import { Button } from './Button';

// More on how to set up stories at: https://storybook.js.org/docs/react/writing-stories/introduction
const meta: Meta<typeof Button> = {
title: 'Example/Button',
component: Button,
tags: ['autodocs'],
argTypes: {
backgroundColor: {
control: 'color',
},
},
};

export default meta;
type Story = StoryObj<typeof Button>;

// More on writing stories with args: https://storybook.js.org/docs/react/writing-stories/args
export const Primary: Story = {
args: {
primary: true,
label: 'Button',
},
};

export const Secondary: Story = {
args: {
label: 'Button',
},
};

export const Large: Story = {
args: {
size: 'large',
label: 'Button',
},
};

export const Small: Story = {
args: {
size: 'small',
label: 'Button',
},
};
43 changes: 43 additions & 0 deletions src/stories/Button.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
import React from 'react';

import './button.css';

interface ButtonProps {
/**
* Is this the principal call to action on the page?
*/
primary?: boolean;
/**
* What background color to use
*/
backgroundColor?: string;
/**
* How large should the button be?
*/
size?: 'small' | 'medium' | 'large';
/**
* Button contents
*/
label: string;
/**
* Optional click handler
*/
onClick?: () => void;
}

/**
* Primary UI component for user interaction
*/
export const Button = ({ primary = false, size = 'medium', backgroundColor, label, ...props }: ButtonProps) => {
const mode = primary ? 'storybook-button--primary' : 'storybook-button--secondary';
return (
<button type="button" className={['storybook-button', `storybook-button--${size}`, mode].join(' ')} {...props}>
{label}
<style jsx>{`
button {
background-color: ${backgroundColor};
}
`}</style>
</button>
);
};
27 changes: 27 additions & 0 deletions src/stories/Header.stories.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
import type { Meta, StoryObj } from '@storybook/react';

import { Header } from './Header';

const meta: Meta<typeof Header> = {
title: 'Example/Header',
component: Header,
// This component will have an automatically generated Autodocs entry: https://storybook.js.org/docs/react/writing-docs/autodocs
tags: ['autodocs'],
parameters: {
// More on how to position stories at: https://storybook.js.org/docs/react/configure/story-layout
layout: 'fullscreen',
},
};

export default meta;
type Story = StoryObj<typeof Header>;

export const LoggedIn: Story = {
args: {
user: {
name: 'Jane Doe',
},
},
};

export const LoggedOut: Story = {};
47 changes: 47 additions & 0 deletions src/stories/Header.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
import React from 'react';

import { Button } from './Button';
import './header.css';

type User = {
name: string;
};

interface HeaderProps {
user?: User;
onLogin: () => void;
onLogout: () => void;
onCreateAccount: () => void;
}

export const Header = ({ user, onLogin, onLogout, onCreateAccount }: HeaderProps) => (
<header>
<div className="wrapper">
<div>
<svg width="32" height="32" viewBox="0 0 32 32" xmlns="http://www.w3.org/2000/svg">
<g fill="none" fillRule="evenodd">
<path d="M10 0h12a10 10 0 0110 10v12a10 10 0 01-10 10H10A10 10 0 010 22V10A10 10 0 0110 0z" fill="#FFF" />
<path d="M5.3 10.6l10.4 6v11.1l-10.4-6v-11zm11.4-6.2l9.7 5.5-9.7 5.6V4.4z" fill="#555AB9" />
<path d="M27.2 10.6v11.2l-10.5 6V16.5l10.5-6zM15.7 4.4v11L6 10l9.7-5.5z" fill="#91BAF8" />
</g>
</svg>
<h1>Acme</h1>
</div>
<div>
{user ? (
<>
<span className="welcome">
Welcome, <b>{user.name}</b>!
</span>
<Button size="small" onClick={onLogout} label="Log out" />
</>
) : (
<>
<Button size="small" onClick={onLogin} label="Log in" />
<Button primary size="small" onClick={onCreateAccount} label="Sign up" />
</>
)}
</div>
</div>
</header>
);
Loading

0 comments on commit d702673

Please sign in to comment.