mirror of
https://github.com/edgelesssys/constellation.git
synced 2025-04-25 17:49:21 -04:00

Signed-off-by: Fabian Kammel <fk@edgeless.systems> Co-authored-by: Moritz Eckert <m1gh7ym0@gmail.com> Co-authored-by: Thomas Tendyck <tt@edgeless.systems> Co-authored-by: 3u13r <lc@edgeless.systems>
23 lines
628 B
JavaScript
23 lines
628 B
JavaScript
import BrowserOnly from '@docusaurus/BrowserOnly';
|
|
import React, { useEffect, useRef } from 'react';
|
|
import 'asciinema-player/dist/bundle/asciinema-player.css';
|
|
|
|
const AsciinemaWidget = ({ src, ...asciinemaOptions}) => {
|
|
return (
|
|
<BrowserOnly fallback={<div>Loading asciinema cast...</div>}>
|
|
{() => {
|
|
const AsciinemaPlayer = require('asciinema-player');
|
|
const ref = useRef(null);
|
|
|
|
useEffect(() => {
|
|
AsciinemaPlayer.create(src, ref.current, asciinemaOptions);
|
|
}, [src]);
|
|
|
|
return <div ref={ref} />;
|
|
}}
|
|
</BrowserOnly>
|
|
);
|
|
};
|
|
|
|
export default AsciinemaWidget;
|