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 20, 2024
1 parent c49f7e9 commit 613fc9d
Show file tree
Hide file tree
Showing 6 changed files with 41 additions and 1 deletion.
8 changes: 8 additions & 0 deletions public/assets/base.css
Original file line number Diff line number Diff line change
Expand Up @@ -44,3 +44,11 @@
font-weight: 400;
font-style: normal;
}

#splash-screen {
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 100%;
}
11 changes: 11 additions & 0 deletions public/assets/splash-screen.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
var isDark = window.matchMedia('(prefers-color-scheme: dark)').matches;
var splashScreen = document.getElementById('splash-screen');

// set accent.background-secondary
if (isDark) {
// darkModeInk.2
splashScreen.style.backgroundColor = '#2C2A24';
} else {
// lightModeInk.3
splashScreen.style.backgroundColor = '#F5F1ED';
}
2 changes: 2 additions & 0 deletions public/html/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,9 @@
/>
</head>
<body>
<div id="splash-screen"></div>
<div id="app"></div>
<script src="/assets/splash-screen.js"></script>
<script src="browser-polyfill.js"></script>
</body>
</html>
2 changes: 2 additions & 0 deletions public/html/popup.html
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,9 @@
<link href="/assets/base.css" rel="stylesheet" />
</head>
<body>
<div id="splash-screen"></div>
<div id="app"></div>
<script src="/assets/splash-screen.js"></script>
<script src="browser-polyfill.js"></script>
</body>
</html>
11 changes: 11 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,19 @@ function setUserSelectedTheme(theme: UserSelectedTheme) {
interface ThemeSwitcherProviderProps {
children: React.JSX.Element | React.JSX.Element[];
}

function removeSplashScreen() {
document.getElementById('splash-screen')?.remove();
}

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

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

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="500ms"
>
<Stack
data-testid={HomePageSelectors.HomePageContainer}
maxWidth={['unset', 'unset', '882px']}
Expand Down

0 comments on commit 613fc9d

Please sign in to comment.