Skip to content

Commit

Permalink
feat: add dark splash screen, ref #4398
Browse files Browse the repository at this point in the history
  • Loading branch information
alter-eggo committed Feb 10, 2024
1 parent 787c03a commit 4e8723b
Show file tree
Hide file tree
Showing 6 changed files with 46 additions and 5 deletions.
5 changes: 5 additions & 0 deletions public/assets/base.css
Original file line number Diff line number Diff line change
Expand Up @@ -44,3 +44,8 @@
font-weight: 400;
font-style: normal;
}

.splash-screen {
/* lightModeBrown.11 */
background-color: #12100F !important;
}
10 changes: 10 additions & 0 deletions public/assets/splash-screen.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
var isDark = window.matchMedia('(prefers-color-scheme: dark)').matches;

var body = document.querySelector('body');
var html = document.querySelector('html');
var defClassName = 'splash-screen';

if (!isDark) {
body?.classList.remove(defClassName);
html.classList.remove(defClassName);
}
5 changes: 3 additions & 2 deletions public/html/index.html
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<!doctype html>
<html class="mode__full-page light">
<html class="mode__full-page light splash-screen">
<!--
Hello! Thanks for showing interest in our code.
Interested in joining our team? To learn more, email us:
Expand Down Expand Up @@ -31,8 +31,9 @@
type="font/woff2"
/>
</head>
<body>
<body class="splash-screen">
<div id="app"></div>
<script src="/assets/splash-screen.js"></script>
<script src="browser-polyfill.js"></script>
</body>
</html>
5 changes: 3 additions & 2 deletions public/html/popup.html
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
<!doctype html>
<html class="mode__popup light">
<html class="mode__popup light splash-screen">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<link href="/assets/base.css" rel="stylesheet" />
</head>
<body>
<body class="splash-screen">
<div id="app"></div>
<script src="/assets/splash-screen.js"></script>
<script src="browser-polyfill.js"></script>
</body>
</html>
18 changes: 18 additions & 0 deletions src/app/common/theme-provider.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ import { store } from '@app/store';
import { settingsActions } from '@app/store/settings/settings.actions';
import { useUserSelectedTheme } from '@app/store/settings/settings.selectors';

import { useOnMount } from './hooks/use-on-mount';

export const themeLabelMap = {
light: 'Light',
dark: 'Dark',
Expand Down Expand Up @@ -48,10 +50,26 @@ function setUserSelectedTheme(theme: UserSelectedTheme) {
interface ThemeSwitcherProviderProps {
children: React.JSX.Element | React.JSX.Element[];
}

function removeDefaultBg() {
const body = document.querySelector('body');
const html = document.querySelector('html');
const defClassName = 'splash-screen';

if (!body || !html) return;

body.classList.remove(defClassName);
html.classList.remove(defClassName);
}

export function ThemeSwitcherProvider({ children }: ThemeSwitcherProviderProps) {
const userSelectedTheme = useUserSelectedTheme();
const [theme, setTheme] = useState<ComputedTheme>(() => getComputedTheme(userSelectedTheme));

useOnMount(() => {
removeDefaultBg();
});

useEffect(() => {
switch (userSelectedTheme) {
case 'system': {
Expand Down
8 changes: 7 additions & 1 deletion src/app/pages/home/components/home.layout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,13 @@ import { AccountInfoCard } from './account-info-card';
type HomeLayoutProps = Record<'currentAccount' | 'children', React.ReactNode>;
export function HomeLayout({ children }: HomeLayoutProps) {
return (
<Stack alignItems="center" width="100%" mx={['', 'space.04']}>
<Stack
alignItems="center"
width="100%"
mx={['', 'space.04']}
animation="fadein"
animationDuration="900ms"
>
<Stack
data-testid={HomePageSelectors.HomePageContainer}
maxWidth={['unset', 'unset', '882px']}
Expand Down

0 comments on commit 4e8723b

Please sign in to comment.