feat: add Video components

This commit is contained in:
Stefan Imhoff
2023-04-23 15:35:18 +02:00
parent af985f2111
commit f62210a3ac
4 changed files with 55 additions and 0 deletions

View File

@@ -0,0 +1,24 @@
import cx from 'classnames';
import type { FunctionalComponent } from 'preact';
interface Props {
class?: string;
id: string;
}
export const OdyseeVideo: FunctionalComponent<Props> = ({ class: className, id, ...props }) => {
const classes = cx('relative aspect-video mbe-10', className);
return (
<div class={classes} {...props}>
<iframe
allow="accelerometer; autoplay; encrypted-media; gyroscope; picture-in-picture"
allowFullScreen
class="absolute h-full w-full"
frameBorder="0"
src={`https://odysee.com/$/embed/${id}`}
></iframe>
</div>
);
};

View File

@@ -0,0 +1,24 @@
import cx from 'classnames';
import type { FunctionalComponent } from 'preact';
interface Props {
class?: string;
id: string;
}
export const YouTubeVideo: FunctionalComponent<Props> = ({ class: className, id, ...props }) => {
const classes = cx('relative aspect-video mbe-10', className);
return (
<div class={classes} {...props}>
<iframe
allow="accelerometer; autoplay; encrypted-media; gyroscope; picture-in-picture"
allowFullScreen
class="absolute h-full w-full"
frameBorder="0"
src={`https://www.youtube.com/embed/${id}`}
></iframe>
</div>
);
};

View File

@@ -11,6 +11,7 @@ export * from './LegalDate';
export * from './Link';
export * from './ListItem';
export * from './NetflixFlag';
export * from './OdyseeVideo';
export * from './OrderedList';
export * from './PrimeVideoFlag';
export * from './Subheadline';
@@ -20,3 +21,4 @@ export * from './TextLink';
export * from './Title';
export * from './UnorderedList';
export * from './Verse';
export * from './YouTubeVideo';

View File

@@ -1,6 +1,7 @@
import {
AffiliateLink,
AmazonBook,
Banner,
Book,
ColorSwatch,
Divider,
@@ -9,6 +10,7 @@ import {
Image,
ListItem,
NetflixFlag,
OdyseeVideo,
OrderedList,
PrimeVideoFlag,
Subheadline,
@@ -18,6 +20,7 @@ import {
Title,
UnorderedList,
Verse,
YouTubeVideo,
} from './components';
export const mapping = {
@@ -39,8 +42,10 @@ export const mapping = {
li: ListItem,
ol: OrderedList,
NetflixFlag,
OdyseeVideo,
p: Text,
ul: UnorderedList,
PrimeVideoFlag,
Verse,
YouTubeVideo,
};