Skip to content

Commit cf988cc

Browse files
authored
Home: improve watch tiles (#4955)
1 parent b2b184d commit cf988cc

3 files changed

Lines changed: 78 additions & 26 deletions

File tree

website/src/components/Home/Watch/index.tsx

Lines changed: 53 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -5,14 +5,16 @@
55
* LICENSE file in the root directory of this source tree.
66
*/
77

8-
import React from 'react';
8+
import {useState} from 'react';
99

1010
import Section from '../Section';
1111
import SectionTitle from '../SectionTitle';
1212

1313
import styles from './styles.module.css';
1414

1515
function Watch() {
16+
const [playingId, setPlayingId] = useState<string | null>(null);
17+
1618
return (
1719
<Section>
1820
<SectionTitle
@@ -34,29 +36,61 @@ function Watch() {
3436
}
3537
/>
3638
<div className={styles.videos}>
37-
<div className={styles.videoContainer}>
38-
<iframe
39-
src="https://www.youtube.com/embed/NCAY0HIfrwc"
40-
title="Mobile Innovation with React Native, ComponentKit, and Litho"
41-
frameBorder="0"
42-
allow="accelerometer; autoplay; encrypted-media; gyroscope; picture-in-picture"
43-
allowFullScreen
44-
className={styles.video}
45-
/>
39+
<div
40+
role="button"
41+
aria-label="Play: FB 2019: Mobile innovation with React Native"
42+
className={[
43+
styles.videoContainer,
44+
playingId === 'fb2019'
45+
? styles.videoContainerPlaying
46+
: styles.videoContainerHover,
47+
].join(' ')}
48+
onClick={() => setPlayingId('fb2019')}>
49+
{playingId === 'fb2019' ? (
50+
<iframe
51+
src="https://www.youtube.com/embed/NCAY0HIfrwc?autoplay=1"
52+
title="Mobile Innovation with React Native, ComponentKit, and Litho"
53+
allow="accelerometer; autoplay; encrypted-media; gyroscope; picture-in-picture"
54+
allowFullScreen
55+
className={styles.video}
56+
/>
57+
) : (
58+
<img
59+
src="https://img.youtube.com/vi/NCAY0HIfrwc/maxresdefault.jpg"
60+
alt="Mobile Innovation with React Native, ComponentKit, and Litho"
61+
className={styles.video}
62+
/>
63+
)}
4664
<div className={styles.videoInfo}>
4765
<h4>FB 2019: Mobile innovation with React Native</h4>
4866
<p>45:29</p>
4967
</div>
5068
</div>
51-
<div className={styles.videoContainer}>
52-
<iframe
53-
src="https://www.youtube.com/embed/wUDeLT6WXnQ"
54-
title="Explain Like I'm 5: React Native"
55-
frameBorder="0"
56-
allow="accelerometer; autoplay; encrypted-media; gyroscope; picture-in-picture"
57-
allowFullScreen
58-
className={styles.video}
59-
/>
69+
<div
70+
role="button"
71+
aria-label="Play: Why React Native?"
72+
className={[
73+
styles.videoContainer,
74+
playingId === 'why'
75+
? styles.videoContainerPlaying
76+
: styles.videoContainerHover,
77+
].join(' ')}
78+
onClick={() => setPlayingId('why')}>
79+
{playingId === 'why' ? (
80+
<iframe
81+
src="https://www.youtube.com/embed/wUDeLT6WXnQ?autoplay=1"
82+
title="Explain Like I'm 5: React Native"
83+
allow="accelerometer; autoplay; encrypted-media; gyroscope; picture-in-picture"
84+
allowFullScreen
85+
className={styles.video}
86+
/>
87+
) : (
88+
<img
89+
src="https://img.youtube.com/vi/wUDeLT6WXnQ/maxresdefault.jpg"
90+
alt="Explain Like I'm 5: React Native"
91+
className={styles.video}
92+
/>
93+
)}
6094
<div className={styles.videoInfo}>
6195
<h4>Why React Native?</h4>
6296
<p>1:42</p>

website/src/components/Home/Watch/styles.module.css

Lines changed: 24 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -15,32 +15,50 @@
1515
.videoContainer {
1616
border: 1px solid var(--home-border);
1717
border-radius: 12px;
18-
box-shadow: 0px 4px 8px rgba(0, 0, 0, 0.03);
18+
box-shadow: 0 4px 8px rgba(0, 0, 0, 0.03);
1919
padding: 16px;
2020
display: flex;
2121
flex-direction: column;
2222
gap: 1rem;
2323
max-width: 400px;
2424
background: var(--home-background);
25+
cursor: pointer;
26+
transition: background-color 0.2s;
27+
}
28+
29+
.videoContainerHover {
30+
&:hover {
31+
background: var(--home-secondary-background);
32+
}
33+
}
34+
35+
.videoContainerPlaying {
36+
cursor: auto;
2537
}
2638

2739
.video {
2840
width: 100%;
29-
height: 200px;
41+
max-height: 206px;
3042
border-radius: 8px;
3143
border: 1px solid var(--home-border);
44+
aspect-ratio: 16/9;
3245
}
3346

3447
.videoInfo {
3548
display: flex;
49+
flex: 1;
3650
gap: 1rem;
3751
align-items: center;
3852
justify-content: space-between;
39-
}
4053

41-
.videoInfo p {
42-
position: relative;
43-
top: 2px;
54+
h4 {
55+
margin-bottom: 0;
56+
}
57+
58+
p {
59+
margin-bottom: 0;
60+
line-height: 21px;
61+
}
4462
}
4563

4664
@media only screen and (max-width: 700px) {

website/src/css/customTheme.scss

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@
113113
--home-feature-background-1: #f4e3fc;
114114
--home-feature-background-2: #e1eefc;
115115
--home-feature-background-3: #d4f3e7;
116-
--home-border: #e5e7eb;
116+
--home-border: #dfe1e6;
117117
--home-background: #fff;
118118
--home-secondary-background: #f6f7f9;
119119
--home-text: #1c1e21;

0 commit comments

Comments
 (0)