Skip to content

🎥 Make videos programmatically with React

refine

Jonny Burger42668713d22f
diff --git a/packages/docs/components/LandingPage/BackgroundAnimation.tsx b/packages/docs/components/LandingPage/BackgroundAnimation.tsx
index 1c0a418d81..b51326297f 100644
--- a/packages/docs/components/LandingPage/BackgroundAnimation.tsx
+++ b/packages/docs/components/LandingPage/BackgroundAnimation.tsx
@@ -1,16 +1,9 @@
-import React from "react";
-import { random, useVideoConfig } from "remotion";
+import React, { useEffect } from "react";
import {getLength} from '@remotion/paths'
-import './bganimation.css'
-
-const style: React.CSSProperties = {
- position: 'absolute',
- width: '100%',
-}
+import styles from './bg-anim.module.css'
-
-const rx = 0.25;
-const ry = 0.5
+const rx = 0.2;
+const ry = 0.45
function ellipseToPath(cx: number, cy: number): string {
@@ -34,32 +27,79 @@ function ellipseToPath(cx: number, cy: number): string {
return output;
}
+const strokeWidth = 0.035
+
export const BackgroundAnimation: React.FC = () => {
const d = ellipseToPath(0.5, 0.5)
const length = getLength(d)
- console.log(length)
+
+ const css = `
+ @keyframes bganimation {
+ from {
+ stroke-dashoffset: 0
+ }
+
+ to {
+ stroke-dashoffset: ${length};
+ }
+ }
+ `;
+
+ useEffect(() => {
+ const _style = document.createElement('style');
+ _style.innerHTML = css;
+ document.head.appendChild(_style);
+ }, [css])
return (
- <div style={style}>
- <svg viewBox="0 0 1 1" style={{
+ <div className={styles.bganimcontainer}>
+ <svg className={styles.svg} viewBox="0 0 1 1" style={{
width: '100%',
+ zIndex: -1,
position: 'absolute',
- zIndex: -1
}}>
- <g transform="translate(0, -0.4)">
<path
d={d}
fill="none"
stroke="var(--ifm-color-primary)"
strokeLinecap="round"
- strokeWidth={0.035}
+ className={styles.p}
+ style={{
+ transformOrigin: 'center center',
+ transform: `rotate(120deg)`,
+ animation: `bganimation 20s linear infinite`,
+ strokeDasharray: `${length * 0.2} ${length * 0.8}`,
+ }}
+ />
+ <path
+ d={d}
+ fill="none"
+ stroke="var(--ifm-color-primary)"
+ strokeLinecap="round"
+ strokeWidth={strokeWidth}
+ className={styles.p}
+ style={{
+ transformOrigin: 'center center',
+ transform: `rotate(0deg)`,
+ animation: `bganimation 20s linear infinite`,
+ strokeDasharray: `${length * 0.2} ${length * 0.8}`,
+
+ }}
+ />
+ <path
+ d={d}
+ fill="none"
+ stroke="var(--ifm-color-primary)"
+ strokeLinecap="round"
+ strokeWidth={strokeWidth}
+ className={styles.p}
style={{
transformOrigin: 'center center',
- transform: `rotate(${random('hia') * 360}deg)`,
- animation: `bganimation 20s linear infinite`
+ transform: `rotate(240deg)`,
+ animation: `bganimation 20s linear infinite`,
+ strokeDasharray: `${length * 0.2} ${length * 0.8}`,
}}
/>
- </g>
</svg>
</div>
)
diff --git a/packages/docs/components/LandingPage/WriteInReact.tsx b/packages/docs/components/LandingPage/WriteInReact.tsx
index 0bfbf16351..1788e37d36 100644
--- a/packages/docs/components/LandingPage/WriteInReact.tsx
+++ b/packages/docs/components/LandingPage/WriteInReact.tsx
@@ -14,6 +14,7 @@ export const WriteInReact: React.FC = () => {
fontSize: "1.2em",
fontWeight: 500,
}}
+ className={styles.text}
>
Create real MP4 videos programmatically. <br /> Scale your video
production using server-side rendering and parametrization.
diff --git a/packages/docs/components/LandingPage/bg-anim.module.css b/packages/docs/components/LandingPage/bg-anim.module.css
new file mode 100644
index 0000000000..048c22e178
--- /dev/null
+++ b/packages/docs/components/LandingPage/bg-anim.module.css
@@ -0,0 +1,38 @@
+.bganimcontainer {
+ width: 100%;
+ max-width: 1200px;
+ min-width: 700px;
+ margin: auto;
+ position: relative;
+}
+
+@media screen and (max-width: 700px) {
+ .bganimcontainer {
+ position: absolute;
+ width: 700px;
+ height: 700px;
+ left: 50%;
+ margin-left: -350px;
+ }
+}
+
+.svg {
+ transform: translateY(-50%);
+}
+
+@media screen and (max-width: 900px) {
+ .svg {
+ transform: translateY(-30%);
+ }
+}
+
+.p {
+ stroke-width: 0.035;
+}
+
+@media screen and (max-width: 900px) {
+ .p {
+ stroke-width: 0.04;
+ }
+
+}
diff --git a/packages/docs/components/LandingPage/bganimation.css b/packages/docs/components/LandingPage/bganimation.css
deleted file mode 100644
index 3ac677e390..0000000000
--- a/packages/docs/components/LandingPage/bganimation.css
+++ /dev/null
@@ -1,12 +0,0 @@
-@keyframes bganimation {
- from {
- stroke-dasharray: 0.2 1.8;
- stroke-dashoffset: 0
- }
-
- to {
- stroke-dasharray: 0.2 1.8;
-
- stroke-dashoffset: 2.2;
- }
-}
diff --git a/packages/docs/components/LandingPage/writeinreact.module.css b/packages/docs/components/LandingPage/writeinreact.module.css
index 75a7579597..069c27e89f 100644
--- a/packages/docs/components/LandingPage/writeinreact.module.css
+++ b/packages/docs/components/LandingPage/writeinreact.module.css
@@ -8,6 +8,11 @@
font-weight: 900;
line-height: 1;
text-align: center;
+ text-shadow: 0 5px 30px var(--background);
+}
+
+.text {
+ text-shadow: 0 5px 30px var(--background);
}
.writeright {
diff --git a/packages/docs/src/components/TemplateIcon.tsx b/packages/docs/src/components/TemplateIcon.tsx
index 86beb2dacc..469a628574 100644
--- a/packages/docs/src/components/TemplateIcon.tsx
+++ b/packages/docs/src/components/TemplateIcon.tsx
@@ -8,6 +8,7 @@ const outer: React.CSSProperties = {
flexDirection: "column",
color: "var(--light-text-color)",
cursor: "pointer",
+ filter: 'drop-shadow(0px 0px 4px var(--background))',
};
const icon: React.CSSProperties = {
diff --git a/packages/docs/src/css/custom.css b/packages/docs/src/css/custom.css
index efb1284fc9..47c6762240 100644
--- a/packages/docs/src/css/custom.css
+++ b/packages/docs/src/css/custom.css
@@ -66,18 +66,20 @@ h1, h2, h3, h4, h5, h6 {
}
[data-theme="light"] {
+ --background: #fff;
--text-color: #000;
--blue-button-color: #084696;
- --blue-underlay: rgba(66, 144, 245, 0.15);
- --blue-underlay-hover: rgba(66, 144, 245, 0.25);
+ --blue-underlay: #e7effe;
+ --blue-underlay-hover: #d5e5fd;
--light-text-color: #777;
--clear-hover: rgba(0, 0, 0, 0.04);
--box-shadow: 0 1px 4px rgba(0, 0, 0, 0.2);
}
[data-theme="dark"] {
+ --background: #18191a;
--text-color: #fff;
- --blue-underlay: rgba(255, 255, 255, 0.15);
- --blue-underlay-hover: rgba(255, 255, 255, 0.25);
+ --blue-underlay: #424243;
+ --blue-underlay-hover: #5b5c5e;
--clear-hover: rgba(255, 255, 255, 0.06);
--blue-button-color: white;
--light-text-color: #aaa;