Skip to content

Commit

Permalink
pkp/pkp-lib#9527 using addons-themes for ltr/rtl, instead of dedicate…
Browse files Browse the repository at this point in the history
…d addons to handle compatibility with modes
  • Loading branch information
jardakotesovec committed Dec 18, 2023
1 parent 2069e0d commit 82a6a2c
Show file tree
Hide file tree
Showing 5 changed files with 35 additions and 207 deletions.
12 changes: 6 additions & 6 deletions .storybook/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@
const config = {
stories: ['../src/**/*.mdx', '../src/**/*.stories.@(js|jsx|mjs|ts|tsx)'],
addons: [
'@storybook/addon-links',
'@storybook/addon-essentials',
'@storybook/addon-interactions',
'storybook-addon-rtl',
"@storybook/addon-mdx-gfm"
],
'@storybook/addon-links',
'@storybook/addon-essentials',
'@storybook/addon-interactions',
'@storybook/addon-themes',
'@storybook/addon-mdx-gfm',
],
framework: {
name: '@storybook/vue3-vite',
options: {},
Expand Down
5 changes: 3 additions & 2 deletions .storybook/modes.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
export const allModes = {
desktop: {
viewport: 'large',
theme: 'LTR',
},
'desktop rtl': {
'desktop RTL': {
viewport: 'large',
direction: 'rtl',
theme: 'RTL',
},
// for snapshotting scrollable areas with all content, like modals
desktopLargeHeight: {
Expand Down
14 changes: 11 additions & 3 deletions .storybook/preview.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
/** @type { import('@storybook/vue3').Preview } */

import {withThemeByDataAttribute} from '@storybook/addon-themes';

import {setup} from '@storybook/vue3';

import GlobalMixins from '@/mixins/global.js';
Expand Down Expand Up @@ -28,14 +30,12 @@ import VueScrollTo from 'vue-scrollto';
import '../src/styles/_import.less';
import '../src/styles/_global.less';
import {allModes} from './modes';
import {initializeRTL} from 'storybook-addon-rtl';
import {initialize, mswLoader} from 'msw-storybook-addon';

import {createPinia} from 'pinia';

const pinia = createPinia();

initializeRTL();
// Initialize MSW
initialize({
onUnhandledRequest: ({method, url}) => {
Expand Down Expand Up @@ -95,6 +95,14 @@ setup((app) => {
const preview = {
loaders: [mswLoader],
decorators: [
withThemeByDataAttribute({
themes: {
ltr: 'LTR',
rtl: 'RTL',
},
defaultTheme: 'LTR',
attributeName: 'RTL',
}),
(story) => ({
components: {story},
template: '<div style="padding: 10px;"><story /></div>',
Expand Down Expand Up @@ -153,7 +161,7 @@ const preview = {
chromatic: {
modes: {
desktop: allModes['desktop'],
'desktop rtl': allModes['desktop rtl'],
'desktop RTL': allModes['desktop RTL'],
},
},
},
Expand Down
208 changes: 14 additions & 194 deletions package-lock.json

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

Loading

0 comments on commit 82a6a2c

Please sign in to comment.