mirror of
https://github.com/ONLYOFFICE/onlyoffice.github.io.git
synced 2026-02-10 18:05:06 +08:00
add storybook for plugins
This commit is contained in:
2
.gitignore
vendored
2
.gitignore
vendored
@ -1,2 +1,4 @@
|
|||||||
*.js.bak
|
*.js.bak
|
||||||
*.json.bak
|
*.json.bak
|
||||||
|
|
||||||
|
*node_modules*
|
||||||
|
|||||||
20
storybook/source/.storybook/main.js
Normal file
20
storybook/source/.storybook/main.js
Normal file
@ -0,0 +1,20 @@
|
|||||||
|
|
||||||
|
|
||||||
|
/** @type { import('@storybook/html-vite').StorybookConfig } */
|
||||||
|
const config = {
|
||||||
|
"stories": [
|
||||||
|
"../stories/**/*.mdx",
|
||||||
|
"../stories/**/*.stories.@(js|jsx|mjs|ts|tsx)"
|
||||||
|
],
|
||||||
|
"addons": [
|
||||||
|
"@storybook/addon-docs",
|
||||||
|
],
|
||||||
|
"framework": {
|
||||||
|
"name": "@storybook/html-vite",
|
||||||
|
"options": {}
|
||||||
|
},
|
||||||
|
"core": {
|
||||||
|
"disableTelemetry": true,
|
||||||
|
},
|
||||||
|
};
|
||||||
|
export default config;
|
||||||
10
storybook/source/.storybook/manager.js
Normal file
10
storybook/source/.storybook/manager.js
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
import { addons } from 'storybook/manager-api';
|
||||||
|
import { themes } from 'storybook/theming';
|
||||||
|
|
||||||
|
addons.setConfig({
|
||||||
|
theme: {
|
||||||
|
...themes.normal,
|
||||||
|
brandImage: './images/logo.svg',
|
||||||
|
brandUrl: 'https://onlyoffice.github.io/',
|
||||||
|
},
|
||||||
|
});
|
||||||
55
storybook/source/.storybook/preview.js
Normal file
55
storybook/source/.storybook/preview.js
Normal file
@ -0,0 +1,55 @@
|
|||||||
|
/** @type { import('@storybook/html-vite').Preview } */
|
||||||
|
const preview = {
|
||||||
|
/* globalTypes: {
|
||||||
|
theme: {
|
||||||
|
description: 'Theme switcher',
|
||||||
|
defaultValue: 'light',
|
||||||
|
toolbar: {
|
||||||
|
title: 'Theme',
|
||||||
|
items: [
|
||||||
|
{ value: 'light', icon: 'sun', title: 'light' },
|
||||||
|
{ value: 'dark', icon: 'moon', title: 'dark' }
|
||||||
|
],
|
||||||
|
dynamicTitle: true,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},*/
|
||||||
|
|
||||||
|
parameters: {
|
||||||
|
controls: {
|
||||||
|
matchers: {
|
||||||
|
color: /(background|color)$/i,
|
||||||
|
date: /Date$/i,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
};
|
||||||
|
|
||||||
|
export const decorators = [
|
||||||
|
(storyFn, context) => {
|
||||||
|
const theme = context.globals.theme || 'light';
|
||||||
|
|
||||||
|
// Apply the theme as a data attribute
|
||||||
|
document.documentElement.setAttribute('data-theme', theme);
|
||||||
|
|
||||||
|
// Set window.Asc.plugin.theme for OnlyOffice plugin compatibility
|
||||||
|
if (!window.Asc) {
|
||||||
|
window.Asc = {};
|
||||||
|
}
|
||||||
|
if (!window.Asc.plugin) {
|
||||||
|
window.Asc.plugin = {};
|
||||||
|
}
|
||||||
|
window.Asc.plugin.theme = {
|
||||||
|
type: theme
|
||||||
|
};
|
||||||
|
|
||||||
|
return storyFn();
|
||||||
|
},
|
||||||
|
];
|
||||||
|
|
||||||
|
const link = document.createElement('link');
|
||||||
|
link.rel = 'stylesheet';
|
||||||
|
link.href = 'https://onlyoffice.github.io/sdkjs-plugins/v1/plugins.css';
|
||||||
|
document.head.appendChild(link);
|
||||||
|
|
||||||
|
export default preview;
|
||||||
BIN
storybook/source/.storybook/public/favicon.ico
Normal file
BIN
storybook/source/.storybook/public/favicon.ico
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 144 KiB |
6
storybook/source/images/logo.svg
Normal file
6
storybook/source/images/logo.svg
Normal file
File diff suppressed because one or more lines are too long
|
After Width: | Height: | Size: 7.1 KiB |
2049
storybook/source/package-lock.json
generated
Normal file
2049
storybook/source/package-lock.json
generated
Normal file
File diff suppressed because it is too large
Load Diff
22
storybook/source/package.json
Normal file
22
storybook/source/package.json
Normal file
@ -0,0 +1,22 @@
|
|||||||
|
{
|
||||||
|
"name": "onlyoffice-storybook",
|
||||||
|
"version": "1.0.0",
|
||||||
|
"main": "index.js",
|
||||||
|
"scripts": {
|
||||||
|
"test": "echo \"Error: no test specified\" && exit 1",
|
||||||
|
"storybook": "storybook dev -p 6006",
|
||||||
|
"build-storybook": "storybook build"
|
||||||
|
},
|
||||||
|
"keywords": [],
|
||||||
|
"author": "ONLYOFFICE",
|
||||||
|
"license": "Apache-2.0",
|
||||||
|
"description": "Storybook for ONLYOFFICE plugins components",
|
||||||
|
"devDependencies": {
|
||||||
|
"@storybook/addon-docs": "^9.0.6",
|
||||||
|
"@storybook/html-vite": "^9.0.6",
|
||||||
|
"storybook": "^9.0.6"
|
||||||
|
},
|
||||||
|
"overrides": {
|
||||||
|
"storybook": "$storybook"
|
||||||
|
}
|
||||||
|
}
|
||||||
32
storybook/source/stories/Button.stories.js
Normal file
32
storybook/source/stories/Button.stories.js
Normal file
@ -0,0 +1,32 @@
|
|||||||
|
export default {
|
||||||
|
title: 'Components/Button',
|
||||||
|
tags: ['autodocs'],
|
||||||
|
parameters: {
|
||||||
|
docs: {
|
||||||
|
description: {
|
||||||
|
component: 'Various styled buttons from ONLYOFFICE plugin UI.'
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
export const Default = () => `
|
||||||
|
<button class="btn-text-default" style="width:75px;">Button 1</button>
|
||||||
|
`;
|
||||||
|
Default.storyName = 'Default Button';
|
||||||
|
|
||||||
|
export const Primary = () => `
|
||||||
|
<button class="btn-text-default submit primary" style="width:75px;">Button 2</button>
|
||||||
|
`;
|
||||||
|
Primary.storyName = 'Primary Button';
|
||||||
|
|
||||||
|
export const Secondary = () => `
|
||||||
|
<button class="btn-text-default submit" style="width:75px;">Button 3</button>
|
||||||
|
`;
|
||||||
|
Secondary.storyName = 'Secondary Button';
|
||||||
|
|
||||||
|
export const EditButton = () => `
|
||||||
|
<label class="for-combo">Edit button</label>
|
||||||
|
<div class="btn-edit" style="display: inline-block; margin-left: 10px;"></div>
|
||||||
|
`;
|
||||||
|
EditButton.storyName = 'Edit Button';
|
||||||
18
storybook/source/stories/Checkbox.stories.js
Normal file
18
storybook/source/stories/Checkbox.stories.js
Normal file
@ -0,0 +1,18 @@
|
|||||||
|
export default {
|
||||||
|
title: 'Components/Checkbox',
|
||||||
|
tags: ['autodocs'],
|
||||||
|
parameters: {
|
||||||
|
docs: {
|
||||||
|
description: {
|
||||||
|
component: 'Checkbox from ONLYOFFICE plugin UI.'
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
export const Basic = () => `
|
||||||
|
<input type="checkbox" class="form-control" style="vertical-align: middle;">
|
||||||
|
<label style="margin-left: 5px; vertical-align: middle;">Checkbox</label>
|
||||||
|
`;
|
||||||
|
|
||||||
|
Basic.storyName = 'Default';
|
||||||
22
storybook/source/stories/ComboBox.stories.js
Normal file
22
storybook/source/stories/ComboBox.stories.js
Normal file
@ -0,0 +1,22 @@
|
|||||||
|
export default {
|
||||||
|
title: 'Components/ComboBox',
|
||||||
|
tags: ['autodocs'],
|
||||||
|
parameters: {
|
||||||
|
docs: {
|
||||||
|
description: {
|
||||||
|
component: 'ComboBox from ONLYOFFICE plugin UI.'
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
export const ComboBox = () => `
|
||||||
|
<label class="header" for="select_example">ComboBox</label>
|
||||||
|
<select id="select_example" class="">
|
||||||
|
<option value="1">Item 1</option>
|
||||||
|
<option value="2">Item 2</option>
|
||||||
|
<option value="3">Item 3</option>
|
||||||
|
</select>
|
||||||
|
`;
|
||||||
|
|
||||||
|
ComboBox.storyName = 'ComboBox';
|
||||||
32
storybook/source/stories/Input.stories.js
Normal file
32
storybook/source/stories/Input.stories.js
Normal file
@ -0,0 +1,32 @@
|
|||||||
|
export default {
|
||||||
|
title: 'Components/Input',
|
||||||
|
tags: ['autodocs'],
|
||||||
|
parameters: {
|
||||||
|
docs: {
|
||||||
|
description: {
|
||||||
|
component: 'Various styled inputs from ONLYOFFICE plugin UI.'
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
export const Textarea = () => `
|
||||||
|
<textarea
|
||||||
|
style="height:45px;width: 100%;"
|
||||||
|
class="form-control"
|
||||||
|
placeholder="textarea control"
|
||||||
|
></textarea>
|
||||||
|
`;
|
||||||
|
|
||||||
|
Textarea.storyName = 'Textarea Control';
|
||||||
|
|
||||||
|
export const TextField = () => `
|
||||||
|
<input
|
||||||
|
type="text"
|
||||||
|
class="form-control"
|
||||||
|
placeholder="text field"
|
||||||
|
style="width: 100%; margin-bottom: 2px;"
|
||||||
|
>
|
||||||
|
`;
|
||||||
|
|
||||||
|
TextField.storyName = 'Text Field Control';
|
||||||
23
storybook/source/stories/Label.stories.js
Normal file
23
storybook/source/stories/Label.stories.js
Normal file
@ -0,0 +1,23 @@
|
|||||||
|
export default {
|
||||||
|
title: 'Components/Label',
|
||||||
|
tags: ['autodocs'],
|
||||||
|
parameters: {
|
||||||
|
docs: {
|
||||||
|
description: {
|
||||||
|
component: 'Various styled labels from ONLYOFFICE plugin UI.'
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
export const Header = () => `
|
||||||
|
<label class="header">Header label</label>
|
||||||
|
`;
|
||||||
|
|
||||||
|
Header.storyName = 'Header Label';
|
||||||
|
|
||||||
|
export const Link = () => `
|
||||||
|
<label class="link">Link label</label>
|
||||||
|
`;
|
||||||
|
|
||||||
|
Link.storyName = 'Link Label';
|
||||||
51
storybook/source/stories/Loader.stories.js
Normal file
51
storybook/source/stories/Loader.stories.js
Normal file
@ -0,0 +1,51 @@
|
|||||||
|
export default {
|
||||||
|
title: 'Components/Loader',
|
||||||
|
tags: ['autodocs'],
|
||||||
|
parameters: {
|
||||||
|
docs: {
|
||||||
|
description: {
|
||||||
|
component: 'Loader from ONLYOFFICE plugin UI.'
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
export const InteractiveLoader = () => {
|
||||||
|
setTimeout(() => {
|
||||||
|
const loadScript = (src) =>
|
||||||
|
new Promise((resolve) => {
|
||||||
|
if (document.querySelector(`script[src="${src}"]`)) return resolve();
|
||||||
|
const script = document.createElement('script');
|
||||||
|
script.src = src;
|
||||||
|
script.onload = resolve;
|
||||||
|
document.head.appendChild(script);
|
||||||
|
});
|
||||||
|
|
||||||
|
(async () => {
|
||||||
|
await loadScript('https://ajax.googleapis.com/ajax/libs/jquery/2.2.2/jquery.min.js');
|
||||||
|
await loadScript('https://onlyoffice.github.io/sdkjs-plugins/v1/plugins.js');
|
||||||
|
await loadScript('https://onlyoffice.github.io/sdkjs-plugins/v1/plugins-ui.js');
|
||||||
|
|
||||||
|
const $ = window.jQuery;
|
||||||
|
let loader;
|
||||||
|
|
||||||
|
$('#show-loader').on('click', function () {
|
||||||
|
loader && (loader.remove ? loader.remove() : $('#loader-container')[0].removeChild(loader));
|
||||||
|
loader = window.showLoader($('#loader-container')[0], 'Loading...');
|
||||||
|
});
|
||||||
|
|
||||||
|
$('#hide-loader').on('click', function () {
|
||||||
|
loader && (loader.remove ? loader.remove() : $('#loader-container')[0].removeChild(loader));
|
||||||
|
loader = undefined;
|
||||||
|
});
|
||||||
|
})();
|
||||||
|
}, 0);
|
||||||
|
|
||||||
|
return `
|
||||||
|
<div id="loader-container" class="asc-loader-container" style="margin: 10px; height: 40px; border: 1px solid #cfcfcf;"></div>
|
||||||
|
<button id="show-loader">Show Loader</button>
|
||||||
|
<button id="hide-loader">Hide Loader</button>
|
||||||
|
`;
|
||||||
|
};
|
||||||
|
|
||||||
|
InteractiveLoader.storyName = 'Interactive Loader';
|
||||||
17
storybook/source/stories/Separator.stories.js
Normal file
17
storybook/source/stories/Separator.stories.js
Normal file
@ -0,0 +1,17 @@
|
|||||||
|
export default {
|
||||||
|
title: 'Components/Separator',
|
||||||
|
tags: ['autodocs'],
|
||||||
|
parameters: {
|
||||||
|
docs: {
|
||||||
|
description: {
|
||||||
|
component: 'Separator from ONLYOFFICE plugin UI.'
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
export const Horizontal = () => `
|
||||||
|
<div class="separator horizontal" style="margin: 5px 0;"></div>
|
||||||
|
`;
|
||||||
|
|
||||||
|
Horizontal.storyName = 'Horizontal Separator';
|
||||||
Reference in New Issue
Block a user