-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
961d2eb
commit 5f4141f
Showing
19 changed files
with
661 additions
and
261 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
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 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 |
---|---|---|
|
@@ -26,3 +26,6 @@ | |
npm-debug.log* | ||
yarn-debug.log* | ||
yarn-error.log* | ||
|
||
*storybook.log | ||
test-report.xml |
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,4 @@ | ||
#!/usr/bin/env sh | ||
. "$(dirname "$0")/_/husky.sh" | ||
|
||
npm run test |
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,54 +1,45 @@ | ||
import { dirname, join } from "path"; | ||
import type { StorybookConfig } from '@storybook/react-webpack5'; | ||
import type { StorybookConfig } from '@storybook/react-webpack5' | ||
|
||
import { join, dirname } from 'path' | ||
|
||
/** | ||
* This function is used to resolve the absolute path of a package. | ||
* It is needed in projects that use Yarn PnP or are set up within a monorepo. | ||
*/ | ||
function getAbsolutePath(value: string): any { | ||
return dirname(require.resolve(join(value, 'package.json'))) | ||
} | ||
const config: StorybookConfig = { | ||
stories: ['../src/**/*.stories.mdx', '../src/**/*.stories.@(js|jsx|ts|tsx)'], | ||
addons: [ | ||
getAbsolutePath("@storybook/preset-scss"), | ||
getAbsolutePath("@storybook/addon-links"), | ||
getAbsolutePath("@storybook/addon-essentials"), | ||
getAbsolutePath("@storybook/addon-interactions"), | ||
{ | ||
name: '@storybook/addon-styling', | ||
options: { | ||
sass: { | ||
// Require your Sass preprocessor here | ||
implementation: require('sass'), | ||
stories: ['../src/**/*.mdx', '../src/**/*.stories.@(js|jsx|mjs|ts|tsx)'], | ||
addons: [ | ||
getAbsolutePath('@storybook/addon-webpack5-compiler-swc'), | ||
getAbsolutePath('@storybook/addon-onboarding'), | ||
getAbsolutePath('@storybook/addon-links'), | ||
getAbsolutePath('@storybook/addon-essentials'), | ||
getAbsolutePath('@chromatic-com/storybook'), | ||
getAbsolutePath('@storybook/addon-interactions'), | ||
getAbsolutePath('@storybook/addon-themes'), | ||
], | ||
framework: { | ||
name: getAbsolutePath('@storybook/react-webpack5'), | ||
options: {}, | ||
}, | ||
babel: async (options:any) => { | ||
options.plugins.push('babel-plugin-inline-react-svg') | ||
return options; | ||
}, | ||
swc: () => ({ | ||
jsc: { | ||
transform: { | ||
react: { | ||
runtime: 'automatic', | ||
}, | ||
}, | ||
}, | ||
}, | ||
}), | ||
staticDirs: ['../public'], | ||
docs: { | ||
autodocs: false, | ||
}, | ||
getAbsolutePath("storybook-addon-themes") | ||
], | ||
framework: { | ||
name: getAbsolutePath("@storybook/react-webpack5"), | ||
|
||
options: { | ||
builder: { | ||
fsCache: true, | ||
lazyCompilation: true | ||
} | ||
} | ||
}, | ||
babel: async (options:any) => { | ||
options.plugins.push('babel-plugin-inline-react-svg') | ||
return options; | ||
}, | ||
// webpackFinal: async config => { | ||
// config.resolve.alias = { | ||
// ...(config.resolve.alias || []) | ||
// }; | ||
// config.resolve.extensions.push('.ts', '.tsx') | ||
// return config | ||
// }, | ||
core: {}, | ||
staticDirs: ['../public'], | ||
docs: { | ||
autodocs: false | ||
} | ||
} | ||
|
||
export default config | ||
|
||
function getAbsolutePath(value: string): any { | ||
return dirname(require.resolve(join(value, "package.json"))); | ||
} |
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,3 +0,0 @@ | ||
<div id="root" class='main-root'></div> | ||
<div id="modal-root"></div> | ||
<div id="modal-floating"></div> | ||
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,44 @@ | ||
import React from 'react' | ||
import type { Preview } from '@storybook/react' | ||
import {ThemeProvider} from "@emotion/react"; | ||
import { withThemeByClassName } from '@storybook/addon-themes' | ||
|
||
import plgd from '../src/components/Atomic/_theme/plgd' | ||
import siemens from "../src/components/Atomic/_theme/siemens"; | ||
import Aoo from "../src/components/Atomic/App/App"; | ||
|
||
const preview: Preview = { | ||
parameters: { | ||
controls: { | ||
matchers: { | ||
color: /(background|color)$/i, | ||
date: /Date$/i, | ||
}, | ||
}, | ||
}, | ||
} | ||
|
||
export default preview | ||
|
||
|
||
const withTheme = (StoryFn: any, context: any) => { | ||
const getThemeByKey = (themeName: string) => themeName === 'plgd' ? plgd : siemens | ||
|
||
return ( | ||
<ThemeProvider theme={getThemeByKey(context.globals.theme)}> | ||
<Aoo> | ||
<StoryFn/> | ||
</Aoo> | ||
<div id="modal-root"></div> | ||
<div id="modal-floating"></div> | ||
</ThemeProvider> | ||
) | ||
} | ||
|
||
export const decorators = [withTheme, withThemeByClassName({ | ||
themes: { | ||
plgd: 'plgd-theme', | ||
siemens: 'siemens-theme', | ||
}, | ||
defaultTheme: 'plgd', | ||
})] |
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,14 @@ | ||
const path = require("path"); | ||
|
||
module.exports = function({ config }: any) { | ||
config.module.rules.push({ | ||
test: /\.(ts|tsx)$/, | ||
loader: require.resolve("babel-loader"), | ||
options: { | ||
presets: [["react-app", { flow: false, typescript: true }], require.resolve("@emotion/babel-preset-css-prop")], | ||
}, | ||
}); | ||
|
||
config.resolve.extensions.push(".ts", ".tsx"); | ||
return config; | ||
}; |
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 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,23 @@ | ||
import { render } from '@testing-library/react' | ||
import CodeEditor from './CodeEditor' | ||
|
||
describe('<CodeEditor>', () => { | ||
it('renders without crashing', () => { | ||
const { container, asFragment } = render(<CodeEditor value='' />) | ||
expect(container).toBeInTheDocument() | ||
|
||
expect(asFragment()).toMatchSnapshot() | ||
}) | ||
|
||
it('displays placeholder text when value is empty', () => { | ||
const { getByText, asFragment } = render(<CodeEditor placeholderText='Placeholder' value='' />) | ||
expect(getByText('Placeholder')).toBeInTheDocument() | ||
|
||
expect(asFragment()).toMatchSnapshot() | ||
}) | ||
|
||
it('does not display placeholder text when value is not empty', () => { | ||
const { queryByText } = render(<CodeEditor placeholderText='Placeholder' value='Some value' />) | ||
expect(queryByText('Placeholder')).not.toBeInTheDocument() | ||
}) | ||
}) |
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
Oops, something went wrong.