Skip to content

Commit 7d8f3b5

Browse files
committed
video fixes
1 parent 53359aa commit 7d8f3b5

5 files changed

Lines changed: 20 additions & 13 deletions

File tree

src/components/css/main/index.module.css

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@
2828
}
2929

3030
.content {
31-
max-width: 1000px;
31+
max-width: 1200px;
3232
width: 100%;
3333
justify-self: "center";
3434
flex-grow: 1;

src/components/css/main/index.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ export const Main: React.FC = () => {
9595

9696
<Expandable expanded={showContent}>
9797
<div ref={contentRef} className={styles.content}>
98-
<div style={{ margin: '5vh 4vw', padding: '5vh 0' }}>{selectedPage?.page}</div>
98+
<div style={{ margin: '32px 24px', padding: '32px 0' }}>{selectedPage?.page}</div>
9999
</div>
100100
</Expandable>
101101

src/lib/Portfolio.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ const titleStyle: CSSProperties = {
3636
export const RenderPortfolioItem: React.FC<{ item: PortfolioItem }> = ({ item }) => {
3737
const [expanded, setExpanded] = useState(false);
3838

39-
const media = item.images?.map((image, i) => <div key={i} style={{ width: 'auto', height: '100%', justifySelf: 'end' }} >{image}</div>)
39+
const media = item.images?.map((image, i) => <div key={i} style={{ width: '100%', height: '100%', justifySelf: 'end' }} >{image}</div>)
4040

4141
const yearStr = item.date.getFullYear().toString().substring(2);
4242

@@ -67,8 +67,8 @@ export const RenderPortfolioItem: React.FC<{ item: PortfolioItem }> = ({ item })
6767
</a> : header}
6868

6969
<div style={{ display: 'flex', flexDirection: 'column' }}>{item.content}</div>
70-
<div style={{ display: 'flex', flexDirection: 'row', alignItems: 'center', flexWrap: 'wrap' }}>
71-
{media?.map((m, i) => <div key={i} style={{ width: expanded ? '90%' : '30%', minWidth: 128, aspectRatio: expanded ? 'initial' : '1', margin: 8 }}>{m}</div>)}
70+
<div style={{ display: 'flex', flexDirection: 'row', alignItems: 'start', flexWrap: 'wrap' }}>
71+
{media?.map((m, i) => <div key={i} style={{ width: expanded ? '45%' : 256, minWidth: 128, aspectRatio: expanded ? 'initial' : '1', margin: 8 }}>{m}</div>)}
7272
</div>
7373
</div>
7474
}

src/lib/Video.tsx

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,13 @@ export const Video = ({ style, src, muted, onExitFullscreen, ...props }: VideoPr
2020

2121
const [fullscreen, setFullscreen] = useState(onExitFullscreen != undefined);
2222

23+
const isBgVideo = onExitFullscreen == null && fullscreen;
24+
2325
function setPlaying(isPlaying: boolean) {
26+
if (isBgVideo && isPlaying) {
27+
setPlaying(false)
28+
return;
29+
}
2430
if (!isPlaying) {
2531
setShowMutedIcon(true)
2632
if (videoRef.current != null)
@@ -37,7 +43,7 @@ export const Video = ({ style, src, muted, onExitFullscreen, ...props }: VideoPr
3743

3844
return <MediaContainer style={{ ...style }}
3945
>
40-
<a href={src} role='button' aria-label='video' style={{ position: 'relative', display: 'flex', width: '100%', height: '100%' }}
46+
<div role='button' aria-label='video' style={{ cursor: 'pointer', position: 'relative', display: 'flex', width: '100%', height: '100%' }}
4147
onMouseOver={
4248
(e) => {
4349
e.preventDefault()
@@ -76,9 +82,10 @@ export const Video = ({ style, src, muted, onExitFullscreen, ...props }: VideoPr
7682
play_circle
7783
</span>}
7884

79-
<a onClick={(e) => {
85+
<div onClick={(e) => {
8086
e.stopPropagation();
8187
e.preventDefault();
88+
setPlaying(false);
8289
return onExitFullscreen != null ? onExitFullscreen() : setFullscreen(true);
8390
}}>
8491
<span className="material-symbols-outlined" style={{
@@ -91,16 +98,16 @@ export const Video = ({ style, src, muted, onExitFullscreen, ...props }: VideoPr
9198
// cursor: 'zoom-in'
9299
// transform: 'translate(-50%, -50%)'
93100
}}>fullscreen</span>
94-
</a>
101+
</div>
95102

96-
<video muted autoPlay={isPlaying} loop ref={videoRef} src={src} style={{ width: '100%', height: '100%', objectFit: "cover" }} {...props} > </video>
103+
<video muted autoPlay={isPlaying} loop ref={videoRef} src={src} style={{ width: '100%', height: '100%' }} {...props} > </video>
97104

98105
{onExitFullscreen == null && <ReactModal isOpen={fullscreen} onRequestClose={() => setFullscreen(false)} style={{
99106
overlay: { backgroundColor: 'rgba(0,0,0,0.8)', zIndex: 1000 },
100107
}}>
101-
<Video onExitFullscreen={() => setFullscreen(false)} src={src} muted={muted} />
108+
<Video onExitFullscreen={() => setFullscreen(false)} src={src} style={{ objectFit: 'inherit', margin: 0 }} muted={muted} />
102109
</ReactModal>}
103110

104-
</a>
111+
</div>
105112
</MediaContainer>
106113
}

src/lib/Youtube.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
import { CSSProperties } from "react"
22
import { MediaContainer } from "./MediaContainer"
33

4-
interface YoutubeParams{
4+
interface YoutubeParams {
55
style?: CSSProperties,
66
embedId: string
77
}
88

9-
export const Youtube = ({embedId, style}: YoutubeParams) =>
9+
export const Youtube = ({ embedId, style }: YoutubeParams) =>
1010
<MediaContainer style={{
1111
position: "relative",
1212
aspectRatio: '16/9',

0 commit comments

Comments
 (0)