Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add dark splash screen, ref #4398 #4935

Merged
merged 1 commit into from
Feb 20, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
pete-watters marked this conversation as resolved.
Show resolved Hide resolved
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>
pete-watters marked this conversation as resolved.
Show resolved Hide resolved
<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"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

While reviewing I was wondering wether we could use a combination of animationDelay and animationDuration so that we can make the fade feel a bit snappier (feels faster / more "performant") while still ensuring all elements are loaded in place to avoid a jumpy UI. However, the delay doesn't seem to work / affect the animation, not sure why. This is already really nice btw and def. an improvement which I think is shippable, just wondering

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I feel like animation duration won't work here. to avoid this jumpy UI we prob need to show some loader/splash screen until page is full rendered https://stackoverflow.com/questions/40987309/react-display-loading-screen-while-dom-is-rendering

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If the loading time is very short (I'd say anything below ~1s) we could get away with just leaving the screen blank and then fade the content in. IMO we should only show a loading screen if we anticipate things taking 1s+, otherwise you end up with an experience where you briefly see a loading spinner flashing and then directly transitioning into something else which doesn't feel great.

>
<Stack
data-testid={HomePageSelectors.HomePageContainer}
maxWidth={['unset', 'unset', '882px']}
Expand Down
Loading