Skip to content

The Postgres development platform. Supabase gives you a dedicated Postgres database to build your web, mobile, and AI applications.

chore: use modal for expanded video

Francesco Sansalvadore7907172d3c3d
diff --git a/apps/docs/layouts/guides/index.tsx b/apps/docs/layouts/guides/index.tsx
index 930d3f8a19d..69d6f421852 100644
--- a/apps/docs/layouts/guides/index.tsx
+++ b/apps/docs/layouts/guides/index.tsx
@@ -5,7 +5,7 @@ import Image from 'next/image'
import Link from 'next/link'
import { useRouter } from 'next/router'
import { FC, useEffect, useRef, useState } from 'react'
-import { IconExternalLink, IconPlay, IconPlayCircle } from 'ui'
+import { IconExternalLink, IconPlay, Modal } from 'ui'
import components from '~/components'
import { highlightSelectedTocItem } from '~/components/CustomHTMLElements/CustomHTMLElements.utils'
import FooterHelpCallout, { FooterHelpCalloutType } from '~/components/FooterHelpCallout'
@@ -39,7 +39,7 @@ const Layout: FC<Props> = (props) => {
const { asPath } = useRouter()
const router = useRouter()
- const [openVideoLightbox, setOpenVideoLightbox] = useState(false)
+ const [expandVideo, setExpandVideo] = useState(false)
const EDIT_BUTTON_EXCLUDE_LIST = ['/404']
@@ -77,6 +77,22 @@ const Layout: FC<Props> = (props) => {
}&title=${props.meta?.title}&description=${props.meta?.description}`
)
+ useEffect(() => {
+ function onKeyDown(e: KeyboardEvent) {
+ switch (e.key) {
+ case 'Escape':
+ return setExpandVideo(false)
+ default:
+ return
+ }
+ }
+
+ window.addEventListener('keydown', onKeyDown)
+ return () => {
+ window.removeEventListener('keydown', onKeyDown)
+ }
+ }, [])
+
return (
<>
<Head>
@@ -107,30 +123,6 @@ const Layout: FC<Props> = (props) => {
},
}}
/>
- {openVideoLightbox && (
- <div
- className="fixed px-12 py-24 z-50 inset-0 w-screen h-screen bg-scale-100/90 backdrop-blur-md flex items-center justify-center hover:cursor-pointer"
- onClick={() => setOpenVideoLightbox(false)}
- >
- <div className="w-full max-w-4xl flex items-center justify-center">
- <div className="relative w-full">
- <button
- onClick={() => setOpenVideoLightbox(false)}
- className="text-scale-1100 hover:text-scale-1200 absolute -top-8 right-0"
- >
- <p className="text-xs">Close</p>
- </button>
- <div className="video-container overflow-hidden rounded-xl">
- <iframe
- src={`https://www.youtube-nocookie.com/embed/${props.meta.tocVideo}`}
- allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture"
- allowFullScreen
- />
- </div>
- </div>
- </div>
- </div>
- )}
<div className={['grid grid-cols-12 relative gap-4'].join(' ')}>
<div
className={[
@@ -185,15 +177,53 @@ const Layout: FC<Props> = (props) => {
].join(' ')}
>
<div className="border-l">
+ <Modal
+ visible={expandVideo}
+ hideFooter
+ className={[
+ '!bg-[#f8f9fa]/95 dark:!bg-[#1c1c1c]/80',
+ '!border-[#e6e8eb]/90 dark:!border-[#282828]/90',
+ 'transition ease-out',
+ 'mx-auto backdrop-blur-md',
+ // animateBounce ? 'scale-[101.5%]' : 'scale-100'
+ ].join(' ')}
+ onInteractOutside={(e) => {
+ // Only hide menu when clicking outside, not focusing outside
+ // Prevents Firefox dropdown issue that immediately closes menu after opening
+ if (e.type === 'dismissableLayer.pointerDownOutside') {
+ setExpandVideo(!expandVideo)
+ }
+ }}
+ size="xxlarge"
+ >
+ <div className="w-full flex items-center justify-center">
+ <div className="relative w-full">
+ <button
+ onClick={() => setExpandVideo(false)}
+ className="text-scale-1100 hover:text-scale-1200 absolute -top-8 right-0"
+ >
+ <p className="text-xs">Close</p>
+ </button>
+ <div className="video-container overflow-hidden rounded-lg">
+ <iframe
+ src={`https://www.youtube-nocookie.com/embed/${props.meta.tocVideo}`}
+ allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture"
+ allowFullScreen
+ />
+ </div>
+ </div>
+ </div>
+ </Modal>
{props.meta?.tocVideo && !!tocVideoPreview && (
<div className="relative mb-6 pl-5">
<div
className="video-container overflow-hidden rounded hover:cursor-pointer"
- onClick={() => setOpenVideoLightbox(true)}
+ onClick={() => setExpandVideo(true)}
>
<div
- className={`absolute inset-0 z-10 text-scale-1100 transition-colors group-hover/toc-video:text-scale-1200 flex flex-col items-center justify-center gap-3 backdrop-blur-sm
- before:content[''] before:-z-10 before:absolute before:inset-0 before:bg-scale-100 before:opacity-30 hover:before:opacity-50 before:transition-opacity`}
+ className={`absolute inset-0 z-10 text-whiteA-1200 flex flex-col items-center justify-center gap-3 backdrop-blur-sm
+ before:content[''] before:-z-10 before:absolute before:inset-0 before:bg-black before:opacity-30 hover:before:opacity-50 before:transition-opacity
+ `}
>
<IconPlay strokeWidth={2} size="small" />
<p className="text-sm">Watch video guide</p>