Skip to content

Commit

Permalink
refactor: seperate storybook (#1455)
Browse files Browse the repository at this point in the history
  • Loading branch information
Saul-Mirone authored Aug 3, 2024
1 parent f232ca7 commit ae18edb
Show file tree
Hide file tree
Showing 39 changed files with 226 additions and 65 deletions.
3 changes: 0 additions & 3 deletions e2e/.storybook/style.css

This file was deleted.

5 changes: 1 addition & 4 deletions e2e/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,7 @@
"test": "nx cypress:e2e",
"test:verbose": "nx open-cypress",
"start:test": "cross-env CYPRESS_SERVER_PORT=8000 start-test setup tcp:8000 test",
"start:test:verbose": "cross-env CYPRESS_SERVER_PORT=8000 start-test setup:verbose tcp:8000 test:verbose",
"storybook": "storybook dev -p 6006",
"storybook:build": "storybook build",
"storybook:serve": "serve storybook-static"
"start:test:verbose": "cross-env CYPRESS_SERVER_PORT=8000 start-test setup:verbose tcp:8000 test:verbose"
},
"dependencies": {
"@codemirror/commands": "^6.3.3",
Expand Down
29 changes: 0 additions & 29 deletions e2e/stories/plugins/emoji.stories.ts

This file was deleted.

6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,12 @@
"test:tsc": "pnpm --filter=@milkdown/* run tsc",
"test:tsc:cache": "nx run-many --target=tsc --all --parallel",
"test:lint": "eslint .",
"test:e2e": "pnpm --filter=@milkdown/e2e run start:test",
"test:e2e": "nx e2e @milkdown/e2e",
"test:e2e:build": "nx build @milkdown/e2e",
"test:e2e:verbose": "pnpm --filter=@milkdown/e2e run start:test:verbose",
"test:e2e:verbose": "nx open-cypress @milkdown/e2e",
"format": "lint-staged",
"watch": "pnpm --filter=./packages --parallel run start",
"start": "pnpm --filter=@milkdown/e2e run storybook",
"start": "pnpm --filter=@milkdown/storybook run start",
"build": "nx run-many --target=build --all --parallel",
"build:affected": "nx affected --target=build",
"build:packs": "pnpm --filter=@milkdown/* run build",
Expand Down
51 changes: 48 additions & 3 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions pnpm-workspace.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,4 @@ packages:
- 'packages/plugins/*'
- 'packages/integrations/*'
- e2e
- storybook
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import type { Preview } from '@storybook/html'

import './style.css'
import '@milkdown/theme-nord/style.css'

const preview: Preview = {
parameters: {
Expand Down
38 changes: 38 additions & 0 deletions storybook/.storybook/style.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
@tailwind base;
@tailwind components;
@tailwind utilities;

body {
padding: 0;
}

.milkdown {
@apply bg-slate-50 border rounded;
}

.milkdown:not(.crepe .milkdown) {
@apply px-8 py-4 mx-5;
}

.editor {
@apply mx-auto max-w-full;
}

input {
border: 0;
outline: none;
}

input:focus {
border: 0;
outline: none;
box-shadow: none;
}

span[data-type='emoji'] {
@apply inline-block;
}

span[data-type='emoji'] .emoji {
@apply w-4;
}
41 changes: 41 additions & 0 deletions storybook/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
{
"name": "@milkdown/storybook",
"version": "7.4.0",
"private": true,
"files": [
"style"
],
"scripts": {
"start": "storybook dev -p 6006",
"build": "storybook build",
"serve": "serve storybook-static"
},
"dependencies": {
"@codemirror/commands": "^6.3.3",
"@codemirror/language-data": "^6.4.1",
"@codemirror/state": "^6.4.1",
"@codemirror/theme-one-dark": "^6.1.2",
"@codemirror/view": "^6.26.0",
"@milkdown/crepe": "workspace:*",
"@milkdown/kit": "workspace:*",
"@milkdown/theme-nord": "workspace:*",
"@uiw/codemirror-theme-basic": "^4.22.1",
"@uiw/codemirror-theme-nord": "^4.22.1",
"atomico": "^1.75.1",
"codemirror": "^6.0.1",
"katex": "^0.16.0",
"tslib": "^2.5.0"
},
"nx": {
"targets": {
"build": {
"outputs": [
"{projectRoot}/lib"
],
"dependsOn": [
"build"
]
}
}
}
}
7 changes: 7 additions & 0 deletions storybook/postcss.config.cjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
module.exports = {
plugins: {
'tailwindcss/nesting': {},
'tailwindcss': {},
'autoprefixer': {},
},
}
Binary file added storybook/public/milkdown-logo.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
20 changes: 20 additions & 0 deletions storybook/public/typescript-label.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions storybook/shim.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/// <reference types="vite/client" />
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import type { Meta, StoryObj } from '@storybook/html'
import { codeBlockComponent, codeBlockConfig } from '@milkdown/components/code-block'
import { codeBlockComponent, codeBlockConfig } from '@milkdown/kit/component/code-block'
import { oneDark } from '@codemirror/theme-one-dark'
import { languages } from '@codemirror/language-data'
import { basicSetup } from 'codemirror'
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import type { Meta, StoryObj } from '@storybook/html'
import { imageBlockComponent } from '@milkdown/components/image-block'
import { imageBlockComponent } from '@milkdown/kit/component/image-block'

import type { CommonArgs } from '../utils/shadow'
import { setupMilkdown } from '../utils/shadow'
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import type { Meta, StoryObj } from '@storybook/html'
import { imageInlineComponent } from '@milkdown/components/image-inline'
import { imageInlineComponent } from '@milkdown/kit/component/image-inline'

import type { CommonArgs } from '../utils/shadow'
import { setupMilkdown } from '../utils/shadow'
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
import type { Meta, StoryObj } from '@storybook/html'
import { editorViewCtx } from '@milkdown/core'
import { linkSchema } from '@milkdown/preset-commonmark'
import { editorViewCtx } from '@milkdown/kit/core'
import { linkSchema } from '@milkdown/kit/preset/commonmark'
import {
configureLinkTooltip,
linkTooltipAPI,
linkTooltipPlugin,
linkTooltipState,
} from '@milkdown/components/link-tooltip'
import { TooltipProvider, tooltipFactory } from '@milkdown/plugin-tooltip'
import type { Ctx } from '@milkdown/ctx'
import type { EditorView } from '@milkdown/prose/view'
import type { EditorState } from '@milkdown/prose/state'
} from '@milkdown/kit/component/link-tooltip'
import { TooltipProvider, tooltipFactory } from '@milkdown/kit/plugin/tooltip'
import type { Ctx } from '@milkdown/kit/ctx'
import type { EditorView } from '@milkdown/kit/prose/view'
import type { EditorState } from '@milkdown/kit/prose/state'

import type { CommonArgs } from '../utils/shadow'
import { setupMilkdown } from '../utils/shadow'
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import type { Meta, StoryObj } from '@storybook/html'
import { gfm } from '@milkdown/preset-gfm'
import { listItemBlockComponent } from '@milkdown/components/list-item-block'
import { gfm } from '@milkdown/kit/preset/gfm'
import { listItemBlockComponent } from '@milkdown/kit/component/list-item-block'

import type { CommonArgs } from '../utils/shadow'
import { setupMilkdown } from '../utils/shadow'
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import type { Meta, StoryObj } from '@storybook/html'
import { gfm } from '@milkdown/preset-gfm'
import { gfm } from '@milkdown/kit/preset/gfm'

import { tableBlock } from '@milkdown/components/table-block'
import tableStyle from '@milkdown/prose/tables/style/tables.css?inline'
import { cursor } from '@milkdown/plugin-cursor'
import { history } from '@milkdown/plugin-history'
import { tableBlock } from '@milkdown/kit/component/table-block'
import tableStyle from '@milkdown/kit/prose/tables/style/tables.css?inline'
import { cursor } from '@milkdown/kit/plugin/cursor'
import { history } from '@milkdown/kit/plugin/history'
import type { CommonArgs } from '../utils/shadow'
import { setupMilkdown } from '../utils/shadow'
import style from './table-block.css?inline'
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import type { Meta, StoryObj } from '@storybook/html'
import { EditorStatus } from '@milkdown/core'
import { listener, listenerCtx } from '@milkdown/plugin-listener'
import { EditorStatus } from '@milkdown/kit/core'
import { listener, listenerCtx } from '@milkdown/kit/plugin/listener'
import { action } from '@storybook/addon-actions'

import type { CommonArgs } from '../utils/shadow'
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import nordStyle from '@milkdown/theme-nord/style.css?inline'
import pmStyle from '@milkdown/prose/view/style/prosemirror.css?inline'
import { Editor, defaultValueCtx, editorViewOptionsCtx, rootCtx } from '@milkdown/core'
import pmStyle from '@milkdown/kit/prose/view/style/prosemirror.css?inline'
import { Editor, defaultValueCtx, editorViewOptionsCtx, rootCtx } from '@milkdown/kit/core'
import { nord } from '@milkdown/theme-nord'
import { commonmark } from '@milkdown/preset-commonmark'
import { history } from '@milkdown/plugin-history'
import { commonmark } from '@milkdown/kit/preset/commonmark'
import { history } from '@milkdown/kit/plugin/history'
import commonStyle from './style.css?inline'

export function wrapInShadow(styles: string[]) {
Expand Down
File renamed without changes.
13 changes: 13 additions & 0 deletions storybook/tailwind.config.cjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
/** @type {import('tailwindcss').Config} */
module.exports = {
content: ['**/*.tsx', '**/*.ts', '**/*.html'],
darkMode: 'class',
theme: {
extend: {},
},
plugins: [
require('@tailwindcss/forms'),
require('@tailwindcss/typography'),
require('tailwind-nord'),
],
}
15 changes: 15 additions & 0 deletions storybook/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{
"extends": "../tsconfig.base.json",
"compilerOptions": {
"lib": ["dom"],
"baseUrl": ".",
"rootDir": ".",
"sourceMap": false
},
"ts-node": {
"compilerOptions": {
"module": "es2022",
"moduleResolution": "node"
}
}
}
Loading

0 comments on commit ae18edb

Please sign in to comment.