Skip to content
This repository was archived by the owner on Mar 7, 2025. It is now read-only.

Commit 69115a6

Browse files
authored
docs: clean html string with redundant parenthesis (#213)
1 parent 2b2bab9 commit 69115a6

File tree

1 file changed

+14
-14
lines changed

1 file changed

+14
-14
lines changed

.storybook/preview.jsx

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,14 @@ import { DocsContainer } from '@storybook/addon-docs';
1111

1212
// export const decorators = [cssVariablesTheme]
1313

14+
function cleanHtmlString(htmlString) {
15+
// Remove the leading and trailing backticks and braces
16+
if (htmlString.startsWith('{`') && htmlString.endsWith('`}')) {
17+
htmlString = htmlString.slice(2, -2);
18+
}
19+
return htmlString;
20+
}
21+
1422
export const decorators = [
1523
(Story, context) => {
1624
useEffect(() => {
@@ -28,15 +36,6 @@ export const decorators = [
2836
];
2937

3038
export const parameters = {
31-
// actions: { argTypesRegex: '^on[A-Z].*' },
32-
// cssVariables: {
33-
// files: {
34-
// 'HSE theme': hseTheme,
35-
// 'AGS theme': agsTheme,
36-
// 'OGCIO theme': defaultTheme,
37-
// },
38-
// defaultTheme: 'OGCIO theme',
39-
// },
4039
controls: {
4140
matchers: {
4241
color: /(background|color)$/i,
@@ -45,12 +44,13 @@ export const parameters = {
4544
sort: 'requiredFirst',
4645
},
4746
docs: {
48-
source: { format: false },
47+
source: {
48+
transform: (code) => {
49+
// Work around solution to remove extra parenthesis like ` and {}
50+
return cleanHtmlString(code);
51+
},
52+
},
4953
container: ({ children, context }) => {
50-
// let newContext;
51-
// cssVariablesTheme((c) => (newContext = c), context);
52-
// <DocsContainer context={newContext}>
53-
5454
return (
5555
<DocsContainer context={context}>
5656
<div className="sb-unstyled">{children}</div>

0 commit comments

Comments
 (0)