mirror of
https://github.com/scm-manager/scm-manager.git
synced 2025-11-14 09:25:43 +01:00
added storybook to ui-components
This commit is contained in:
1
scm-ui/ui-components/.storybook/addons.js
Normal file
1
scm-ui/ui-components/.storybook/addons.js
Normal file
@@ -0,0 +1 @@
|
|||||||
|
import 'storybook-addon-i18next/register';
|
||||||
28
scm-ui/ui-components/.storybook/config.js
Normal file
28
scm-ui/ui-components/.storybook/config.js
Normal file
@@ -0,0 +1,28 @@
|
|||||||
|
import i18n from "i18next";
|
||||||
|
import { reactI18nextModule } from "react-i18next";
|
||||||
|
import { addDecorator, configure } from "@storybook/react";
|
||||||
|
import { withI18next } from "storybook-addon-i18next";
|
||||||
|
|
||||||
|
import "!style-loader!css-loader!sass-loader!../../ui-webapp/src/style/scm.scss";
|
||||||
|
|
||||||
|
i18n.use(reactI18nextModule).init({
|
||||||
|
whitelist: ["en", "de", "es"],
|
||||||
|
lng: "en",
|
||||||
|
fallbackLng: "en",
|
||||||
|
interpolation: {
|
||||||
|
escapeValue: false
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
addDecorator(
|
||||||
|
withI18next({
|
||||||
|
i18n,
|
||||||
|
languages: {
|
||||||
|
en: "English",
|
||||||
|
de: "Deutsch",
|
||||||
|
es: "Spanisch"
|
||||||
|
}
|
||||||
|
})
|
||||||
|
);
|
||||||
|
|
||||||
|
configure(require.context("../src", true, /\.stories\.js$/), module);
|
||||||
@@ -12,16 +12,22 @@
|
|||||||
"license": "BSD-3-Clause",
|
"license": "BSD-3-Clause",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"eslint-fix": "eslint src --fix",
|
"eslint-fix": "eslint src --fix",
|
||||||
"test": "jest"
|
"test": "jest",
|
||||||
|
"storybook": "start-storybook"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
|
"@storybook/addon-actions": "^5.2.3",
|
||||||
|
"@storybook/addon-storyshots": "^5.2.3",
|
||||||
|
"@storybook/react": "^5.2.3",
|
||||||
"enzyme": "^3.5.0",
|
"enzyme": "^3.5.0",
|
||||||
"enzyme-adapter-react-16": "^1.3.1",
|
"enzyme-adapter-react-16": "^1.3.1",
|
||||||
"fetch-mock": "^7.5.1",
|
"fetch-mock": "^7.5.1",
|
||||||
"flow-bin": "^0.109.0",
|
"flow-bin": "^0.109.0",
|
||||||
"flow-typed": "^2.5.1",
|
"flow-typed": "^2.5.1",
|
||||||
"raf": "^3.4.0",
|
"raf": "^3.4.0",
|
||||||
"react-router-enzyme-context": "^1.2.0"
|
"react-router-enzyme-context": "^1.2.0",
|
||||||
|
"storybook-addon-i18next": "^1.2.1",
|
||||||
|
"storybook-react-router": "^1.0.8"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@scm-manager/ui-extensions": "^0.1.2",
|
"@scm-manager/ui-extensions": "^0.1.2",
|
||||||
@@ -32,7 +38,7 @@
|
|||||||
"react": "^16.8.6",
|
"react": "^16.8.6",
|
||||||
"react-diff-view": "^1.8.1",
|
"react-diff-view": "^1.8.1",
|
||||||
"react-dom": "^16.8.6",
|
"react-dom": "^16.8.6",
|
||||||
"react-i18next": "^7.11.0",
|
"react-i18next": "^7.9.0",
|
||||||
"react-jss": "^8.6.1",
|
"react-jss": "^8.6.1",
|
||||||
"react-markdown": "^4.0.6",
|
"react-markdown": "^4.0.6",
|
||||||
"react-router-dom": "^4.3.1",
|
"react-router-dom": "^4.3.1",
|
||||||
@@ -45,6 +51,9 @@
|
|||||||
"jest": {
|
"jest": {
|
||||||
"transform": {
|
"transform": {
|
||||||
"^.+\\.js$": "../scripts/babelMonoRepoTransformer.js"
|
"^.+\\.js$": "../scripts/babelMonoRepoTransformer.js"
|
||||||
|
},
|
||||||
|
"moduleNameMapper": {
|
||||||
|
"\\.(css|scss|sass)$": "<rootDir>/src/tests/styleMock.js"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
14
scm-ui/ui-components/src/DateFromNow.stories.js
Normal file
14
scm-ui/ui-components/src/DateFromNow.stories.js
Normal file
@@ -0,0 +1,14 @@
|
|||||||
|
import React from "react";
|
||||||
|
import DateFromNow from "./DateFromNow";
|
||||||
|
import { storiesOf } from "@storybook/react";
|
||||||
|
|
||||||
|
storiesOf("DateFromNow", module).add("Default", () => (
|
||||||
|
<div>
|
||||||
|
<p>
|
||||||
|
<DateFromNow date="2009-06-30T18:30:00+02:00" />
|
||||||
|
</p>
|
||||||
|
<p>
|
||||||
|
<DateFromNow date="2019-06-30T18:30:00+02:00" />
|
||||||
|
</p>
|
||||||
|
</div>
|
||||||
|
));
|
||||||
23
scm-ui/ui-components/src/buttons/Button.stories.js
Normal file
23
scm-ui/ui-components/src/buttons/Button.stories.js
Normal file
@@ -0,0 +1,23 @@
|
|||||||
|
import React from "react";
|
||||||
|
import Button from "./Button";
|
||||||
|
import { storiesOf } from "@storybook/react";
|
||||||
|
import StoryRouter from "storybook-react-router";
|
||||||
|
import styled from "styled-components";
|
||||||
|
|
||||||
|
const colors = ["primary", "success", "info", "warning", "danger", "black"];
|
||||||
|
|
||||||
|
const Spacing = styled.div`
|
||||||
|
padding: 1em;
|
||||||
|
`;
|
||||||
|
|
||||||
|
storiesOf("Button", module)
|
||||||
|
.addDecorator(StoryRouter())
|
||||||
|
.add("Colors", () => (
|
||||||
|
<div>
|
||||||
|
{colors.map(color => (
|
||||||
|
<Spacing>
|
||||||
|
<Button color={color} label={color} />
|
||||||
|
</Spacing>
|
||||||
|
))}
|
||||||
|
</div>
|
||||||
|
));
|
||||||
1
scm-ui/ui-components/src/tests/styleMock.js
Normal file
1
scm-ui/ui-components/src/tests/styleMock.js
Normal file
@@ -0,0 +1 @@
|
|||||||
|
module.exports = {};
|
||||||
Reference in New Issue
Block a user