Skip to content

Commit

Permalink
[DDW-596] Upgraded story files to storybook 6
Browse files Browse the repository at this point in the history
  • Loading branch information
danielmain committed Dec 24, 2021
2 parents fadfb7c + b696f1e commit b53b9d6
Show file tree
Hide file tree
Showing 65 changed files with 3,906 additions and 2,774 deletions.
1 change: 1 addition & 0 deletions netlify.toml
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
[build]
environment = { YARN_VERSION = "1.22.4", NODE_VERSION = "14.17.0" }
command = "yarn && yarn storybook:build"
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,7 @@
"@dump247/storybook-state": "1.6.1",
"@pmmmwh/react-refresh-webpack-plugin": "0.5.3",
"@storybook/addon-actions": "6.4.9",
"@storybook/addon-essentials": "^6.4.9",
"@storybook/addon-knobs": "6.4.0",
"@storybook/addon-links": "6.4.9",
"@storybook/addons": "6.4.9",
Expand Down
11 changes: 7 additions & 4 deletions storybook/main.js
Original file line number Diff line number Diff line change
@@ -1,19 +1,22 @@
const MiniCssExtractPlugin = require('mini-css-extract-plugin');
const path = require('path');
const isCi = process.env.CI && process.env.CI !== '';

module.exports = {
alias: {
Renderer: path.resolve(__dirname, 'source/renderer'),
},
stories: ['./stories/**/*.stories.@(js|mdx|ts)'],
stories: ['../source/**/*.stories.js', './stories/index.js'],
addons: [
'@storybook/addon-essentials',
'@storybook/addon-knobs',
'@storybook/addon-actions',
'@storybook/addon-links',
'@storybook/builder-webpack5',
'@storybook/manager-webpack5',
'./addons/DaedalusMenu/register',
],
previewHead: (head) => `
${head}
${isCi ? '' : '<script src="vendor.dll.js"></script>'}
`,
core: {
builder: 'webpack5',
},
Expand Down
Empty file added storybook/preview-head.html
Empty file.
6 changes: 6 additions & 0 deletions storybook/preview.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
import React from 'react';
import StoryWrapper from './stories/_support/StoryWrapper';
import '!style-loader!css-loader!sass-loader!../source/renderer/app/themes/index.global.scss'; // eslint-disable-line
import './stories/_support/environment';

export const decorators = [(story) => <StoryWrapper>{story}</StoryWrapper>];
2 changes: 1 addition & 1 deletion storybook/stories/assets/Asset.stories.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import { withKnobs, boolean, number, text } from '@storybook/addon-knobs';
import StoryDecorator from '../_support/StoryDecorator';
import Asset from '../../../source/renderer/app/components/assets/Asset';

storiesOf('Assets|Asset pill', module)
storiesOf('Assets/Asset pill', module)
.addDecorator((story) => <StoryDecorator>{story()}</StoryDecorator>)
.addDecorator(withKnobs)

Expand Down
9 changes: 2 additions & 7 deletions storybook/stories/assets/AssetSettingsDialog.stories.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import { storiesOf } from '@storybook/react';
import { action } from '@storybook/addon-actions';
import { withKnobs, number } from '@storybook/addon-knobs';
import StoryDecorator from '../_support/StoryDecorator';
import StoryProvider from '../_support/StoryProvider';
import AssetSettingsDialog from '../../../source/renderer/app/components/assets/AssetSettingsDialog';

const asset = {
Expand All @@ -20,12 +19,8 @@ const asset = {
metadata: null,
};

storiesOf('Assets|AssetSettingsDialog', module)
.addDecorator((story) => (
<StoryProvider>
<StoryDecorator>{story()}</StoryDecorator>
</StoryProvider>
))
storiesOf('Assets/AssetSettingsDialog', module)
.addDecorator((story) => <StoryDecorator>{story()}</StoryDecorator>)
.addDecorator(withKnobs)

// ====== Stories ======
Expand Down
2 changes: 1 addition & 1 deletion storybook/stories/common/ItemsDropdown.stories.js
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ const stakePoolsOptions = stakePoolsList.reduce((obj, pool) => {
return obj;
}, {});

storiesOf('Common|ItemsDropdown', module)
storiesOf('Common/ItemsDropdown', module)
.addDecorator((story: any, context: any) => {
if (context.name === 'CountdownWidget') {
return story();
Expand Down
79 changes: 41 additions & 38 deletions storybook/stories/common/Widgets.stories.js
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ const messages = defineMessages({
},
});

storiesOf('Common|Widgets', module)
storiesOf('Common/Widgets', module)
.addDecorator((story: any, context: any) => {
if (context.name === 'CountdownWidget') {
return story();
Expand Down Expand Up @@ -134,43 +134,46 @@ storiesOf('Common|Widgets', module)
</div>
))

.add('BigButtonForDialogs', (props: { locale: string }) => (
<div>
<div style={{ width: '300px', height: '200px', display: 'flex' }}>
<BigButtonForDialogs
description={intl[props.locale].formatMessage(
messages.createNewWallet
)}
label={intl[props.locale].formatMessage(messages.create)}
icon={createIcon}
onClick={() => {}}
/>
</div>
<div style={{ width: '300px', height: '200px', display: 'flex' }}>
<BigButtonForDialogs
description={intl[props.locale].formatMessage(
messages.joinSharedWallet
)}
label={intl[props.locale].formatMessage(messages.join)}
icon={joinSharedIcon}
onClick={() => {}}
isDisabled
/>
</div>
<div style={{ width: '300px', height: '200px', display: 'flex' }}>
<BigButtonForDialogs
description={intl[props.locale].formatMessage(
messages.importExistingWallet
)}
label={intl[props.locale].formatMessage(messages.import)}
icon={importIcon}
onClick={() => {}}
/>
.add('BigButtonForDialogs', (_, props: { locale: string }) => {
console.log('_', _);
return (
<div>
<div style={{ width: '300px', height: '200px', display: 'flex' }}>
<BigButtonForDialogs
description={intl[props.locale].formatMessage(
messages.createNewWallet
)}
label={intl[props.locale].formatMessage(messages.create)}
icon={createIcon}
onClick={() => {}}
/>
</div>
<div style={{ width: '300px', height: '200px', display: 'flex' }}>
<BigButtonForDialogs
description={intl[props.locale].formatMessage(
messages.joinSharedWallet
)}
label={intl[props.locale].formatMessage(messages.join)}
icon={joinSharedIcon}
onClick={() => {}}
isDisabled
/>
</div>
<div style={{ width: '300px', height: '200px', display: 'flex' }}>
<BigButtonForDialogs
description={intl[props.locale].formatMessage(
messages.importExistingWallet
)}
label={intl[props.locale].formatMessage(messages.import)}
icon={importIcon}
onClick={() => {}}
/>
</div>
</div>
</div>
))
);
})

.add('MnemonicInputWidget - 9 words', (props: { locale: string }) => {
.add('MnemonicInputWidget - 9 words', (_, props: { locale: string }) => {
const tokens = observable(['', '', '', '', '', '', '', '', '']);
return (
<div style={{ padding: 20 }}>
Expand All @@ -187,11 +190,11 @@ storiesOf('Common|Widgets', module)

.add('TinySwitch', () => <TinySwitch />)

.add('TinySwitch - short label', (props: { locale: string }) => (
.add('TinySwitch - short label', (_, props: { locale: string }) => (
<TinySwitch label={intl[props.locale].formatMessage(messages.save)} />
))

.add('ButtonLink', (props: { locale: string }) => (
.add('ButtonLink', (_, props: { locale: string }) => (
<ButtonLink
label={intl[props.locale].formatMessage(messages.save)}
onClick={action('onClick')}
Expand Down
10 changes: 3 additions & 7 deletions storybook/stories/dapps/TransactionRequest.stories.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import { withState } from '@dump247/storybook-state';
import StoryDecorator from '../_support/StoryDecorator';
import DappTransactionRequest from '../../../source/renderer/app/components/dapp/DappTransactionRequest';
import Notification from '../../../source/renderer/app/components/notifications/Notification';
import StoryProvider, { WALLETS_V2 } from '../_support/StoryProvider';
import { WALLETS_V2 } from '../_support/StoryProvider';
import { generateAssetToken } from '../_support/utils';

const allAssets = [
Expand Down Expand Up @@ -37,12 +37,8 @@ const allAssets = [
),
];

storiesOf('dApps|TransactionRequest', module)
.addDecorator((story) => (
<StoryProvider>
<StoryDecorator>{story()}</StoryDecorator>
</StoryProvider>
))
storiesOf('dApps/TransactionRequest', module)
.addDecorator((story) => <StoryDecorator>{story()}</StoryDecorator>)
.addDecorator(withKnobs)

// ====== Stories ======
Expand Down
2 changes: 0 additions & 2 deletions storybook/stories/index.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
// @flow
import '../../source/renderer/app/themes/index.global.scss';
import './_support/environment';

// Wallets
import './wallets';
Expand Down
8 changes: 2 additions & 6 deletions storybook/stories/navigation/Sidebar.stories.js
Original file line number Diff line number Diff line change
Expand Up @@ -109,12 +109,8 @@ const sidebarMenusHardware = observable({

let emptyMenus;

storiesOf('Navigation|Sidebar', module)
.addDecorator((story) => (
<StoryProvider>
<StoryDecorator>{story()}</StoryDecorator>
</StoryProvider>
))
storiesOf('Navigation/Sidebar', module)
.addDecorator((story) => <StoryDecorator>{story()}</StoryDecorator>)
.addDecorator(withKnobs)
// ====== Stories ======
.add('No Category', (props: { currentTheme: string }) => (
Expand Down
2 changes: 1 addition & 1 deletion storybook/stories/navigation/SidebarCategory.stories.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ const category = {
icon: walletsIcon,
route: 'WALLETS',
};
storiesOf('Navigation|Sidebar', module)
storiesOf('Navigation/Sidebar', module)
.addDecorator((story) => <StoryDecorator>{story()}</StoryDecorator>)

// ====== Stories ======
Expand Down
2 changes: 1 addition & 1 deletion storybook/stories/navigation/SidebarWalletsMenu.stories.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import { isShelleyTestnetTheme } from '../_support/utils';
import WalletsWrapper from '../wallets/_utils/WalletsWrapper';
import SidebarWalletsMenu from '../../../source/renderer/app/components/sidebar/wallets/SidebarWalletsMenu';

storiesOf('Navigation|Wallets Menu', module)
storiesOf('Navigation/Wallets Menu', module)
.addDecorator((story) => (
<StoryDecorator>
<div style={{ width: '200px' }}>{story()}</div>
Expand Down
4 changes: 2 additions & 2 deletions storybook/stories/news/AlertsOverlay.stories.js
Original file line number Diff line number Diff line change
Expand Up @@ -84,11 +84,11 @@ const getAlerts = (locale: string) => [
}),
];

storiesOf('News|Overlays', module)
storiesOf('News/Overlays', module)
.addDecorator((story, context) => (
<StoryDecorator>{withKnobs(story, context)}</StoryDecorator>
))
.add('Alerts', (props: { locale: string }) => (
.add('Alerts', (_, props: { locale: string }) => (
<AlertsOverlay
allAlertsCount={getAlerts(props.locale).length}
alerts={getAlerts(props.locale)}
Expand Down
4 changes: 2 additions & 2 deletions storybook/stories/news/AppUpdateOverlay.stories.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,10 @@ import AppUpdateOverlay from '../../../source/renderer/app/components/appUpdate/
import { update, version, availableAppVersion } from './_utils/fakeDataUpdate';
import { rangeMap } from '../../../source/renderer/app/utils/numbers';

storiesOf('News|Overlays', module)
storiesOf('News/Overlays', module)
.addDecorator((story) => <StoryDecorator>{story()}</StoryDecorator>)
.addDecorator(withKnobs)
.add('Update', ({ locale }: { locale: string }) => {
.add('Update', (_, { locale }: { locale: string }) => {
const scenario = radios(
'Scenario',
{
Expand Down
8 changes: 4 additions & 4 deletions storybook/stories/news/IncidentOverlay.stories.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import IncidentOverlay from '../../../source/renderer/app/components/news/Incide
import { dateOptions } from '../_support/profileSettings';
import { DATE_ENGLISH_OPTIONS } from '../../../source/renderer/app/config/profileConfig';

storiesOf('News|Overlays', module)
storiesOf('News/Overlays', module)
.addDecorator((story) => (
<StoryDecorator>
{story({
Expand All @@ -29,7 +29,7 @@ storiesOf('News|Overlays', module)
</StoryDecorator>
))
.addDecorator(withKnobs)
.add('Incident Overlay', (props) => (
.add('Incident Overlay', (_, props) => (
<IncidentOverlay
incident={props}
onOpenExternalLink={action('onOpenExternalLink')}
Expand All @@ -41,7 +41,7 @@ storiesOf('News|Overlays', module)
)}
/>
))
.add('Incident - Themed', (props) => (
.add('Incident - Themed', (_, props) => (
<IncidentOverlay
incident={{
...props,
Expand All @@ -56,7 +56,7 @@ storiesOf('News|Overlays', module)
)}
/>
))
.add('Incident - Grey', (props) => (
.add('Incident - Grey', (_, props) => (
<IncidentOverlay
incident={{
...props,
Expand Down
4 changes: 2 additions & 2 deletions storybook/stories/news/NewsFeed.stories.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ const updateDownloadProgressOptions = {
step: 1,
};

storiesOf('News|NewsFeed', module)
storiesOf('News/NewsFeed', module)
.addDecorator((story, context) => (
<StoryDecorator>{withKnobs(story, context)}</StoryDecorator>
))
Expand Down Expand Up @@ -66,7 +66,7 @@ storiesOf('News|NewsFeed', module)
</div>
))

.add('Fetched', ({ locale }: { locale: string }) => {
.add('Fetched', (_, { locale }: { locale: string }) => {
const displayAppUpdateNewsItem = boolean('displayAppUpdateNewsItem', true);
const updateDownloadProgress = displayAppUpdateNewsItem
? number('updateDownloadProgress', 30, updateDownloadProgressOptions)
Expand Down
2 changes: 1 addition & 1 deletion storybook/stories/nodes/about/About.stories.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import StoryDecorator from '../../_support/StoryDecorator';
import AboutDialog from '../../../../source/renderer/app/containers/static/AboutDialog';
import { aboutDialogProps } from '../_utils/props';

storiesOf('Nodes|About', module)
storiesOf('Nodes/About', module)
.addDecorator((story, context) => (
<StoryDecorator>{withKnobs(story, context)}</StoryDecorator>
))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -107,12 +107,8 @@ const topBarProductionEnv = (currentTheme) => (
</TopBar>
);

storiesOf('Nodes|Environment', module)
.addDecorator((story) => (
<StoryProvider>
<StoryDecorator>{story()}</StoryDecorator>
</StoryProvider>
))
storiesOf('Nodes/Environment', module)
.addDecorator((story) => <StoryDecorator>{story()}</StoryDecorator>)
.addDecorator(withKnobs)
// ====== Stories ======
.add('Testnet', (props: { currentTheme: string }) => (
Expand Down
2 changes: 1 addition & 1 deletion storybook/stories/nodes/errors/Errors.stories.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import StoryDecorator from '../../_support/StoryDecorator';
import { NoDiskSpaceErrorStory } from './NoDiskSpaceError.stories';
import { SystemTimeErrorStory } from './SystemTimeError.stories';

storiesOf('Nodes | Errors', module)
storiesOf('Nodes / Errors', module)
.addDecorator((story, context) => (
<StoryDecorator>{withKnobs(story, context)}</StoryDecorator>
))
Expand Down
5 changes: 4 additions & 1 deletion storybook/stories/nodes/errors/SystemTimeError.stories.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,10 @@ import { action } from '@storybook/addon-actions';

import SystemTimeError from '../../../../source/renderer/app/components/loading/system-time-error/SystemTimeError';

export const SystemTimeErrorStory = ({ locale }: { locale: string }) => (
export const SystemTimeErrorStory = (
_: any,
{ locale }: { locale: string }
) => (
<SystemTimeError
localTimeDifference={number('localTimeDifference', 0)}
currentLocale={locale}
Expand Down
2 changes: 1 addition & 1 deletion storybook/stories/nodes/splash/Splash.stories.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { storiesOf } from '@storybook/react';
import SplashNetworkFlight from '../../../../source/renderer/app/components/splash/SplashNetworkFlight';
import StoryDecorator from '../../_support/StoryDecorator';

storiesOf('Nodes|Splash Network Info', module)
storiesOf('Nodes/Splash Network Info', module)
.addDecorator((story) => <StoryDecorator>{story()}</StoryDecorator>)
.add('Flight', () => (
<SplashNetworkFlight onClose={() => null} openExternalLink={() => null} />
Expand Down
2 changes: 1 addition & 1 deletion storybook/stories/nodes/status/Diagnostics.stories.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ const coreInfo = {
'/Users/daedalus/Library/Application Support/Daedalus Demo',
};

storiesOf('Nodes|Status', module)
storiesOf('Nodes/Status', module)
.addDecorator((story) => <StoryDecorator>{story()}</StoryDecorator>)
.addDecorator(withKnobs)

Expand Down
Loading

0 comments on commit b53b9d6

Please sign in to comment.