1
0
mirror of https://github.com/kremalicious/metamask-extension.git synced 2024-11-23 02:10:12 +01:00
metamask-extension/ui/components/app/cancel-speedup-popover/cancel-speedup-popover.stories.js
Matthias Kretschmann 113fdc189c
Part of #17670: Replace Typography with Text component in CancelSpeedupPopover (#18638)
* create story

* replace Typography with Text component

* review changes

* replace CSS with props styling
* use `Button` from `component-library`
* tooltip HTML refactor with `component-library` components
* remove whitespace in story

* strong tag support within Text component

* addresses #18651
* taken from #18752 as suggested in https://github.com/MetaMask/metamask-extension/pull/18638#discussion_r1176334805

* replace `strong` with new `Text as="strong"`

* remove unneccessary css from fa564e3f036f1439f9f220cca23595b508760614

* add text variant definition

* Updating text variant of button

* restrore proper spacing between elements

* Quick fix for test

* Adding key

---------

Co-authored-by: georgewrmarshall <george.marshall@consensys.net>
Co-authored-by: Garrett Bear <gwhisten@gmail.com>
2023-06-26 13:52:54 -07:00

81 lines
2.4 KiB
JavaScript

import React from 'react';
import { Provider } from 'react-redux';
import BigNumber from 'bignumber.js';
import configureStore from '../../../store/store';
import { TransactionModalContext } from '../../../contexts/transaction-modal';
import mockEstimates from '../../../../test/data/mock-estimates.json';
import mockState from '../../../../test/data/mock-state.json';
import {
EditGasModes,
GasEstimateTypes,
} from '../../../../shared/constants/gas';
import { decGWEIToHexWEI } from '../../../../shared/modules/conversion.utils';
import { GasFeeContextProvider } from '../../../contexts/gasFee';
import CancelSpeedupPopover from './cancel-speedup-popover';
const store = configureStore({
metamask: {
...mockState.metamask,
accounts: {
[mockState.metamask.selectedAddress]: {
address: mockState.metamask.selectedAddress,
balance: '0x1F4',
},
},
gasFeeEstimates: mockEstimates[GasEstimateTypes.feeMarket].gasFeeEstimates,
},
});
const MOCK_SUGGESTED_MEDIUM_MAXFEEPERGAS_DEC_GWEI =
mockEstimates[GasEstimateTypes.feeMarket].gasFeeEstimates.medium
.suggestedMaxFeePerGas;
const MOCK_SUGGESTED_MEDIUM_MAXFEEPERGAS_BN_WEI = new BigNumber(
decGWEIToHexWEI(MOCK_SUGGESTED_MEDIUM_MAXFEEPERGAS_DEC_GWEI),
16,
);
const MOCK_SUGGESTED_MEDIUM_MAXFEEPERGAS_HEX_WEI =
MOCK_SUGGESTED_MEDIUM_MAXFEEPERGAS_BN_WEI.toString(16);
export default {
title: 'Components/App/CancelSpeedupPopover',
component: CancelSpeedupPopover,
decorators: [
(story) => (
<Provider store={store}>
<GasFeeContextProvider
transaction={{
userFeeLevel: 'tenPercentIncreased',
txParams: {
gas: '0x5208',
maxFeePerGas: MOCK_SUGGESTED_MEDIUM_MAXFEEPERGAS_HEX_WEI,
maxPriorityFeePerGas: '0x59682f00',
},
}}
editGasMode={EditGasModes.cancel}
>
<TransactionModalContext.Provider
value={{
closeModal: () => undefined,
currentModal: 'cancelSpeedUpTransaction',
}}
>
{story()}
</TransactionModalContext.Provider>
</GasFeeContextProvider>
</Provider>
),
],
};
export const DefaultStory = (args) => {
return (
<div style={{ width: '600px' }}>
<CancelSpeedupPopover {...args} />
</div>
);
};
DefaultStory.storyName = 'Default';