Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
import * as React from 'react';
Comment thread
dmytrokirpa marked this conversation as resolved.

export const ButtonAppearance = () => () =>
(
<>
<Button>Default button</Button>
<Button appearance="primary">Primary button</Button>
<Button appearance="outline">Outline button</Button>
<Button appearance="subtle">Subtle button</Button>
<Button appearance="transparent">Transparent button</Button>
</>
);
export const ButtonAppearance = () => (
<>
<Button>Default button</Button>
<Button appearance="primary">Primary button</Button>
<Button appearance="outline">Outline button</Button>
<Button appearance="subtle">Subtle button</Button>
<Button appearance="transparent">Transparent button</Button>
</>
);
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import * as React from 'react';
export const ButtonAppearance = () => () =>
export const ButtonAppearance = () =>
/*#__PURE__*/ React.createElement(
React.Fragment,
null,
Expand Down Expand Up @@ -35,4 +35,4 @@ export const ButtonAppearance = () => () =>
);
ButtonAppearance.parameters = {};
ButtonAppearance.parameters.fullSource =
'import * as React from "react";\n\nexport const ButtonAppearance = () => () =>\n (\n <>\n <Button>Default button</Button>\n <Button appearance="primary">Primary button</Button>\n <Button appearance="outline">Outline button</Button>\n <Button appearance="subtle">Subtle button</Button>\n <Button appearance="transparent">Transparent button</Button>\n </>\n );\n';
'import * as React from "react";\n\nexport const ButtonAppearance = () => (\n <>\n <Button>Default button</Button>\n <Button appearance="primary">Primary button</Button>\n <Button appearance="outline">Outline button</Button>\n <Button appearance="subtle">Subtle button</Button>\n <Button appearance="transparent">Transparent button</Button>\n </>\n);\n';
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
import * as React from 'react';

const Child1 = () => (
<>
<Button>Default button</Button>
<Button appearance="primary">Primary button</Button>
<Button appearance="outline">Outline button</Button>
</>
);

export const ButtonAppearance = () => (
<>
<Child1 />
<Child2 />
</>
);

const Child2 = () => (
<>
<Button appearance="subtle">Subtle button</Button>
<Button appearance="transparent">Transparent button</Button>
</>
);
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
import * as React from 'react';
const Child1 = () =>
/*#__PURE__*/ React.createElement(
Comment thread
dmytrokirpa marked this conversation as resolved.
React.Fragment,
null,
/*#__PURE__*/ React.createElement(Button, null, 'Default button'),
/*#__PURE__*/ React.createElement(
Button,
{
appearance: 'primary',
},
'Primary button',
),
/*#__PURE__*/ React.createElement(
Button,
{
appearance: 'outline',
},
'Outline button',
),
);
export const ButtonAppearance = () =>
/*#__PURE__*/ React.createElement(
React.Fragment,
null,
/*#__PURE__*/ React.createElement(Child1, null),
/*#__PURE__*/ React.createElement(Child2, null),
);
const Child2 = () =>
/*#__PURE__*/ React.createElement(
React.Fragment,
null,
/*#__PURE__*/ React.createElement(
Button,
{
appearance: 'subtle',
},
'Subtle button',
),
/*#__PURE__*/ React.createElement(
Button,
{
appearance: 'transparent',
},
'Transparent button',
),
);
ButtonAppearance.parameters = {};
ButtonAppearance.parameters.fullSource =
'import * as React from "react";\n\nconst Child1 = () => (\n <>\n <Button>Default button</Button>\n <Button appearance="primary">Primary button</Button>\n <Button appearance="outline">Outline button</Button>\n </>\n);\n\nexport const ButtonAppearance = () => (\n <>\n <Child1 />\n <Child2 />\n </>\n);\n\nconst Child2 = () => (\n <>\n <Button appearance="subtle">Subtle button</Button>\n <Button appearance="transparent">Transparent button</Button>\n </>\n);\n';
Original file line number Diff line number Diff line change
Expand Up @@ -54,13 +54,28 @@ export function fullSourcePlugin(babel: typeof Babel, options: BabelPluginOption
name: PLUGIN_NAME,
visitor: {
// eslint-disable-next-line @typescript-eslint/naming-convention
VariableDeclarator(path) {
ExportNamedDeclaration(path) {
const declaration = path.node.declaration;

// Check if it's a function declaration
if (
t.isFunctionDeclaration(declaration) &&
t.isIdentifier(declaration.id) &&
isComponentLikeName(declaration.id.name)
) {
storyName = declaration.id.name;
return;
}

// Check if it's a variable declaration
if (
t.isArrowFunctionExpression(path.node.init) &&
t.isIdentifier(path.node.id) &&
isComponentLikeName(path.node.id.name)
t.isVariableDeclaration(declaration) &&
declaration.declarations.length === 1 &&
t.isIdentifier(declaration.declarations[0].id) &&
isComponentLikeName(declaration.declarations[0].id.name)
) {
storyName = path.node.id.name;
storyName = declaration.declarations[0].id.name;
return;
}
},
// eslint-disable-next-line @typescript-eslint/naming-convention
Expand Down