🎥 Make videos programmatically with React
Add brand assets menu to docs logo
Igor Samokhovets65a3c4dbaa84
diff --git a/packages/docs/src/theme/Footer/index.tsx b/packages/docs/src/theme/Footer/index.tsxindex 12bf26dbe3..069a5d610e 100644--- a/packages/docs/src/theme/Footer/index.tsx+++ b/packages/docs/src/theme/Footer/index.tsx@@ -1,22 +1,11 @@import {useThemeConfig} from '@docusaurus/theme-common';-import React, {useEffect} from 'react';+import React from 'react';import FooterLayout from './Layout';import FooterLinks from './Links';const Footer = () => {const {footer} = useThemeConfig();- useEffect(() => {- if (typeof document !== 'undefined') {- document- .querySelector('.navbar__logo')!- .addEventListener('contextmenu', (e) => {- e.preventDefault();- window.open('https://remotion.dev/brand', '_blank');- });- }- }, []);-if (!footer) {return null;}@@ -31,5 +20,3 @@ const Footer = () => {};export default React.memo(Footer);--// Right-click on the Remotion logo to get branddiff --git a/packages/docs/src/theme/Navbar/Logo/index.tsx b/packages/docs/src/theme/Navbar/Logo/index.tsxnew file mode 100644index 0000000000..1519846ff6--- /dev/null+++ b/packages/docs/src/theme/Navbar/Logo/index.tsx@@ -0,0 +1,119 @@+import Logo from '@theme/Logo';+import React, {type MouseEvent, type ReactNode, useEffect, useRef} from 'react';+import styles from './styles.module.css';++export default function NavbarLogo(): ReactNode {+ const contextMenuRef = useRef<HTMLDivElement>(null);++ useEffect(() => {+ const hideContextMenu = () => {+ const menu = contextMenuRef.current;+ if (menu?.matches(':popover-open')) {+ menu.hidePopover();+ }+ };++ const hideOnPointerDown = (event: PointerEvent) => {+ if (!contextMenuRef.current?.contains(event.target as Node)) {+ hideContextMenu();+ }+ };++ const hideOnEscape = (event: KeyboardEvent) => {+ if (event.key === 'Escape') {+ hideContextMenu();+ }+ };++ document.addEventListener('pointerdown', hideOnPointerDown);+ document.addEventListener('keydown', hideOnEscape);+ return () => {+ document.removeEventListener('pointerdown', hideOnPointerDown);+ document.removeEventListener('keydown', hideOnEscape);+ };+ }, []);++ const openContextMenu = (event: MouseEvent<HTMLAnchorElement>) => {+ event.preventDefault();++ const menu = contextMenuRef.current;+ if (!menu) {+ return;+ }++ const logoBounds = event.currentTarget.getBoundingClientRect();+ menu.style.left = `${event.clientX || logoBounds.left}px`;+ menu.style.top = `${event.clientY || logoBounds.bottom}px`;+ menu.showPopover();+ menu.querySelector<HTMLAnchorElement>('a')?.focus();+ };++ return (+ <>+ <Logo+ className="navbar__brand"+ imageClassName="navbar__logo"+ titleClassName="navbar__title text--truncate"+ onContextMenu={openContextMenu}+ />+ <div+ ref={contextMenuRef}+ popover="manual"+ role="menu"+ className={styles.contextMenu}+ onClick={() => contextMenuRef.current?.hidePopover()}+ >+ <a+ className={styles.contextMenuItem}+ href="https://remotion.dev/brand"+ target="_blank"+ rel="noreferrer"+ role="menuitem"+ >+ <svg+ className={styles.contextMenuIcon}+ width="16"+ height="16"+ viewBox="0 0 24 24"+ fill="none"+ stroke="currentColor"+ strokeWidth="2"+ strokeLinecap="round"+ strokeLinejoin="round"+ aria-hidden="true"+ >+ <path d="M12 3a9 9 0 1 0 0 18h1.5a1.5 1.5 0 0 0 0-3H12a1.5 1.5 0 0 1 0-3h2a7 7 0 0 0 0-14Z" />+ <circle cx="7.5" cy="10.5" r="0.5" fill="currentColor" />+ <circle cx="10" cy="7" r="0.5" fill="currentColor" />+ <circle cx="14" cy="6.5" r="0.5" fill="currentColor" />+ </svg>+ Brand design system+ </a>+ <a+ className={styles.contextMenuItem}+ href="https://remotion.media/remotion-brand-assets.zip"+ target="_blank"+ rel="noreferrer"+ role="menuitem"+ >+ <svg+ className={styles.contextMenuIcon}+ width="16"+ height="16"+ viewBox="0 0 24 24"+ fill="none"+ stroke="currentColor"+ strokeWidth="2"+ strokeLinecap="round"+ strokeLinejoin="round"+ aria-hidden="true"+ >+ <path d="M6 2h8l4 4v16H6Z" />+ <path d="M14 2v5h4M10 2v2h2v2h-2v2h2v2h-2v2h2" />+ </svg>+ Download brand assets (.zip)+ </a>+ </div>+ </>+ );+}diff --git a/packages/docs/src/theme/Navbar/Logo/styles.module.css b/packages/docs/src/theme/Navbar/Logo/styles.module.cssnew file mode 100644index 0000000000..b9c6aa3547--- /dev/null+++ b/packages/docs/src/theme/Navbar/Logo/styles.module.css@@ -0,0 +1,35 @@+.contextMenu {+ position: fixed;+ inset: auto;+ min-width: 190px;+ margin: 0;+ padding: 6px;+ background: var(--ifm-background-surface-color);+ border: 1px solid var(--ifm-color-emphasis-300);+ border-radius: 8px;+ box-shadow: var(--box-shadow);+}++.contextMenuItem {+ display: flex;+ align-items: center;+ gap: 8px;+ padding: 7px 10px;+ color: var(--ifm-font-color-base);+ font-size: 0.875rem;+ line-height: 1.25rem;+ white-space: nowrap;+ border-radius: 5px;+}++.contextMenuIcon {+ flex: 0 0 auto;+}++.contextMenuItem:hover,+.contextMenuItem:focus-visible {+ color: var(--ifm-font-color-base);+ text-decoration: none;+ background: var(--ifm-color-emphasis-200);+ outline: none;+}