-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
solve position. still need to figure the content better
- Loading branch information
1 parent
f46db88
commit 0c6bff6
Showing
4 changed files
with
78 additions
and
76 deletions.
There are no files selected for viewing
10 changes: 10 additions & 0 deletions
10
src/components/PageLayout/Header/HeaderHeightContainer.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
import {useState} from 'react' | ||
import {createContainer} from 'unstated-next' | ||
|
||
const useHeaderHeight = () => { | ||
const [height, setHeight] = useState(0) | ||
|
||
return {height, setHeight} | ||
} | ||
|
||
export const HeaderHeightContainer = createContainer(useHeaderHeight) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,60 +1,34 @@ | ||
import {Box, Button} from '@mui/material' | ||
import {FC, useEffect, useRef, useState} from 'react' | ||
import {Box} from '@mui/material' | ||
import {FC} from 'react' | ||
|
||
import Strom from '@/svg/strom.svg' | ||
import {BannerContainer} from '@/utils/BannerContainer' | ||
|
||
export const StromLogo: FC = () => { | ||
const firstBoxRef = useRef<HTMLDivElement>(null) | ||
const [topPosition, setTopPosition] = useState(0) | ||
|
||
const {bannerMessages} = BannerContainer.useContainer() | ||
|
||
const updateTopPosition = () => { | ||
if (firstBoxRef.current) { | ||
const rect = firstBoxRef.current.getBoundingClientRect() | ||
setTopPosition(rect.top) | ||
console.log(rect.top) | ||
} | ||
} | ||
import {HeaderHeightContainer} from '../Header/HeaderHeightContainer' | ||
|
||
useEffect(() => { | ||
updateTopPosition() | ||
// toto sa prepocita skor ako sa baner zobrazi v plnej sirke, takze toto uplne nefunguje | ||
// dalsim problemom je ked sa zmeni nadpis (napriklad pri poradi prejdes z poradia semestra na seriu - zvacsi sa nadpis - banner sa posunie nizsie) | ||
}, [bannerMessages]) | ||
export const StromLogo: FC = () => { | ||
const {height} = HeaderHeightContainer.useContainer() | ||
|
||
return ( | ||
<> | ||
{/* zistit pozicitu tohto boxu a nastavit to ako top pre box obsahujuci strom */} | ||
<Box ref={firstBoxRef}> | ||
<Button onClick={updateTopPosition}>Update top position</Button> | ||
<Box | ||
sx={{ | ||
// NOTE (odstranit): 'sticky' (a bez width) ma inak tiez celkom zaujimavy vysledok | ||
position: 'fixed', | ||
width: '25%', | ||
// cisla odpovedaju top paddingom v `PageLayout` (dali by sa sem asi passnut zhora ci ukonstantovat) | ||
top: {xs: height + 32, md: height + 64, lg: height + 96}, | ||
zIndex: -1, | ||
}} | ||
> | ||
{/* TODO: vyriesit lepsie :D nastavit nejak SVG ako background a nejake repeat-nieco? */} | ||
<Box> | ||
<Strom width="100%" height="100%" preserveAspectRatio="xMaxYMin" /> | ||
</Box> | ||
<Box> | ||
<Strom width="100%" height="100%" preserveAspectRatio="xMaxYMin" /> | ||
</Box> | ||
<Box | ||
sx={{ | ||
position: 'fixed', | ||
// tieto cisla su take dost ad-hoc | ||
// je potrebne doratat este podla toho ze ci sa zobrazuje alebo nezobrazuje baner | ||
// taktiez pri sirke 900 - 1100px sa niektore nadpisy zalomuju a rozbijaju zarovnanie stromu | ||
// - problem toho je ze to je rozlisenie vacsinu tabletov na vysku, takze to bude treba fixnut | ||
// top: {md: '213px', lg: '265px', xl: '301px'}, | ||
top: topPosition, | ||
left: 0, | ||
bottom: 0, | ||
width: '25%', | ||
// paddingTop: 2, | ||
overflow: 'hidden', | ||
display: 'flex', | ||
flexDirection: 'column', | ||
alignItems: 'end', | ||
zIndex: -1, | ||
}} | ||
> | ||
<Box> | ||
{/* itenditfikovat vysku obrazovky a podla toho pasnut strom s potrebnym poctom trojuholnikov */} | ||
<Strom width="100%" height="auto" preserveAspectRatio="xMaxYMin" /> | ||
</Box> | ||
<Box> | ||
<Strom width="100%" height="100%" preserveAspectRatio="xMaxYMin" /> | ||
</Box> | ||
</> | ||
</Box> | ||
) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters