Skip to content

Commit e7bbf5c

Browse files
committed
fix: add back missing VideoDrawer block
1 parent 36041c5 commit e7bbf5c

7 files changed

Lines changed: 180 additions & 0 deletions

File tree

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
import type { Block } from 'payload'
2+
3+
export const VideoDrawerBlock: Block = {
4+
slug: 'VideoDrawer',
5+
fields: [
6+
{
7+
name: 'id',
8+
type: 'text',
9+
required: true,
10+
},
11+
{
12+
name: 'label',
13+
type: 'text',
14+
required: true,
15+
},
16+
{
17+
name: 'drawerTitle',
18+
type: 'text',
19+
required: true,
20+
},
21+
],
22+
interfaceName: 'VideoDrawerBlock',
23+
jsx: {
24+
export: ({ fields }) => {
25+
return {
26+
props: {
27+
id: fields.id,
28+
drawerTitle: fields.drawerTitle,
29+
label: fields.label,
30+
},
31+
}
32+
},
33+
import: ({ props }) => {
34+
return {
35+
id: props.id,
36+
drawerTitle: props.drawerTitle,
37+
label: props.label,
38+
}
39+
},
40+
},
41+
}

src/collections/Docs/index.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ import { LightDarkImageBlock } from './blocks/lightDarkImage'
2222
import { RestExamplesBlock } from './blocks/restExamples'
2323
import { TableWithDrawersBlock } from './blocks/tableWithDrawers'
2424
import { UploadBlock } from './blocks/upload'
25+
import { VideoDrawerBlock } from './blocks/VideoDrawer'
2526
import { YoutubeBlock } from './blocks/youtube'
2627
import { lexicalToMDX } from './mdxToLexical'
2728

@@ -38,6 +39,7 @@ export const contentLexicalEditorFeatures: FeatureProviderServer[] = [
3839
UploadBlock,
3940
RestExamplesBlock,
4041
TableWithDrawersBlock,
42+
VideoDrawerBlock,
4143
],
4244
}),
4345
]
Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
@use '@scss/common' as *;
2+
.videoDrawerToggler {
3+
@include btnReset;
4+
width: 100%;
5+
margin: 0.5rem 0 1.5rem 0;
6+
background: var(--theme-elevation-150);
7+
transition: all 200ms ease-in-out;
8+
border-bottom: 2px solid var(--theme-elevation-700);
9+
&:hover {
10+
background: var(--theme-elevation-200);
11+
cursor: pointer;
12+
.playIcon {
13+
transform: translate(-50%, -50%) scale(1.1);
14+
}
15+
}
16+
.wrap {
17+
display: flex;
18+
}
19+
.thumbnail {
20+
position: relative;
21+
flex-shrink: 0;
22+
height: auto;
23+
width: 6rem;
24+
}
25+
.playIcon {
26+
position: absolute;
27+
top: 50%;
28+
left: 50%;
29+
transform: translate(-50%, -50%);
30+
transition: all 200ms ease-in-out;
31+
}
32+
.arrow {
33+
margin-left: 1rem;
34+
}
35+
.labelWrap {
36+
width: 100%;
37+
padding: 1.5rem;
38+
display: flex;
39+
align-items: center;
40+
justify-content: space-between;
41+
text-align: left;
42+
}
43+
@include large-break {
44+
.labelWrap {
45+
padding: 1rem;
46+
}
47+
}
48+
@include mid-break {
49+
.thumbnail {
50+
width: 4rem;
51+
}
52+
}
53+
@include extra-small-break {
54+
.labelWrap {
55+
display: inline-block;
56+
}
57+
.arrow {
58+
margin-left: 0.5rem;
59+
width: 0.5rem;
60+
height: 0.5rem;
61+
}
62+
}
63+
}
64+
html[data-theme='light'] {
65+
.videoDrawerToggler {
66+
background: var(--theme-elevation-100);
67+
border-bottom: 2px solid var(--theme-elevation-400);
68+
&:hover {
69+
background: var(--theme-elevation-150);
70+
}
71+
}
72+
}
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
import { Drawer, DrawerToggler } from '@components/Drawer/index.js'
2+
import YouTube from '@components/YouTube/index.js'
3+
import { ArrowIcon } from '@root/icons/ArrowIcon/index.js'
4+
import { PlayIcon } from '@root/icons/PlayIcon/index.js'
5+
import Image from 'next/image'
6+
import React from 'react'
7+
8+
import classes from './index.module.scss'
9+
type Props = {
10+
drawerTitle?: string
11+
id: string
12+
label?: string
13+
}
14+
export const VideoDrawer: React.FC<Props> = ({ id, drawerTitle, label }) => {
15+
const drawerSlug = `video-drawer-${id}`
16+
return (
17+
<>
18+
<DrawerToggler className={classes.videoDrawerToggler} slug={drawerSlug}>
19+
<div className={classes.wrap}>
20+
<div className={classes.thumbnail}>
21+
<Image
22+
alt={drawerTitle || label || 'Video Thumbnail'}
23+
fill
24+
src={`https://img.youtube.com/vi/${id}/mqdefault.jpg`}
25+
style={{ objectFit: 'cover', objectPosition: 'left', opacity: 0.85 }}
26+
/>
27+
<PlayIcon className={classes.playIcon} size="large" />
28+
</div>
29+
<div className={classes.labelWrap}>
30+
<strong>{label}</strong>
31+
<ArrowIcon className={classes.arrow} />
32+
</div>
33+
</div>
34+
</DrawerToggler>
35+
<Drawer size="m" slug={drawerSlug} title={drawerTitle}>
36+
<YouTube id={`${id}?autoplay=1`} title={drawerTitle || ''} />
37+
</Drawer>
38+
</>
39+
)
40+
}

src/components/RichText/index.tsx

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ import type {
1818
TemplateCardsBlock,
1919
UploadBlock,
2020
VideoBlock,
21+
VideoDrawerBlock,
2122
YoutubeBlock,
2223
} from '@types'
2324

@@ -52,6 +53,7 @@ import { RestExamples } from './RestExamples'
5253
import { CustomTableJSXConverters } from './Table/index.js'
5354
import { TableWithDrawers } from './TableWithDrawers'
5455
import { UploadBlockImage } from './UploadBlock/index.js'
56+
import { VideoDrawer } from './VideoDrawer'
5557

5658
type Props = {
5759
className?: string
@@ -72,6 +74,7 @@ export type NodeTypes =
7274
| TemplateCardsBlock
7375
| UploadBlock
7476
| VideoBlock
77+
| VideoDrawerBlock
7578
| YoutubeBlock
7679
>
7780
| SerializedLabelNode
@@ -165,6 +168,15 @@ export const jsxConverters: (args: { toc?: boolean }) => JSXConvertersFunction<N
165168

166169
return null
167170
},
171+
VideoDrawer: ({ node }) => {
172+
return (
173+
<VideoDrawer
174+
drawerTitle={node.fields.drawerTitle}
175+
id={node.fields.id}
176+
label={node.fields.label}
177+
/>
178+
)
179+
},
168180
YouTube: ({ node }) => {
169181
return <YouTube id={node.fields.id} title={node.fields.title ?? ''} />
170182
},

src/payload-types.ts

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13679,6 +13679,17 @@ export interface BrBlock {
1367913679
blockName?: string | null;
1368013680
blockType: 'br';
1368113681
}
13682+
/**
13683+
* This interface was referenced by `Config`'s JSON-Schema
13684+
* via the `definition` "VideoDrawerBlock".
13685+
*/
13686+
export interface VideoDrawerBlock {
13687+
id: string | null;
13688+
label: string;
13689+
drawerTitle: string;
13690+
blockName?: string | null;
13691+
blockType: 'VideoDrawer';
13692+
}
1368213693
/**
1368313694
* This interface was referenced by `Config`'s JSON-Schema
1368413695
* via the `definition` "CommandLineBlock".

src/payload.config.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ import { CommunityHelp } from './collections/CommunityHelp'
2727
import { Docs } from './collections/Docs'
2828
import { BannerBlock } from './collections/Docs/blocks/banner'
2929
import { CodeBlock } from './collections/Docs/blocks/code'
30+
import { VideoDrawerBlock } from './collections/Docs/blocks/VideoDrawer'
3031
import { Media } from './collections/Media'
3132
import { Pages } from './collections/Pages'
3233
import { Budgets, Industries, Regions, Specialties } from './collections/PartnerFilters'
@@ -173,6 +174,7 @@ export default buildConfig({
173174

174175
interfaceName: 'BrBlock',
175176
},
177+
VideoDrawerBlock,
176178
{
177179
slug: 'commandLine',
178180
fields: [

0 commit comments

Comments
 (0)