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

Move THEME_TYPE to new preferences.ts file (#17515)

This commit is contained in:
Brad Decker 2023-01-31 17:49:00 -06:00 committed by GitHub
parent 7a29d896ad
commit 6e7f5c3e21
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 16 additions and 16 deletions

View File

@ -3,7 +3,7 @@ import { normalize as normalizeAddress } from 'eth-sig-util';
import { IPFS_DEFAULT_GATEWAY_URL } from '../../../shared/constants/network';
import { isPrefixedFormattedHexString } from '../../../shared/modules/network.utils';
import { LedgerTransportTypes } from '../../../shared/constants/hardware-wallets';
import { THEME_TYPE } from '../../../ui/pages/settings/settings-tab/settings-tab.constant';
import { ThemeType } from '../../../shared/constants/preferences';
import { NETWORK_EVENTS } from './network';
export default class PreferencesController {
@ -66,7 +66,7 @@ export default class PreferencesController {
? LedgerTransportTypes.webhid
: LedgerTransportTypes.u2f,
transactionSecurityCheckEnabled: false,
theme: THEME_TYPE.OS,
theme: ThemeType.os,
...opts.initState,
};

View File

@ -0,0 +1,5 @@
export enum ThemeType {
light = 'light',
dark = 'dark',
os = 'os',
}

View File

@ -77,9 +77,9 @@ import ConfirmationPage from '../confirmation';
import OnboardingFlow from '../onboarding-flow/onboarding-flow';
import QRHardwarePopover from '../../components/app/qr-hardware-popover';
import { SEND_STAGES } from '../../ducks/send';
import { THEME_TYPE } from '../settings/settings-tab/settings-tab.constant';
import DeprecatedTestNetworks from '../../components/ui/deprecated-test-networks/deprecated-test-networks';
import NewNetworkInfo from '../../components/ui/new-network-info/new-network-info';
import { ThemeType } from '../../../shared/constants/preferences';
export default class Routes extends Component {
static propTypes = {
@ -125,8 +125,8 @@ export default class Routes extends Component {
handleOsTheme() {
const osTheme = window?.matchMedia('(prefers-color-scheme: dark)')?.matches
? THEME_TYPE.DARK
: THEME_TYPE.LIGHT;
? ThemeType.dark
: ThemeType.light;
document.documentElement.setAttribute('data-theme', osTheme);
}
@ -135,7 +135,7 @@ export default class Routes extends Component {
const { theme } = this.props;
if (theme !== prevProps.theme) {
if (theme === THEME_TYPE.OS) {
if (theme === ThemeType.OS) {
this.handleOsTheme();
} else {
document.documentElement.setAttribute('data-theme', theme);
@ -160,7 +160,7 @@ export default class Routes extends Component {
pageChanged(locationObj.pathname);
}
});
if (theme === THEME_TYPE.OS) {
if (theme === ThemeType.os) {
this.handleOsTheme();
} else {
document.documentElement.setAttribute('data-theme', theme);

View File

@ -15,7 +15,7 @@ import {
getNumberOfSettingsInSection,
handleSettingsRefs,
} from '../../../helpers/utils/settings-search';
import { THEME_TYPE } from './settings-tab.constant';
import { ThemeType } from '../../../../shared/constants/preferences';
const sortedCurrencies = availableCurrencies.sort((a, b) => {
return a.name.toLocaleLowerCase().localeCompare(b.name.toLocaleLowerCase());
@ -336,15 +336,15 @@ export default class SettingsTab extends PureComponent {
const themesOptions = [
{
name: t('lightTheme'),
value: THEME_TYPE.LIGHT,
value: ThemeType.light,
},
{
name: t('darkTheme'),
value: THEME_TYPE.DARK,
value: ThemeType.dark,
},
{
name: t('osTheme'),
value: THEME_TYPE.OS,
value: ThemeType.os,
},
];

View File

@ -1,5 +0,0 @@
export const THEME_TYPE = {
LIGHT: 'light',
DARK: 'dark',
OS: 'os',
};