Skip to content

Commit

Permalink
Merge pull request #3 from blopa/feature/use-puppeteer-recorder
Browse files Browse the repository at this point in the history
add puppeteer recorder
  • Loading branch information
blopa authored Jan 2, 2022
2 parents 5c9d5ee + 666a373 commit fe9176b
Show file tree
Hide file tree
Showing 12 changed files with 629 additions and 431 deletions.
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,5 @@
node_modules
node_modules/
node_modules/*
frames
html
output.mp4
34 changes: 17 additions & 17 deletions CodeHighlighter.jsx
Original file line number Diff line number Diff line change
@@ -1,31 +1,31 @@
import React from 'react';
import { HEIGHT, WIDTH, SCALE } from "./constants";
import { HEIGHT, WIDTH, SCALE } from './constants';

function CodeHighlighter({
codeHtml,
totalLines,
currentLine,
}) {
const lines = new Array(totalLines).fill(null).map((v, index) => {
return ((
<span
key={index}
style={{
height: '16px',
width: `${8 * (totalLines).toString().length}px`,
}}
>
{index + 1}
</span>
));
});
const lines = new Array(totalLines).fill(null).map((v, index) => ((
<span
key={index}
style={{
height: '16px',
width: `${8 * (totalLines).toString().length}px`,
}}
>
{index + 1}
</span>
)));

return (
<html>
<html lang="en">
<style
dangerouslySetInnerHTML={{__html: `
dangerouslySetInnerHTML={{
__html: `
body { color: white; }
`}}
`,
}}
/>
<body
style={{
Expand Down
8 changes: 5 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,9 @@

Create a video file showing line by line of a code file or React component.

![ScreenShot](https://raw.githubusercontent.com/blopa/code-video-creator/main/image.png)
<img src="/examples/sample.gif?raw=true" width="890px" />

![ScreenShot](https://raw.githubusercontent.com/blopa/code-video-creator/main/examples/image.png)

I have no idea why I made this... but there you go.

Expand All @@ -18,9 +20,9 @@ npm install
To install dependencies, then run

```shell
npm run generate Test.jsx
npm run generate test.js
```

Where "Test.jsx" should be the path to your file.
Where "test.js" should be the path to your file.

PS: You need to have `ffmpeg` installed for this to work!
6 changes: 6 additions & 0 deletions constants.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,9 @@ export const WIDTH = Math.floor(1920);
export const HEIGHT = Math.floor(1080);
export const SCALE = 4;
export const MAX_LINES = 16;

export const ADD = 'ADD';
export const REMOVE = 'REMOVE';
export const REPLACE = 'REPLACE';
export const SELECT = 'SELECT';
export const SKIP_TO = 'SKIP_TO';
6 changes: 5 additions & 1 deletion examples/Test.jsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@
import { useState } from 'react';
//# has-script
//# skip_to,5
import { useState } from "react";

function Test() {
const [val, setVal] = useState(1);
//# replace,6,true
const [val, setVal] = useState(2);

return (
<div>
Expand Down
File renamed without changes
Binary file added examples/sample.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
5 changes: 5 additions & 0 deletions examples/test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
const text1 = 'this script will transform code';
const text2 = 'into a video like this one';
console.log('using Prism.js and React');
// access the project at:
// https://github.com/blopa/code-video-creator
Loading

0 comments on commit fe9176b

Please sign in to comment.