Skip to content

Commit

Permalink
Allow switch on PrestaShop BO themes
Browse files Browse the repository at this point in the history
  • Loading branch information
Quetzacoalt91 committed Jul 4, 2024
1 parent 6160aa6 commit ff61ed8
Show file tree
Hide file tree
Showing 158 changed files with 26 additions and 2 deletions.
3 changes: 2 additions & 1 deletion storybook/.storybook/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,13 @@ const config: StorybookConfig = {
],
additionalWatchPaths: [
'assets',
]
],
}
},
},
docs: {
autodocs: "tag",
},
staticDirs: ['../public'],
};
export default config;
25 changes: 24 additions & 1 deletion storybook/.storybook/preview.ts
Original file line number Diff line number Diff line change
@@ -1,19 +1,42 @@
import { Preview, twig } from "@sensiolabs/storybook-symfony-webpack5";
import './bo-themes/1.7.8.0/theme.css';

const cssEntrypoints = {
'1.7.8.0': '/bo-themes/1.7.8.0/theme.css',
'1.7.3.0': '/bo-themes/1.7.3.0/css/admin-theme.css',
};
const availableBoThemes = Object.keys(cssEntrypoints);
const defaultBoTheme = availableBoThemes[0];

const preview: Preview = {
parameters: {
backgrounds: {
disable: true,
},
},
globalTypes: {
backofficeTheme: {
description: "PrestaShop Back-office theme",
toolbar: {
icon: "paintbrush",
default: defaultBoTheme,
items: availableBoThemes.map((prestashopVersion) => ({
value: prestashopVersion,
title: `PrestaShop ${prestashopVersion}`,
})),
},
},
},
decorators: [
(story, context) => {
const selectedTheme = context.globals.backofficeTheme || defaultBoTheme;
const cssContents = (cssEntrypoints[selectedTheme]);

const calledStory = story();
calledStory.template = twig(`
<div id="main">
<div class="bootstrap">
${calledStory.template.getSource()}
<link rel="stylesheet" type="text/css" href="${cssContents}" />
</div>
</div>
`);
Expand Down
File renamed without changes

0 comments on commit ff61ed8

Please sign in to comment.