🎥 Make videos programmatically with React
Elements: Generate sidebar from registry (#10396)
Igor Samokhovetsa7892268b92e
diff --git a/packages/docs/elements-sidebars.ts b/packages/docs/elements-sidebars.tsindex cbd1052841..5f0d1846dd 100644--- a/packages/docs/elements-sidebars.ts+++ b/packages/docs/elements-sidebars.ts@@ -1,5 +1,21 @@// @ts-expect-errorimport type {SidebarsConfig} from '@docusaurus/plugin-content-docs';+import {+ elementCategories,+ elementRegistry,+} from './src/components/Elements/element-registry';++const compareStrings = (a: string, b: string) => {+ if (a < b) {+ return -1;+ }++ if (a > b) {+ return 1;+ }++ return 0;+};const sidebars: SidebarsConfig = {elementsSidebar: [@@ -12,94 +28,16 @@ const sidebars: SidebarsConfig = {'<hr style="margin-top: 4px; margin-bottom: 4px; border-bottom: none"/>',defaultStyle: true,},- {- type: 'category',- label: 'Backgrounds',- link: {type: 'doc', id: 'backgrounds/index'},- collapsed: false,- items: [- 'backgrounds/liquid-contours/index',- 'backgrounds/notebook-paper/index',- 'backgrounds/paper-texture/index',- 'backgrounds/rotating-starburst/index',- ],- },- {- type: 'category',- label: 'Captions',- link: {type: 'doc', id: 'captions/index'},- collapsed: false,- items: [- 'captions/moving-pill-captions/index',- 'captions/popping-word-captions/index',- 'captions/word-highlight-captions/index',- ],- },- {- type: 'category',- label: 'Commerce',- link: {type: 'doc', id: 'commerce/index'},- collapsed: false,- items: [- 'commerce/product-discount-callout/index',- 'commerce/product-offer/index',- ],- },- {- type: 'category',- label: 'Data',- link: {type: 'doc', id: 'data/index'},- collapsed: false,- items: [- 'data/horizontal-bar-chart/index',- 'data/number-counter/index',- 'data/pie-chart/index',- 'data/vertical-bar-chart/index',- ],- },- {- type: 'category',- label: 'Maps',- link: {type: 'doc', id: 'maps/index'},- collapsed: false,- items: ['maps/map-flyover/index'],- },- {- type: 'category',- label: 'Overlays',- link: {type: 'doc', id: 'overlays/index'},- collapsed: false,- items: [- 'overlays/location-lower-third/index',- 'overlays/name-lower-third/index',- ],- },- {- type: 'category',- label: 'Storytelling',- link: {type: 'doc', id: 'storytelling/index'},+ ...elementCategories.map(({category, label}) => ({+ type: 'category' as const,+ label,+ link: {type: 'doc' as const, id: `${category}/index`},collapsed: false,- items: ['text/news-article-highlight/index'],- },- {- type: 'category',- label: 'Text',- link: {type: 'doc', id: 'text/index'},- collapsed: false,- items: [- 'text/circle-marker/index',- 'text/crossed-off/index',- 'text/strike-through/index',- 'text/text-marker/index',- ],- },- {- type: 'category',- label: 'YouTube',- link: {type: 'doc', id: 'youtube/index'},- collapsed: false,- items: ['youtube/youtube-end-card/index'],- },+ items: Object.entries(elementRegistry)+ .filter(([, metadata]) => metadata.category === category)+ .sort(([, a], [, b]) => compareStrings(a.displayName, b.displayName))+ .map(([slug]) => `${slug}/index`),+ })),],};diff --git a/packages/docs/src/components/Elements/element-definitions.ts b/packages/docs/src/components/Elements/element-definitions.tsindex c593b76601..b5b409b3fd 100644--- a/packages/docs/src/components/Elements/element-definitions.ts+++ b/packages/docs/src/components/Elements/element-definitions.ts@@ -26,6 +26,11 @@ import {StrikeThroughText} from '../../../elements/text/strike-through/strike-thimport {TextMarker} from '../../../elements/text/text-marker/text-marker';import {YouTubeEndCard} from '../../../elements/youtube/youtube-end-card/youtube-end-card';import type {Contributor} from '../Credits';+import {+ elementRegistry,+ type ElementCategory,+ type ElementSlug,+} from './element-registry';export type ElementPreviewMetadata = {readonly posterUrl:@@ -37,7 +42,7 @@ export type ElementPreviewMetadata = {};export type ElementDefinition = {- readonly category: string;+ readonly category: ElementCategory;readonly component: ComponentType<Record<string, never>>;readonly contributors: readonly Contributor[];readonly dependencies: readonly ElementDependency[];@@ -56,15 +61,13 @@ export type ElementDefinition = {readonly width: number;};-export const elementDefinitions = {+const elementImplementations = {'backgrounds/liquid-contours': {- category: 'backgrounds',component: LiquidContours,contributors: [],description:'A flowing two-color background made from animated liquid contour bands.',dependencies: [{name: '@remotion/effects', version: null}],- displayName: 'Liquid Contours',durationInFrames: 240,elementHeight: null,elementWidth: null,@@ -78,12 +81,10 @@ export const elementDefinitions = {'https://remotion.media/elements/backgrounds-liquid-contours-preview.mp4',},previewPadding: 0,- slug: 'backgrounds/liquid-contours',installationMode: 'wrapped',width: 1920,},'maps/map-flyover': {- category: 'maps',component: MapFlyover,contributors: [],description:@@ -92,7 +93,6 @@ export const elementDefinitions = {{name: '@turf/turf', version: '7.3.2'},{name: 'maplibre-gl', version: '5.24.0'},],- displayName: 'A-to-B Map Flyover',durationInFrames: 285,elementHeight: null,elementWidth: null,@@ -104,17 +104,14 @@ export const elementDefinitions = {videoUrl: 'https://remotion.media/elements/maps-map-flyover-preview.mp4',},previewPadding: 0,- slug: 'maps/map-flyover',installationMode: 'component-owned-sequence',width: 1920,},'backgrounds/notebook-paper': {- category: 'backgrounds',component: NotebookPaper,contributors: [],description: 'A white paper background with subtle blue gridlines.',dependencies: [{name: '@remotion/effects', version: null}],- displayName: 'Notebook Paper',durationInFrames: 120,elementHeight: null,elementWidth: null,@@ -128,18 +125,15 @@ export const elementDefinitions = {'https://remotion.media/elements/backgrounds-notebook-paper-preview.mp4',},previewPadding: 0,- slug: 'backgrounds/notebook-paper',installationMode: 'wrapped',width: 1920,},'backgrounds/paper-texture': {- category: 'backgrounds',component: PaperTexture,contributors: [],description:'A white paper texture background with a slowly changing posterized seed.',dependencies: [{name: '@remotion/effects', version: null}],- displayName: 'Paper Texture',durationInFrames: 120,elementHeight: null,elementWidth: null,@@ -153,17 +147,14 @@ export const elementDefinitions = {'https://remotion.media/elements/backgrounds-paper-texture-preview.mp4',},previewPadding: 0,- slug: 'backgrounds/paper-texture',installationMode: 'wrapped',width: 1920,},'backgrounds/rotating-starburst': {- category: 'backgrounds',component: RotatingStarburst,contributors: [],description: 'A solid background with a slowly rotating starburst effect.',dependencies: [{name: '@remotion/effects', version: null}],- displayName: 'Rotating Starburst',durationInFrames: 240,elementHeight: null,elementWidth: null,@@ -177,17 +168,14 @@ export const elementDefinitions = {'https://remotion.media/elements/backgrounds-rotating-starburst-preview.mp4',},previewPadding: 0,- slug: 'backgrounds/rotating-starburst',installationMode: 'wrapped',width: 1920,},'overlays/location-lower-third': {- category: 'overlays',component: LocationLowerThird,contributors: [],description: 'An animated lower third for an event location and venue.',dependencies: [],- displayName: 'Location Lower Third',durationInFrames: 120,elementHeight: 138,elementWidth: 680,@@ -201,18 +189,15 @@ export const elementDefinitions = {'https://remotion.media/elements/overlays-location-lower-third-preview.mp4',},previewPadding: 300,- slug: 'overlays/location-lower-third',installationMode: 'wrapped',width: 1920,},'overlays/name-lower-third': {- category: 'overlays',component: NameLowerThird,contributors: [],description:'A clean animated lower third for introducing a speaker, guest, or host.',dependencies: [{name: '@remotion/google-fonts', version: null}],- displayName: 'Name Lower Third',durationInFrames: 120,elementHeight: 132,elementWidth: 534,@@ -226,18 +211,15 @@ export const elementDefinitions = {'https://remotion.media/elements/overlays-name-lower-third-preview.mp4',},previewPadding: 300,- slug: 'overlays/name-lower-third',installationMode: 'wrapped',width: 1920,},'youtube/youtube-end-card': {- category: 'youtube',component: YouTubeEndCard,contributors: [],description:'A clean YouTube endcard with social links and space for recommended videos.',dependencies: [{name: '@remotion/google-fonts', version: null}],- displayName: 'YouTube End Card',durationInFrames: 150,elementHeight: null,elementWidth: null,@@ -251,18 +233,15 @@ export const elementDefinitions = {'https://remotion.media/elements/overlays-social-endcard-preview.mp4',},previewPadding: 0,- slug: 'youtube/youtube-end-card',installationMode: 'wrapped',width: 1920,},'data/horizontal-bar-chart': {- category: 'data',component: HorizontalBarChart,contributors: [],description:'A bold bar chart card with three directly labeled data points.',dependencies: [{name: '@remotion/google-fonts', version: null}],- displayName: 'Horizontal Bar Chart',durationInFrames: 120,elementHeight: 864,elementWidth: 1560,@@ -276,18 +255,15 @@ export const elementDefinitions = {'https://remotion.media/elements/data-horizontal-bar-chart-preview.mp4',},previewPadding: 56,- slug: 'data/horizontal-bar-chart',installationMode: 'wrapped',width: 1920,},'data/pie-chart': {- category: 'data',component: PieChart,contributors: [],description:'A bold animated pie chart with four directly labeled data points.',dependencies: [{name: '@remotion/google-fonts', version: null}],- displayName: 'Pie Chart',durationInFrames: 120,elementHeight: 864,elementWidth: 1560,@@ -299,12 +275,10 @@ export const elementDefinitions = {videoUrl: 'https://remotion.media/elements/data-pie-chart-preview.mp4',},previewPadding: 56,- slug: 'data/pie-chart',installationMode: 'wrapped',width: 1920,},'data/number-counter': {- category: 'data',component: NumberCounter,contributors: [{@@ -315,7 +289,6 @@ export const elementDefinitions = {description:'A simple animated counter that smoothly counts from a start value to an end value.',dependencies: [{name: '@remotion/google-fonts', version: null}],- displayName: 'Number Counter',durationInFrames: 120,elementHeight: 200,elementWidth: 640,@@ -329,18 +302,15 @@ export const elementDefinitions = {'https://remotion.media/elements/data-number-counter-preview.mp4',},previewPadding: 120,- slug: 'data/number-counter',installationMode: 'wrapped',width: 1920,},'data/vertical-bar-chart': {- category: 'data',component: VerticalBarChart,contributors: [],description:'A bold vertical bar chart with three directly labeled data points.',dependencies: [{name: '@remotion/google-fonts', version: null}],- displayName: 'Vertical Bar Chart',durationInFrames: 120,elementHeight: 864,elementWidth: 1560,@@ -354,12 +324,10 @@ export const elementDefinitions = {'https://remotion.media/elements/data-vertical-bar-chart-preview.mp4',},previewPadding: 56,- slug: 'data/vertical-bar-chart',installationMode: 'wrapped',width: 1920,},'commerce/product-discount-callout': {- category: 'commerce',component: ProductDiscountCallout,contributors: [],description:@@ -368,7 +336,6 @@ export const elementDefinitions = {{name: '@remotion/google-fonts', version: null},{name: '@remotion/shapes', version: null},],- displayName: 'Product Discount Callout',durationInFrames: 120,elementHeight: 650,elementWidth: 900,@@ -382,18 +349,15 @@ export const elementDefinitions = {'https://remotion.media/elements/commerce-product-discount-callout-preview.mp4',},previewPadding: 90,- slug: 'commerce/product-discount-callout',installationMode: 'wrapped',width: 1080,},'commerce/product-offer': {- category: 'commerce',component: ProductOffer,contributors: [],description:'An animated product card with a bold title, catalog image, pricing, and discount.',dependencies: [{name: '@remotion/google-fonts', version: null}],- displayName: 'Product Offer',durationInFrames: 150,elementHeight: 900,elementWidth: 900,@@ -407,12 +371,10 @@ export const elementDefinitions = {'https://remotion.media/elements/commerce-product-offer-preview.mp4',},previewPadding: 90,- slug: 'commerce/product-offer',installationMode: 'wrapped',width: 1080,},'text/circle-marker': {- category: 'text',component: CircleMarker,contributors: [],description:@@ -421,7 +383,6 @@ export const elementDefinitions = {{name: '@remotion/google-fonts', version: null},{name: '@remotion/rough-notation', version: null},],- displayName: 'Circle Marker',durationInFrames: 120,elementHeight: 220,elementWidth: 900,@@ -435,12 +396,10 @@ export const elementDefinitions = {'https://remotion.media/elements/text-circle-marker-preview.mp4',},previewPadding: 120,- slug: 'text/circle-marker',installationMode: 'wrapped',width: 1920,},'text/crossed-off': {- category: 'text',component: CrossedOffText,contributors: [],description:@@ -449,7 +408,6 @@ export const elementDefinitions = {{name: '@remotion/google-fonts', version: null},{name: '@remotion/rough-notation', version: null},],- displayName: 'Crossed Off',durationInFrames: 120,elementHeight: 220,elementWidth: 900,@@ -461,18 +419,15 @@ export const elementDefinitions = {videoUrl: 'https://remotion.media/elements/text-crossed-off-preview.mp4',},previewPadding: 120,- slug: 'text/crossed-off',installationMode: 'wrapped',width: 1920,},'text/news-article-highlight': {- category: 'storytelling',component: NewsArticleHighlight,contributors: [],description:'A framed news article with camera movement, blur, and animated passage highlights.',dependencies: [{name: '@remotion/rough-notation', version: null}],- displayName: 'News Article Highlight',durationInFrames: 150,elementHeight: null,elementWidth: null,@@ -486,12 +441,10 @@ export const elementDefinitions = {'https://remotion.media/elements/text-news-article-highlight-preview.mp4',},previewPadding: 0,- slug: 'text/news-article-highlight',installationMode: 'wrapped',width: 1920,},'text/strike-through': {- category: 'text',component: StrikeThroughText,contributors: [],description:@@ -500,7 +453,6 @@ export const elementDefinitions = {{name: '@remotion/google-fonts', version: null},{name: '@remotion/rough-notation', version: null},],- displayName: 'Strike Through',durationInFrames: 120,elementHeight: 220,elementWidth: 900,@@ -514,12 +466,10 @@ export const elementDefinitions = {'https://remotion.media/elements/text-strike-through-preview.mp4',},previewPadding: 120,- slug: 'text/strike-through',installationMode: 'wrapped',width: 1920,},'text/text-marker': {- category: 'text',component: TextMarker,contributors: [],description:@@ -528,7 +478,6 @@ export const elementDefinitions = {{name: '@remotion/google-fonts', version: null},{name: '@remotion/rough-notation', version: null},],- displayName: 'Text Marker',durationInFrames: 120,elementHeight: 220,elementWidth: 900,@@ -540,12 +489,10 @@ export const elementDefinitions = {videoUrl: 'https://remotion.media/elements/text-text-marker-preview.mp4',},previewPadding: 120,- slug: 'text/text-marker',installationMode: 'wrapped',width: 1920,},'captions/moving-pill-captions': {- category: 'captions',component: MovingPillCaptions,contributors: [{username: 'JonnyBurger', contribution: null}],description:@@ -555,7 +502,6 @@ export const elementDefinitions = {{name: '@remotion/google-fonts', version: null},{name: '@remotion/layout-utils', version: null},],- displayName: 'Moving Pill Captions',durationInFrames: 210,elementHeight: 180,elementWidth: 900,@@ -569,12 +515,10 @@ export const elementDefinitions = {'https://remotion.media/elements/captions-moving-pill-captions-preview.mp4',},previewPadding: 120,- slug: 'captions/moving-pill-captions',installationMode: 'component-owned-sequence',width: 1920,},'captions/popping-word-captions': {- category: 'captions',component: PoppingWordCaptions,contributors: [{username: 'JonnyBurger', contribution: null}],description: 'Synchronized captions that pop each spoken word into focus.',@@ -583,7 +527,6 @@ export const elementDefinitions = {{name: '@remotion/google-fonts', version: null},{name: '@remotion/layout-utils', version: null},],- displayName: 'Popping Word Captions',durationInFrames: 210,elementHeight: 180,elementWidth: 900,@@ -597,12 +540,10 @@ export const elementDefinitions = {'https://remotion.media/elements/captions-popping-word-captions-preview.mp4',},previewPadding: 120,- slug: 'captions/popping-word-captions',installationMode: 'component-owned-sequence',width: 1920,},'captions/word-highlight-captions': {- category: 'captions',component: WordHighlightCaptions,contributors: [{username: 'JonnyBurger', contribution: null}],description: 'Synchronized captions that highlight each spoken word.',@@ -611,7 +552,6 @@ export const elementDefinitions = {{name: '@remotion/google-fonts', version: null},{name: '@remotion/layout-utils', version: null},],- displayName: 'Word Highlight Captions',durationInFrames: 210,elementHeight: 180,elementWidth: 900,@@ -625,8 +565,26 @@ export const elementDefinitions = {'https://remotion.media/elements/captions-word-highlight-captions-preview.mp4',},previewPadding: 120,- slug: 'captions/word-highlight-captions',installationMode: 'component-owned-sequence',width: 1920,},-} satisfies Record<string, ElementDefinition>;+} satisfies Record<+ ElementSlug,+ Omit<ElementDefinition, 'category' | 'displayName' | 'slug'>+>;++type ElementDefinitions = {+ readonly [Slug in ElementSlug]: ElementDefinition &+ (typeof elementRegistry)[Slug] & {readonly slug: Slug};+};++export const elementDefinitions = Object.fromEntries(+ (Object.keys(elementImplementations) as ElementSlug[]).map((slug) => [+ slug,+ {+ ...elementRegistry[slug],+ ...elementImplementations[slug],+ slug,+ },+ ]),+) as ElementDefinitions;diff --git a/packages/docs/src/components/Elements/element-registry.ts b/packages/docs/src/components/Elements/element-registry.tsnew file mode 100644index 0000000000..7c4a280e13--- /dev/null+++ b/packages/docs/src/components/Elements/element-registry.ts@@ -0,0 +1,109 @@+export const elementCategories = [+ {category: 'backgrounds', label: 'Backgrounds'},+ {category: 'captions', label: 'Captions'},+ {category: 'commerce', label: 'Commerce'},+ {category: 'data', label: 'Data'},+ {category: 'maps', label: 'Maps'},+ {category: 'overlays', label: 'Overlays'},+ {category: 'storytelling', label: 'Storytelling'},+ {category: 'text', label: 'Text'},+ {category: 'youtube', label: 'YouTube'},+] as const;++export type ElementCategory = (typeof elementCategories)[number]['category'];++export const elementRegistry = {+ 'backgrounds/liquid-contours': {+ category: 'backgrounds',+ displayName: 'Liquid Contours',+ },+ 'backgrounds/notebook-paper': {+ category: 'backgrounds',+ displayName: 'Notebook Paper',+ },+ 'backgrounds/paper-texture': {+ category: 'backgrounds',+ displayName: 'Paper Texture',+ },+ 'backgrounds/rotating-starburst': {+ category: 'backgrounds',+ displayName: 'Rotating Starburst',+ },+ 'captions/moving-pill-captions': {+ category: 'captions',+ displayName: 'Moving Pill Captions',+ },+ 'captions/popping-word-captions': {+ category: 'captions',+ displayName: 'Popping Word Captions',+ },+ 'captions/word-highlight-captions': {+ category: 'captions',+ displayName: 'Word Highlight Captions',+ },+ 'commerce/product-discount-callout': {+ category: 'commerce',+ displayName: 'Product Discount Callout',+ },+ 'commerce/product-offer': {+ category: 'commerce',+ displayName: 'Product Offer',+ },+ 'data/horizontal-bar-chart': {+ category: 'data',+ displayName: 'Horizontal Bar Chart',+ },+ 'data/number-counter': {+ category: 'data',+ displayName: 'Number Counter',+ },+ 'data/pie-chart': {+ category: 'data',+ displayName: 'Pie Chart',+ },+ 'data/vertical-bar-chart': {+ category: 'data',+ displayName: 'Vertical Bar Chart',+ },+ 'maps/map-flyover': {+ category: 'maps',+ displayName: 'A-to-B Map Flyover',+ },+ 'overlays/location-lower-third': {+ category: 'overlays',+ displayName: 'Location Lower Third',+ },+ 'overlays/name-lower-third': {+ category: 'overlays',+ displayName: 'Name Lower Third',+ },+ 'text/news-article-highlight': {+ category: 'storytelling',+ displayName: 'News Article Highlight',+ },+ 'text/circle-marker': {+ category: 'text',+ displayName: 'Circle Marker',+ },+ 'text/crossed-off': {+ category: 'text',+ displayName: 'Crossed Off',+ },+ 'text/strike-through': {+ category: 'text',+ displayName: 'Strike Through',+ },+ 'text/text-marker': {+ category: 'text',+ displayName: 'Text Marker',+ },+ 'youtube/youtube-end-card': {+ category: 'youtube',+ displayName: 'YouTube End Card',+ },+} as const satisfies Record<+ string,+ {readonly category: ElementCategory; readonly displayName: string}+>;++export type ElementSlug = keyof typeof elementRegistry;diff --git a/packages/docs/src/test/elements.test.ts b/packages/docs/src/test/elements.test.tsindex a45182ad45..40d89eb08d 100644--- a/packages/docs/src/test/elements.test.ts+++ b/packages/docs/src/test/elements.test.ts@@ -3,6 +3,7 @@ import {existsSync, readdirSync, readFileSync, statSync} from 'fs';import path from 'path';import React from 'react';import {renderToStaticMarkup} from 'react-dom/server';+import elementSidebars from '../../elements-sidebars';import {expandElementSourceReferences,getRemotionElementDependencies,@@ -13,6 +14,10 @@ import {getElementDocumentationUrl,getElementLibrarySections,} from '../components/Elements/element-library-data';+import {+ elementCategories,+ elementRegistry,+} from '../components/Elements/element-registry';import {getElementCompositionId,getElementDimensionsLabel,@@ -30,10 +35,6 @@ const staticElementsRoot = path.join('static','elements',);-const elementSidebars = readFileSync(- path.join(__dirname, '..', '..', 'elements-sidebars.ts'),- 'utf8',-);const elementDefinitionList = Object.values(elementDefinitions);const exactVersionPattern =/^(0|[1-9]\d*)\.(0|[1-9]\d*)\.(0|[1-9]\d*)(?:-(?:0|[1-9]\d*|[A-Za-z-][0-9A-Za-z-]*)(?:\.(?:0|[1-9]\d*|[A-Za-z-][0-9A-Za-z-]*))*)?(?:\+[0-9A-Za-z-]+(?:\.[0-9A-Za-z-]+)*)?$/;@@ -304,6 +305,123 @@ describe('Element social previews', () => {});});+describe('Elements sidebar', () => {+ test('lists every registered Element exactly once in deterministic order', () => {+ const sidebar = elementSidebars.elementsSidebar;+ if (!Array.isArray(sidebar)) {+ throw new Error('Elements sidebar must be an array');+ }++ expect(sidebar.slice(0, 4)).toEqual([+ 'index',+ 'guidelines',+ 'submit-an-element',+ {+ type: 'html',+ value:+ '<hr style="margin-top: 4px; margin-bottom: 4px; border-bottom: none"/>',+ defaultStyle: true,+ },+ ]);++ const categories = sidebar.slice(4);+ const expectedCategories = [+ {+ category: 'backgrounds',+ label: 'Backgrounds',+ items: [+ 'backgrounds/liquid-contours/index',+ 'backgrounds/notebook-paper/index',+ 'backgrounds/paper-texture/index',+ 'backgrounds/rotating-starburst/index',+ ],+ },+ {+ category: 'captions',+ label: 'Captions',+ items: [+ 'captions/moving-pill-captions/index',+ 'captions/popping-word-captions/index',+ 'captions/word-highlight-captions/index',+ ],+ },+ {+ category: 'commerce',+ label: 'Commerce',+ items: [+ 'commerce/product-discount-callout/index',+ 'commerce/product-offer/index',+ ],+ },+ {+ category: 'data',+ label: 'Data',+ items: [+ 'data/horizontal-bar-chart/index',+ 'data/number-counter/index',+ 'data/pie-chart/index',+ 'data/vertical-bar-chart/index',+ ],+ },+ {+ category: 'maps',+ label: 'Maps',+ items: ['maps/map-flyover/index'],+ },+ {+ category: 'overlays',+ label: 'Overlays',+ items: [+ 'overlays/location-lower-third/index',+ 'overlays/name-lower-third/index',+ ],+ },+ {+ category: 'storytelling',+ label: 'Storytelling',+ items: ['text/news-article-highlight/index'],+ },+ {+ category: 'text',+ label: 'Text',+ items: [+ 'text/circle-marker/index',+ 'text/crossed-off/index',+ 'text/strike-through/index',+ 'text/text-marker/index',+ ],+ },+ {+ category: 'youtube',+ label: 'YouTube',+ items: ['youtube/youtube-end-card/index'],+ },+ ] as const;++ expect(categories).toEqual(+ expectedCategories.map(({category, label, items}) => ({+ type: 'category',+ label,+ link: {type: 'doc', id: `${category}/index`},+ collapsed: false,+ items,+ })),+ );+ expect(elementCategories).toEqual(+ expectedCategories.map(({category, label}) => ({category, label})),+ );++ const listedElementPages = expectedCategories.flatMap(({items}) => items);+ const registeredElementPages = Object.keys(elementRegistry).map(+ (slug) => `${slug}/index`,+ );+ expect([...listedElementPages].sort()).toEqual(+ registeredElementPages.sort(),+ );+ expect(new Set(listedElementPages).size).toBe(listedElementPages.length);+ });+});+describe('Element preview definitions', () => {test('contains every production Element exactly once', () => {const elementSlugs = productionElements@@ -495,12 +613,10 @@ describe('Element preview definitions', () => {if (usesReviewUrls) {expect(String(definition.preview.videoUrl)).toBe(localVideoUrl);- const isSubmitted = elementSidebars.includes(- `'${definition.slug}/index'`,- );- expect(existsSync(posterPath)).toBe(isSubmitted);- expect(existsSync(videoPath)).toBe(isSubmitted);- if (isSubmitted) {+ const isRegistered = definition.slug in elementRegistry;+ expect(existsSync(posterPath)).toBe(isRegistered);+ expect(existsSync(videoPath)).toBe(isRegistered);+ if (isRegistered) {const poster = readFileSync(posterPath);const video = readFileSync(videoPath);expect(Array.from(poster.subarray(0, 8))).toEqual([