Skip to content

🎥 Make videos programmatically with React

Elements: Redesign catalog layout

Igor Samokhovets7f96c607e45e
diff --git a/packages/docs/elements-sidebars.ts b/packages/docs/elements-sidebars.ts
index c8a138805e..9e5e25771e 100644
--- a/packages/docs/elements-sidebars.ts
+++ b/packages/docs/elements-sidebars.ts
@@ -10,17 +10,11 @@ const sidebars: SidebarsConfig = {
elementsSidebar: [
{
type: 'category',
- label: 'All Elements',
- className: 'elements-sidebar-root',
+ label: 'Elements',
+ className: 'elements-sidebar-root catalog-sidebar-root',
link: {type: 'doc', id: 'index'},
collapsible: false,
items: [
- {
- type: 'html',
- value:
- '<hr style="margin-top: 4px; margin-bottom: 4px; border-bottom: none"/>',
- defaultStyle: true,
- },
...elementCategories.map(({category, label}) => ({
type: 'category' as const,
label,
@@ -40,11 +34,15 @@ const sidebars: SidebarsConfig = {
},
{
type: 'html',
- value:
- '<hr style="margin-top: 4px; margin-bottom: 4px; border-bottom: none"/>',
+ value: '<hr />',
+ className: 'catalog-sidebar-divider',
defaultStyle: true,
},
- 'libraries',
+ {
+ type: 'doc',
+ id: 'libraries',
+ className: 'catalog-sidebar-libraries',
+ },
],
};
diff --git a/packages/docs/elements/index.mdx b/packages/docs/elements/index.mdx
index 9524f13b45..a034119c54 100644
--- a/packages/docs/elements/index.mdx
+++ b/packages/docs/elements/index.mdx
@@ -2,25 +2,25 @@
title: Remotion Elements
sidebar_label: Overview
hide_table_of_contents: true
+hide_title: true
pagination_next: null
pagination_prev: null
description: Drop-in, remixable video building blocks for Remotion.
---
+import {CatalogHero} from '@site/src/components/Catalog/CatalogHero';
import {ElementLibrary} from '@site/src/components/Elements/ElementLibrary';
-# Remotion Elements
-
-Drop-in video building blocks. Make it yours, [interactively](/docs/studio/interactivity) or [with an agent](/docs/ai).
-
-Browse the catalog here or [directly inside Remotion Studio](/docs/studio/browse-elements).
+<CatalogHero title="Remotion Elements">
+Drop-in video building blocks. Make it yours,<br /> [interactively](/docs/studio/interactivity) or [with an agent](/docs/ai).
+</CatalogHero>
<ElementLibrary category={null} />
-<div style={{height: 24}} />
-
## More Elements
+Browse the catalog [directly inside Remotion Studio](/docs/studio/browse-elements).
+
Add [third-party Element Libraries](/elements/libraries) to browse and install Elements from other creators in Studio.
Have an Element idea? [Contribute](/docs/contributing/elements).
diff --git a/packages/docs/src/components/Catalog/CatalogHero.module.css b/packages/docs/src/components/Catalog/CatalogHero.module.css
new file mode 100644
index 0000000000..34b2109408
--- /dev/null
+++ b/packages/docs/src/components/Catalog/CatalogHero.module.css
@@ -0,0 +1,66 @@
+.hero {
+ display: flex;
+ flex-direction: column;
+ align-items: center;
+ gap: 24px;
+ padding: 24px 0 32px;
+ text-align: center;
+}
+
+.hero .title:first-child {
+ max-width: 24ch;
+ margin: 0;
+ font-size: clamp(2.5rem, 5.2vw, 5rem);
+ font-weight: 500;
+ letter-spacing: -0.045em;
+ text-wrap: balance;
+}
+
+.hero .description {
+ max-width: 44ch;
+ margin: 0;
+ color: var(--catalog-muted-color);
+ font-family: 'GTPlanar', sans-serif;
+ font-size: 1rem;
+ line-height: 1.8;
+ text-wrap: pretty;
+}
+
+.description p {
+ margin: 0;
+}
+
+.description a {
+ text-decoration: none;
+}
+
+.description a:hover {
+ text-decoration: underline;
+}
+
+@media (max-width: 599px) {
+ .hero {
+ gap: 20px;
+ padding: 16px 0 32px;
+ }
+
+ .hero .description {
+ font-size: 1.25rem;
+ }
+}
+
+:global(.studio-elements-embed) .hero {
+ align-items: flex-start;
+ gap: 12px;
+ padding: 0;
+ text-align: left;
+}
+
+:global(.studio-elements-embed) .hero .title {
+ font-size: 2rem;
+}
+
+:global(.studio-elements-embed) .hero .description {
+ max-width: 56ch;
+ font-size: 1rem;
+}
diff --git a/packages/docs/src/components/Catalog/CatalogHero.tsx b/packages/docs/src/components/Catalog/CatalogHero.tsx
new file mode 100644
index 0000000000..edb945ec29
--- /dev/null
+++ b/packages/docs/src/components/Catalog/CatalogHero.tsx
@@ -0,0 +1,14 @@
+import React, {type ReactNode} from 'react';
+import styles from './CatalogHero.module.css';
+
+export const CatalogHero: React.FC<{
+ readonly title: string;
+ readonly children: ReactNode;
+}> = ({title, children}) => {
+ return (
+ <header className={`catalog-hero ${styles.hero}`}>
+ <h1 className={styles.title}>{title}</h1>
+ <div className={styles.description}>{children}</div>
+ </header>
+ );
+};
diff --git a/packages/docs/src/components/Elements/ElementLibrary.module.css b/packages/docs/src/components/Elements/ElementLibrary.module.css
index 4ddc79a1a4..6a9e85808e 100644
--- a/packages/docs/src/components/Elements/ElementLibrary.module.css
+++ b/packages/docs/src/components/Elements/ElementLibrary.module.css
@@ -99,12 +99,13 @@
}
.section + .section {
- margin-top: 48px;
+ margin-top: 32px;
}
.categoryTitle {
- margin: 0 0 20px;
+ margin: 0 0 16px;
font-weight: 500;
+ font-size: 1.5rem;
text-wrap: balance;
}
@@ -182,7 +183,13 @@
position: relative;
aspect-ratio: 16 / 9;
overflow: hidden;
- border-radius: 8px;
+ border-radius: min(1vw, 10px);
+ outline: 1px solid rgb(17 24 39 / 8%);
+ outline-offset: -1px;
+}
+
+:global([data-theme='dark']) .preview {
+ outline-color: rgb(255 255 255 / 10%);
}
.card[aria-pressed='true'] .previewMedia {
@@ -217,12 +224,12 @@
@container element-library (min-width: 600px) {
.grid {
- grid-template-columns: repeat(2, minmax(0, 320px));
+ grid-template-columns: repeat(2, minmax(0, 1fr));
gap: 24px;
}
.content {
- padding: 16px 0;
+ padding: 8px 0;
}
.title {
@@ -232,7 +239,7 @@
@container element-library (min-width: 858px) {
.grid {
- grid-template-columns: repeat(3, minmax(0, 320px));
+ grid-template-columns: repeat(3, minmax(0, 1fr));
}
}
diff --git a/packages/docs/src/components/Elements/ElementPage.module.css b/packages/docs/src/components/Elements/ElementPage.module.css
index 0e0e1038bb..a91372f787 100644
--- a/packages/docs/src/components/Elements/ElementPage.module.css
+++ b/packages/docs/src/components/Elements/ElementPage.module.css
@@ -7,9 +7,9 @@
margin-bottom: 28px;
}
-.catalogLink {
- flex-basis: 100%;
- font-size: 0.875rem;
+/* Element details have their own actions instead of the generic docs footer. */
+:global(article):has(.workbench) > :global(.theme-doc-footer) {
+ display: none;
}
.previewColumn {
diff --git a/packages/docs/src/components/Elements/ElementPage.tsx b/packages/docs/src/components/Elements/ElementPage.tsx
index 5e44a035ff..dbdcee2944 100644
--- a/packages/docs/src/components/Elements/ElementPage.tsx
+++ b/packages/docs/src/components/Elements/ElementPage.tsx
@@ -1,5 +1,4 @@
import Head from '@docusaurus/Head';
-import Link from '@docusaurus/Link';
import {
isInsideStudio,
StudioProtocolInternals,
@@ -25,7 +24,6 @@ import {
createElementPayloadFromDefinition,
installElementInStudio,
} from './element-drag-data';
-import {getElementCategoryHeadingId} from './element-library-data';
import {getElementDimensionsLabel} from './element-utils';
import {ElementPreview} from './ElementPreview';
import {
@@ -171,12 +169,6 @@ export const ElementPage: React.FC<ElementPageProps> = ({
return (
<div className={styles.workbench}>
- <Link
- className={styles.catalogLink}
- to={`/elements/#${getElementCategoryHeadingId(definition.category)}`}
- >
- ← All Elements
- </Link>
<img
ref={posterRef}
alt=""
diff --git a/packages/docs/src/components/Elements/element-library-data.ts b/packages/docs/src/components/Elements/element-library-data.ts
index 3edc100c83..5fe1053494 100644
--- a/packages/docs/src/components/Elements/element-library-data.ts
+++ b/packages/docs/src/components/Elements/element-library-data.ts
@@ -14,9 +14,12 @@ export type ElementLibrarySection = {
readonly label: string;
};
-const elementCategories = Array.from(
- new Set(elementDefinitions.map(({category}) => category)),
-);
+// Use the sidebar's category order for the gallery as well.
+const elementCategories = registeredCategories
+ .map(({category}) => category)
+ .filter((category) =>
+ elementDefinitions.some((definition) => definition.category === category),
+ );
export const getElementCategoryLabel = (category: ElementCategory) => {
return (
diff --git a/packages/docs/src/css/catalog.css b/packages/docs/src/css/catalog.css
new file mode 100644
index 0000000000..c317f031d0
--- /dev/null
+++ b/packages/docs/src/css/catalog.css
@@ -0,0 +1,122 @@
+/* Shared Docusaurus catalog skin. Sidebar membership and mobile navigation
+ remain owned by Docusaurus; catalogs opt in at DocRoot/Layout. */
+.catalog-layout {
+ --catalog-background: #f8f9fb;
+ --catalog-muted-color: #59616d;
+ --catalog-divider: rgb(17 24 39 / 10%);
+ --catalog-hover: rgb(17 24 39 / 4%);
+ --doc-sidebar-width: 254px;
+ --ifm-background-color: var(--catalog-background);
+ --ifm-menu-color: var(--catalog-muted-color);
+ --ifm-menu-color-background-hover: var(--catalog-hover);
+ --ifm-menu-color-background-active: var(--catalog-hover);
+}
+
+.catalog-layout[data-theme='dark'] {
+ --catalog-background: #18191a;
+ --catalog-muted-color: #afb5bf;
+ --catalog-divider: rgb(255 255 255 / 10%);
+ --catalog-hover: rgb(255 255 255 / 6%);
+}
+
+.catalog-layout main {
+ min-width: 0;
+}
+
+.catalog-layout main > .container {
+ max-width: 1440px;
+ /* Override Docusaurus's !important container spacing utilities. */
+ padding: 32px clamp(20px, 3.33vw, 48px) 64px !important;
+}
+
+.catalog-layout article:has(.catalog-hero) > .elements-embed-breadcrumbs {
+ display: none;
+}
+
+.catalog-layout .menu {
+ padding: 32px 20px;
+ font-family: 'GTPlanar', sans-serif;
+ font-size: 1rem;
+}
+
+.catalog-layout .menu__link {
+ min-height: 36px;
+ padding: 6px 12px;
+ border-radius: 6px;
+ font-weight: 400;
+}
+
+.catalog-layout .menu__link:focus-visible,
+.catalog-layout .menu__caret:focus-visible {
+ outline: 2px solid var(--ifm-color-primary);
+ outline-offset: 2px;
+}
+
+.catalog-sidebar-root > .menu__list-item-collapsible > .menu__link {
+ min-height: 44px;
+ color: var(--ifm-font-color-base);
+ font-size: 1.125rem;
+ font-weight: 500;
+}
+
+.catalog-sidebar-root > .menu__list {
+ margin: 8px 0 0;
+ padding-left: 0;
+}
+
+.catalog-sidebar-root > .menu__list-item-collapsible--active,
+.catalog-sidebar-root > .menu__list-item-collapsible > .menu__link--active {
+ background: transparent;
+}
+
+.catalog-sidebar-root > .menu__list-item-collapsible > .menu__link--active {
+ color: var(--ifm-font-color-base);
+}
+
+.catalog-sidebar-root .menu__list-item {
+ margin-top: 0;
+}
+
+.catalog-sidebar-root .menu__link--active {
+ background: var(--catalog-hover);
+ color: var(--ifm-color-primary);
+}
+
+.catalog-layout .menu .catalog-sidebar-divider {
+ margin: 16px 0;
+ padding: 0;
+}
+
+.catalog-sidebar-divider hr {
+ height: 1px;
+ margin: 0;
+ border: 0;
+ background: var(--catalog-divider);
+}
+
+.catalog-layout .menu .catalog-sidebar-libraries {
+ margin-top: 0;
+}
+
+@media (max-width: 996px) {
+ .catalog-layout .menu {
+ padding: 16px;
+ }
+
+ .catalog-layout .menu__link {
+ min-height: 44px;
+ }
+}
+
+/* Studio uses the same cards in a denser, application-sized catalog. */
+.catalog-layout:has(.studio-elements-embed) main > .container {
+ padding: 24px !important;
+}
+
+.catalog-layout:has(.studio-elements-embed) .menu {
+ padding: 16px 12px;
+}
+
+.studio-elements-embed .catalog-sidebar-divider {
+ display: none;
+}
diff --git a/packages/docs/src/css/custom.css b/packages/docs/src/css/custom.css
index ea227a131b..8ece2146f2 100644
--- a/packages/docs/src/css/custom.css
+++ b/packages/docs/src/css/custom.css
@@ -152,16 +152,6 @@ html:has(.studio-caption-picker),
}
}
-.elements-sidebar-root > .menu__list {
- padding-left: 0;
-}
-
-.elements-sidebar-root
- > .menu__list-item-collapsible:not(.menu__list-item-collapsible--active)
- > .menu__link--active {
- color: var(--ifm-menu-color);
-}
-
.theme-doc-sidebar-item-link > hr {
background-color: var(--border-color);
}
diff --git a/packages/docs/src/theme/DocRoot/Layout/index.tsx b/packages/docs/src/theme/DocRoot/Layout/index.tsx
new file mode 100644
index 0000000000..bc7a210340
--- /dev/null
+++ b/packages/docs/src/theme/DocRoot/Layout/index.tsx
@@ -0,0 +1,21 @@
+import {useDocsSidebar} from '@docusaurus/plugin-content-docs/client';
+import {HtmlClassNameProvider} from '@docusaurus/theme-common';
+import DocRootLayout from '@theme-original/DocRoot/Layout';
+import type {Props} from '@theme/DocRoot/Layout';
+import React, {type ReactNode} from 'react';
+import '../../../css/catalog.css';
+
+export default function DocRootLayoutWrapper(props: Props): ReactNode {
+ const sidebar = useDocsSidebar();
+
+ // Opt other catalog sidebars into this skin when they adopt the layout.
+ if (sidebar?.name !== 'elementsSidebar') {
+ return <DocRootLayout {...props} />;
+ }
+
+ return (
+ <HtmlClassNameProvider className="catalog-layout">
+ <DocRootLayout {...props} />
+ </HtmlClassNameProvider>
+ );
+}
diff --git a/packages/docs/src/theme/DocSidebarItem/Category/index.tsx b/packages/docs/src/theme/DocSidebarItem/Category/index.tsx
index 7131f8209d..e9f2442736 100644
--- a/packages/docs/src/theme/DocSidebarItem/Category/index.tsx
+++ b/packages/docs/src/theme/DocSidebarItem/Category/index.tsx
@@ -32,16 +32,18 @@ const ElementsSidebarRoot: React.FC<Props> = (props) => {
const updateActiveCategory = () => {
animationFrame = null;
- // Use the same offset as native anchor navigation, allowing subpixel rounding.
const scrollOffset =
Number.parseFloat(
getComputedStyle(document.documentElement).scrollPaddingTop,
) || 0;
+ // Highlight approaching sections before their titles reach the sticky navbar.
+ const activationOffset =
+ scrollOffset + Math.min(120, window.innerHeight * 0.2);
let activeId: string | null = null;
for (const heading of catalogContent.querySelectorAll<HTMLElement>(
'h2[id^="element-category-"]',
)) {
- if (heading.getBoundingClientRect().top <= scrollOffset + 1) {
+ if (heading.getBoundingClientRect().top <= activationOffset + 1) {
activeId = heading.id;
}
}
@@ -84,7 +86,7 @@ export default function DocSidebarItemCategoryWrapper(props: Props): ReactNode {
const activeHeadingId = useContext(ActiveElementCategoryContext);
const catalogHref = item.customProps?.catalogHref;
- if (item.className === 'elements-sidebar-root') {
+ if (item.className?.split(' ').includes('elements-sidebar-root')) {
return <ElementsSidebarRoot {...props} />;
}