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 './Link';
export * from './ListItem'; export * from './ListItem';
export * from './NetflixFlag'; export * from './NetflixFlag';
export * from './OdyseeVideo';
export * from './OrderedList'; export * from './OrderedList';
export * from './PrimeVideoFlag'; export * from './PrimeVideoFlag';
export * from './Subheadline'; export * from './Subheadline';
@@ -20,3 +21,4 @@ export * from './TextLink';
export * from './Title'; export * from './Title';
export * from './UnorderedList'; export * from './UnorderedList';
export * from './Verse'; export * from './Verse';
export * from './YouTubeVideo';

View File

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