Skip to content

Commit cbc359e

Browse files
authored
Merge pull request #25 from templerobotics/fixing-video
Fixed video and copyright
2 parents e301810 + b1c8d53 commit cbc359e

File tree

4 files changed

+66
-32
lines changed

4 files changed

+66
-32
lines changed

src/App.tsx

Lines changed: 53 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@ import React, { useEffect } from 'react'
44
import { BrowserRouter as Router, Route, Routes } from 'react-router-dom'
55
import { ToastContainer } from 'react-toastify'
66
import 'react-toastify/dist/ReactToastify.css'
7+
import { isMobile } from 'react-device-detect'
8+
import styled from 'styled-components'
79

810
// Styles
911
import 'bootstrap/dist/css/bootstrap.min.css'
@@ -19,44 +21,71 @@ import Copyright from './pages/general/copyright/Copyright'
1921
import Rocksat from './pages/rocksat/Rocksat'
2022
import Ballooning from './pages/ballooning/Ballooning'
2123
import NoMatch404 from './pages/general/NoMatch404'
24+
import spaceBackground from './assets/pics/outreach/space-background.jpeg'
2225

2326
// Images
2427
import backgroundVideo1 from './assets/vids/nasa-vid-1.webm'
2528
import { PATHS } from './tools/Constants'
2629

30+
class Styles {
31+
static readonly AppContainer = styled.div<{height: number}>`
32+
min-height: ${props => props.height + 'px'};
33+
`
34+
35+
static readonly Content = styled.div<{height: number}>`
36+
min-height: ${props => props.height + 'px'};
37+
display: grid;
38+
`
39+
}
40+
2741
const App = (): React.ReactElement => {
2842
// Used for Sign-Ups
2943
useEffect(() => { getEventToasts() })
44+
const height = window.innerHeight
45+
46+
const getBackground = (): React.ReactElement => {
47+
if (isMobile) {
48+
return (
49+
<img src={spaceBackground} id='video-background'/>
50+
)
51+
} else {
52+
return (
53+
<video loop muted autoPlay playsInline id='video-background'>
54+
<source src={backgroundVideo1} type='video/webm'/>
55+
</video>
56+
)
57+
}
58+
}
3059

3160
return (
32-
<>
61+
<Styles.AppContainer height={height}>
3362
<ToastContainer style={{fontSize: 'var(--bs-body-font-size)'}}/>
34-
<video loop muted autoPlay playsInline id='video-background'>
35-
<source src={backgroundVideo1} type='video/webm'/>
36-
</video>
63+
{getBackground()}
3764
<GlobalStyles/>
3865
{/* The basename is if this is not a org website <Router basename='website-2.0'> */}
39-
<Router>
40-
<div className='App'>
41-
<Navigation/>
42-
<div className='content'>
43-
{/* Define routes within the website */}
44-
<Routes>
45-
<Route path='/' element={<Home/>}/>
46-
<Route path={PATHS.HOME} element={<Home/>}/>
47-
<Route path={PATHS.EVENTS} element={<Events/>}/>
48-
<Route path={PATHS.ROBOTICS} element={<RoboticMining/>}/>
49-
<Route path={PATHS.SPONSORS} element={<Sponsors/>}/>
50-
<Route path={PATHS.ROCKSAT} element={<Rocksat/>}/>
51-
<Route path={PATHS.BALLOONING} element={<Ballooning/>}/>
52-
{/* If no path was matched, go to 404 page */}
53-
<Route path='*' element={<NoMatch404/>}/>
54-
</Routes>
66+
<Styles.Content height={height}>
67+
<Router>
68+
<div className='App'>
69+
<Navigation/>
70+
<div className='content'>
71+
{/* Define routes within the website */}
72+
<Routes>
73+
<Route path='/' element={<Home/>}/>
74+
<Route path={PATHS.HOME} element={<Home/>}/>
75+
<Route path={PATHS.EVENTS} element={<Events/>}/>
76+
<Route path={PATHS.ROBOTICS} element={<RoboticMining/>}/>
77+
<Route path={PATHS.SPONSORS} element={<Sponsors/>}/>
78+
<Route path={PATHS.ROCKSAT} element={<Rocksat/>}/>
79+
<Route path={PATHS.BALLOONING} element={<Ballooning/>}/>
80+
{/* If no path was matched, go to 404 page */}
81+
<Route path='*' element={<NoMatch404/>}/>
82+
</Routes>
83+
</div>
5584
</div>
56-
</div>
57-
</Router>
58-
<Copyright/>
59-
</>
85+
</Router>
86+
<Copyright/>
87+
</Styles.Content>
88+
</Styles.AppContainer>
6089
)
6190
}
6291

src/pages/general/copyright/CopyrightStyles.tsx

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,13 @@ import { COLORS } from '../../../tools/Constants'
44

55
export default class CopyrightStyles {
66
static readonly CopyrightContainer = styled.div`
7-
background-color: ${COLORS.PRIMARY};
8-
text-align: center;
9-
height: 100%;
7+
height: calc(var(--vh) * .02);
8+
align-self: end;
9+
background-color: ${COLORS.PRIMARY};
10+
text-align: center;
11+
width: 100%;
12+
display: flex;
13+
justify-content: center;
14+
align-items: center;
1015
`
1116
}

src/pages/general/navigation/Navigation.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,14 +8,14 @@ import Styles from './NavigationStyles'
88

99
// General tools
1010
import * as Constants from '../../../tools/Constants'
11-
import { getScrollY, getWindowWidth, scrollToTop } from '../../../tools/HelpfulFunctions'
11+
import { getScrollY, useWindowSize, scrollToTop } from '../../../tools/HelpfulFunctions'
1212

1313
// Images
1414
import nasaLogo from '../../../assets/pics/logos/nasa.png'
1515

1616
const Navigation = (): React.ReactElement => {
1717
const { scroll } = getScrollY()
18-
const { width } = getWindowWidth()
18+
const { width } = useWindowSize()
1919
return (
2020
<>
2121
{/* The rest of the navigation bar. The className is dependent on whether the navbar is expanded or not */}

src/tools/HelpfulFunctions.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,12 @@ export const scrollToTop = (): void =>{
99
})
1010
}
1111

12-
export const getWindowWidth = (): {width: number} => {
13-
const [dimensions, setWidth] = useState({ width: window.innerWidth })
12+
export const useWindowSize = (): {width: number, height: number} => {
13+
const [dimensions, setWidth] = useState({ width: window.innerWidth, height: window.innerHeight })
1414

1515
useEffect(() => {
1616
const handler = debounce(() => {
17-
setWidth({ width: window.innerWidth })
17+
setWidth({ width: window.innerWidth, height: window.innerHeight })
1818
}, 10)
1919

2020
window.addEventListener('scroll', handler)

0 commit comments

Comments
 (0)