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:
parent
7a29d896ad
commit
6e7f5c3e21
@ -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,
|
||||
};
|
||||
|
||||
|
5
shared/constants/preferences.ts
Normal file
5
shared/constants/preferences.ts
Normal file
@ -0,0 +1,5 @@
|
||||
export enum ThemeType {
|
||||
light = 'light',
|
||||
dark = 'dark',
|
||||
os = 'os',
|
||||
}
|
@ -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);
|
||||
|
@ -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,
|
||||
},
|
||||
];
|
||||
|
||||
|
@ -1,5 +0,0 @@
|
||||
export const THEME_TYPE = {
|
||||
LIGHT: 'light',
|
||||
DARK: 'dark',
|
||||
OS: 'os',
|
||||
};
|
Loading…
Reference in New Issue
Block a user