mirror of
https://gitlab.com/MrFry/qmining-page
synced 2025-04-01 20:23:44 +02:00
Merge branch 'master' of gitlab.com:MrFry/qmining-page
This commit is contained in:
commit
7c51651a6c
1 changed files with 33 additions and 18 deletions
|
@ -1,4 +1,5 @@
|
||||||
import React, { useState, useEffect } from 'react'
|
import React, { useState, useEffect } from 'react'
|
||||||
|
import ReactDOM from 'react-dom'
|
||||||
import Link from 'next/link'
|
import Link from 'next/link'
|
||||||
import dynamic from 'next/dynamic'
|
import dynamic from 'next/dynamic'
|
||||||
|
|
||||||
|
@ -13,12 +14,42 @@ import styles from './layout.module.css'
|
||||||
import tabs from '../data/tabs.json'
|
import tabs from '../data/tabs.json'
|
||||||
import topBarLinks from '../data/topBarLinks.json'
|
import topBarLinks from '../data/topBarLinks.json'
|
||||||
|
|
||||||
const renderSnow = () => {
|
const shouldRenderSnow = () => {
|
||||||
const date = new Date()
|
const date = new Date()
|
||||||
// if its december, and date is more than 5
|
// if its december, and date is more than 5
|
||||||
return date.getMonth() === 11 && date.getDate() > 5
|
return date.getMonth() === 11 && date.getDate() > 5
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function Snow() {
|
||||||
|
const [windowSize, setWindowSize] = useState([100, 200])
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
setWindowSize([window.innerWidth, window.innerHeight])
|
||||||
|
window.addEventListener('resize', () => {
|
||||||
|
setWindowSize([window.innerWidth, window.innerHeight])
|
||||||
|
})
|
||||||
|
}, [])
|
||||||
|
|
||||||
|
const snowflakeCount = (windowSize[0] + windowSize[1]) / 26
|
||||||
|
|
||||||
|
if (typeof window !== 'object') return null
|
||||||
|
|
||||||
|
return ReactDOM.createPortal(
|
||||||
|
<div
|
||||||
|
style={{
|
||||||
|
pointerEvents: 'none',
|
||||||
|
zIndex: 900,
|
||||||
|
position: 'fixed',
|
||||||
|
width: `${windowSize[0]}px`,
|
||||||
|
height: `${windowSize[1]}px`,
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
<Snowfall snowflakeCount={snowflakeCount} />
|
||||||
|
</div>,
|
||||||
|
document.body
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
function TopBar({
|
function TopBar({
|
||||||
setSidebarOpen,
|
setSidebarOpen,
|
||||||
sidebarOpen,
|
sidebarOpen,
|
||||||
|
@ -192,7 +223,6 @@ function MenuIcon({ setSidebarOpen, sidebarOpen }) {
|
||||||
|
|
||||||
export default function Layout({ children, router, globalData }) {
|
export default function Layout({ children, router, globalData }) {
|
||||||
const [sidebarOpen, setSidebarOpen] = useState(true)
|
const [sidebarOpen, setSidebarOpen] = useState(true)
|
||||||
const [windowSize, setWindowSize] = useState([100, 200])
|
|
||||||
const [donateShowing, setDonateShowing] = useState(false)
|
const [donateShowing, setDonateShowing] = useState(false)
|
||||||
|
|
||||||
const userId = globalData.userId
|
const userId = globalData.userId
|
||||||
|
@ -217,29 +247,13 @@ export default function Layout({ children, router, globalData }) {
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
closeSideBar()
|
closeSideBar()
|
||||||
setWindowSize([window.innerWidth, window.innerHeight])
|
|
||||||
window.addEventListener('resize', () => {
|
window.addEventListener('resize', () => {
|
||||||
setWindowSize([window.innerWidth, window.innerHeight])
|
|
||||||
setSidebarOpen(window.innerWidth >= 700)
|
setSidebarOpen(window.innerWidth >= 700)
|
||||||
})
|
})
|
||||||
}, [])
|
}, [])
|
||||||
const snowflakeCount = (windowSize[0] + windowSize[1]) / 26
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
{renderSnow() && (
|
|
||||||
<div
|
|
||||||
style={{
|
|
||||||
pointerEvents: 'none',
|
|
||||||
zIndex: 900,
|
|
||||||
position: 'fixed',
|
|
||||||
width: `${windowSize[0]}px`,
|
|
||||||
height: `${windowSize[1]}px`,
|
|
||||||
}}
|
|
||||||
>
|
|
||||||
<Snowfall snowflakeCount={snowflakeCount} />
|
|
||||||
</div>
|
|
||||||
)}
|
|
||||||
<div className={styles.topBar}>
|
<div className={styles.topBar}>
|
||||||
<TopBar
|
<TopBar
|
||||||
setSidebarOpen={setSidebarOpen}
|
setSidebarOpen={setSidebarOpen}
|
||||||
|
@ -269,6 +283,7 @@ export default function Layout({ children, router, globalData }) {
|
||||||
) : null}
|
) : null}
|
||||||
<div className={styles.content}>{children}</div>
|
<div className={styles.content}>{children}</div>
|
||||||
<BB />
|
<BB />
|
||||||
|
{shouldRenderSnow() && <Snow />}
|
||||||
</>
|
</>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue