Skip to content
This repository was archived by the owner on Nov 8, 2022. It is now read-only.

Commit 49ed43a

Browse files
authored
fix(wallpaper): global blur issue, adjust layout in global (#1342)
1 parent 6b82bed commit 49ed43a

File tree

4 files changed

+29
-23
lines changed

4 files changed

+29
-23
lines changed
Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { FC, memo, ReactNode } from 'react'
1+
import { FC, memo } from 'react'
22

33
import type { TWallpaper } from '@/spec'
44
import { parseWallpaper } from '@/utils/wallpaper'
@@ -8,20 +8,15 @@ import { Wrapper } from './styles/wallpaper'
88
type TProps = {
99
wallpaper: string
1010
wallpapers: Record<string, TWallpaper>
11-
children: ReactNode
1211
}
1312

14-
const Wallpaper: FC<TProps> = ({ wallpaper, wallpapers, children }) => {
13+
const Wallpaper: FC<TProps> = ({ wallpaper, wallpapers }) => {
1514
const { background, effect } = parseWallpaper(wallpapers, wallpaper)
1615

1716
// for custom image/svg
1817
// for use style object not passing props
1918
// @link see https://github.com/styled-components/styled-components/issues/3315#issuecomment-885977691
20-
return (
21-
<Wrapper style={{ background }} effect={effect}>
22-
{children}
23-
</Wrapper>
24-
)
19+
return <Wrapper style={{ background }} effect={effect} />
2520
}
2621

2722
export default memo(Wallpaper)

src/containers/layout/GlobalLayout/index.tsx

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,13 @@ import Wallpaper from './Wallpaper'
2828

2929
import { CustomScroller, Footer, ModeLine } from './dynamic'
3030

31-
import { Wrapper, InnerWrapper, BodyWrapper, ContentWrapper } from './styles'
31+
import {
32+
Skeleton,
33+
Wrapper,
34+
InnerWrapper,
35+
BodyWrapper,
36+
ContentWrapper,
37+
} from './styles'
3238
import { useInit, onPageScrollDirhange, childrenWithProps } from './logic'
3339

3440
const Addon = dynamic(() => import('./Addon'), {
@@ -62,7 +68,7 @@ const GlobalLayoutContainer: FC<TProps> = ({
6268
<ThemePalette>
6369
{/* @ts-ignore */}
6470
<Addon />
65-
<Wallpaper wallpaper={wallpaper} wallpapers={wallpapers}>
71+
<Skeleton>
6672
{/* @ts-ignore */}
6773
<CustomScroller
6874
instanceKey={BODY_SCROLLER}
@@ -75,6 +81,7 @@ const GlobalLayoutContainer: FC<TProps> = ({
7581
>
7682
<Wrapper>
7783
<SEO metric={metric} config={seoConfig} />
84+
<Wallpaper wallpaper={wallpaper} wallpapers={wallpapers} />
7885
<InnerWrapper metric={metric} sidebarPin={sidebarPin}>
7986
{/* @ts-ignore */}
8087
<ContentWrapper offsetLeft={sidebarPin}>
@@ -96,7 +103,7 @@ const GlobalLayoutContainer: FC<TProps> = ({
96103
{isMobile && <ModeLine metric={metric} />}
97104
</Wrapper>
98105
</CustomScroller>
99-
</Wallpaper>
106+
</Skeleton>
100107
</ThemePalette>
101108
)
102109
}

src/containers/layout/GlobalLayout/styles/index.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,15 @@ import type { TMetric } from '@/spec'
55
// import { ASSETS_ENDPOINT } from '@/config'
66
import css, { theme } from '@/utils/css'
77

8+
/**
9+
* see layout details:
10+
" @link https://css-tricks.com/the-fixed-background-attachment-hack/
11+
*/
12+
export const Skeleton = styled.div`
13+
height: 100vh;
14+
width: 100vw;
15+
`
16+
817
// background: #3b5456;
918
export const Wrapper = styled.div`
1019
${css.flex('justify-center')};
@@ -26,6 +35,7 @@ export const InnerWrapper = styled.div<TInner>`
2635
background: ${theme('bodyBg')};
2736
transition: all 0.2s;
2837
overflow-x: ${({ sidebarPin }) => (sidebarPin ? 'hidden' : '')};
38+
z-index: 1;
2939
${css.media.tablet`
3040
position: relative;
3141
padding-left: 0;

src/containers/layout/GlobalLayout/styles/wallpaper.ts

Lines changed: 6 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,18 @@
11
import styled from 'styled-components'
22

3-
/**
4-
* see layout details:
5-
" @link https://css-tricks.com/the-fixed-background-attachment-hack/
6-
*/
7-
83
export const Wrapper = styled.div<{ effect: string }>`
9-
/* position: fixed; */
10-
/* see https://www.zhangxinxu.com/wordpress/2015/11/css3-will-change-improve-paint/ */
11-
will-change: transform;
124
${({ effect }) => effect || ''};
13-
5+
position: fixed;
6+
top: 0;
147
height: 100vh;
158
width: 100vw;
169
17-
transition: all 0.25s;
10+
/* position: fixed; */
11+
/* see https://www.zhangxinxu.com/wordpress/2015/11/css3-will-change-improve-paint/ */
12+
will-change: transform;
13+
transition: all 0.3s;
1814
`
19-
2015
export const InnerWrapper = styled.div`
21-
position: relative;
2216
left: 50%;
2317
transform: translateX(-50%);
2418
width: 80%;

0 commit comments

Comments
 (0)