mirror of
https://github.com/roleypoly/roleypoly-v1.git
synced 2025-06-16 18:29:08 +00:00
[design]: overrides pattern, tests, yay!
This commit is contained in:
parent
0ccb5fa32f
commit
dd6f02f4e2
22 changed files with 6165 additions and 1328 deletions
|
@ -1,2 +0,0 @@
|
|||
import '@storybook/addon-actions/register';
|
||||
import '@storybook/addon-links/register';
|
3
packages/roleypoly-design/.storybook/addons.ts
Normal file
3
packages/roleypoly-design/.storybook/addons.ts
Normal file
|
@ -0,0 +1,3 @@
|
|||
import '@storybook/addon-actions/register'
|
||||
import '@storybook/addon-links/register'
|
||||
import '@storybook/addon-knobs/register'
|
|
@ -1,8 +0,0 @@
|
|||
import { configure } from '@storybook/react'
|
||||
const req = require.context('../src', true, /\.stor\bies|y\b\.[tj]sx?$/)
|
||||
|
||||
function loadStories() {
|
||||
req.keys().forEach(req)
|
||||
}
|
||||
|
||||
configure(loadStories, module)
|
51
packages/roleypoly-design/.storybook/config.ts
Normal file
51
packages/roleypoly-design/.storybook/config.ts
Normal file
|
@ -0,0 +1,51 @@
|
|||
const { configure } = require('@storybook/react')
|
||||
|
||||
// polyfill for require.context
|
||||
try {
|
||||
if (require.context === undefined) {
|
||||
const fs = require('fs')
|
||||
const path = require('path')
|
||||
// @ts-ignore
|
||||
require.context = (base: string = '.', scanSubDirectories: boolean = false, regularExpression: RegExp = /\.js$/) => {
|
||||
const files = {}
|
||||
|
||||
function readDirectory (directory: string) {
|
||||
fs.readdirSync(directory).forEach((file) => {
|
||||
const fullPath = path.resolve(directory, file)
|
||||
|
||||
if (fs.statSync(fullPath).isDirectory()) {
|
||||
if (scanSubDirectories) readDirectory(fullPath)
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
if (!regularExpression.test(fullPath)) return
|
||||
|
||||
files[fullPath] = true
|
||||
})
|
||||
}
|
||||
|
||||
readDirectory(path.resolve(__dirname, base))
|
||||
|
||||
function Module (file: string) {
|
||||
return require(file)
|
||||
}
|
||||
|
||||
Module.keys = () => Object.keys(files)
|
||||
|
||||
return Module
|
||||
}
|
||||
}
|
||||
} catch (e) {
|
||||
if (e) {
|
||||
console.log(e)
|
||||
}
|
||||
}
|
||||
|
||||
const req = require.context('../src', true, /\.stor\bies|y\b\.[tj]sx?$/)
|
||||
|
||||
function loadStories () {
|
||||
req.keys().forEach(req)
|
||||
}
|
||||
|
||||
configure(loadStories, module)
|
Loading…
Add table
Add a link
Reference in a new issue