Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: storybook does not work #838

Merged
merged 4 commits into from
May 31, 2022
Merged
Show file tree
Hide file tree
Changes from 2 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
14 changes: 7 additions & 7 deletions .github/CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,8 @@ This is a multi-package repository which uses [lerna](https://github.com/lerna/l
- `enigma-mocker`: Public JavaScript API which creates a mocked enigma app to renders visualizations without a connected Qlik engine
- `snapshooter`: Public JavaScript API which captures rendered charts as images
- `conversion`: [private] Provides conversion functionality to extensions with hyperCubes.
- `theme`: [private] Access/consume the currently applied theme
- `locale`: [private] Handle translation string to generate all locales
- `theme`: [private] Accesses/consumes the currently applied theme
- `locale`: [private] Handles translation string to generate all locales
LiKang6688 marked this conversation as resolved.
Show resolved Hide resolved
- `commands` - CLI commands
- `build`: cli command to build a supernova
- `cli`: entry point for all cli commands
Expand All @@ -54,15 +54,15 @@ This is a multi-package repository which uses [lerna](https://github.com/lerna/l

### Development workflow

- `yarn` install all dependencies
- `yarn run build` generates UMD bundles for all packages and a ESM bundle for stardust
- `yarn` installs all dependencies
- `yarn run build` generates UMD bundles for all packages and an ESM bundle for stardust
- `yarn run lint` checks code style
- `yarn run format` format code style
- `yarn run format` formats code style
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

keep as is.

- `yarn run test` runs all tests

### Cutting a release

**Prerelase**
**Pre-release**

```sh
npx lerna version --no-git-tag-version --no-push --no-conventional-commits --preid alpha --exact
Expand Down Expand Up @@ -136,4 +136,4 @@ The `<scope>` of the commit is optional and can be omitted. When used though, it

## <a name="cla"></a> Signing the CLA

We need you to sign our Contributor License Agreement (CLA) before we can accept your Pull Request. Visit this link for more information: https://github.com/qlik-oss/open-source/blob/master/sign-cla.md.
We need you to sign our Contributor License Agreement (CLA) before we can accept your Pull Request. Visit this link for more information: <https://github.com/qlik-oss/open-source/blob/master/sign-cla.md>.
1 change: 0 additions & 1 deletion .storybook/addons.js

This file was deleted.

41 changes: 0 additions & 41 deletions .storybook/config.js

This file was deleted.

17 changes: 17 additions & 0 deletions .storybook/main.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
module.exports = {
stories: [
'../apis/nucleus/src/components/**/__stories__/**/*.stories.mdx',
'../apis/nucleus/src/components/**/__stories__/**/*.stories.@(js|jsx|ts|tsx)',
],
addons: [
'@storybook/addon-links',
'@storybook/addon-essentials',
'@storybook/addon-interactions',
'@storybook/addon-controls',
'@storybook/addon-docs',
],
framework: '@storybook/react',
core: {
builder: '@storybook/builder-webpack5',
},
};
1 change: 0 additions & 1 deletion .storybook/presets.js

This file was deleted.

32 changes: 32 additions & 0 deletions .storybook/preview.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
import React from 'react';
import { createTheme, ThemeProvider } from '@nebula.js/ui/theme';

import InstanceContext from '../apis/nucleus/src/contexts/InstanceContext';

const translator = {
get(s) {
return s;
},
};

const t = createTheme('light');

export const decorators = [
(Story) => (
<ThemeProvider theme={t}>
<InstanceContext.Provider value={{ translator }}>
<Story />
</InstanceContext.Provider>
</ThemeProvider>
),
];

export const parameters = {
actions: { argTypesRegex: '^on[A-Z].*' },
controls: {
matchers: {
color: /(background|color)$/i,
date: /Date$/,
},
},
};
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import React from 'react';
import { Grid } from '@material-ui/core';
import { text, boolean } from '@storybook/addon-knobs'; // eslint-disable-line

import { AppSelections } from '../AppSelections';

export default {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import React from 'react';
import { Grid } from '@material-ui/core';
import { text, boolean } from '@storybook/addon-knobs'; // eslint-disable-line

import MultiState from '../MultiState';

export default {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import React from 'react';
import { Grid } from '@material-ui/core';
import { text, boolean } from '@storybook/addon-knobs'; // eslint-disable-line

import OneField from '../OneField';

export default {
Expand All @@ -25,8 +24,11 @@ const api = {
return false;
},
};

const states = [
const info = {
states: ['$'],
qField: 'Product',
};
const selections = [
{ info: 'None', qTotal: 0 },
{
info: 'One locked',
Expand Down Expand Up @@ -60,28 +62,46 @@ const states = [
},
];

const stateFn = (state) => (
<OneField
api={api}
field={{
states: [text('State', '$')],
selections: [{ qField: text('Field', 'Product'), ...state, qLocked: !!state.qLocked }],
}}
/>
);
function Template(args) {
const { states, qLocked, ...rest } = args;

return (
<OneField
api={api}
field={{
states,
selections: [{ ...rest, qLocked: !!qLocked }],
}}
/>
);
}

export const locked = Template.bind({});
locked.args = {
...info,
...selections[1],
};

export const none = Template.bind({});
none.args = {
...info,
...selections[0],
};

export const one = Template.bind({});
one.args = {
...info,
...selections[2],
};

export const fields = () => (
<Grid container spacing={1} wrap="nowrap">
<Grid item>{stateFn(states[0])}</Grid>
<Grid item>{stateFn(states[1])}</Grid>
<Grid item>{stateFn(states[2])}</Grid>
<Grid item>{stateFn(states[3])}</Grid>
<Grid item>{stateFn(states[4])}</Grid>
</Grid>
);
export const some = Template.bind({});
some.args = {
...info,
...selections[3],
};

export const none = () => stateFn(states[0]);
export const locked = () => stateFn(states[1]);
export const one = () => stateFn(states[2]);
export const some = () => stateFn(states[3]);
export const all = () => stateFn(states[4]);
export const all = Template.bind({});
all.args = {
...info,
...selections[4],
};
19 changes: 14 additions & 5 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@
"locale:generate": "node apis/locale/scripts/generate-all.mjs",
"lint": "eslint packages apis commands --ext .js,.jsx",
"lint:check": "eslint --print-config ./aw.config.js | eslint-config-prettier-check",
"start:ui": "start-storybook",
"storybook": "start-storybook -p 6006",
"build-storybook": "build-storybook",
"spec": "lerna run spec --stream --concurrency 99 && lerna run ts --stream --concurrency 99 ",
"test": "yarn run test:unit",
"mashup": "node scripts/start-mashup.js",
Expand Down Expand Up @@ -44,9 +45,16 @@
"@rollup/plugin-json": "4.1.0",
"@rollup/plugin-node-resolve": "13.3.0",
"@rollup/plugin-replace": "4.0.0",
"@storybook/addon-docs": "6.4.22",
"@storybook/addon-knobs": "6.4.0",
"@storybook/react": "6.4.22",
"@storybook/addon-docs": "6.5.6",
"@storybook/addon-controls": "6.5.6",
"@storybook/addon-actions": "6.5.6",
"@storybook/addon-essentials": "6.5.6",
"@storybook/addon-interactions": "6.5.6",
"@storybook/addon-links": "6.5.6",
"@storybook/builder-webpack5": "6.5.6",
"@storybook/manager-webpack5": "6.5.6",
"@storybook/react": "6.5.6",
"@storybook/testing-library": "0.0.11",
"babel-loader": "8.2.5",
"babel-plugin-istanbul": "6.1.1",
"body-parser": "1.20.0",
Expand All @@ -60,8 +68,9 @@
"eslint-plugin-mocha": "10.0.4",
"eslint-plugin-prettier": "4.0.0",
"eslint-plugin-react": "7.29.4",
"eslint-plugin-storybook": "0.5.12",
"express": "4.18.1",
"husky": "^7.0.4",
"husky": "7.0.4",
"jimp": "0.16.1",
"lerna": "4.0.0",
"lint-staged": "12.4.1",
Expand Down
Loading