1
0
mirror of https://github.com/kremalicious/metamask-extension.git synced 2024-11-22 09:57:02 +01:00

Renaming broken stories to clean up console (#16905)

* Renaming broken stories. Fixing deprecated default arg syntax for stories using defaultValue

* Fixing imports
This commit is contained in:
George Marshall 2022-12-15 14:46:30 -08:00 committed by GitHub
parent 1acb1b2e5d
commit 09d29ef00d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
18 changed files with 119 additions and 137 deletions

View File

@ -30,7 +30,7 @@ module.exports = {
return { return {
...config, ...config,
// Creates the icon names environment variable for the component-library/icon/icon.js component // Creates the icon names environment variable for the component-library/icon/icon.js component
ICON_NAMES: await generateIconNames(), ICON_NAMES: generateIconNames(),
}; };
}, },
webpackFinal: async (config) => { webpackFinal: async (config) => {
@ -96,7 +96,7 @@ module.exports = {
new ProvidePlugin({ new ProvidePlugin({
Buffer: ['buffer', 'Buffer'], Buffer: ['buffer', 'Buffer'],
}), }),
) );
return config; return config;
}, },
}; };

View File

@ -60,7 +60,6 @@ export default {
display: { display: {
options: Object.values(DISPLAY), options: Object.values(DISPLAY),
control: 'select', control: 'select',
defaultValue: DISPLAY.FLEX,
table: { category: 'box props' }, table: { category: 'box props' },
}, },
marginTop: { marginTop: {

View File

@ -12,7 +12,7 @@ import {
import Box from '../../ui/box/box'; import Box from '../../ui/box/box';
import { Icon } from '../icon'; import { Icon, ICON_NAMES } from '../icon';
import { AvatarBase } from '../avatar-base'; import { AvatarBase } from '../avatar-base';
import { AVATAR_ICON_SIZES } from './avatar-icon.constants'; import { AVATAR_ICON_SIZES } from './avatar-icon.constants';
@ -48,7 +48,7 @@ AvatarIcon.propTypes = {
* *
* The name of the icon to display. Should be one of ICON_NAMES * The name of the icon to display. Should be one of ICON_NAMES
*/ */
iconName: PropTypes.string.isRequired, // Can't set PropTypes.oneOf(ICON_NAMES) because ICON_NAMES is an environment variable iconName: PropTypes.oneOf(Object.values(ICON_NAMES)).isRequired,
/** /**
* Props for the icon inside AvatarIcon. All Icon props can be used * Props for the icon inside AvatarIcon. All Icon props can be used
*/ */

View File

@ -10,7 +10,7 @@ import {
ICON_COLORS, ICON_COLORS,
} from '../../../helpers/constants/design-system'; } from '../../../helpers/constants/design-system';
import { ICON_SIZES } from './icon.constants'; import { ICON_SIZES, ICON_NAMES } from './icon.constants';
export const Icon = ({ export const Icon = ({
name, name,
@ -43,7 +43,7 @@ Icon.propTypes = {
/** /**
* The name of the icon to display. Should be one of ICON_NAMES * The name of the icon to display. Should be one of ICON_NAMES
*/ */
name: PropTypes.string.isRequired, // Can't set PropTypes.oneOf(ICON_NAMES) because ICON_NAMES is an environment variable name: PropTypes.oneOf(Object.values(ICON_NAMES)).isRequired,
/** /**
* The size of the Icon. * The size of the Icon.
* Possible values could be SIZES.XXS (10px), SIZES.XS (12px), SIZES.SM (16px), SIZES.MD (20px), SIZES.LG (24px), SIZES.XL (32px), * Possible values could be SIZES.XXS (10px), SIZES.XS (12px), SIZES.SM (16px), SIZES.MD (20px), SIZES.LG (24px), SIZES.XL (32px),

View File

@ -55,29 +55,24 @@ export default {
size: { size: {
control: { type: 'range', min: 50, max: 500, step: 10 }, control: { type: 'range', min: 50, max: 500, step: 10 },
table: { category: 'children' }, table: { category: 'children' },
defaultValue: 100,
}, },
items: { items: {
control: 'number', control: 'number',
table: { category: 'children' }, table: { category: 'children' },
defaultValue: 1,
}, },
display: { display: {
options: Object.values(DISPLAY), options: Object.values(DISPLAY),
control: 'select', control: 'select',
defaultValue: DISPLAY.BLOCK,
table: { category: 'display' }, table: { category: 'display' },
}, },
width: { width: {
options: Object.values(BLOCK_SIZES), options: Object.values(BLOCK_SIZES),
control: 'select', control: 'select',
defaultValue: BLOCK_SIZES.HALF,
table: { category: 'display' }, table: { category: 'display' },
}, },
height: { height: {
options: Object.values(BLOCK_SIZES), options: Object.values(BLOCK_SIZES),
control: 'select', control: 'select',
defaultValue: BLOCK_SIZES.HALF,
table: { category: 'display' }, table: { category: 'display' },
}, },
gap: { gap: {
@ -100,7 +95,6 @@ export default {
borderStyle: { borderStyle: {
options: Object.values(BORDER_STYLE), options: Object.values(BORDER_STYLE),
control: 'select', control: 'select',
defaultValue: BORDER_STYLE.DASHED,
table: { category: 'border' }, table: { category: 'border' },
}, },
borderWidth: { borderWidth: {
@ -111,7 +105,6 @@ export default {
borderColor: { borderColor: {
options: Object.values(BORDER_COLORS), options: Object.values(BORDER_COLORS),
control: 'select', control: 'select',
defaultValue: COLORS.BORDER_DEFAULT,
table: { category: 'border' }, table: { category: 'border' },
}, },
borderRadius: { borderRadius: {
@ -132,19 +125,16 @@ export default {
justifyContent: { justifyContent: {
options: Object.values(JUSTIFY_CONTENT), options: Object.values(JUSTIFY_CONTENT),
control: 'select', control: 'select',
defaultValue: JUSTIFY_CONTENT.FLEX_START,
table: { category: 'display' }, table: { category: 'display' },
}, },
alignItems: { alignItems: {
options: Object.values(ALIGN_ITEMS), options: Object.values(ALIGN_ITEMS),
control: 'select', control: 'select',
defaultValue: ALIGN_ITEMS.FLEX_START,
table: { category: 'display' }, table: { category: 'display' },
}, },
textAlign: { textAlign: {
options: Object.values(TEXT_ALIGN), options: Object.values(TEXT_ALIGN),
control: 'select', control: 'select',
defaultValue: TEXT_ALIGN.LEFT,
table: { category: 'text' }, table: { category: 'text' },
}, },
margin: { margin: {
@ -203,6 +193,18 @@ export default {
table: { category: 'as (root html element)' }, table: { category: 'as (root html element)' },
}, },
}, },
args: {
size: 100,
items: 1,
display: DISPLAY.BLOCK,
width: BLOCK_SIZES.HALF,
height: BLOCK_SIZES.HALF,
borderStyle: BORDER_STYLE.DASHED,
borderColor: COLORS.BORDER_DEFAULT,
justifyContent: JUSTIFY_CONTENT.FLEX_START,
alignItems: ALIGN_ITEMS.FLEX_START,
textAlign: TEXT_ALIGN.LEFT,
},
}; };
export const DefaultStory = (args) => { export const DefaultStory = (args) => {
@ -220,7 +222,11 @@ export const DefaultStory = (args) => {
/>, />,
); );
} }
return <Box {...rest}>{children}</Box>; return (
<Box {...rest} borderColor={COLORS.BORDER_MUTED}>
{children}
</Box>
);
}; };
DefaultStory.storyName = 'Default'; DefaultStory.storyName = 'Default';

View File

@ -11,30 +11,31 @@ export default {
type: 'select', type: 'select',
}, },
options: SIZES, options: SIZES,
defaultValue: SIZES.LG,
}, },
type: { type: {
control: { control: {
type: 'select', type: 'select',
}, },
options: ColorIndicator.TYPES, options: ColorIndicator.TYPES,
defaultValue: ColorIndicator.TYPES.FILLED,
}, },
color: { color: {
control: { control: {
type: 'select', type: 'select',
}, },
options: COLORS, options: COLORS,
defaultValue: COLORS.PRIMARY_DEFAULT,
}, },
borderColor: { borderColor: {
control: { control: {
type: 'select', type: 'select',
}, },
options: { NONE: undefined, ...COLORS }, options: { NONE: undefined, ...COLORS },
defaultValue: undefined,
}, },
}, },
args: {
size: SIZES.LG,
type: ColorIndicator.TYPES.FILLED,
color: COLORS.PRIMARY_DEFAULT,
},
}; };
export const DefaultStory = (args) => ( export const DefaultStory = (args) => (

View File

@ -79,14 +79,17 @@ export const SendComponent = (args) => (
SendComponent.argTypes = { SendComponent.argTypes = {
secondaryButtonText: { secondaryButtonText: {
control: 'text', control: 'text',
defaultValue: 'Speed up',
}, },
cancelButtonText: { cancelButtonText: {
control: 'text', control: 'text',
defaultValue: 'Cancel',
}, },
}; };
SendComponent.args = {
secondaryButtonText: 'Speed up',
cancelButtonText: 'Cancel',
};
export const PendingComponent = (args) => ( export const PendingComponent = (args) => (
<ListItem <ListItem
title={args.title} title={args.title}

View File

@ -5,7 +5,18 @@ export default {
title: 'Components/UI/TruncatedDefinitionList', title: 'Components/UI/TruncatedDefinitionList',
id: __filename, id: __filename,
argTypes: { argTypes: {
title: { control: 'text', defaultValue: 'Basic definitions' }, title: {
control: 'text',
},
dictionary: {
control: 'object',
},
prefaceKeys: {
control: 'object',
},
},
args: {
title: 'Basic definitions',
}, },
}; };
@ -32,32 +43,17 @@ const tooltips = {
export const DefaultStory = (args) => <TruncatedDefinitionList {...args} />; export const DefaultStory = (args) => <TruncatedDefinitionList {...args} />;
DefaultStory.argTypes = {
dictionary: {
control: 'object',
defaultValue: basic,
},
prefaceKeys: {
control: 'object',
defaultValue: ['term', 'definition'],
},
};
DefaultStory.storyName = 'Default'; DefaultStory.storyName = 'Default';
DefaultStory.args = {
dictionary: basic,
prefaceKeys: ['term', 'definition'],
};
export const WithTooltips = (args) => <TruncatedDefinitionList {...args} />; export const WithTooltips = (args) => <TruncatedDefinitionList {...args} />;
WithTooltips.argTypes = { WithTooltips.args = {
dictionary: { dictionary: advanced,
control: 'object', tooltips,
defaultValue: advanced, prefaceKeys: ['Chain ID'],
},
tooltips: {
control: 'object',
defaultValue: tooltips,
},
prefaceKeys: {
control: 'array',
defaultValue: ['Chain ID'],
},
}; };

View File

@ -15,15 +15,17 @@ export default {
argTypes: { argTypes: {
address: { address: {
control: { type: 'text' }, control: { type: 'text' },
defaultValue: '0xdeDbcA0156308960E3bBa2f5a273E72179940788',
}, },
showPopover: { showPopover: {
control: { type: 'boolean' }, control: { type: 'boolean' },
defaultValue: false,
}, },
onAdd: { action: 'onAdd' }, onAdd: { action: 'onAdd' },
onClose: { action: 'onClose' }, onClose: { action: 'onClose' },
}, },
args: {
address: '0xdeDbcA0156308960E3bBa2f5a273E72179940788',
showPopover: false,
},
}; };
export const DefaultStory = (args) => { export const DefaultStory = (args) => {

View File

@ -10,6 +10,7 @@ import { store, getNewState } from '../../../.storybook/preview';
import { subjectMetadata } from '../../../.storybook/initial-states/approval-screens/token-approval'; import { subjectMetadata } from '../../../.storybook/initial-states/approval-screens/token-approval';
import ConfirmApprove from '.'; import ConfirmApprove from '.';
// eslint-disable-next-line import/no-anonymous-default-export
export default { export default {
title: 'Pages/ConfirmApprove', title: 'Pages/ConfirmApprove',
id: __filename, id: __filename,

View File

@ -2,6 +2,7 @@
import React from 'react'; import React from 'react';
import ConfirmDeployContract from '.'; import ConfirmDeployContract from '.';
// eslint-disable-next-line import/no-anonymous-default-export
export default { export default {
title: 'Pages/ConfirmDeployContract', title: 'Pages/ConfirmDeployContract',
id: __filename, id: __filename,

View File

@ -1,6 +1,7 @@
import React from 'react'; import React from 'react';
import ConfirmSendEther from '.'; import ConfirmSendEther from '.';
// eslint-disable-next-line import/no-anonymous-default-export
export default { export default {
title: 'Pages/ConfirmSendEther', title: 'Pages/ConfirmSendEther',
id: __filename, id: __filename,

View File

@ -1,6 +1,7 @@
import React from 'react'; import React from 'react';
import ConfirmSendToken from './confirm-send-token.component'; import ConfirmSendToken from './confirm-send-token.component';
// eslint-disable-next-line import/no-anonymous-default-export
export default { export default {
title: 'Pages/ConfirmSendToken', title: 'Pages/ConfirmSendToken',
id: __filename, id: __filename,

View File

@ -2,6 +2,7 @@ import React from 'react';
import { store } from '../../../.storybook/preview'; import { store } from '../../../.storybook/preview';
import ConfirmTokenTransactionBase from './confirm-token-transaction-base'; import ConfirmTokenTransactionBase from './confirm-token-transaction-base';
// eslint-disable-next-line import/no-anonymous-default-export
export default { export default {
title: 'Pages/ConfirmTokenTransactionBase', title: 'Pages/ConfirmTokenTransactionBase',
id: __filename, id: __filename,

View File

@ -2,6 +2,7 @@ import React from 'react';
import ConfirmTransactionBase from '.'; import ConfirmTransactionBase from '.';
// eslint-disable-next-line import/no-anonymous-default-export
export default { export default {
title: 'Pages/ConfirmTransactionBase', title: 'Pages/ConfirmTransactionBase',
id: __filename, id: __filename,

View File

@ -94,13 +94,11 @@ export const ErrorStory = (args) => {
</div> </div>
); );
}; };
ErrorStory.argTypes = {
// domainError must be the key for a translation
domainError: { type: 'text', defaultValue: 'loading' },
};
ErrorStory.storyName = 'Error'; ErrorStory.storyName = 'Error';
ErrorStory.args = {
// domainError must be the key for a translation
domainError: 'loading',
};
export const WarningStory = (args) => { export const WarningStory = (args) => {
return ( return (
@ -113,10 +111,8 @@ export const WarningStory = (args) => {
</div> </div>
); );
}; };
WarningStory.argTypes = {
// domainWarning must be the key for a translation
domainWarning: { type: 'text', defaultValue: 'loading' },
};
WarningStory.storyName = 'Warning'; WarningStory.storyName = 'Warning';
WarningStory.args = {
// domainWarning must be the key for a translation
domainWarning: 'loading',
};

View File

@ -23,11 +23,12 @@ export default {
}, },
argTypes: { argTypes: {
insufficientBalance: { insufficientBalance: {
name: 'Is Insufficient Balance',
control: { type: 'boolean' }, control: { type: 'boolean' },
defaultValue: false,
}, },
}, },
args: {
insufficientBalance: false,
},
}; };
export const DefaultStory = (args) => { export const DefaultStory = (args) => {

View File

@ -4,6 +4,36 @@ import ExchangeRateDisplay from './exchange-rate-display';
export default { export default {
title: 'Pages/Swaps/ExchangeRateDisplay', title: 'Pages/Swaps/ExchangeRateDisplay',
id: __filename, id: __filename,
argTypes: {
primaryTokenValue: {
control: {
type: 'text',
},
},
primaryTokenDecimals: {
control: {
type: 'number',
},
},
primaryTokenSymbol: {
control: {
type: 'text',
},
},
secondaryTokenValue: {
control: {
type: 'text',
},
},
secondaryTokenDecimals: {
control: 'number',
},
secondaryTokenSymbol: {
control: {
type: 'text',
},
},
},
}; };
export const DefaultStory = (args) => { export const DefaultStory = (args) => {
@ -12,41 +42,13 @@ export const DefaultStory = (args) => {
DefaultStory.storyName = 'Default'; DefaultStory.storyName = 'Default';
DefaultStory.argTypes = { DefaultStory.args = {
primaryTokenValue: { primaryTokenValue: '2000000000000000000',
control: { primaryTokenDecimals: 18,
type: 'text', primaryTokenSymbol: 'ETH',
}, secondaryTokenValue: '200000000000000000',
defaultValue: '2000000000000000000', secondaryTokenDecimals: 18,
}, secondaryTokenSymbol: 'ABC',
primaryTokenDecimals: {
control: {
type: 'number',
},
defaultValue: 18,
},
primaryTokenSymbol: {
control: {
type: 'text',
},
defaultValue: 'ETH',
},
secondaryTokenValue: {
control: {
type: 'text',
},
defaultValue: '200000000000000000',
},
secondaryTokenDecimals: {
control: 'number',
defaultValue: 18,
},
secondaryTokenSymbol: {
control: {
type: 'text',
},
defaultValue: 'ABC',
},
}; };
export const WhiteOnBlue = (args) => { export const WhiteOnBlue = (args) => {
@ -68,41 +70,11 @@ export const WhiteOnBlue = (args) => {
); );
}; };
WhiteOnBlue.argTypes = { WhiteOnBlue.args = {
primaryTokenValue: { primaryTokenValue: '2000000000000000000',
control: { primaryTokenDecimals: 18,
type: 'text', primaryTokenSymbol: 'ETH',
}, secondaryTokenValue: '200000000000000000',
defaultValue: '2000000000000000000', secondaryTokenDecimals: 18,
}, secondaryTokenSymbol: 'ABC',
primaryTokenDecimals: {
control: {
type: 'number',
},
defaultValue: 18,
},
primaryTokenSymbol: {
control: {
type: 'text',
},
defaultValue: 'ETH',
},
secondaryTokenValue: {
control: {
type: 'text',
},
defaultValue: '200000000000000000',
},
secondaryTokenDecimals: {
control: {
type: 'number',
},
defaultValue: 18,
},
secondaryTokenSymbol: {
control: {
type: 'text',
},
defaultValue: 'ABC',
},
}; };