Skip to content

🎥 Make videos programmatically with React

feat(docs): improve line highlighting

Frencoc9a14acefce3
diff --git a/packages/docs/docs/animating-properties.md b/packages/docs/docs/animating-properties.md
index a4eb1a2488..dae6ceb9f1 100644
--- a/packages/docs/docs/animating-properties.md
+++ b/packages/docs/docs/animating-properties.md
@@ -8,7 +8,9 @@ Let's start with a simple example, let's say we want to create a fade in animati
If we want to fade the text in over 20 frames, we need to gradually change the `opacity` style over time so that it goes from 0 to 1.
-```tsx {4,11}
+```tsx twoslash {3, 10}
+import { useCurrentFrame } from "remotion"
+// ---cut---
export const MyVideo = () => {
const frame = useCurrentFrame();
@@ -37,7 +39,7 @@ The function takes 4 arguments:
3. The range of values that you want to map the input to
4. Optional settings
-```tsx {6,13}
+```tsx twoslash {5, 12}
import {useCurrentFrame, interpolate} from 'remotion';
export const MyVideo = () => {
@@ -64,7 +66,7 @@ In this example, we map the frames 0 to 20 to their opacity values `(0, 0.05, 0.
Spring animations are beautiful way to put things into motion and make them natural. Remotion includes a helper function to make spring animations easy! This time, let's animate the scale of the text.
-```tsx {7,20}
+```tsx twoslash {6-11, 19}
import {useCurrentFrame, useVideoConfig, spring} from 'remotion';
export const MyVideo = () => {
diff --git a/packages/docs/docs/the-fundamentals.md b/packages/docs/docs/the-fundamentals.md
index 0eafbe3e28..eb1b360d1b 100644
--- a/packages/docs/docs/the-fundamentals.md
+++ b/packages/docs/docs/the-fundamentals.md
@@ -3,7 +3,7 @@ id: the-fundamentals
title: The fundamentals
---
-```twoslash include sample
+```twoslash include example
import { useCurrentFrame } from "remotion";
export const MyVideo = () => {
@@ -23,7 +23,7 @@ The basic idea behind Remotion is that you get a frame number and blank canvas t
You express those ideas using **[React](https://reactjs.org)**.
```tsx twoslash
-// @include: sample-MyVideo
+// @include: example-MyVideo
```
## Video properties
@@ -58,7 +58,7 @@ Compositions are components with the above mentioned metadata. You can define co
```tsx twoslash
import { Composition } from "remotion"
-// @include: sample-MyVideo
+// @include: example-MyVideo
// ---cut---
export const RemotionVideo: React.FC = () => {
diff --git a/packages/docs/src/css/twoslash.css b/packages/docs/src/css/twoslash.css
index ecda993195..98d8359b52 100644
--- a/packages/docs/src/css/twoslash.css
+++ b/packages/docs/src/css/twoslash.css
@@ -14,30 +14,47 @@ pre.shiki.min-light {
/* None theme specific styles */
pre {
- padding: 1rem;
+ padding: 0;
+ margin: 0;
margin-bottom: 3rem;
overflow-x: auto;
+ position: relative;
}
pre.shiki {
overflow-x: auto;
}
-pre.shiki:hover .dim {
- opacity: 1;
-}
-pre.shiki div.dim {
- opacity: 0.5;
+pre.shiki div.line {
+ min-height: 1rem;
}
+
+/** Line highlighting **/
pre.shiki div.dim,
pre.shiki div.highlight {
margin: 0;
padding: 0;
}
-pre.shiki div.highlight {
+pre.shiki:hover .dim {
opacity: 1;
- background-color: #f1f8ff;
+ filter: none;
}
-pre.shiki div.line {
- min-height: 1rem;
+pre.shiki div.dim {
+ opacity: 0.5;
+ filter: grayscale(1);
+}
+pre.shiki div.highlight::before {
+ content: "";
+ opacity: 0;
+ position: absolute;
+ z-index: 0;
+ height: 1.4rem;
+ width: calc(100% + 2rem - 3px);
+ left: 0;
+ background-color: var(--blue-underlay);
+ border-left: 3px solid var(--ifm-color-primary);
+ pointer-events: none;
+}
+pre.shiki:hover div.highlight::before {
+ opacity: 1;
}
/** Hide language identifiers */
@@ -69,6 +86,7 @@ pre.twoslash data-lsp:hover::before {
}
pre .code-container {
+ padding: 1rem;
overflow: auto;
}