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

INT-3307: Update storybook to use v8 and Vite builder #55

Merged
merged 8 commits into from
Jun 13, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
23 changes: 0 additions & 23 deletions .storybook/main.js

This file was deleted.

18 changes: 18 additions & 0 deletions .storybook/main.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
import type { StorybookConfig } from '@storybook/svelte-vite';

const config: StorybookConfig = {
core: {
disableTelemetry: true,
},
stories: ['../src/**/*.stories.mdx', '../src/**/*.stories.@(js|jsx|ts|tsx|svelte)'],
framework: {
name: '@storybook/svelte-vite',
options: {},
},
addons: ['@storybook/addon-essentials', '@storybook/addon-svelte-csf'],
docs: {
autodocs: 'tag',
},
};

export default config;
File renamed without changes.
33 changes: 13 additions & 20 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,9 @@
"validate": "svelte-check",
"lint": "eslint src/main/**/*.{ts,svelte}",
"test": "echo 'No tests hooked up yet'",
"storybook": "start-storybook -p 6006",
"build-storybook": "build-storybook",
"deploy-storybook": "yarn storybook-to-ghpages --source-branch=main",
"storybook": "storybook dev -p 6006",
"build-storybook": "storybook build",
"deploy-storybook": "storybook build && gh-pages -d ./storybook-static -u 'tiny-bot <no-reply@tiny.cloud>' --nojekyll",
"prepublishOnly": "yarn run build"
},
"keywords": [
Expand All @@ -50,21 +50,11 @@
"@rollup/plugin-commonjs": "^17.0.0",
"@rollup/plugin-node-resolve": "^11.0.0",
"@rollup/plugin-typescript": "^8.2.5",
"@storybook/addon-actions": "^6.3.7",
"@storybook/addon-essentials": "^6.3.7",
"@storybook/addon-links": "^6.3.7",
"@storybook/addon-svelte-csf": "^1.1.0",
"@storybook/addons": "^6.2.9",
"@storybook/api": "^6.2.9",
"@storybook/builder-webpack5": "^6.5.16",
"@storybook/client-api": "^6.2.9",
"@storybook/client-logger": "^6.2.9",
"@storybook/components": "^6.2.9",
"@storybook/core-events": "^6.2.9",
"@storybook/manager-webpack5": "^6.5.16",
"@storybook/storybook-deployer": "^2.8.10",
"@storybook/svelte": "^6.3.7",
"@storybook/theming": "^6.2.9",
"@storybook/addon-essentials": "^8.1.3",
"@storybook/addon-svelte-csf": "^4.1.3",
"@storybook/svelte": "^8.1.3",
"@storybook/svelte-vite": "^8.1.3",
"@sveltejs/vite-plugin-svelte": "^3.1.1",
"@tinymce/beehive-flow": "^0.19.0",
"@tinymce/eslint-plugin": "^1.9.2",
"@tsconfig/svelte": "^5.0.4",
Expand All @@ -73,20 +63,23 @@
"babel-loader": "^8.2.2",
"eslint": "^7.32.0",
"eslint-plugin-svelte": "^2.34.0",
"react": "^17.0.0",
"react-dom": "^17.0.0",
"gh-pages": "^6.1.1",
"react": "^18.3.1",
"react-dom": "^18.3.1",
"rollup": "^2.56.2",
"rollup-plugin-css-only": "^3.1.0",
"rollup-plugin-livereload": "^2.0.0",
"rollup-plugin-svelte": "^7.1.5",
"rollup-plugin-terser": "^7.0.0",
"storybook": "^8.1.6",
"svelte": "^4.2.17",
"svelte-check": "^3.8.0",
"svelte-loader": "^3.2.0",
"svelte-preprocess": "^5.1.4",
"tinymce": "^7.1.1",
"tslib": "^2.6.2",
"typescript": "^5.4.5",
"vite": "^5.2.13",
"webpack": "^5.76.2"
},
"resolutions": {
Expand Down
51 changes: 28 additions & 23 deletions src/stories/Editor.stories.svelte
Original file line number Diff line number Diff line change
@@ -1,16 +1,22 @@
<script context="module">
export const meta = {
danoaky-tiny marked this conversation as resolved.
Show resolved Hide resolved
title: 'Editor',
component: Editor
}
</script>

<script>
//
import Editor from '../main/component/Editor.svelte';
import { Meta, Story } from '@storybook/addon-svelte-csf';
import { Story } from '@storybook/addon-svelte-csf';

const apiKey = 'b1g4d59rwwqxx1vj7mci23rjj8ubgb46i4xsio6ieig6fkps';
const content = `
<h2 style="text-align: center;">
TinyMCE provides a <span style="text-decoration: underline;">full-featured</span> rich text editing experience, and a featherweight download.
</h2>
<p style="text-align: center;">
<strong><span style="font-size: 14pt;"><span style="color: #7e8c8d; font-weight: 600;">No matter what you're building, TinyMCE has got you covered.</span></span></strong>
</p>`;
<h2 style="text-align: center;">
TinyMCE provides a <span style="text-decoration: underline;">full-featured</span> rich text editing experience, and a featherweight download.
</h2>
<p style="text-align: center;">
<strong><span style="font-size: 14pt;"><span style="color: #7e8c8d; font-weight: 600;">No matter what you're building, TinyMCE has got you covered.</span></span></strong>
</p>`.trim();

let value = content;
let disabled = true;
Expand All @@ -19,48 +25,47 @@
const toggleDisabled = () => {
disabled = !disabled;
}
const controls = { channel: '7', conf: { plugins: 'help' } }
</script>

<Meta title="Editor" component={Editor}/>

<Story name="Iframe">
<Editor {apiKey} value={content}/>
<Story name="Iframe" args={{ ...controls, inline: false }} let:args>
<Editor {apiKey} {value} {...args}/>
</Story>

<Story name="Inline">
<Story name="Inline" args={{ ...controls, inline: true }} let:args>
<div style="padding-top:100px;">
<Editor {apiKey} inline={true} value={content} />
<Editor {apiKey} {value} {...args} />
</div>
</Story>

<Story name="Value binding">
<Story name="Value binding" args={controls} let:args>
<div>
<Editor {apiKey} bind:value={value} />
<Editor {apiKey} bind:value {...args}/>
<div>
{@html value}
</div>
</div>
</Story>

<Story name="Input binding">
<Story name="Input binding" args={controls} let:args>
<div>
<Editor {apiKey} bind:value={value} />
<textarea style="width:100%;height:200px" bind:value={value}></textarea>
<Editor {apiKey} bind:value {...args}/>
<textarea style="width:100%;height:200px" bind:value></textarea>
</div>
</Story>

<Story name="Text binding">
<Story name="Text binding" args={controls} let:args>
<div>
<Editor {apiKey} bind:value={value} bind:text={text} />
<Editor {apiKey} bind:value bind:text {...args}/>
<div>{text}</div>
<div>{@html value}</div>
<textarea style="width:100%;height:200px" bind:value={text}></textarea>
</div>
</Story>

<Story name="Disabling">
<Story name="Disabling" args={controls} let:args>
<div>
<button on:click={toggleDisabled}>{#if disabled}Enable{:else}Disable{/if}</button>
<Editor {disabled} />
<Editor {apiKey} {disabled} {value} {...args}/>
</div>
</Story>
10 changes: 10 additions & 0 deletions vite.config.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import { defineConfig } from 'vite';
import { svelte } from '@sveltejs/vite-plugin-svelte';
import { vitePreprocess } from '@sveltejs/vite-plugin-svelte';

// As of right now, this is just used for building the storybook.
export default defineConfig({
plugins: [svelte({
preprocess: [vitePreprocess()]
})]
});
Loading
Loading