Real-time collaboration for Jupyter Notebooks, Linux Terminals, LaTeX, VS Code, R IDE, and more,
all in one place.
Real-time collaboration for Jupyter Notebooks, Linux Terminals, LaTeX, VS Code, R IDE, and more,
all in one place.
Path: blob/master/src/packages/next/components/videos.tsx
Views: 687
import { Carousel } from "antd";1import { useState } from "react";2import { Icon } from "@cocalc/frontend/components/icon";3import { Paragraph } from "components/misc";4import A from "components/misc/A";56export interface Video {7id: string;8title: string;9}1011export default function Videos({ videos }: { videos: Readonly<Video[]> }) {12const [current, setCurrent] = useState<number>(0);13let n = -1;14return (15<div style={{ margin: "0 auto", textAlign: "center" }}>16<Paragraph>17<Carousel afterChange={setCurrent}>18{videos.map(({ id, title }) => {19n += 1;20return (21<VideoItem22key={id}23id={id}24number={n}25current={current}26title={title}27/>28);29})}30</Carousel>31</Paragraph>32</div>33);34}3536export function VideoItem({37id,38title,39number = 0,40current = 0,41style,42width = 672,43}: {44id: string;45title?: string;46number?: number;47current?: number;48style?;49width?: number;50}) {51return (52<div style={style}>53<div54style={{55background: "black",56paddingBottom: "30px",57paddingTop: "5px",58}}59>60{title && (61<A style={{ color: "white" }} href={`https://youtu.be/${id}`}>62<Icon name="youtube" style={{ color: "red" }} /> {title}63</A>64)}65<div style={{ textAlign: "center" }}>66<iframe67style={{ marginTop: "30px", maxWidth: "100%" }}68width={width}69height={(width * 9) / 16}70src={`https://www.youtube.com/embed/${current == number ? id : ""}`}71title="YouTube video player"72frameBorder={0}73allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture"74allowFullScreen75></iframe>76</div>77<A78style={{ color: "white", float: "right", marginRight: "10px" }}79href="https://www.youtube.com/@cocalc-cloud"80>81<Icon name="youtube" style={{ color: "red" }} /> More Videos82</A>83</div>84</div>85);86}878889