Set up API spec and basic components

This commit is contained in:
Ben Grant 2023-05-20 01:52:44 +10:00
parent 2adecd13f7
commit 61bd31eb7e
20 changed files with 353 additions and 26 deletions

View file

@ -0,0 +1,64 @@
.videoWrapper {
margin: 0 auto;
position: relative;
padding-bottom: 56.4%;
width: 100%;
iframe {
position: absolute;
width: 100%;
height: 100%;
border-radius: 10px;
}
}
.preview {
display: block;
text-decoration: none;
position: relative;
width: 100%;
max-width: 400px;
margin: 0 auto;
transition: transform .15s;
&:hover, &:focus {
transform: translateY(-2px);
}
&:active {
transform: translateY(-1px);
}
img {
width: 100%;
display: block;
border-radius: 10px;
background-color: #CCC;
}
span {
color: #FFFFFF;
position: absolute;
top: 50%;
font-size: 1.5rem;
text-align: center;
width: 100%;
display: block;
transform: translateY(-50%);
text-shadow: 0 0 20px rgba(0,0,0,.8);
user-select: none;
&::before {
content: '';
display: block;
height: 2em;
width: 2em;
background: currentColor;
border-radius: 100%;
margin: 0 auto .4em;
background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='24' height='24' viewBox='0 0 24 24' fill='none' stroke='%23F79E00' stroke-width='2' stroke-linecap='round' stroke-linejoin='round' class='feather feather-play'%3E%3Cpolygon points='5 3 19 12 5 21 5 3'%3E%3C/polygon%3E%3C/svg%3E");
background-position: center;
background-repeat: no-repeat;
background-size: 1em;
box-shadow: 0 0 20px 0 rgba(0,0,0,.3);
}
}
}

View file

@ -0,0 +1,43 @@
'use client'
import { useState } from 'react'
import { useTranslation } from '/src/i18n/client'
import video_thumb from '/src/res/video_thumb.jpg'
import styles from './Video.module.scss'
const Video = () => {
const { t } = useTranslation('common')
const [isPlaying, setIsPlaying] = useState(false)
return isPlaying ? (
<div className={styles.videoWrapper}>
<iframe
width="560"
height="315"
src="https://www.youtube.com/embed/yXGd4VXZzcY?modestbranding=1&rel=0&autoplay=1"
title={t<string>('video.title')}
frameBorder="0"
allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture"
allowFullScreen
/>
</div>
) : (
<a
className={styles.preview}
href="https://www.youtube.com/watch?v=yXGd4VXZzcY"
target="_blank"
rel="nofollow noreferrer"
onClick={e => {
e.preventDefault()
setIsPlaying(true)
}}
>
<img src={video_thumb.src} alt={t<string>('video.button')} />
<span>{t('video.button')}</span>
</a>
)
}
export default Video