chore(client): tidy Flash by tidying tone (#44320)

* chore(client): tidy Flash by tidying tone

* add store import

* fix enum, remove default switch case

Co-authored-by: Nicholas Carrigan <nhcarrigan@gmail.com>

* typo galore

Co-authored-by: Nicholas Carrigan (he/him) <nhcarrigan@gmail.com>

* rejig everything, because refactoring is fun 🙃

* refactor: DRY playTone

* fix url to foss library

Co-authored-by: Nicholas Carrigan <nhcarrigan@gmail.com>

* alphabetasize FlashMessage enum

* add all FlashMessages to tone/index.ts

* remove redundant type

* my code is correctnpm run develop:client

* fix: remove circular dependency

* fix: typo

* remove logs, play special tones for nightmode

* play sound on challengeComplete

Co-authored-by: Nicholas Carrigan (he/him) <nhcarrigan@gmail.com>

Co-authored-by: Nicholas Carrigan <nhcarrigan@gmail.com>
Co-authored-by: Oliver Eyton-Williams <ojeytonwilliams@gmail.com>
This commit is contained in:
Shaun Hamilton
2021-12-01 18:45:17 +00:00
committed by GitHub
parent edf3185b2b
commit 23e241bbc0
29 changed files with 216 additions and 145 deletions

View File

@@ -28,6 +28,7 @@ import { hardGoTo as navigate } from '../../../redux';
import { updateUserFlag } from '../../../redux/settings';
import createLanguageRedirect from '../../create-language-redirect';
import { Link } from '../../helpers';
import { Themes } from '../../settings/theme';
const { clientLocale, radioLocation, apiLocation } = envData;
@@ -46,7 +47,7 @@ export interface NavLinksProps {
const mapDispatchToProps = {
navigate,
toggleNightMode: (theme: unknown) => updateUserFlag({ theme })
toggleNightMode: (theme: Themes) => updateUserFlag({ theme })
};
export class NavLinks extends Component<NavLinksProps, {}> {
@@ -57,8 +58,10 @@ export class NavLinks extends Component<NavLinksProps, {}> {
this.handleLanguageChange = this.handleLanguageChange.bind(this);
}
toggleTheme(currentTheme = 'default', toggleNightMode: any) {
toggleNightMode(currentTheme === 'night' ? 'default' : 'night');
toggleTheme(currentTheme = Themes.Default, toggleNightMode: any) {
toggleNightMode(
currentTheme === Themes.Night ? Themes.Default : Themes.Night
);
}
handleLanguageChange = (
@@ -175,7 +178,7 @@ export class NavLinks extends Component<NavLinksProps, {}> {
{username ? (
<>
<span>{t('settings.labels.night-mode')}</span>
{theme === 'night' ? (
{theme === Themes.Night ? (
<FontAwesomeIcon icon={faCheckSquare} />
) : (
<FontAwesomeIcon icon={faSquare} />

View File

@@ -12,6 +12,7 @@ import {
availableLangs,
langDisplayNames
} from '../../../../config/i18n/all-langs';
import { Themes } from '../settings/theme';
import AuthOrProfile from './components/auth-or-profile';
import { NavLinks } from './components/nav-links';
import { UniversalNav } from './components/universal-nav';
@@ -50,12 +51,12 @@ describe('<NavLinks />', () => {
user: {
isDonating: false,
username: null,
theme: 'default'
theme: Themes.Default
},
i18n: {
language: 'en'
},
toggleNightMode: (theme: string) => theme,
toggleNightMode: (theme: Themes) => theme,
t: t
};
const utils = ShallowRenderer.createRenderer();
@@ -81,13 +82,13 @@ describe('<NavLinks />', () => {
user: {
isDonating: false,
username: 'nhcarrigan',
theme: 'default'
theme: Themes.Default
},
i18n: {
language: 'en'
},
t: t,
toggleNightMode: (theme: string) => theme
toggleNightMode: (theme: Themes) => theme
};
const utils = ShallowRenderer.createRenderer();
utils.render(<NavLinks {...landingPageProps} />);
@@ -111,13 +112,13 @@ describe('<NavLinks />', () => {
user: {
isDonating: true,
username: 'moT01',
theme: 'default'
theme: Themes.Default
},
i18n: {
language: 'en'
},
t: t,
toggleNightMode: (theme: string) => theme
toggleNightMode: (theme: Themes) => theme
};
const utils = ShallowRenderer.createRenderer();
utils.render(<NavLinks {...landingPageProps} />);
@@ -143,13 +144,13 @@ describe('<NavLinks />', () => {
user: {
isDonating: true,
username: 'moT01',
theme: 'default'
theme: Themes.Default
},
i18n: {
language: 'en'
},
t: t,
toggleNightMode: (theme: string) => theme
toggleNightMode: (theme: Themes) => theme
};
const utils = ShallowRenderer.createRenderer();
utils.render(<NavLinks {...landingPageProps} />);
@@ -169,13 +170,13 @@ describe('<NavLinks />', () => {
user: {
isDonating: true,
username: 'moT01',
theme: 'default'
theme: Themes.Default
},
i18n: {
language: 'en'
},
t: t,
toggleNightMode: (theme: string) => theme
toggleNightMode: (theme: Themes) => theme
};
const utils = ShallowRenderer.createRenderer();
utils.render(<NavLinks {...landingPageProps} />);