hedgedoc/frontend/src/extensions/extra-integrations/asciinema/asciinema-frame.tsx
Tilman Vatteroth 5a2a3a4964 feat(frontend): Add Asciinema replacer
Signed-off-by: Tilman Vatteroth <git@tilmanvatteroth.de>
2023-02-05 21:23:39 +01:00

34 lines
1.1 KiB
TypeScript

/*
* SPDX-FileCopyrightText: 2023 The HedgeDoc developers (see AUTHORS file)
*
* SPDX-License-Identifier: AGPL-3.0-only
*/
import { ClickShield } from '../../../components/markdown-renderer/replace-components/click-shield/click-shield'
import type { IdProps } from '../../../components/markdown-renderer/replace-components/custom-tag-with-id-component-replacer'
import React from 'react'
/**
* Renders an embedding for https://asciinema.org
*
* @param id The id from the asciinema url
*/
export const AsciinemaFrame: React.FC<IdProps> = ({ id }) => {
return (
<ClickShield
hoverIcon={'play'}
targetDescription={'asciinema'}
fallbackPreviewImageUrl={`https://asciinema.org/a/${id}.png`}
fallbackBackgroundColor={'#d40000'}
containerClassName={''}
data-cypress-id={'click-shield-asciinema'}>
<span className={'ratio ratio-16x9'}>
<iframe
allowFullScreen={true}
className=''
title={`asciinema cast ${id}`}
src={`https://asciinema.org/a/${id}/iframe?autoplay=1`}
/>
</span>
</ClickShield>
)
}