Skip to content

Commit

Permalink
Override the default storybook babel configuration (#809)
Browse files Browse the repository at this point in the history
This change allows the @compiled/babel-plugin to run on source code,
instead of transpiled code
  • Loading branch information
MonicaOlejniczak authored Aug 12, 2021
1 parent 60aa93e commit 5703722
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 3 deletions.
4 changes: 4 additions & 0 deletions .storybook/.babelrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"plugins": [["@compiled/babel-plugin", { "importReact": false }]],
"presets": ["@babel/preset-typescript", ["@babel/preset-react", { "runtime": "automatic" }]]
}
2 changes: 1 addition & 1 deletion .storybook/main.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
module.exports = {
addons: ['storybook-addon-performance/register', 'storybook-addon-pseudo-states'],
stories: ['../examples/stories/*.tsx'],
core: {
builder: 'webpack5',
},
stories: ['../examples/stories/*.tsx'],
};
14 changes: 12 additions & 2 deletions examples/stories/css-prop-string.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,15 @@ export const TemplateLiteral = (): JSX.Element => {
<div
css={`
display: flex;
font-size: 50px;
font-size: 30px;
color: blue;
`}>
blue text
</div>
);
};

export const TemplateLiteralCSS = (): JSX.Element => {
export const InlineCssTaggedTemplateExpression = (): JSX.Element => {
return (
<div
css={css`
Expand All @@ -31,6 +31,16 @@ export const TemplateLiteralCSS = (): JSX.Element => {
);
};

const taggedTemplateExpressionCss = css`
display: flex;
font-size: 30px;
color: green;
`;

export const CssTaggedTemplateExpression = (): JSX.Element => {
return <div css={taggedTemplateExpressionCss}>green text</div>;
};

export const UsingMixinImportSpread = (): JSX.Element => {
return <div css={{ ...primary }}>purple text spread</div>;
};
Expand Down

0 comments on commit 5703722

Please sign in to comment.