🎥 Make videos programmatically with React
Elements: Add On-Screen Messages (#10764)
Igor Samokhovets948840f726f8
diff --git a/packages/docs/elements/storytelling/on-screen-messages/index.mdx b/packages/docs/elements/storytelling/on-screen-messages/index.mdxnew file mode 100644index 0000000000..43f8d2954b--- /dev/null+++ b/packages/docs/elements/storytelling/on-screen-messages/index.mdx@@ -0,0 +1,12 @@+---+title: On-Screen Messages+description: An iMessage-inspired text exchange with staggered reveals, focus shifts, and familiar blue and gray chat bubbles.+image: https://remotion.media/elements/storytelling-on-screen-messages-preview.png+---++import {elementDefinitions} from '@site/src/components/Elements/element-definitions';+import {ElementPage} from '@site/src/components/Elements/ElementPage';++# On-Screen Messages++<ElementPage definition={elementDefinitions['storytelling/on-screen-messages']} sourceFile="./on-screen-messages.tsx" />diff --git a/packages/docs/elements/storytelling/on-screen-messages/on-screen-messages.tsx b/packages/docs/elements/storytelling/on-screen-messages/on-screen-messages.tsxnew file mode 100644index 0000000000..33641d0c8d--- /dev/null+++ b/packages/docs/elements/storytelling/on-screen-messages/on-screen-messages.tsx@@ -0,0 +1,217 @@+import {fontFamily, loadFont} from '@remotion/google-fonts/Inter';+import {+ Easing,+ Interactive,+ interpolate,+ useCurrentFrame,+ useVideoConfig,+} from 'remotion';++loadFont('normal', {+ subsets: ['latin'],+ weights: ['500'],+});++export const OnScreenMessages = () => {+ const frame = useCurrentFrame();+ const {durationInFrames} = useVideoConfig();++ return (+ <Interactive.Div+ name="Container"+ style={{+ color: '#f8fafc',+ fontFamily,+ height: 680,+ isolation: 'isolate',+ position: 'relative',+ width: 1260,+ }}+ >+ <Interactive.Div+ name="Message 1"+ style={{+ backgroundColor: '#e9e9eb',+ borderRadius: '38px 38px 38px 12px',+ boxShadow: '0 8px 24px rgba(0, 0, 0, 0.16)',+ boxSizing: 'border-box',+ color: '#111111',+ filter: `blur(${interpolate(+ frame,+ [8, 26, durationInFrames - 14, durationInFrames - 1],+ [12, 0, 0, 8],+ {+ easing: Easing.bezier(0.16, 1, 0.3, 1),+ extrapolateLeft: 'clamp',+ extrapolateRight: 'clamp',+ },+ )}px)`,+ fontSize: 46,+ fontWeight: 500,+ left: 70,+ lineHeight: 1.12,+ opacity: interpolate(+ frame,+ [+ 8,+ 26,+ 50,+ 68,+ 94,+ 112,+ durationInFrames - 14,+ durationInFrames - 1,+ ],+ [0, 1, 1, 0.64, 0.64, 0.44, 0.44, 0],+ {+ easing: Easing.bezier(0.16, 1, 0.3, 1),+ extrapolateLeft: 'clamp',+ extrapolateRight: 'clamp',+ },+ ),+ padding: '24px 32px 26px',+ position: 'absolute',+ scale: interpolate(+ frame,+ [8, 26, durationInFrames - 14, durationInFrames - 1],+ [0.94, 1, 1, 1.015],+ {+ easing: Easing.bezier(0.16, 1, 0.3, 1),+ extrapolateLeft: 'clamp',+ extrapolateRight: 'clamp',+ output: 'perceptual-scale',+ },+ ),+ top: 72,+ translate: interpolate(+ frame,+ [8, 26, durationInFrames - 14, durationInFrames - 1],+ ['-42px 10px', '0px 0px', '0px 0px', '-24px -20px'],+ {+ easing: Easing.bezier(0.16, 1, 0.3, 1),+ extrapolateLeft: 'clamp',+ extrapolateRight: 'clamp',+ },+ ),+ width: 560,+ willChange: 'filter, opacity, transform',+ }}+ >+ I just saw you at the station.+ </Interactive.Div>+ <Interactive.Div+ name="Message 2"+ style={{+ backgroundColor: '#0a84ff',+ borderRadius: '38px 38px 12px 38px',+ boxShadow: '0 8px 24px rgba(0, 0, 0, 0.16)',+ boxSizing: 'border-box',+ color: '#ffffff',+ filter: `blur(${interpolate(+ frame,+ [50, 68, durationInFrames - 14, durationInFrames - 1],+ [12, 0, 0, 8],+ {+ easing: Easing.bezier(0.16, 1, 0.3, 1),+ extrapolateLeft: 'clamp',+ extrapolateRight: 'clamp',+ },+ )}px)`,+ fontSize: 46,+ fontWeight: 500,+ lineHeight: 1.12,+ opacity: interpolate(+ frame,+ [50, 68, 94, 112, durationInFrames - 14, durationInFrames - 1],+ [0, 1, 1, 0.68, 0.68, 0],+ {+ easing: Easing.bezier(0.16, 1, 0.3, 1),+ extrapolateLeft: 'clamp',+ extrapolateRight: 'clamp',+ },+ ),+ padding: '24px 32px 26px',+ position: 'absolute',+ right: 70,+ scale: interpolate(+ frame,+ [50, 68, durationInFrames - 14, durationInFrames - 1],+ [0.94, 1, 1, 1.015],+ {+ easing: Easing.bezier(0.16, 1, 0.3, 1),+ extrapolateLeft: 'clamp',+ extrapolateRight: 'clamp',+ output: 'perceptual-scale',+ },+ ),+ top: 273,+ translate: interpolate(+ frame,+ [50, 68, durationInFrames - 14, durationInFrames - 1],+ ['42px 10px', '0px 0px', '0px 0px', '24px -20px'],+ {+ easing: Easing.bezier(0.16, 1, 0.3, 1),+ extrapolateLeft: 'clamp',+ extrapolateRight: 'clamp',+ },+ ),+ width: 470,+ willChange: 'filter, opacity, transform',+ }}+ >+ I’m still in Berlin.+ </Interactive.Div>+ <Interactive.Div+ name="Message 3"+ style={{+ backgroundColor: '#e9e9eb',+ borderRadius: '38px 38px 38px 12px',+ bottom: 64,+ boxShadow: '0 8px 24px rgba(0, 0, 0, 0.16)',+ boxSizing: 'border-box',+ color: '#111111',+ filter: `blur(${interpolate(+ frame,+ [94, 112, durationInFrames - 14, durationInFrames - 1],+ [12, 0, 0, 8],+ {+ easing: Easing.bezier(0.16, 1, 0.3, 1),+ extrapolateLeft: 'clamp',+ extrapolateRight: 'clamp',+ },+ )}px)`,+ fontSize: 46,+ fontWeight: 500,+ left: 185,+ lineHeight: 1.12,+ opacity: interpolate(+ frame,+ [94, 112, durationInFrames - 14, durationInFrames - 1],+ [0, 1, 1, 0],+ {+ easing: Easing.bezier(0.16, 1, 0.3, 1),+ extrapolateLeft: 'clamp',+ extrapolateRight: 'clamp',+ },+ ),+ padding: '24px 32px 26px',+ position: 'absolute',+ translate: interpolate(+ frame,+ [94, 112, durationInFrames - 14, durationInFrames - 1],+ ['-30px 24px', '0px 0px', '0px 0px', '-20px -24px'],+ {+ easing: Easing.bezier(0.16, 1, 0.3, 1),+ extrapolateLeft: 'clamp',+ extrapolateRight: 'clamp',+ },+ ),+ width: 620,+ willChange: 'filter, opacity, transform',+ }}+ >+ Then who waved back?+ </Interactive.Div>+ </Interactive.Div>+ );+};diff --git a/packages/docs/src/components/Elements/element-definitions.ts b/packages/docs/src/components/Elements/element-definitions.tsindex 4248f46a6a..857ff6765a 100644--- a/packages/docs/src/components/Elements/element-definitions.ts+++ b/packages/docs/src/components/Elements/element-definitions.ts@@ -22,6 +22,7 @@ import {MapFlyover} from '../../../elements/maps/map-flyover/a-to-b-map-flyover'import {WatercolorMap} from '../../../elements/maps/watercolor-map/watercolor-map';import {LocationLowerThird} from '../../../elements/overlays/location-lower-third/location-lower-third';import {NameLowerThird} from '../../../elements/overlays/name-lower-third/name-lower-third';+import {OnScreenMessages} from '../../../elements/storytelling/on-screen-messages/on-screen-messages';import {PolaroidPictures} from '../../../elements/storytelling/polaroid-pictures/polaroid-pictures';import {CircleMarker} from '../../../elements/text/circle-marker/circle-marker';import {CrossedOffText} from '../../../elements/text/crossed-off/crossed-off';@@ -563,6 +564,28 @@ const elementImplementations = {installationMode: 'component-owned-sequence',width: 1920,},+ 'storytelling/on-screen-messages': {+ component: OnScreenMessages,+ contributors: [],+ description:+ 'An iMessage-inspired text exchange with staggered reveals, focus shifts, and familiar blue and gray chat bubbles.',+ dependencies: [{name: '@remotion/google-fonts', version: null}],+ durationInFrames: 162,+ elementHeight: 680,+ elementWidth: 1260,+ fps: 30,+ height: 1080,+ posterFrame: 114,+ preview: {+ posterUrl:+ 'https://remotion.media/elements/storytelling-on-screen-messages-preview.png',+ videoUrl:+ 'https://remotion.media/elements/storytelling-on-screen-messages-preview.mp4',+ },+ safeArea: 180,+ installationMode: 'wrapped',+ width: 1920,+ },'storytelling/polaroid-pictures': {component: PolaroidPictures,contributors: [],diff --git a/packages/docs/src/components/Elements/element-registry.ts b/packages/docs/src/components/Elements/element-registry.tsindex 3bfd81b7f5..a4e7b28753 100644--- a/packages/docs/src/components/Elements/element-registry.ts+++ b/packages/docs/src/components/Elements/element-registry.ts@@ -89,6 +89,10 @@ export const elementRegistry = {category: 'overlays',displayName: 'Name Lower Third',},+ 'storytelling/on-screen-messages': {+ category: 'storytelling',+ displayName: 'On-Screen Messages',+ },'storytelling/polaroid-pictures': {category: 'storytelling',displayName: 'Polaroid Pictures',diff --git a/packages/docs/src/test/elements.test.ts b/packages/docs/src/test/elements.test.tsindex 9dafef68fc..f6a0610638 100644--- a/packages/docs/src/test/elements.test.ts+++ b/packages/docs/src/test/elements.test.ts@@ -283,6 +283,8 @@ describe('Element library', () => {{path: path.join(elementsRoot, 'storytelling', 'index.mdx')},);expect(getInjectedSourceCodeBySlug(storytelling)).toEqual({+ 'storytelling/on-screen-messages':+ completeSourceCodeBySlug['storytelling/on-screen-messages'],'storytelling/polaroid-pictures':completeSourceCodeBySlug['storytelling/polaroid-pictures'],'text/news-article-highlight':@@ -559,6 +561,7 @@ describe('Elements sidebar', () => {label: 'Storytelling',items: ['text/news-article-highlight/index',+ 'storytelling/on-screen-messages/index','storytelling/polaroid-pictures/index',],},