-
Notifications
You must be signed in to change notification settings - Fork 18
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #117 from icaldana/release/0.0.21
Release/0.0.21
- Loading branch information
Showing
9 changed files
with
5,468 additions
and
12,250 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,4 +3,5 @@ dist | |
build | ||
coverage | ||
.DS_Store | ||
./package-lock.json | ||
./package-lock.json | ||
/.storybook/stories |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
const fs = require('fs'); | ||
const path = require('path'); | ||
|
||
const examplesDir = path.join(__dirname, '../examples'); | ||
const storiesDir = path.join(__dirname, './stories'); | ||
|
||
if (!fs.existsSync(storiesDir)) { | ||
fs.mkdirSync(storiesDir, { recursive: true }); | ||
} | ||
|
||
const storyTemplate = (componentPath, storyTitle, exportName) => ` | ||
import React, { useEffect, useState } from 'react'; | ||
import { Meta, StoryFn } from '@storybook/react'; | ||
const ExampleComponent = ({ file }) => { | ||
const [component, setComponent] = useState<React.ReactElement | null>(null); | ||
console.log('Loading component', \`../../examples/\${file}\`); | ||
useEffect(() => { | ||
import(\`../../examples/\${file}\`).then(({ default: App }) => { | ||
setComponent( | ||
<React.StrictMode> | ||
<App /> | ||
</React.StrictMode> | ||
); | ||
}); | ||
}, [file]); | ||
return component; | ||
}; | ||
export default { | ||
title: '${storyTitle}', | ||
component: ExampleComponent, | ||
} as Meta; | ||
export const ${exportName}: StoryFn = () => <ExampleComponent file="${componentPath}" />; | ||
`; | ||
|
||
const processDirectory = (currentDir) => { | ||
fs.readdirSync(currentDir, { withFileTypes: true }).forEach((entry) => { | ||
const fullPath = path.join(currentDir, entry.name); | ||
if (entry.isDirectory()) { | ||
processDirectory(fullPath); | ||
} else if (entry.isFile() && fullPath.includes('/bricks/')) { | ||
const relativePath = path.relative(examplesDir, fullPath).replace(/\\/g, '/'); | ||
const storyName = path.basename(entry.name, '.tsx').replace(/^\d+-|-/g, ''); | ||
const storyFileName = `${relativePath.split('/')[1]}-${storyName}.stories.tsx`; | ||
const storyPath = path.join(storiesDir, storyFileName); | ||
const storyTitle = relativePath.substring(0, relativePath.lastIndexOf('/')); | ||
|
||
const storyContent = storyTemplate(relativePath, storyTitle, storyName); | ||
fs.writeFileSync(storyPath, storyContent.trim()); | ||
} | ||
}); | ||
}; | ||
|
||
processDirectory(examplesDir); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,14 @@ | ||
module.exports = { | ||
stories: ['./examples.stories.tsx'], | ||
features: { | ||
storyStoreV7: false, | ||
}, | ||
stories: ['./stories/**/*.stories.tsx'], | ||
addons: ['@storybook/addon-webpack5-compiler-babel'], | ||
features: {}, | ||
|
||
framework: { | ||
name: '@storybook/react-webpack5', | ||
options: {}, | ||
}, | ||
|
||
typescript: { | ||
reactDocgen: 'react-docgen-typescript', | ||
}, | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
Oops, something went wrong.