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

chore(components): sub in storybook for styleguidist #7549

Merged
merged 91 commits into from
May 3, 2021
Merged
Show file tree
Hide file tree
Changes from 88 commits
Commits
Show all changes
91 commits
Select commit Hold shift + click to select a range
084411e
remove at flow, add tsconfig, change file extensions
b-cooper Feb 23, 2021
86a7336
mixed to unknown and pull type imports out
b-cooper Feb 23, 2021
a08ddc6
add types
b-cooper Feb 23, 2021
7e7e8d4
migrate synthetic mouse events over
b-cooper Feb 23, 2021
f926dc5
add typings for css modules dep
b-cooper Feb 24, 2021
2b743ca
update loader
b-cooper Feb 24, 2021
c883f15
swap css modules plugin out
b-cooper Feb 24, 2021
b338c8a
tsx ext for jsx files
b-cooper Feb 24, 2021
dfeb0f5
pick at style props
b-cooper Feb 24, 2021
df2d557
tests with jsx ext
b-cooper Feb 25, 2021
4a7ecd0
migrate more ts
b-cooper Feb 26, 2021
0d7b91a
work through tsc errors
b-cooper Mar 3, 2021
546b50a
jsx element return type
b-cooper Mar 3, 2021
9481e40
jest styled components types
b-cooper Mar 3, 2021
dc17d4e
add types for react test renderer
b-cooper Mar 3, 2021
8918d62
interface for prop types
b-cooper Mar 3, 2021
0f1546a
misc clean up
b-cooper Mar 3, 2021
bb8b4d8
Merge branch 'edge' into components_port-source-to-ts
b-cooper Mar 3, 2021
3db923d
shared data types
b-cooper Mar 3, 2021
d105565
continue clean up
b-cooper Mar 3, 2021
6b65363
styled components types clean up
b-cooper Mar 4, 2021
973a566
use PrimitiveComponent props
b-cooper Mar 4, 2021
a581bf3
knockin the errors down
b-cooper Mar 4, 2021
7b71e14
address first batch of pr commments
b-cooper Mar 5, 2021
2f28bf1
fine tooth combing
b-cooper Mar 5, 2021
eb371dd
clean up some tooltip type gunk
b-cooper Mar 5, 2021
be07f4b
clean up shared data stubstypes
b-cooper Mar 8, 2021
8b23039
fixup: fix errors with atoms types
mcous Mar 8, 2021
8f6ace7
forms bits
b-cooper Mar 8, 2021
baba5c3
fixup: get types working in interaction-enhancers
mcous Mar 8, 2021
35c39ff
some deck comp type fixes
b-cooper Mar 8, 2021
9ee75f8
memo exotic component type
b-cooper Mar 8, 2021
ffe808a
a couple more
b-cooper Mar 8, 2021
9f82285
fixup: get types sorted in tooltips
mcous Mar 8, 2021
de6b1c4
correct type for deck components
b-cooper Mar 8, 2021
1ec3f5d
add webpack env types and fix getDeckDefMock
b-cooper Mar 8, 2021
65a9013
formatOptionLabel returns react node
b-cooper Mar 9, 2021
e795522
type for fill
b-cooper Mar 9, 2021
6937b25
gitignore lib dir
b-cooper Mar 9, 2021
b3b9ce2
Well pointer events type
b-cooper Mar 9, 2021
90578a0
memo exotic component
b-cooper Mar 9, 2021
aaead15
robot coords text extend text props
b-cooper Mar 9, 2021
f9ed804
indeterminate prop missing todo
b-cooper Mar 9, 2021
bcd9311
struggle through react select generic types
b-cooper Mar 10, 2021
154b9cc
iron out select types
b-cooper Mar 10, 2021
6b0c746
disabled prop fixups
b-cooper Mar 10, 2021
f01e901
last errors
b-cooper Mar 10, 2021
7e214f1
no extension in import
b-cooper Mar 11, 2021
1d5908a
add react docgen typescript
b-cooper Mar 12, 2021
2c52afc
init storybook at root
b-cooper Mar 12, 2021
207fdbb
try out migrating alert item to storybook
b-cooper Mar 12, 2021
5bafba9
proof of concept btn and alert item in storybook
b-cooper Mar 15, 2021
eba7114
make stories for all atom
b-cooper Mar 16, 2021
2494b20
icon stories
b-cooper Mar 17, 2021
b18be1a
checkbox field and dropdown field
b-cooper Mar 17, 2021
0f835c0
Merge branch 'edge' into components_add-storybook
b-cooper Mar 24, 2021
cd9aeba
regrab deps
b-cooper Mar 24, 2021
7c23b61
add tooltip story
b-cooper Mar 29, 2021
b39773a
house-keeping todo comments in tabbed nav and structure dirs
b-cooper Mar 29, 2021
dbfd400
stories for structure components
b-cooper Mar 29, 2021
ed529a6
add todo comment to slot map component
b-cooper Mar 29, 2021
3c1b764
story for side panel
b-cooper Mar 29, 2021
030eaf0
add modal stories
b-cooper Mar 29, 2021
c406412
add instrument stories
b-cooper Mar 31, 2021
b562f32
form group story
b-cooper Apr 1, 2021
fae5813
hoist basic story components to top
b-cooper Apr 1, 2021
122d2f5
form components
b-cooper Apr 7, 2021
a66e8e4
select for module mode
b-cooper Apr 9, 2021
62f3782
wire up storybook in place of styleguidist deploy
b-cooper Apr 9, 2021
3b1d517
fix tab in makefile
b-cooper Apr 9, 2021
325ea8d
add makefile to path for components build action
b-cooper Apr 9, 2021
72b850f
deckLayerBlocklist control
b-cooper Apr 14, 2021
82ebdb6
chore(components): sub in storybook for styleguidist
b-cooper Apr 15, 2021
c2a9fc8
remove duplicate lint override
b-cooper Apr 15, 2021
0902454
delint
b-cooper Apr 15, 2021
ef32740
Merge branch 'edge' into components_add-storybook
b-cooper Apr 15, 2021
d0d9be0
bump flow memory capacity
b-cooper Apr 15, 2021
04f18d4
nuke merge conflict
b-cooper Apr 15, 2021
6aad3a7
clean up css lint
b-cooper Apr 15, 2021
109785d
remove react styleguidist dep
b-cooper Apr 15, 2021
0487af7
remove styleguidist markdown files
b-cooper Apr 15, 2021
915478c
remove styleguide config
b-cooper Apr 15, 2021
49fb4e5
remove styleguidist flow types
b-cooper Apr 16, 2021
4764d83
Merge branch 'edge' into components_add-storybook
b-cooper Apr 19, 2021
2d3a7b7
Merge branch 'edge' into components_add-storybook
b-cooper Apr 19, 2021
bcd2fdb
fixup: tweak eslint config for Storybook (#7708)
mcous Apr 27, 2021
1fe352e
fixup: fix linting and storybook build
mcous Apr 27, 2021
18058ca
fixup: add note about story classname
mcous Apr 27, 2021
09678be
fixup: fix broken teardown and dev tasks for components
mcous Apr 29, 2021
f1686ff
Merge branch 'edge' into components_add-storybook
mcous May 3, 2021
df28643
fixup: fix TS linting after shared-data merge
mcous May 3, 2021
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
3 changes: 3 additions & 0 deletions .eslintignore
Original file line number Diff line number Diff line change
Expand Up @@ -24,5 +24,8 @@ lerna.json
!api/release-notes.md
!app-shell/build/release-notes.md

# components library
storybook-static

# mypy
**/.mypy_cache/**
10 changes: 9 additions & 1 deletion .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ module.exports = {
root: true,

parserOptions: {
project: './*/tsconfig.json',
project: './tsconfig-eslint.json',
},

extends: ['standard-with-typescript', 'plugin:react/recommended', 'prettier'],
Expand Down Expand Up @@ -66,6 +66,7 @@ module.exports = {
'@typescript-eslint/prefer-nullish-coalescing': 'warn',
'@typescript-eslint/prefer-optional-chain': 'warn',
'@typescript-eslint/restrict-plus-operands': 'warn',
'@typescript-eslint/restrict-template-expressions': 'warn',
},
},
{
Expand Down Expand Up @@ -95,6 +96,13 @@ module.exports = {
'jest/no-done-callback': 'warn',
},
},
{
files: ['**/*.stories.tsx'],
rules: {
'import/no-default-export': 'off',
'@typescript-eslint/consistent-type-assertions': 'off',
},
},
{
files: ['**/cypress/**'],
extends: ['plugin:cypress/recommended'],
Expand Down
2 changes: 1 addition & 1 deletion .flowconfig
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ merge_timeout=300
esproposal.optional_chaining=enable
; default value of 19 (16 * 2^19 bytes > 8ish MB) isn't quite enough and can
; result in flow crashing with `Unhandled exception: SharedMem.Hash_table_full`
sharedmemory.hash_table_pow=20
sharedmemory.hash_table_pow=21
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

out of curiosity how come we gotta bump this up?

Copy link
Contributor

@mcous mcous Apr 29, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not bumping it can result in flow crashing with Unhandled exception: SharedMem.Hash_table_full 🙃

But yeah, as the codebase grew, we started seeing that particular flow crash. Added the config to bump it up to 20 in #4959. As Brian was working on this PR, he started seeing this crash again, and bumping it again (from 16 MB to 32 MB) seemed to resolve it.

Since Flow is on its way out, it seemed like the most straightforward thing to do to keep things chugging along rather than investigating it too deeply

; enable types-first mode for speed and explicitness
; https://flow.org/en/docs/lang/types-first/
types_first=true
Expand Down
8 changes: 4 additions & 4 deletions .github/workflows/components-test-build-deploy.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ name: 'Components test, build, and deploy'
on:
pull_request:
paths:
- 'Makefile'
- 'components/**'
- 'webpack-config/**'
- 'package.json'
Expand Down Expand Up @@ -78,17 +79,16 @@ jobs:
yarn config set cache-folder ./.yarn-cache
make setup-js
- name: 'build components'
run: |
make -C components
run: make -C components
- name: 'upload github artifact'
uses: actions/upload-artifact@v2
with:
name: 'components-artifact'
path: components/dist
path: storybook-static
deploy-components:
name: 'deploy components artifact to S3'
runs-on: 'ubuntu-18.04'
needs: ["js-unit-test", "build-components"]
needs: ['js-unit-test', 'build-components']
if: github.event_name != 'pull_request'
steps:
- uses: 'actions/checkout@v2'
Expand Down
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -122,3 +122,6 @@ api/pyproject.toml

# typescript incremental files
*.tsbuildinfo

# Static storybook build artifacts
storybook-static/
13 changes: 13 additions & 0 deletions .storybook/main.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
'use strict'

const { baseConfig } = require('@opentrons/webpack-config')

module.exports = {
webpackFinal: config => ({
...config,
module: { ...config.module, rules: baseConfig.module.rules },
plugins: [...config.plugins, ...baseConfig.plugins],
}),
stories: ['../components/**/*.stories.@(js|jsx|ts|tsx)'],
addons: ['@storybook/addon-links', '@storybook/addon-essentials'],
}
17 changes: 17 additions & 0 deletions .storybook/preview.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
export const parameters = {
actions: { argTypesRegex: '^on[A-Z].*' },
}

import React from 'react'

import { GlobalStyle } from '../app/src/atoms/GlobalStyle'

// Global decorator to apply the styles to all stories
export const decorators = [
Story => (
<>
<GlobalStyle />
<Story />
</>
),
]
1 change: 1 addition & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ clean-py:
.PHONY: clean-js
clean-js: clean-ts
$(MAKE) -C $(DISCOVERY_CLIENT_DIR) clean
$(MAKE) -C $(COMPONENTS_DIR) clean

.PHONY: setup-py
setup-py:
Expand Down
14 changes: 4 additions & 10 deletions components/Makefile
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# opentrons component library makefile

# dev server port
port ?= 8081
port ?= 6060
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

how come we're switching this to port 6060? upon googling looks like 6060 is used to indicate the use of the X Windows Protocol which i'd never heard of!

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

😬 so yeah, turns out we never used this $(port) variable. If you run make -C components dev in edge right now, the dev server will launch on port 6060. This PR changes this value to match the currently used port and actually uses it in the make dev target now


# type definitions
typedefs := $(shell yarn -s shx find "lib/**/*.d.ts")
Expand All @@ -13,21 +13,16 @@ flow_out := $(patsubst lib/%.d.ts,flow-types/%.js.flow,$(typedefs))
.PHONY: all
all: clean dist

.PHONY: setup
setup:
yarn

.PHONY: clean
clean:
yarn shx rm -rf dist
yarn --cwd .. shx rm -rf storybook-static

# artifacts
#####################################################################

.PHONY: dist
dist: export NODE_ENV := development
dist:
yarn styleguidist build
yarn --cwd .. build-storybook

.PHONY: flow-types
flow-types: $(flow_out)
Expand All @@ -39,6 +34,5 @@ flow-types/%.js.flow: lib/%.d.ts
#####################################################################

.PHONY: dev
build: export NODE_ENV := development
dev:
yarn styleguidist server
yarn --cwd .. storybook --port $(port)
157 changes: 0 additions & 157 deletions components/src/alerts/AlertItem.md

This file was deleted.

49 changes: 49 additions & 0 deletions components/src/alerts/AlertItem.stories.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
import * as React from 'react'
import { AlertItem } from './AlertItem'
mcous marked this conversation as resolved.
Show resolved Hide resolved

import type { Story, Meta } from '@storybook/react'

export default {
title: 'Library/Molecules/AlertItem',
component: AlertItem,
argTypes: { onCloseClick: { action: 'clicked' } },
} as Meta

const Template: Story<React.ComponentProps<typeof AlertItem>> = args => (
<AlertItem {...args} />
)

export const Basic = Template.bind({})
Basic.args = {
type: 'success',
title: 'good job!',
}

export const OverriddenIcon = Template.bind({})
OverriddenIcon.args = {
type: 'info',
title: 'Alert with overridden icon',
icon: { name: 'pause-circle' },
}

export const Stackable: Story<
React.ComponentProps<typeof AlertItem>
> = args => (
<div>
<Template {...args} type="warning" title={'Warning with close button'} />
<Template
{...args}
onCloseClick={undefined}
type="warning"
title={'Warning with no close button'}
/>
<Template {...args} type="warning" title={'Warning with no children'} />
<Template
{...args}
type="warning"
title={'Warning with React Node children'}
>
<p>Some additional info</p>
</Template>
</div>
)
1 change: 0 additions & 1 deletion components/src/alerts/AlertItem.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ import type { IconProps } from '../icons'

export type AlertType = 'success' | 'warning' | 'error' | 'info'

// TODO(bc, 2021-03-23): create and use AlertType Enum here and in rest of file
export interface AlertItemProps {
/** name constant of the icon to display */
type: AlertType
Expand Down
Loading