-
-
Notifications
You must be signed in to change notification settings - Fork 1.4k
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
build(#10336): Storybook & Chromatic & msw #10365
Merged
Changes from 6 commits
Commits
Show all changes
102 commits
Select commit
Hold shift + click to select a range
1dfcca7
build(#10336): init
acid-chicken 91e0e49
fix(#10336): invalid name conversion
acid-chicken 0dcb99d
build(#10336): load locales and vite config
acid-chicken a19c560
refactor(#10336): remove unused imports
acid-chicken 6e21147
build(#10336): separate definitions and generated codes
acid-chicken be7b71a
refactor(#10336): remove hatches
acid-chicken 3907cb5
refactor(#10336): module semantics
acid-chicken ca7d208
refactor(#10336): remove unused common preferences
acid-chicken 2ec608f
fix: typo
acid-chicken 2eecb8e
build(#10336): mock assets
acid-chicken bdbbb92
build(#10336): impl `SatisfiesExpression`
acid-chicken 0ac4d74
build(#10336): control themes
acid-chicken bf527cd
refactor(#10336): semantics
acid-chicken cc3fbef
build(#10336): make .storybook as an individual TypeScript project
acid-chicken 49f8bb4
style(#10336): use single quote
acid-chicken 5ced8ae
build(#10336): avoid intrinsic component names
acid-chicken 1d0ca7e
chore: suppress linter
acid-chicken bf5fff8
style: typing
acid-chicken c2d8759
build(#10336): update dependencies
acid-chicken bd7cc6a
docs: note about Storybook
acid-chicken 723cff0
Merge branch 'develop' of https://github.com/misskey-dev/misskey into…
acid-chicken 8332c03
build(#10336): sync
acid-chicken 2bce064
build(#10336): full reload server on change
acid-chicken b56d173
chore: use defaultStore instead
acid-chicken 8ca9621
build(#10336): show popups on Story
acid-chicken 899c624
refactor(#10336): remove redundant div
acid-chicken 225a8e1
docs: fix
acid-chicken 356fd72
build(#10336): interactions
acid-chicken bc6d576
build(#10336): add an interaction test for `<MkA/>`
acid-chicken 3db0147
build(#10336): bump storybook
acid-chicken d1c5556
Merge branch 'develop' of https://github.com/misskey-dev/misskey into…
acid-chicken 5393436
docs(#10336): mention to pre-build misskey-js
acid-chicken 98fd6b5
build(#10336): write stories for `MkAcct`
acid-chicken 70fc25a
build(#10336): write stories for `MkAd`
acid-chicken bf9846a
Merge branch 'develop' of https://github.com/misskey-dev/misskey into…
acid-chicken 558d73b
build(#10336): fix missing type definition
acid-chicken 85f50f3
build(#10336): use `toHaveTextContent`
acid-chicken 671ce6a
build(#10336): write some stories
acid-chicken 5605b03
build(#10336): hide internal args
acid-chicken a47f4b8
build(#10336): generate `components/global` stories only
acid-chicken 2b831da
Merge branch 'develop' of https://github.com/misskey-dev/misskey into…
acid-chicken c6d12c2
build(#10336): write stories for `MkMisskeyFlavoredMarkdown`
acid-chicken d300f4a
fix: conflict errors
acid-chicken 5667f0f
build(#10336): subcomponents on sidebar
acid-chicken f246699
refactor: restore `SatisfiesExpression`
acid-chicken f3a29cb
docs(#10336): note development status
acid-chicken 3f1a87d
Merge branch 'develop' of https://github.com/misskey-dev/misskey into…
acid-chicken 139dade
build(#10336): use chokidar-cli
acid-chicken f7bc442
docs(#10336): note chokidar-cli mode
acid-chicken f5fd59d
chore(#10336): untrack generated stories files
acid-chicken 38b153c
fix: pointer handling
acid-chicken 1521bb0
build(#10336): finalize
acid-chicken 0960d61
chore: add static option to `MkLoading`
acid-chicken f39b5be
refactor(#10336): bind to local args
acid-chicken 4521e61
fix: missing case
acid-chicken e7a15b5
revert: restore `SatisfiesExpression`
acid-chicken 65f20de
build(#10336): make storybook buildable
acid-chicken ec8905f
build(#10336): staticify assets
acid-chicken 88981e9
build(#10336): staticified directory structure
acid-chicken 0f334f9
build(#10336): normalize path for Windows
acid-chicken 7256b1f
ci(#10336): create actions
acid-chicken 20fb266
build(#10336): ignore tsc errors
acid-chicken b0fa9f3
build(#10336): ignore tsc errors
acid-chicken 9773170
build(#10336): missing dependencies
acid-chicken 8b30a0d
build(#10336): missing dependencies
acid-chicken fc76829
build(#10336): use fast-glob
acid-chicken 97e7f7e
fix: invalid lockfile
acid-chicken b9289c3
ci(#10336): increase heap size
acid-chicken 3f4d93a
build(#10336): use unpkg for storybook tabler icons
acid-chicken edeabac
build(#10336): use unpkg for storybook twemojis
acid-chicken 903d0bd
build(#10336): disable `ProfilePageCat`
acid-chicken 9982ead
build(#10336): blur `MkA` before interaction ends
acid-chicken 388ecfb
ci(#10336): stabilize
acid-chicken a217344
ci(#10336): fetch-depth
acid-chicken faf827a
build(#10336): isChromatic
acid-chicken 5ab02cb
Merge branch 'storybook' of https://github.com/misskey-dev/misskey in…
acid-chicken 5143f33
ci(#10336): notify on changes
acid-chicken 252fe24
ci(#10336): fix typo
acid-chicken f9693d1
ci(#10336): missing working directory
acid-chicken e4f6fac
ci(#10336): skip build
acid-chicken d57a504
ci(#10336): fix path
acid-chicken 29c63ad
build(#10336): fails on Windows
acid-chicken 9946ba0
build(#10336): available on Windows
acid-chicken ddb1635
ci(#10336): disable animation on chromatic
acid-chicken d6b1e5b
Merge branch 'storybook' of https://github.com/misskey-dev/misskey in…
acid-chicken dfb6df0
ci(#10336): add static option to `PageHeader.tabs`
acid-chicken 36e8988
chore: void
acid-chicken a61fe90
Merge branch 'develop' into storybook
acid-chicken 3ab2a00
ci(#10336): change parameters
acid-chicken 423a67f
Merge branch 'storybook' of https://github.com/misskey-dev/misskey in…
acid-chicken 902d7c5
docs(#10336): update CONTRIBUTING
acid-chicken 4f7ba29
docs(#10336): note about meta overriding and etc.
acid-chicken b1b871a
ci(#10336): use Chromatic for checks
acid-chicken b303a80
Merge branch 'storybook' of https://github.com/misskey-dev/misskey in…
acid-chicken 9b00424
ci(#10336): use `pull_request` instead of `pull_request_target` for now
acid-chicken 8d90e88
Merge branch 'develop' of https://github.com/misskey-dev/misskey into…
acid-chicken 2acb655
ci(#10336): use `exitOnceUploaded`
acid-chicken b3b64d8
ci(#10336): reuse built storybook
acid-chicken 211682d
ci(#10336): back to `pull_request_target`
acid-chicken 38b9fc4
chore: unused dependencies
acid-chicken 14591aa
style(#10336): reduce prettier indents
acid-chicken b91d831
style: note about `TSSatisfiesExpression`
acid-chicken File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
/storybook-static |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
# (cd .; pnpm tsc --jsx react --jsxFactory h ./generate.tsx && node ./generate.js) | ||
/generate.js | ||
# (cd .; pnpm tsc ./preload-locale.ts && node ./preload-locale.js) | ||
/preload-locale.js | ||
/locale.ts | ||
# (cd .; pnpm tsc ./preload-theme.ts && node ./preload-theme.js) | ||
/preload-theme.js | ||
/theme.ts |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,234 @@ | ||
import { existsSync, readFileSync } from 'node:fs'; | ||
import { writeFile } from 'node:fs/promises'; | ||
import { basename, dirname } from 'node:path/posix'; | ||
import { promisify } from 'node:util'; | ||
import { generate } from 'astring'; | ||
import type * as estree from 'estree'; | ||
import * as glob from 'glob'; | ||
import { format } from 'prettier'; | ||
|
||
function h<T extends estree.Node>(component: T['type'], props: Omit<T, 'type'>): T { | ||
const type = component.replace(/(?:^|-)([a-z])/g, (_, c) => c.toUpperCase()); | ||
return Object.assign(props, { type }) as T; | ||
} | ||
|
||
function toStories(component: string): string { | ||
const msw = `${component.slice(0, -'.vue'.length)}.msw`; | ||
const implStories = `${component.slice(0, -'.vue'.length)}.stories.impl`; | ||
const hasMsw = existsSync(`${msw}.ts`); | ||
const hasImplStories = existsSync(`${implStories}.ts`); | ||
const base = basename(component); | ||
const dir = dirname(component); | ||
const literal = ( | ||
<literal value={component.slice('src/'.length, -'.vue'.length)} /> | ||
) as unknown as estree.Literal; | ||
const identifier = ( | ||
<identifier name={base.slice(0, -'.vue'.length).replace(/[-.]|^(?=\d)/g, '_')} /> | ||
) as unknown as estree.Identifier; | ||
const parameters = ( | ||
<object-expression | ||
properties={[ | ||
<property | ||
key={<identifier name="layout" />} | ||
value={<literal value={`${dir}/`.startsWith('src/pages/') ? 'fullscreen' : 'centered'} />} | ||
kind="init" | ||
/>, | ||
...hasMsw | ||
? [ | ||
<property | ||
key={<identifier name="msw" />} | ||
value={<identifier name="msw" />} | ||
kind="init" | ||
shorthand | ||
/>, | ||
] | ||
: [], | ||
]} | ||
/> | ||
); | ||
const program = ( | ||
<program | ||
body={[ | ||
<import-declaration | ||
source={<literal value="@storybook/vue3" />} | ||
specifiers={[ | ||
<import-specifier | ||
local={<identifier name="Meta" />} | ||
imported={<identifier name="Meta" />} | ||
/>, | ||
<import-specifier | ||
local={<identifier name="Story" />} | ||
imported={<identifier name="Story" />} | ||
/>, | ||
]} | ||
/>, | ||
...hasMsw | ||
? [ | ||
<import-declaration | ||
source={<literal value={`./${basename(msw)}`} />} | ||
specifiers={[ | ||
<import-namespace-specifier | ||
local={<identifier name="msw" />} | ||
/>, | ||
]} | ||
/>, | ||
] | ||
: [], | ||
<import-declaration | ||
source={<literal value={`./${base}`} />} | ||
specifiers={[ | ||
<import-default-specifier | ||
local={identifier} | ||
imported={identifier} | ||
/>, | ||
]} | ||
/>, | ||
<variable-declaration | ||
kind="const" | ||
declarations={[ | ||
<variable-declarator | ||
id={<identifier name="meta" />} | ||
init={ | ||
<object-expression | ||
properties={[ | ||
<property | ||
key={<identifier name="title" />} | ||
value={literal} | ||
kind="init" | ||
/>, | ||
<property | ||
key={<identifier name="component" />} | ||
value={identifier} | ||
kind="init" | ||
/>, | ||
]} | ||
/> | ||
} | ||
/>, | ||
]} | ||
/>, | ||
...hasImplStories | ||
? [ | ||
] | ||
: [ | ||
<export-named-declaration | ||
declaration={ | ||
<variable-declaration | ||
kind="const" | ||
declarations={[ | ||
<variable-declarator | ||
id={<identifier name="Default" />} | ||
init={ | ||
<object-expression | ||
properties={[ | ||
<property | ||
key={<identifier name="render" />} | ||
value={ | ||
<function-expression | ||
id={<identifier name="render" />} | ||
params={[ | ||
<identifier name="args" />, | ||
<object-pattern | ||
properties={[ | ||
<property | ||
key={<identifier name="argTypes" />} | ||
value={<identifier name="argTypes" />} | ||
kind="init" | ||
shorthand | ||
/>, | ||
]} | ||
/>, | ||
]} | ||
body={ | ||
<block-statement | ||
body={[ | ||
<return-statement | ||
argument={ | ||
<object-expression | ||
properties={[ | ||
<property | ||
key={<identifier name="components" />} | ||
value={ | ||
<object-expression | ||
properties={[ | ||
<property | ||
key={identifier} | ||
value={identifier} | ||
kind="init" | ||
shorthand | ||
/>, | ||
]} | ||
/> | ||
} | ||
kind="init" | ||
/>, | ||
<property | ||
key={<identifier name="props" />} | ||
value={ | ||
<call-expression | ||
callee={ | ||
<member-expression | ||
object={<identifier name="Object" />} | ||
property={<identifier name="keys" />} | ||
/> | ||
} | ||
arguments={[ | ||
<identifier name="argTypes" />, | ||
]} | ||
/> | ||
} | ||
kind="init" | ||
/>, | ||
<property | ||
key={<identifier name="template" />} | ||
value={<literal value={`<${identifier.name} v-bind="$props" />`} />} | ||
kind="init" | ||
/>, | ||
]} | ||
/> | ||
} | ||
/>, | ||
]} | ||
/> | ||
} | ||
/> | ||
} | ||
method | ||
kind="init" | ||
/>, | ||
<property | ||
key={<identifier name="parameters" />} | ||
value={parameters} | ||
kind="init" | ||
/>, | ||
]} | ||
/> | ||
} | ||
/>, | ||
]} | ||
/> | ||
} | ||
/>, | ||
], | ||
<export-default-declaration | ||
declaration={<identifier name="meta" />} | ||
/>, | ||
]} | ||
/> | ||
) as unknown as estree.Program; | ||
return format( | ||
generate(program) + (hasImplStories ? readFileSync(`${implStories}.ts`, 'utf-8') : ''), | ||
{ | ||
parser: 'babel-ts', | ||
singleQuote: true, | ||
useTabs: true, | ||
} | ||
); | ||
} | ||
|
||
promisify(glob)('src/{components,pages,ui,widgets}/**/*.vue').then((components) => Promise.all( | ||
components.map((component) => { | ||
const stories = component.replace(/\.vue$/, '.stories.ts'); | ||
return writeFile(stories, toStories(component)); | ||
}) | ||
)); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
import type { StorybookConfig } from '@storybook/vue3-vite'; | ||
import { mergeConfig } from 'vite'; | ||
import { getConfig } from '../vite.config'; | ||
const config = { | ||
stories: ['../src/**/*.mdx', '../src/**/*.stories.@(js|jsx|ts|tsx)'], | ||
addons: [ | ||
'@storybook/addon-links', | ||
'@storybook/addon-essentials', | ||
'@storybook/addon-interactions', | ||
], | ||
framework: { | ||
name: '@storybook/vue3-vite', | ||
options: {}, | ||
}, | ||
docs: { | ||
autodocs: 'tag', | ||
}, | ||
core: { | ||
disableTelemetry: true, | ||
}, | ||
async viteFinal(config, options) { | ||
const { plugins, build: { rollupOptions, ...build }, ...original } = getConfig(); | ||
const x = mergeConfig(config, { | ||
...original, | ||
build, | ||
}); | ||
return x; | ||
}, | ||
} satisfies StorybookConfig; | ||
export default config; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
import { addons } from '@storybook/manager-api'; | ||
import { create } from '@storybook/theming/create'; | ||
|
||
addons.setConfig({ | ||
theme: create({ | ||
base: 'dark', | ||
brandTitle: 'Misskey Storybook', | ||
brandUrl: 'https://misskey-hub.net', | ||
brandImage: 'https://github.com/misskey-dev/assets/blob/main/misskey.svg?raw=true', | ||
brandTarget: '_blank', | ||
}), | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
import { writeFile } from 'node:fs/promises'; | ||
import { resolve } from 'node:path'; | ||
import * as locales from '../../../locales'; | ||
|
||
writeFile( | ||
resolve(__dirname, 'locale.ts'), | ||
`export default ${JSON.stringify(locales['ja-JP'], undefined, 2)} as const;`, | ||
'utf8', | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
import { readFile, writeFile } from 'node:fs/promises'; | ||
import { resolve } from 'node:path'; | ||
import * as JSON5 from 'json5'; | ||
|
||
Promise.all([ | ||
readFile(resolve(__dirname, '../src/themes/_light.json5'), 'utf8'), | ||
readFile(resolve(__dirname, '../src/themes/l-light.json5'), 'utf8'), | ||
]).then((sources) => { | ||
const base = JSON5.parse(sources[0]); | ||
const theme = JSON5.parse(sources[1]); | ||
writeFile( | ||
resolve(__dirname, './theme.ts'), | ||
`export default ${JSON.stringify( | ||
Object.assign(theme, { | ||
base: undefined, | ||
props: Object.assign(base.props, theme.props), | ||
}), | ||
undefined, | ||
2, | ||
)} as const;`, | ||
'utf8' | ||
); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
<script> | ||
window.global = window; | ||
</script> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
import { type Preview, setup } from '@storybook/vue3'; | ||
import { initialize, mswDecorator } from 'msw-storybook-addon'; | ||
import locale from './locale'; | ||
import theme from './theme'; | ||
import '../src/style.scss'; | ||
|
||
initialize(); | ||
localStorage.setItem("locale", JSON.stringify(locale)); | ||
Promise.all([ | ||
import('../src/components'), | ||
import('../src/directives'), | ||
import('../src/widgets'), | ||
import('../src/scripts/theme').then(({ applyTheme }) => applyTheme(theme)), | ||
]).then(([{ default: components }, { default: directives }, { default: widgets }]) => { | ||
setup((app) => { | ||
components(app); | ||
directives(app); | ||
widgets(app); | ||
}); | ||
}); | ||
|
||
const preview = { | ||
decorators: [ | ||
mswDecorator, | ||
], | ||
parameters: { | ||
layout: 'centered', | ||
}, | ||
argTypes: { | ||
default: { | ||
control: { | ||
type: 'text', | ||
}, | ||
}, | ||
}, | ||
} satisfies Preview; | ||
|
||
export default preview; |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
現時点ではこのファイルに書いてあるコマンドでストーリーを生成してから
pnpm storybook dev
して Storybook の画面を開くことができるThere was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[vite] Internal server error: Failed to resolve import "../node_modules/storybook-addon-misskey-theme/preview" from "..\..\..\..\..\..\virtual:\@storybook\builder-vite\vite-app.js". Does the file exist?
が出た
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
CI は回ってるし謎
あとで調査します
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Windows 環境で再現した
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@syuilo 多分直った