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

build(#10336): Storybook & Chromatic & msw #10365

Merged
merged 102 commits into from
Apr 4, 2023
Merged
Show file tree
Hide file tree
Changes from 100 commits
Commits
Show all changes
102 commits
Select commit Hold shift + click to select a range
1dfcca7
build(#10336): init
acid-chicken Mar 19, 2023
91e0e49
fix(#10336): invalid name conversion
acid-chicken Mar 19, 2023
0dcb99d
build(#10336): load locales and vite config
acid-chicken Mar 20, 2023
a19c560
refactor(#10336): remove unused imports
acid-chicken Mar 20, 2023
6e21147
build(#10336): separate definitions and generated codes
acid-chicken Mar 20, 2023
be7b71a
refactor(#10336): remove hatches
acid-chicken Mar 20, 2023
3907cb5
refactor(#10336): module semantics
acid-chicken Mar 20, 2023
ca7d208
refactor(#10336): remove unused common preferences
acid-chicken Mar 20, 2023
2ec608f
fix: typo
acid-chicken Mar 20, 2023
2eecb8e
build(#10336): mock assets
acid-chicken Mar 20, 2023
bdbbb92
build(#10336): impl `SatisfiesExpression`
acid-chicken Mar 20, 2023
0ac4d74
build(#10336): control themes
acid-chicken Mar 20, 2023
bf527cd
refactor(#10336): semantics
acid-chicken Mar 21, 2023
cc3fbef
build(#10336): make .storybook as an individual TypeScript project
acid-chicken Mar 21, 2023
49f8bb4
style(#10336): use single quote
acid-chicken Mar 21, 2023
5ced8ae
build(#10336): avoid intrinsic component names
acid-chicken Mar 21, 2023
1d0ca7e
chore: suppress linter
acid-chicken Mar 21, 2023
bf5fff8
style: typing
acid-chicken Mar 21, 2023
c2d8759
build(#10336): update dependencies
acid-chicken Mar 23, 2023
bd7cc6a
docs: note about Storybook
acid-chicken Mar 24, 2023
723cff0
Merge branch 'develop' of https://github.com/misskey-dev/misskey into…
acid-chicken Mar 24, 2023
8332c03
build(#10336): sync
acid-chicken Mar 24, 2023
2bce064
build(#10336): full reload server on change
acid-chicken Mar 25, 2023
b56d173
chore: use defaultStore instead
acid-chicken Mar 25, 2023
8ca9621
build(#10336): show popups on Story
acid-chicken Mar 25, 2023
899c624
refactor(#10336): remove redundant div
acid-chicken Mar 25, 2023
225a8e1
docs: fix
acid-chicken Mar 25, 2023
356fd72
build(#10336): interactions
acid-chicken Mar 25, 2023
bc6d576
build(#10336): add an interaction test for `<MkA/>`
acid-chicken Mar 25, 2023
3db0147
build(#10336): bump storybook
acid-chicken Mar 30, 2023
d1c5556
Merge branch 'develop' of https://github.com/misskey-dev/misskey into…
acid-chicken Mar 30, 2023
5393436
docs(#10336): mention to pre-build misskey-js
acid-chicken Mar 30, 2023
98fd6b5
build(#10336): write stories for `MkAcct`
acid-chicken Mar 30, 2023
70fc25a
build(#10336): write stories for `MkAd`
acid-chicken Mar 31, 2023
bf9846a
Merge branch 'develop' of https://github.com/misskey-dev/misskey into…
acid-chicken Mar 31, 2023
558d73b
build(#10336): fix missing type definition
acid-chicken Mar 31, 2023
85f50f3
build(#10336): use `toHaveTextContent`
acid-chicken Mar 31, 2023
671ce6a
build(#10336): write some stories
acid-chicken Mar 31, 2023
5605b03
build(#10336): hide internal args
acid-chicken Apr 1, 2023
a47f4b8
build(#10336): generate `components/global` stories only
acid-chicken Apr 1, 2023
2b831da
Merge branch 'develop' of https://github.com/misskey-dev/misskey into…
acid-chicken Apr 1, 2023
c6d12c2
build(#10336): write stories for `MkMisskeyFlavoredMarkdown`
acid-chicken Apr 1, 2023
d300f4a
fix: conflict errors
acid-chicken Apr 1, 2023
5667f0f
build(#10336): subcomponents on sidebar
acid-chicken Apr 1, 2023
f246699
refactor: restore `SatisfiesExpression`
acid-chicken Apr 1, 2023
f3a29cb
docs(#10336): note development status
acid-chicken Apr 1, 2023
3f1a87d
Merge branch 'develop' of https://github.com/misskey-dev/misskey into…
acid-chicken Apr 1, 2023
139dade
build(#10336): use chokidar-cli
acid-chicken Apr 1, 2023
f7bc442
docs(#10336): note chokidar-cli mode
acid-chicken Apr 1, 2023
f5fd59d
chore(#10336): untrack generated stories files
acid-chicken Apr 1, 2023
38b153c
fix: pointer handling
acid-chicken Apr 1, 2023
1521bb0
build(#10336): finalize
acid-chicken Apr 1, 2023
0960d61
chore: add static option to `MkLoading`
acid-chicken Apr 1, 2023
f39b5be
refactor(#10336): bind to local args
acid-chicken Apr 1, 2023
4521e61
fix: missing case
acid-chicken Apr 1, 2023
e7a15b5
revert: restore `SatisfiesExpression`
acid-chicken Apr 1, 2023
65f20de
build(#10336): make storybook buildable
acid-chicken Apr 1, 2023
ec8905f
build(#10336): staticify assets
acid-chicken Apr 1, 2023
88981e9
build(#10336): staticified directory structure
acid-chicken Apr 1, 2023
0f334f9
build(#10336): normalize path for Windows
acid-chicken Apr 1, 2023
7256b1f
ci(#10336): create actions
acid-chicken Apr 1, 2023
20fb266
build(#10336): ignore tsc errors
acid-chicken Apr 1, 2023
b0fa9f3
build(#10336): ignore tsc errors
acid-chicken Apr 1, 2023
9773170
build(#10336): missing dependencies
acid-chicken Apr 1, 2023
8b30a0d
build(#10336): missing dependencies
acid-chicken Apr 1, 2023
fc76829
build(#10336): use fast-glob
acid-chicken Apr 1, 2023
97e7f7e
fix: invalid lockfile
acid-chicken Apr 1, 2023
b9289c3
ci(#10336): increase heap size
acid-chicken Apr 1, 2023
3f4d93a
build(#10336): use unpkg for storybook tabler icons
acid-chicken Apr 1, 2023
edeabac
build(#10336): use unpkg for storybook twemojis
acid-chicken Apr 1, 2023
903d0bd
build(#10336): disable `ProfilePageCat`
acid-chicken Apr 2, 2023
9982ead
build(#10336): blur `MkA` before interaction ends
acid-chicken Apr 2, 2023
388ecfb
ci(#10336): stabilize
acid-chicken Apr 2, 2023
a217344
ci(#10336): fetch-depth
acid-chicken Apr 2, 2023
faf827a
build(#10336): isChromatic
acid-chicken Apr 2, 2023
5ab02cb
Merge branch 'storybook' of https://github.com/misskey-dev/misskey in…
acid-chicken Apr 2, 2023
5143f33
ci(#10336): notify on changes
acid-chicken Apr 2, 2023
252fe24
ci(#10336): fix typo
acid-chicken Apr 2, 2023
f9693d1
ci(#10336): missing working directory
acid-chicken Apr 2, 2023
e4f6fac
ci(#10336): skip build
acid-chicken Apr 2, 2023
d57a504
ci(#10336): fix path
acid-chicken Apr 2, 2023
29c63ad
build(#10336): fails on Windows
acid-chicken Apr 2, 2023
9946ba0
build(#10336): available on Windows
acid-chicken Apr 2, 2023
ddb1635
ci(#10336): disable animation on chromatic
acid-chicken Apr 2, 2023
d6b1e5b
Merge branch 'storybook' of https://github.com/misskey-dev/misskey in…
acid-chicken Apr 2, 2023
dfb6df0
ci(#10336): add static option to `PageHeader.tabs`
acid-chicken Apr 2, 2023
36e8988
chore: void
acid-chicken Apr 2, 2023
a61fe90
Merge branch 'develop' into storybook
acid-chicken Apr 2, 2023
3ab2a00
ci(#10336): change parameters
acid-chicken Apr 2, 2023
423a67f
Merge branch 'storybook' of https://github.com/misskey-dev/misskey in…
acid-chicken Apr 2, 2023
902d7c5
docs(#10336): update CONTRIBUTING
acid-chicken Apr 3, 2023
4f7ba29
docs(#10336): note about meta overriding and etc.
acid-chicken Apr 3, 2023
b1b871a
ci(#10336): use Chromatic for checks
acid-chicken Apr 3, 2023
b303a80
Merge branch 'storybook' of https://github.com/misskey-dev/misskey in…
acid-chicken Apr 3, 2023
9b00424
ci(#10336): use `pull_request` instead of `pull_request_target` for now
acid-chicken Apr 3, 2023
8d90e88
Merge branch 'develop' of https://github.com/misskey-dev/misskey into…
acid-chicken Apr 3, 2023
2acb655
ci(#10336): use `exitOnceUploaded`
acid-chicken Apr 3, 2023
b3b64d8
ci(#10336): reuse built storybook
acid-chicken Apr 3, 2023
211682d
ci(#10336): back to `pull_request_target`
acid-chicken Apr 3, 2023
38b9fc4
chore: unused dependencies
acid-chicken Apr 3, 2023
14591aa
style(#10336): reduce prettier indents
acid-chicken Apr 3, 2023
b91d831
style: note about `TSSatisfiesExpression`
acid-chicken Apr 3, 2023
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
56 changes: 56 additions & 0 deletions .github/workflows/storybook.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
name: Storybook

on:
push:
branches:
- master
- develop
pull_request_target:

jobs:
build:
runs-on: ubuntu-latest

steps:
- uses: actions/[email protected]
with:
fetch-depth: 0
submodules: true
- name: Install pnpm
uses: pnpm/action-setup@v2
with:
version: 7
run_install: false
- name: Use Node.js 18.x
uses: actions/[email protected]
with:
node-version: 18.x
cache: 'pnpm'
- run: corepack enable
- run: pnpm i --frozen-lockfile
- name: Check pnpm-lock.yaml
run: git diff --exit-code pnpm-lock.yaml
- name: Build misskey-js
run: pnpm --filter misskey-js build
- name: Build storybook
run: pnpm --filter frontend build-storybook
env:
NODE_OPTIONS: "--max_old_space_size=7168"
- name: Publish to Chromatic
id: chromatic
uses: chromaui/action@v1
with:
exitOnceUploaded: true
projectToken: ${{ secrets.CHROMATIC_PROJECT_TOKEN }}
storybookBuildDir: storybook-static
workingDir: packages/frontend
- name: Compare on Chromatic
if: github.event_name == 'pull_request_target'
run: pnpm --filter frontend chromatic -d storybook-static --exit-once-uploaded --patch-build ${{ github.head_ref }}...${{ github.base_ref }}
env:
CHROMATIC_PROJECT_TOKEN: ${{ secrets.CHROMATIC_PROJECT_TOKEN }}
- name: Upload Artifacts
uses: actions/upload-artifact@v3
with:
name: storybook
path: packages/frontend/storybook-static
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ api-docs.json
/files
ormconfig.json
temp
/packages/frontend/src/**/*.stories.ts

# blender backups
*.blend1
Expand Down
110 changes: 110 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -203,6 +203,116 @@ niraxは、Misskeyで使用しているオリジナルのフロントエンド
vue-routerとの最大の違いは、niraxは複数のルーターが存在することを許可している点です。
これにより、アプリ内ウィンドウでブラウザとは個別にルーティングすることなどが可能になります。

## Storybook

Misskey uses [Storybook](https://storybook.js.org/) for UI development.

### Setup & Run

#### Universal

##### Setup

```bash
pnpm --filter misskey-js build
pnpm --filter frontend tsc -p .storybook && (node packages/frontend/.storybook/preload-locale.js & node packages/frontend/.storybook/preload-theme.js)
```

##### Run

```bash
node packages/frontend/.storybook/generate.js && pnpm --filter frontend storybook dev
```

#### macOS & Linux

##### Setup

```bash
pnpm --filter misskey-js build
```

##### Run

```bash
pnpm --filter frontend storybook-dev
```

### Usage

When you create a new component (in this example, `MyComponent.vue`), the story file (`MyComponent.stories.ts`) will be automatically generated by the `.storybook/generate.js` script.
You can override the default story by creating a impl story file (`MyComponent.stories.impl.ts`).

```ts
/* eslint-disable @typescript-eslint/explicit-function-return-type */
/* eslint-disable import/no-duplicates */
import { StoryObj } from '@storybook/vue3';
import MyComponent from './MyComponent.vue';
export const Default = {
render(args) {
return {
components: {
MyComponent,
},
setup() {
return {
args,
};
},
computed: {
props() {
return {
...this.args,
};
},
},
template: '<MyComponent v-bind="props" />',
};
},
args: {
foo: 'bar',
},
parameters: {
layout: 'centered',
},
} satisfies StoryObj<typeof MkAvatar>;
```

If you want to opt-out from the automatic generation, create a `MyComponent.stories.impl.ts` file and add the following line to the file.

```ts
import MyComponent from './MyComponent.vue';
void MyComponent;
```

You can override the component meta by creating a meta story file (`MyComponent.stories.meta.ts`).

```ts
export const argTypes = {
scale: {
control: {
type: 'range',
min: 1,
max: 4,
},
};
```

Also, you can use msw to mock API requests in the storybook. Creating a `MyComponent.stories.msw.ts` file to define the mock handlers.

```ts
import { rest } from 'msw';
export const handlers = [
rest.post('/api/notes/timeline', (req, res, ctx) => {
return res(
ctx.json([]),
);
}),
];
```

Don't forget to re-run the `.storybook/generate.js` script after adding, editing, or removing the above files.

## Notes
### How to resolve conflictions occurred at pnpm-lock.yaml?

Expand Down
1 change: 1 addition & 0 deletions packages/frontend/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/storybook-static
9 changes: 9 additions & 0 deletions packages/frontend/.storybook/.gitignore
Copy link
Member Author

Choose a reason for hiding this comment

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

現時点ではこのファイルに書いてあるコマンドでストーリーを生成してから pnpm storybook dev して Storybook の画面を開くことができる

Copy link
Member

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?
が出た

Copy link
Member Author

Choose a reason for hiding this comment

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

CI は回ってるし謎
あとで調査します

Copy link
Member Author

Choose a reason for hiding this comment

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

Windows 環境で再現した

Copy link
Member Author

Choose a reason for hiding this comment

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

@syuilo 多分直った

Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# (cd path/to/frontend; pnpm tsc -p .storybook)
# (cd path/to/frontend; node .storybook/generate.js)
/generate.js
# (cd path/to/frontend; node .storybook/preload-locale.js)
/preload-locale.js
/locale.ts
# (cd path/to/frontend; node .storybook/preload-theme.js)
/preload-theme.js
/themes.ts
54 changes: 54 additions & 0 deletions packages/frontend/.storybook/fakes.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
import type { entities } from 'misskey-js'

export const userDetailed = {
id: 'someuserid',
username: 'miskist',
host: 'misskey-hub.net',
name: 'Misskey User',
onlineStatus: 'unknown',
avatarUrl: 'https://github.com/misskey-dev/misskey/blob/master/packages/frontend/assets/about-icon.png?raw=true',
avatarBlurhash: 'eQFRshof5NWBRi},juayfPju53WB?0ofs;s*a{ofjuay^SoMEJR%ay',
emojis: [],
bannerBlurhash: 'eQA^IW^-MH8w9tE8I=S^o{$*R4RikXtSxutRozjEnNR.RQadoyozog',
bannerColor: '#000000',
bannerUrl: 'https://github.com/misskey-dev/misskey/blob/master/packages/frontend/assets/fedi.jpg?raw=true',
birthday: '2014-06-20',
createdAt: '2016-12-28T22:49:51.000Z',
description: 'I am a cool user!',
ffVisibility: 'public',
fields: [
{
name: 'Website',
value: 'https://misskey-hub.net',
},
],
followersCount: 1024,
followingCount: 16,
hasPendingFollowRequestFromYou: false,
hasPendingFollowRequestToYou: false,
isAdmin: false,
isBlocked: false,
isBlocking: false,
isBot: false,
isCat: false,
isFollowed: false,
isFollowing: false,
isLocked: false,
isModerator: false,
isMuted: false,
isSilenced: false,
isSuspended: false,
lang: 'en',
location: 'Fediverse',
notesCount: 65536,
pinnedNoteIds: [],
pinnedNotes: [],
pinnedPage: null,
pinnedPageId: null,
publicReactions: false,
securityKeys: false,
twoFactorEnabled: false,
updatedAt: null,
uri: null,
url: null,
} satisfies entities.UserDetailed
Loading