Skip to content

Commit ae7b652

Browse files
authored
Create a storybook with callout component (github#20902)
* Create a storybook with callout component * Add to dist/storybook * Remove references to dist dir, storybook takes place * Update Callout.stories.tsx * Update Dockerfile * Update Dockerfile
1 parent 8ded5d9 commit ae7b652

File tree

15 files changed

+38868
-17100
lines changed

15 files changed

+38868
-17100
lines changed

Diff for: .eslintignore

+1-1
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
dist/
1+
storybook/

Diff for: .gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ coverage/
1010
/data/early-access
1111
.next
1212
.eslintcache
13+
/storybook/
1314

1415
# blc: broken link checker
1516
blc_output.log

Diff for: .storybook/main.js

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
const path = require('path')
2+
3+
module.exports = {
4+
stories: [
5+
'../components/stories/**/*.stories.mdx',
6+
'../components/stories/**/*.stories.@(js|jsx|ts|tsx)',
7+
],
8+
addons: ['@storybook/addon-links', '@storybook/addon-essentials', '@storybook/preset-scss'],
9+
}

Diff for: .storybook/preview.js

+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
import '../stylesheets/index.scss'
2+
3+
export const parameters = {
4+
actions: { argTypesRegex: '^on[A-Z].*' },
5+
controls: {
6+
matchers: {
7+
color: /(background|color)$/i,
8+
date: /Date$/,
9+
},
10+
},
11+
}

Diff for: Dockerfile

+1
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@ COPY content/index.md ./content/index.md
4848
COPY next.config.js ./next.config.js
4949
COPY tsconfig.json ./tsconfig.json
5050
COPY next-env.d.ts ./next-env.d.ts
51+
COPY .storybook ./.storybook
5152

5253
RUN npx tsc --noEmit
5354

Diff for: components/stories/Callout.stories.tsx

+30
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
import React from 'react'
2+
import { ComponentStory, ComponentMeta } from '@storybook/react'
3+
4+
// @ts-ignore
5+
import { Callout } from '../ui/Callout.tsx'
6+
7+
export default {
8+
title: 'UI/Callout',
9+
component: Callout,
10+
} as ComponentMeta<typeof Callout>
11+
12+
const Template: ComponentStory<typeof Callout> = (args) => <Callout {...args} />
13+
14+
export const Success = Template.bind({})
15+
Success.args = {
16+
variant: 'success',
17+
children: <p>Hello!</p>,
18+
}
19+
20+
export const Info = Template.bind({})
21+
Info.args = {
22+
variant: 'info',
23+
children: <p>Hello!</p>,
24+
}
25+
26+
export const Warning = Template.bind({})
27+
Warning.args = {
28+
variant: 'warning',
29+
children: <p>Hello!</p>,
30+
}

Diff for: components/stories/Introduction.stories.mdx

+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
import { Meta } from '@storybook/addon-docs';
2+
3+
<Meta title="Example/Introduction" />
4+
5+
# Welcome to Storybook
6+
7+
Storybook helps you build UI components in isolation from your app's business logic, data, and context.
8+
That makes it easy to develop hard-to-reach states. Save these UI states as **stories** to revisit during development, testing, or QA.
9+
10+
Browse example stories now by navigating to them in the sidebar.
11+
View their code in the `src/stories` directory to learn how they work.
12+
We recommend building UIs with a [**component-driven**](https://componentdriven.org) process starting with atomic components and ending with pages.

Diff for: contributing/development.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ When you're ready to stop your local server, type <kbd>CTRL</kbd><kbd>c</kbd> in
2828

2929
Note that `npm ci` and `npm run build` are steps that should typically only need to be run once each time you pull the latest for a branch.
3030
- `npm ci` does a clean install of dependencies, without updating the `package-lock.json` file
31-
- `npm run build` creates static assets, such as the `dist/index.js` and `dist/index.css` files
31+
- `npm run build` creates static assets, such as JavaScript and CSS files
3232

3333
### Using GitHub Codespaces
3434

Diff for: middleware/csp.js

+5
Original file line numberDiff line numberDiff line change
@@ -70,5 +70,10 @@ export default function csp(req, res, next) {
7070
csp.directives.scriptSrc.push("'unsafe-inline'")
7171
}
7272

73+
if (req.path.startsWith('/storybook')) {
74+
csp.directives.scriptSrc.push("'unsafe-eval'", "'unsafe-inline'")
75+
csp.directives.frameSrc.push("'self'")
76+
}
77+
7378
return contentSecurityPolicy(csp)(req, res, next)
7479
}

Diff for: middleware/index.js

+5-4
Original file line numberDiff line numberDiff line change
@@ -137,19 +137,20 @@ export default function (app) {
137137

138138
// *** Rendering, 2xx responses ***
139139
// I largely ordered these by use frequency
140+
// archivedEnterpriseVersionsAssets must come before static/assets
140141
app.use(
141142
asyncMiddleware(
142143
instrument(archivedEnterpriseVersionsAssets, './archived-enterprise-versions-assets')
143144
)
144-
) // Must come before static/assets
145+
)
145146
app.use(
146-
'/dist',
147-
express.static('dist', {
147+
'/storybook',
148+
express.static('storybook', {
148149
index: false,
149150
etag: false,
150151
immutable: true,
151152
lastModified: false,
152-
maxAge: '28 days', // Could be infinite given our fingerprinting
153+
maxAge: '1 day', // Relatively short in case we update index.html
153154
})
154155
)
155156
app.use(

Diff for: nodemon.json

+1-3
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,8 @@
22
"ext": "js,json,yml,md,html,scss",
33
"ignore": [
44
"assets",
5-
"scripts",
5+
"script",
66
"translations",
7-
"dist",
8-
"javascripts",
97
"stylesheets",
108
"tests"
119
]

0 commit comments

Comments
 (0)