Skip to content

Commit

Permalink
perf: reduce layout shift
Browse files Browse the repository at this point in the history
(mainly to fix tests)
  • Loading branch information
Xiphe committed Feb 7, 2021
1 parent 0219706 commit 5239ad3
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 18 deletions.
10 changes: 7 additions & 3 deletions src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,11 @@ import {
useBudgetReducer,
initialInitDataRes,
} from './budget';
import { ErrorBoundary, Startup } from './components';
import {
ErrorBoundary,
Startup,
ScrollBarDimensionProvider,
} from './components';
import styles from './App.module.scss';
import { useNumberFormatter, useRetryResource } from './lib';
import { useMoneyMoney } from './moneymoney';
Expand Down Expand Up @@ -71,7 +75,7 @@ export default function AppWrapper() {
);

return (
<div
<ScrollBarDimensionProvider
className={classNames(
styles.app,
process.env.REACT_APP_ENV === 'test' && styles.appTest,
Expand All @@ -82,6 +86,6 @@ export default function AppWrapper() {
<App readInitialView={retryReadInit} />
</ErrorBoundary>
</Suspense>
</div>
</ScrollBarDimensionProvider>
);
}
1 change: 1 addition & 0 deletions src/components/Content/Content.module.scss
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
.content {
margin-top: var(--header-height);
height: calc(100vh - var(--header-height));
overflow: hidden;
}
.padding {
padding: 0 2rem;
Expand Down
5 changes: 2 additions & 3 deletions src/components/Content/Content.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import React, { ReactNode } from 'react';
import classNames from 'classnames';
import styles from './Content.module.scss';
import ScrollbarDimensionProvider from '../ScrollBarDimensionProvider';

type Props = {
className?: string;
Expand All @@ -22,7 +21,7 @@ export default function Content({
return (
<>
{header}
<ScrollbarDimensionProvider
<div
className={classNames(
className,
styles.content,
Expand All @@ -32,7 +31,7 @@ export default function Content({
)}
>
{children}
</ScrollbarDimensionProvider>
</div>
</>
);
}
1 change: 1 addition & 0 deletions src/components/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,6 @@ export { default as Select } from './Select';
export { default as Row } from './Row';
export { default as Button } from './Button';
export { default as InfiniteSlider } from './InfiniteSlider';
export { default as ScrollBarDimensionProvider } from './ScrollBarDimensionProvider';
export * from './TabBar';
export type ScrollTo = ScrollToT;
16 changes: 4 additions & 12 deletions src/views/Month/Month.module.scss
Original file line number Diff line number Diff line change
Expand Up @@ -6,20 +6,12 @@
max-width: calc(100vw - var(--sidebar-width) - var(--scrollbar-x, 0));
height: var(--sidebar-height, 'auto');
@media (min-width: 800px) {
min-width: calc(
calc(100vw - var(--sidebar-width) - var(--scrollbar-x, 0)) / 2
);
max-width: calc(
calc(100vw - var(--sidebar-width) - var(--scrollbar-x, 0)) / 2
);
min-width: calc((100vw - var(--sidebar-width) - var(--scrollbar-x, 0)) / 2);
max-width: calc((100vw - var(--sidebar-width) - var(--scrollbar-x, 0)) / 2);
}
@media (min-width: 1100px) {
min-width: calc(
calc(100vw - var(--sidebar-width) - var(--scrollbar-x, 0)) / 3
);
max-width: calc(
calc(100vw - var(--sidebar-width) - var(--scrollbar-x, 0)) / 3
);
min-width: calc((100vw - var(--sidebar-width) - var(--scrollbar-x, 0)) / 3);
max-width: calc((100vw - var(--sidebar-width) - var(--scrollbar-x, 0)) / 3);
}
}

Expand Down

0 comments on commit 5239ad3

Please sign in to comment.