Dark Mode: Elevate the theme dropdown from experimental to regular settings (#15865)

* Dark Mode: Elevate the theme dropdown from experimental to regular settings

* Fix search

* Fix test

* Adjust settings order

* removing renderTheme call from experimental tab and rearranging setting ref number in general tab

Co-authored-by: Niranjana Binoy <43930900+NiranjanaBinoy@users.noreply.github.com>
feature/default_network_editable
David Walsh 2 years ago committed by GitHub
parent c83a307e90
commit d468c9dbde
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 2
      development/ts-migration-dashboard/files-to-convert.json
  2. 14
      ui/helpers/constants/settings.js
  3. 4
      ui/helpers/utils/settings-search.test.js
  4. 2
      ui/pages/routes/routes.component.js
  5. 57
      ui/pages/settings/experimental-tab/experimental-tab.component.js
  6. 4
      ui/pages/settings/experimental-tab/experimental-tab.container.js
  7. 62
      ui/pages/settings/settings-tab/settings-tab.component.js
  8. 0
      ui/pages/settings/settings-tab/settings-tab.constant.js
  9. 5
      ui/pages/settings/settings-tab/settings-tab.container.js

@ -1531,7 +1531,6 @@
"ui/pages/settings/contact-list-tab/view-contact/view-contact.container.js", "ui/pages/settings/contact-list-tab/view-contact/view-contact.container.js",
"ui/pages/settings/experimental-tab/experimental-tab.component.js", "ui/pages/settings/experimental-tab/experimental-tab.component.js",
"ui/pages/settings/experimental-tab/experimental-tab.component.test.js", "ui/pages/settings/experimental-tab/experimental-tab.component.test.js",
"ui/pages/settings/experimental-tab/experimental-tab.constant.js",
"ui/pages/settings/experimental-tab/experimental-tab.container.js", "ui/pages/settings/experimental-tab/experimental-tab.container.js",
"ui/pages/settings/experimental-tab/index.js", "ui/pages/settings/experimental-tab/index.js",
"ui/pages/settings/flask/snaps-list-tab/index.js", "ui/pages/settings/flask/snaps-list-tab/index.js",
@ -1580,6 +1579,7 @@
"ui/pages/settings/settings-tab/index.js", "ui/pages/settings/settings-tab/index.js",
"ui/pages/settings/settings-tab/settings-tab.component.js", "ui/pages/settings/settings-tab/settings-tab.component.js",
"ui/pages/settings/settings-tab/settings-tab.component.test.js", "ui/pages/settings/settings-tab/settings-tab.component.test.js",
"ui/pages/settings/settings-tab/settings-tab.constant.js",
"ui/pages/settings/settings-tab/settings-tab.container.js", "ui/pages/settings/settings-tab/settings-tab.container.js",
"ui/pages/settings/settings.component.js", "ui/pages/settings/settings.component.js",
"ui/pages/settings/settings.component.test.js", "ui/pages/settings/settings.component.test.js",

@ -34,6 +34,13 @@ export const SETTINGS_CONSTANTS = [
route: `${GENERAL_ROUTE}#current-language`, route: `${GENERAL_ROUTE}#current-language`,
icon: 'fa fa-cog', icon: 'fa fa-cog',
}, },
{
tabMessage: (t) => t('general'),
sectionMessage: (t) => t('theme'),
descriptionMessage: (t) => t('themeDescription'),
route: `${GENERAL_ROUTE}#theme`,
icon: 'fa fa-flask',
},
{ {
tabMessage: (t) => t('general'), tabMessage: (t) => t('general'),
sectionMessage: (t) => t('accountIdenticon'), sectionMessage: (t) => t('accountIdenticon'),
@ -313,13 +320,6 @@ export const SETTINGS_CONSTANTS = [
route: `${EXPERIMENTAL_ROUTE}#enable-advanced-gas`, route: `${EXPERIMENTAL_ROUTE}#enable-advanced-gas`,
icon: 'fa fa-flask', icon: 'fa fa-flask',
}, },
{
tabMessage: (t) => t('experimental'),
sectionMessage: (t) => t('theme'),
descriptionMessage: (t) => t('themeDescription'),
route: `${EXPERIMENTAL_ROUTE}#theme`,
icon: 'fa fa-flask',
},
{ {
tabMessage: (t) => t('advanced'), tabMessage: (t) => t('advanced'),
sectionMessage: (t) => t('enhancedTokenDetection'), sectionMessage: (t) => t('enhancedTokenDetection'),

@ -165,7 +165,7 @@ describe('Settings Search Utils', () => {
describe('getNumberOfSettingsInSection', () => { describe('getNumberOfSettingsInSection', () => {
it('should get good general section number', () => { it('should get good general section number', () => {
expect(getNumberOfSettingsInSection(t, t('general'))).toStrictEqual(5); expect(getNumberOfSettingsInSection(t, t('general'))).toStrictEqual(6);
}); });
it('should get good advanced section number', () => { it('should get good advanced section number', () => {
@ -192,7 +192,7 @@ describe('Settings Search Utils', () => {
it('should get good experimental section number', () => { it('should get good experimental section number', () => {
expect(getNumberOfSettingsInSection(t, t('experimental'))).toStrictEqual( expect(getNumberOfSettingsInSection(t, t('experimental'))).toStrictEqual(
3, 2,
); );
}); });

@ -77,7 +77,7 @@ import ConfirmationPage from '../confirmation';
import OnboardingFlow from '../onboarding-flow/onboarding-flow'; import OnboardingFlow from '../onboarding-flow/onboarding-flow';
import QRHardwarePopover from '../../components/app/qr-hardware-popover'; import QRHardwarePopover from '../../components/app/qr-hardware-popover';
import { SEND_STAGES } from '../../ducks/send'; import { SEND_STAGES } from '../../ducks/send';
import { THEME_TYPE } from '../settings/experimental-tab/experimental-tab.constant'; import { THEME_TYPE } from '../settings/settings-tab/settings-tab.constant';
import DeprecatedTestNetworks from '../../components/ui/deprecated-test-networks/deprecated-test-networks'; import DeprecatedTestNetworks from '../../components/ui/deprecated-test-networks/deprecated-test-networks';
import NewNetworkInfo from '../../components/ui/new-network-info/new-network-info'; import NewNetworkInfo from '../../components/ui/new-network-info/new-network-info';

@ -5,9 +5,7 @@ import {
getNumberOfSettingsInSection, getNumberOfSettingsInSection,
handleSettingsRefs, handleSettingsRefs,
} from '../../../helpers/utils/settings-search'; } from '../../../helpers/utils/settings-search';
import Dropdown from '../../../components/ui/dropdown';
import { EVENT } from '../../../../shared/constants/metametrics'; import { EVENT } from '../../../../shared/constants/metametrics';
import { THEME_TYPE } from './experimental-tab.constant';
export default class ExperimentalTab extends PureComponent { export default class ExperimentalTab extends PureComponent {
static contextTypes = { static contextTypes = {
@ -22,8 +20,6 @@ export default class ExperimentalTab extends PureComponent {
openSeaEnabled: PropTypes.bool, openSeaEnabled: PropTypes.bool,
eip1559V2Enabled: PropTypes.bool, eip1559V2Enabled: PropTypes.bool,
setEIP1559V2Enabled: PropTypes.func, setEIP1559V2Enabled: PropTypes.func,
theme: PropTypes.string,
setTheme: PropTypes.func,
customNetworkListEnabled: PropTypes.bool, customNetworkListEnabled: PropTypes.bool,
setCustomNetworkListEnabled: PropTypes.func, setCustomNetworkListEnabled: PropTypes.func,
}; };
@ -196,58 +192,6 @@ export default class ExperimentalTab extends PureComponent {
); );
} }
renderTheme() {
const { t } = this.context;
const { theme, setTheme } = this.props;
const themesOptions = [
{
name: t('lightTheme'),
value: THEME_TYPE.LIGHT,
},
{
name: t('darkTheme'),
value: THEME_TYPE.DARK,
},
{
name: t('osTheme'),
value: THEME_TYPE.OS,
},
];
const onChange = (newTheme) => {
this.context.trackEvent({
category: EVENT.CATEGORIES.SETTINGS,
event: 'Theme Changed',
properties: {
theme_selected: newTheme,
},
});
setTheme(newTheme);
};
return (
<div ref={this.settingsRefs[4]} className="settings-page__content-row">
<div className="settings-page__content-item">
<span>{this.context.t('theme')}</span>
<div className="settings-page__content-description">
{this.context.t('themeDescription')}
</div>
</div>
<div className="settings-page__content-item">
<div className="settings-page__content-item-col">
<Dropdown
id="select-theme"
options={themesOptions}
selectedOption={theme}
onChange={onChange}
/>
</div>
</div>
</div>
);
}
renderCustomNetworkListToggle() { renderCustomNetworkListToggle() {
const { t } = this.context; const { t } = this.context;
const { customNetworkListEnabled, setCustomNetworkListEnabled } = const { customNetworkListEnabled, setCustomNetworkListEnabled } =
@ -291,7 +235,6 @@ export default class ExperimentalTab extends PureComponent {
{this.renderOpenSeaEnabledToggle()} {this.renderOpenSeaEnabledToggle()}
{this.renderCollectibleDetectionToggle()} {this.renderCollectibleDetectionToggle()}
{this.renderEIP1559V2EnabledToggle()} {this.renderEIP1559V2EnabledToggle()}
{this.renderTheme()}
{this.renderCustomNetworkListToggle()} {this.renderCustomNetworkListToggle()}
</div> </div>
); );

@ -5,14 +5,12 @@ import {
setUseCollectibleDetection, setUseCollectibleDetection,
setOpenSeaEnabled, setOpenSeaEnabled,
setEIP1559V2Enabled, setEIP1559V2Enabled,
setTheme,
setCustomNetworkListEnabled, setCustomNetworkListEnabled,
} from '../../../store/actions'; } from '../../../store/actions';
import { import {
getUseCollectibleDetection, getUseCollectibleDetection,
getOpenSeaEnabled, getOpenSeaEnabled,
getEIP1559V2Enabled, getEIP1559V2Enabled,
getTheme,
getIsCustomNetworkListEnabled, getIsCustomNetworkListEnabled,
} from '../../../selectors'; } from '../../../selectors';
import ExperimentalTab from './experimental-tab.component'; import ExperimentalTab from './experimental-tab.component';
@ -22,7 +20,6 @@ const mapStateToProps = (state) => {
useCollectibleDetection: getUseCollectibleDetection(state), useCollectibleDetection: getUseCollectibleDetection(state),
openSeaEnabled: getOpenSeaEnabled(state), openSeaEnabled: getOpenSeaEnabled(state),
eip1559V2Enabled: getEIP1559V2Enabled(state), eip1559V2Enabled: getEIP1559V2Enabled(state),
theme: getTheme(state),
customNetworkListEnabled: getIsCustomNetworkListEnabled(state), customNetworkListEnabled: getIsCustomNetworkListEnabled(state),
}; };
}; };
@ -33,7 +30,6 @@ const mapDispatchToProps = (dispatch) => {
dispatch(setUseCollectibleDetection(val)), dispatch(setUseCollectibleDetection(val)),
setOpenSeaEnabled: (val) => dispatch(setOpenSeaEnabled(val)), setOpenSeaEnabled: (val) => dispatch(setOpenSeaEnabled(val)),
setEIP1559V2Enabled: (val) => dispatch(setEIP1559V2Enabled(val)), setEIP1559V2Enabled: (val) => dispatch(setEIP1559V2Enabled(val)),
setTheme: (val) => dispatch(setTheme(val)),
setCustomNetworkListEnabled: (val) => setCustomNetworkListEnabled: (val) =>
dispatch(setCustomNetworkListEnabled(val)), dispatch(setCustomNetworkListEnabled(val)),
}; };

@ -9,11 +9,13 @@ import locales from '../../../../app/_locales/index.json';
import Jazzicon from '../../../components/ui/jazzicon'; import Jazzicon from '../../../components/ui/jazzicon';
import BlockieIdenticon from '../../../components/ui/identicon/blockieIdenticon'; import BlockieIdenticon from '../../../components/ui/identicon/blockieIdenticon';
import Typography from '../../../components/ui/typography'; import Typography from '../../../components/ui/typography';
import { EVENT } from '../../../../shared/constants/metametrics';
import { import {
getNumberOfSettingsInSection, getNumberOfSettingsInSection,
handleSettingsRefs, handleSettingsRefs,
} from '../../../helpers/utils/settings-search'; } from '../../../helpers/utils/settings-search';
import { THEME_TYPE } from './settings-tab.constant';
const sortedCurrencies = availableCurrencies.sort((a, b) => { const sortedCurrencies = availableCurrencies.sort((a, b) => {
return a.name.toLocaleLowerCase().localeCompare(b.name.toLocaleLowerCase()); return a.name.toLocaleLowerCase().localeCompare(b.name.toLocaleLowerCase());
@ -37,6 +39,7 @@ export default class SettingsTab extends PureComponent {
static contextTypes = { static contextTypes = {
t: PropTypes.func, t: PropTypes.func,
metricsEvent: PropTypes.func, metricsEvent: PropTypes.func,
trackEvent: PropTypes.func,
}; };
static propTypes = { static propTypes = {
@ -55,6 +58,8 @@ export default class SettingsTab extends PureComponent {
lastFetchedConversionDate: PropTypes.number, lastFetchedConversionDate: PropTypes.number,
selectedAddress: PropTypes.string, selectedAddress: PropTypes.string,
tokenList: PropTypes.object, tokenList: PropTypes.object,
theme: PropTypes.string,
setTheme: PropTypes.func,
}; };
settingsRefs = Array( settingsRefs = Array(
@ -144,7 +149,7 @@ export default class SettingsTab extends PureComponent {
return ( return (
<div <div
ref={this.settingsRefs[4]} ref={this.settingsRefs[5]}
className="settings-page__content-row" className="settings-page__content-row"
id="toggle-zero-balance" id="toggle-zero-balance"
> >
@ -179,7 +184,7 @@ export default class SettingsTab extends PureComponent {
return ( return (
<div <div
ref={this.settingsRefs[3]} ref={this.settingsRefs[4]}
className="settings-page__content-row" className="settings-page__content-row"
id="blockie-optin" id="blockie-optin"
> >
@ -320,6 +325,58 @@ export default class SettingsTab extends PureComponent {
); );
} }
renderTheme() {
const { t } = this.context;
const { theme, setTheme } = this.props;
const themesOptions = [
{
name: t('lightTheme'),
value: THEME_TYPE.LIGHT,
},
{
name: t('darkTheme'),
value: THEME_TYPE.DARK,
},
{
name: t('osTheme'),
value: THEME_TYPE.OS,
},
];
const onChange = (newTheme) => {
this.context.trackEvent({
category: EVENT.CATEGORIES.SETTINGS,
event: 'Theme Changed',
properties: {
theme_selected: newTheme,
},
});
setTheme(newTheme);
};
return (
<div ref={this.settingsRefs[3]} className="settings-page__content-row">
<div className="settings-page__content-item">
<span>{this.context.t('theme')}</span>
<div className="settings-page__content-description">
{this.context.t('themeDescription')}
</div>
</div>
<div className="settings-page__content-item">
<div className="settings-page__content-item-col">
<Dropdown
id="select-theme"
options={themesOptions}
selectedOption={theme}
onChange={onChange}
/>
</div>
</div>
</div>
);
}
render() { render() {
const { warning } = this.props; const { warning } = this.props;
@ -329,6 +386,7 @@ export default class SettingsTab extends PureComponent {
{this.renderCurrentConversion()} {this.renderCurrentConversion()}
{this.renderUsePrimaryCurrencyOptions()} {this.renderUsePrimaryCurrencyOptions()}
{this.renderCurrentLocale()} {this.renderCurrentLocale()}
{this.renderTheme()}
{this.renderBlockieOptIn()} {this.renderBlockieOptIn()}
{this.renderHideZeroBalanceTokensOptIn()} {this.renderHideZeroBalanceTokensOptIn()}
</div> </div>

@ -6,8 +6,9 @@ import {
setUseNativeCurrencyAsPrimaryCurrencyPreference, setUseNativeCurrencyAsPrimaryCurrencyPreference,
setHideZeroBalanceTokens, setHideZeroBalanceTokens,
setParticipateInMetaMetrics, setParticipateInMetaMetrics,
setTheme,
} from '../../../store/actions'; } from '../../../store/actions';
import { getTokenList, getPreferences } from '../../../selectors'; import { getTokenList, getPreferences, getTheme } from '../../../selectors';
import SettingsTab from './settings-tab.component'; import SettingsTab from './settings-tab.component';
const mapStateToProps = (state, ownProps) => { const mapStateToProps = (state, ownProps) => {
@ -39,6 +40,7 @@ const mapStateToProps = (state, ownProps) => {
lastFetchedConversionDate, lastFetchedConversionDate,
selectedAddress, selectedAddress,
tokenList, tokenList,
theme: getTheme(state),
}; };
}; };
@ -54,6 +56,7 @@ const mapDispatchToProps = (dispatch) => {
dispatch(setParticipateInMetaMetrics(val)), dispatch(setParticipateInMetaMetrics(val)),
setHideZeroBalanceTokens: (value) => setHideZeroBalanceTokens: (value) =>
dispatch(setHideZeroBalanceTokens(value)), dispatch(setHideZeroBalanceTokens(value)),
setTheme: (val) => dispatch(setTheme(val)),
}; };
}; };

Loading…
Cancel
Save