📝 add asciinema svg to install doc

This commit is contained in:
yanyongyu
2022-01-27 21:24:56 +08:00
parent afea004421
commit 15d68706b3
9 changed files with 105 additions and 17 deletions

View File

@ -0,0 +1,39 @@
import "asciinema-player/dist/bundle/asciinema-player.css";
import "./styles.css";
import * as AsciinemaPlayer from "asciinema-player";
import React, { useEffect, useRef } from "react";
export type AsciinemaOptions = {
cols: number;
rows: number;
autoPlay: boolean;
preload: boolean;
loop: boolean;
startAt: number | string;
speed: number;
idleTimeLimit: number;
theme: string;
poster: string;
fit: string;
fontSize: string;
};
export type AsciinemaProps = {
url: string;
options?: Partial<AsciinemaOptions>;
};
export default function Asciinema({
url,
options = {},
}: AsciinemaProps): JSX.Element {
const ref = useRef<HTMLDivElement>(null);
useEffect(() => {
AsciinemaPlayer.create(url, ref.current, options);
}, []);
return <div ref={ref} className="not-prose w-full max-w-full my-4"></div>;
}

View File

@ -0,0 +1,3 @@
.asciinema-player svg {
display: inline-block;
}