Skip to content

Commit

Permalink
feat(core): use contain strict optimizing performance (#8553)
Browse files Browse the repository at this point in the history
  • Loading branch information
EYHN committed Oct 21, 2024
1 parent a25bb0d commit 42b3e06
Show file tree
Hide file tree
Showing 9 changed files with 17 additions and 17 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ export const root = style({
},
'&[data-open="true"][data-handle-position="left"][data-is-floating="true"]':
{
transform: `translateX(-${panelWidthVar})`,
transform: `translateX(calc(${panelWidthVar} * -1))`,
},
'&[data-enable-animation="true"]': {
transition: `margin-left ${animationTimeout}, margin-right ${animationTimeout}, transform ${animationTimeout}, background ${animationTimeout}`,
Expand All @@ -46,6 +46,12 @@ export const root = style({
},
});

export const content = style({
contain: 'strict',
width: '100%',
height: '100%',
});

export const panelContent = style({
position: 'relative',
height: '100%',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,9 @@ export const ResizePanel = forwardRef<HTMLDivElement, ResizePanelProps>(
data-handle-position={resizeHandlePos}
data-enable-animation={enableAnimation && !resizing}
>
{!(status === 'exited' && unmountOnExit !== false) && children}
<div className={styles.content}>
{!(status === 'exited' && unmountOnExit !== false) && children}
</div>
<ResizeHandle
resizeHandlePos={resizeHandlePos}
resizeHandleOffset={resizeHandleOffset}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ export const root = style({
height: '54px',
// 42 + 12
flexShrink: 0,
contain: 'strict',
width: '100%',
alignItems: 'stretch',
transition: 'background-color 0.2s, opacity 0.2s',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ export const root = style({
flexShrink: 0,
width: '100%',
alignItems: 'stretch',
contain: 'strict',
transition: 'background-color 0.2s, opacity 0.2s',
':hover': {
backgroundColor: cssVar('hoverColor'),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ export const header = style({
alignItems: 'center',
padding: '0px 16px 0px 6px',
height: '28px',
contain: 'strict',
background: cssVar('backgroundPrimaryColor'),
':hover': {
background: cssVar('hoverColorFilled'),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ export const root = style({
// 42 + 12
flexShrink: 0,
width: '100%',
contain: 'strict',
alignItems: 'stretch',
transition: 'background-color 0.2s, opacity 0.2s',
':hover': {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ export const header = style({
flexShrink: 0,
background: cssVar('backgroundPrimaryColor'),
padding: '0 16px',
contain: 'strict',
'@media': {
print: {
display: 'none',
Expand All @@ -31,6 +32,7 @@ export const viewBodyContainer = style({
display: 'flex',
flex: 1,
overflow: 'hidden',
contain: 'strict',
});

export const leftSidebarButton = style({
Expand Down
2 changes: 1 addition & 1 deletion tests/affine-local/e2e/layout.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ test('Drag resizer can resize sidebar', async ({ page }) => {
});
await page.mouse.up();
const boundingBox = await page.getByTestId('app-sidebar').boundingBox();
expect(boundingBox?.width).toBe(399);
expect(Math.floor(boundingBox?.width ?? 0)).toBe(399);
});

test('Sidebar in between sm & md breakpoint', async ({ page }) => {
Expand Down
14 changes: 0 additions & 14 deletions tests/affine-local/e2e/subpage.spec.ts

This file was deleted.

0 comments on commit 42b3e06

Please sign in to comment.