mirror of
https://github.com/kremalicious/metamask-extension.git
synced 2024-12-23 09:52:26 +01:00
updated to newer Checkbox (#20242)
* updated to newer Checkbox * removed commented code * Adjusting styles removing deprecated code * alignment update --------- Co-authored-by: georgewrmarshall <george.marshall@consensys.net> Co-authored-by: Garrett Bear <gwhisten@gmail.com>
This commit is contained in:
parent
6c1b71b584
commit
d482b21513
@ -3,20 +3,17 @@ import { useSelector, useDispatch } from 'react-redux';
|
|||||||
|
|
||||||
import { useTransactionEventFragment } from '../../../../hooks/useTransactionEventFragment';
|
import { useTransactionEventFragment } from '../../../../hooks/useTransactionEventFragment';
|
||||||
import { EditGasModes } from '../../../../../shared/constants/gas';
|
import { EditGasModes } from '../../../../../shared/constants/gas';
|
||||||
import Box from '../../../ui/box';
|
|
||||||
import CheckBox from '../../../ui/check-box';
|
|
||||||
import {
|
import {
|
||||||
Display,
|
Display,
|
||||||
FlexDirection,
|
FlexDirection,
|
||||||
TextColor,
|
|
||||||
TextVariant,
|
|
||||||
} from '../../../../helpers/constants/design-system';
|
} from '../../../../helpers/constants/design-system';
|
||||||
import { getAdvancedGasFeeValues } from '../../../../selectors';
|
import { getAdvancedGasFeeValues } from '../../../../selectors';
|
||||||
import { setAdvancedGasFee } from '../../../../store/actions';
|
import { setAdvancedGasFee } from '../../../../store/actions';
|
||||||
import { useGasFeeContext } from '../../../../contexts/gasFee';
|
import { useGasFeeContext } from '../../../../contexts/gasFee';
|
||||||
import { useAdvancedGasFeePopoverContext } from '../context';
|
import { useAdvancedGasFeePopoverContext } from '../context';
|
||||||
import { useI18nContext } from '../../../../hooks/useI18nContext';
|
import { useI18nContext } from '../../../../hooks/useI18nContext';
|
||||||
import { Text } from '../../../component-library';
|
import { Checkbox, Box } from '../../../component-library';
|
||||||
|
|
||||||
const AdvancedGasFeeDefaults = () => {
|
const AdvancedGasFeeDefaults = () => {
|
||||||
const t = useI18nContext();
|
const t = useI18nContext();
|
||||||
@ -77,27 +74,22 @@ const AdvancedGasFeeDefaults = () => {
|
|||||||
marginTop={4}
|
marginTop={4}
|
||||||
marginLeft={2}
|
marginLeft={2}
|
||||||
marginRight={2}
|
marginRight={2}
|
||||||
|
paddingTop={4}
|
||||||
|
paddingBottom={4}
|
||||||
className="advanced-gas-fee-defaults"
|
className="advanced-gas-fee-defaults"
|
||||||
>
|
>
|
||||||
<label className="advanced-gas-fee-defaults__label">
|
<Checkbox
|
||||||
<CheckBox
|
isChecked={isDefaultSettingsSelected}
|
||||||
checked={isDefaultSettingsSelected}
|
onChange={handleUpdateDefaultSettings}
|
||||||
className="advanced-gas-fee-defaults__checkbox"
|
isDisabled={gasErrors.maxFeePerGas || gasErrors.maxPriorityFeePerGas}
|
||||||
onClick={handleUpdateDefaultSettings}
|
label={
|
||||||
disabled={gasErrors.maxFeePerGas || gasErrors.maxPriorityFeePerGas}
|
isDefaultSettingsSelected
|
||||||
/>
|
|
||||||
<Text
|
|
||||||
variant={TextVariant.bodySm}
|
|
||||||
as="h6"
|
|
||||||
color={TextColor.textAlternative}
|
|
||||||
>
|
|
||||||
{isDefaultSettingsSelected
|
|
||||||
? t('advancedGasFeeDefaultOptOut')
|
? t('advancedGasFeeDefaultOptOut')
|
||||||
: t('advancedGasFeeDefaultOptIn', [
|
: t('advancedGasFeeDefaultOptIn', [
|
||||||
<strong key="default-value-change">{t('newValues')}</strong>,
|
<strong key="default-value-change">{t('newValues')}</strong>,
|
||||||
])}
|
])
|
||||||
</Text>
|
}
|
||||||
</label>
|
/>
|
||||||
</Box>
|
</Box>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
@ -0,0 +1,47 @@
|
|||||||
|
import React from 'react';
|
||||||
|
import { Provider } from 'react-redux';
|
||||||
|
import mockEstimates from '../../../../../test/data/mock-estimates.json';
|
||||||
|
import mockState from '../../../../../test/data/mock-state.json';
|
||||||
|
import configureStore from '../../../../store/store';
|
||||||
|
import { AdvancedGasFeePopoverContextProvider } from '../context';
|
||||||
|
import { GasFeeContextProvider } from '../../../../contexts/gasFee';
|
||||||
|
import { GasEstimateTypes } from '../../../../../shared/constants/gas';
|
||||||
|
import AdvancedGasFeeDefaults from './advanced-gas-fee-defaults';
|
||||||
|
|
||||||
|
const store = configureStore({
|
||||||
|
...mockState,
|
||||||
|
metamask: {
|
||||||
|
...mockState.metamask,
|
||||||
|
accounts: {
|
||||||
|
[mockState.metamask.selectedAddress]: {
|
||||||
|
address: mockState.metamask.selectedAddress,
|
||||||
|
balance: '0x1F4',
|
||||||
|
},
|
||||||
|
},
|
||||||
|
featureFlags: { advancedInlineGas: true },
|
||||||
|
gasFeeEstimates: mockEstimates[GasEstimateTypes.feeMarket].gasFeeEstimates,
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
export default {
|
||||||
|
title: 'Components/App/AdvancedGasFeePopover/AdvancedGasFeeDefaults',
|
||||||
|
decorators: [
|
||||||
|
(story) => (
|
||||||
|
<Provider store={store}>
|
||||||
|
<GasFeeContextProvider
|
||||||
|
transaction={{
|
||||||
|
userFeeLevel: 'medium',
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
<AdvancedGasFeePopoverContextProvider>
|
||||||
|
{story()}
|
||||||
|
</AdvancedGasFeePopoverContextProvider>
|
||||||
|
</GasFeeContextProvider>
|
||||||
|
</Provider>
|
||||||
|
),
|
||||||
|
],
|
||||||
|
};
|
||||||
|
|
||||||
|
export const DefaultStory = () => <AdvancedGasFeeDefaults />;
|
||||||
|
|
||||||
|
DefaultStory.storyName = 'Default';
|
@ -1,13 +1,3 @@
|
|||||||
.advanced-gas-fee-defaults {
|
.advanced-gas-fee-defaults {
|
||||||
border-top: 1px solid var(--color-border-muted);
|
border-top: 1px solid var(--color-border-muted);
|
||||||
padding-top: 16px;
|
|
||||||
|
|
||||||
& &__checkbox {
|
|
||||||
font-size: $font-size-h4;
|
|
||||||
margin: 0 8px;
|
|
||||||
}
|
|
||||||
|
|
||||||
&__label {
|
|
||||||
display: flex;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user