fix(core): onboading performance improvement (#8790)

- compress images
- remove noise assets (700kb)
- remove lottie animations
- remove `perspective` after paper animation to reduce layers
This commit is contained in:
CatsJuice committed 2024-11-13 08:25:05 +00:00
1 parent f85dfae63b
commit c32b29a293
27 files changed
+67 -89

No files matched your search

@@ -2,6 +2,7 @@ import { join } from 'node:path';
import {
app,
BrowserWindow,
Menu,
MenuItem,
session,
@@ -38,7 +39,6 @@ import {
type WorkbenchViewMeta,
} from '../shared-state-schema';
import { globalStateStorage } from '../shared-storage/storage';
import { getCustomThemeWindow } from './custom-theme-window';
import { getMainWindow, MainWindowManager } from './main-window';
async function getAdditionalArguments() {
@@ -1083,24 +1083,19 @@ export const onActiveTabChanged = (fn: (tabId: string) => void) => {
export const showDevTools = (id?: string) => {
// use focusedWindow?
// const focusedWindow = BrowserWindow.getFocusedWindow()
// workaround for opening devtools for theme-editor window
// there should be some strategy like windows manager, so we can know which window is active
getCustomThemeWindow()
.then(w => {
if (w && w.isFocused()) {
w.webContents.openDevTools();
} else {
const view = id
? WebContentViewsManager.instance.getViewById(id)
: WebContentViewsManager.instance.activeWorkbenchView;
if (view) {
view.webContents.openDevTools();
}
}
})
.catch(console.error);
const focusedWindow = BrowserWindow.getFocusedWindow();
// check if focused window is main window
const mainWindow = WebContentViewsManager.instance.mainWindow;
if (focusedWindow && focusedWindow.id !== mainWindow?.id) {
focusedWindow.webContents.openDevTools();
} else {
const view = id
? WebContentViewsManager.instance.getViewById(id)
: WebContentViewsManager.instance.activeWorkbenchView;
if (view) {
view.webContents.openDevTools();
}
}
};
export const pingAppLayoutReady = (wc: WebContents, ready: boolean) => {
Binary file not shown.

Before

Width:  |  Height:  |  Size: 87 KiB

After

Width:  |  Height:  |  Size: 45 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 344 KiB

After

Width:  |  Height:  |  Size: 119 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 636 KiB

After

Width:  |  Height:  |  Size: 132 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 324 KiB

After

Width:  |  Height:  |  Size: 110 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 289 KiB

After

Width:  |  Height:  |  Size: 120 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 464 KiB

After

Width:  |  Height:  |  Size: 140 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 35 KiB

After

Width:  |  Height:  |  Size: 5.1 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 50 KiB

After

Width:  |  Height:  |  Size: 8.3 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 21 KiB

After

Width:  |  Height:  |  Size: 5.0 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 225 KiB

After

Width:  |  Height:  |  Size: 190 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 110 KiB

After

Width:  |  Height:  |  Size: 41 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 108 KiB

After

Width:  |  Height:  |  Size: 16 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 122 KiB

After

Width:  |  Height:  |  Size: 20 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 110 KiB

After

Width:  |  Height:  |  Size: 16 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 177 KiB

After

Width:  |  Height:  |  Size: 28 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 112 KiB

After

Width:  |  Height:  |  Size: 16 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 197 KiB

After

Width:  |  Height:  |  Size: 68 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 123 KiB

After

Width:  |  Height:  |  Size: 49 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 78 KiB

After

Width:  |  Height:  |  Size: 12 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 48 KiB

After

Width:  |  Height:  |  Size: 11 KiB

@@ -52,6 +52,7 @@ export const orbitItem = style({
flexShrink: 0,
flexGrow: 0,
overflow: 'hidden',
position: 'relative',
});
export const doc = style({
selectors: {
@@ -171,6 +172,7 @@ export const noDragWrapper = style({
position: 'absolute',
inset: 0,
pointerEvents: 'none',
width: '100%',
});
globalStyle(`${noDragWrapper} > *`, {
pointerEvents: 'auto',
@@ -113,7 +113,6 @@ export const EdgelessSwitch = ({
turnOffScalingRef.current?.();
};
// TODO(@catsjuice): mobile support
const onMouseDown = (e: MouseEvent) => {
const target = e.target as HTMLElement;
if (target.closest('[data-no-drag]')) return;
@@ -61,10 +61,6 @@ export const onboardingVars = {
nextButtonShowUpDelay: '20s',
},
};
export const perspective = style({
perspective: '10000px',
transformStyle: 'preserve-3d',
});
export const fadeIn = keyframes({
from: {
opacity: 0,
@@ -73,38 +69,39 @@ export const fadeIn = keyframes({
opacity: 1,
},
});
export const onboarding = style([
perspective,
{
width: '100vw',
height: '100vh',
display: 'flex',
alignItems: 'center',
justifyContent: 'center',
position: 'relative',
selectors: {
// hack background color for web
'&::after': {
content: '',
position: 'absolute',
inset: 0,
background: onboardingVars.web.bg,
transform: 'translateZ(-1000px) scale(2)',
transition: 'opacity 0.3s ease',
},
'&[data-is-desktop="true"]::after': {
animation: `${fadeIn} 0.8s linear`,
// content: 'unset',
background:
'linear-gradient(180deg, rgba(0,0,0,0.8) 0%, rgba(0,0,0,0) 99.58%)',
},
'&[data-is-window="true"][data-is-desktop="true"]::after': {
opacity: 0,
},
export const onboarding = style({
width: '100vw',
height: '100vh',
display: 'flex',
alignItems: 'center',
justifyContent: 'center',
position: 'relative',
selectors: {
'&[data-is-window="false"]': {
perspective: '10000px',
transformStyle: 'preserve-3d',
},
// hack background color for web
'&::after': {
content: '',
position: 'absolute',
inset: 0,
background: onboardingVars.web.bg,
transform: 'translateZ(-1000px) scale(2)',
transition: 'opacity 0.3s ease',
},
'&[data-is-desktop="true"]::after': {
animation: `${fadeIn} 0.8s linear`,
// content: 'unset',
background:
'linear-gradient(180deg, rgba(0,0,0,0.8) 0%, rgba(0,0,0,0) 99.58%)',
},
'&[data-is-window="true"][data-is-desktop="true"]::after': {
opacity: 0,
},
},
]);
globalStyle(`${onboarding} *`, {
});
globalStyle(`${onboarding}[data-is-window="false"] *`, {
perspective: '10000px',
transformStyle: 'preserve-3d',
});
@@ -146,3 +143,7 @@ globalStyle(`${tipsWrapper} > *`, {
globalStyle(`${tipsWrapper}[data-visible="true"] > *`, {
pointerEvents: 'auto',
});
// transparent background for onboarding window
globalStyle(`:root`, {
backgroundColor: 'transparent',
});
@@ -1,3 +1,4 @@
import { cssVarV2 } from '@toeverything/theme/v2';
import { keyframes, style } from '@vanilla-extract/css';
import { block } from '../articles/blocks.css';
@@ -33,24 +34,21 @@ export const switchButtons = style({
});
export const switchButton = style({
width: 24,
height: 24,
transform: 'scale(2)',
width: 48,
height: 48,
fontSize: 36,
display: 'flex',
alignItems: 'center',
justifyContent: 'center',
boxShadow: 'none',
opacity: 0.6,
cursor: 'pointer',
color: cssVarV2('switch/iconColor/default'),
position: 'relative',
selectors: {
'&:nth-child(1)': {
transformOrigin: 'left',
},
'&:nth-child(2)': {
transformOrigin: 'right',
},
'&[data-active="true"]': {
opacity: 1,
color: cssVarV2('switch/iconColor/active'),
},
},
});
@@ -1,10 +1,7 @@
import { EdgelessIcon, PageIcon } from '@blocksuite/icons/rc';
import clsx from 'clsx';
import type { HTMLAttributes } from 'react';
import {
EdgelessSwitchItem,
PageSwitchItem,
} from '../../../blocksuite/block-suite-mode-switch/switch-items';
import type { EdgelessSwitchMode } from '../types';
import * as styles from './style.css';
@@ -27,16 +24,20 @@ export const EdgelessSwitchButtons = ({
className={clsx(styles.switchButtons, className)}
{...attrs}
>
<PageSwitchItem
<div
className={styles.switchButton}
data-active={mode === 'page'}
onClick={onSwitchToPageMode}
/>
<EdgelessSwitchItem
>
<PageIcon />
</div>
<div
className={styles.switchButton}
data-active={mode === 'edgeless'}
onClick={onSwitchToEdgelessMode}
/>
>
<EdgelessIcon />
</div>
</div>
);
};
@@ -349,7 +349,6 @@ export const ToolbarSVG = memo(function ToolbarSVG() {
fillRule="evenodd"
clipRule="evenodd"
d="M378.235 49.6273C377.131 49.6273 376.235 50.5228 376.235 51.6273V77.6087H448.178V51.6273C448.178 50.5227 447.283 49.6273 446.178 49.6273H378.235ZM399.765 53.9412C398.205 53.9412 396.941 55.2053 396.941 56.7647C396.941 58.3241 398.205 59.5883 399.765 59.5883H425.177C426.736 59.5883 428 58.3241 428 56.7647C428 55.2053 426.736 53.9412 425.177 53.9412H399.765Z"
fill="url(#pattern0)"
fillOpacity="0.24"
/>
<path
@@ -1823,17 +1822,6 @@ export const ToolbarSVG = memo(function ToolbarSVG() {
result="shape"
/>
</filter>
<pattern
id="pattern0"
patternContentUnits="objectBoundingBox"
width="1.49325"
height="3.83929"
>
<use
xlinkHref="#image0_14855_31855"
transform="scale(0.000729125 0.00187465)"
/>
</pattern>
<filter
id="filter10_f_14855_31855"
x="439.342"
@@ -3731,12 +3719,6 @@ export const ToolbarSVG = memo(function ToolbarSVG() {
fill="white"
/>
</clipPath>
<image
id="image0_14855_31855"
width="2048"
height="2048"
xlinkHref="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAACAAAAAgACAYAAACyp9MwAAAAAXNSR0IArs4c6QAAIABJREFUeF7sveHa3ritK9p9/xd9zuOu5S6PK4kACFLym+RPpxEJAqAsUV/S6f/7F/fr//vXv/71//435fnPHIoW3V1PY/nfWSPPslpW+Vlsl24XDqLnHYPkuPi5cVzcRzgMNhPr9qAbb6b1Sx5UcGUwmVhnf9Vvv5tvd72Rx677+wQtlXvIif0XK+/Aifvt5pThhuYicUjMqhNofsdduWu+RT24fXTsgQtLravk5r/G/+PL8n7zVfLf3jv0vDHe9+S1fr97K+o5MTOeOnnM5o9KL13zjWOPXVwirWyv2Hilnx01nryc9TJYJ+wdhf8op+OOVvZWR47iIcKrytM3LsIfiUE0nRLj0hPhROuO+bjC0wzv1V2G4CIxFZqr7giUK6objZvVZfOj+Gg982ZAsFF/T/rWvqyrijsyvzp6/RUM5Z5mz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