Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: video component #1131

Draft
wants to merge 3 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
55 changes: 55 additions & 0 deletions src/Video/Video.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
import React, { ElementType, FC, ReactNode, useEffect } from 'react';

import { CSSModule } from 'reactstrap/types/lib/utils';
import { InputProps } from '../Input/Input';

import { VideoPlayer } from 'bootstrap-italia'

Check failure on line 6 in src/Video/Video.tsx

View workflow job for this annotation

GitHub Actions / lint-commits

Module '"bootstrap-italia"' has no exported member 'VideoPlayer'.

Check failure on line 6 in src/Video/Video.tsx

View workflow job for this annotation

GitHub Actions / build

Module '"bootstrap-italia"' has no exported member 'VideoPlayer'.

Check failure on line 6 in src/Video/Video.tsx

View workflow job for this annotation

GitHub Actions / coverage

Module '"bootstrap-italia"' has no exported member 'VideoPlayer'.

export interface VideoProps extends InputProps {
/** Label da mostrare per il componente */
label: string | ReactNode;
/** Dimensioni ammissibili per il componente */
bsSize?: 'lg' | 'sm';
/** Utilizzarlo in caso di utilizzo di componenti personalizzati */
tag?: ElementType;
/** Da utilizzare per impostare un riferimento all'elemento DOM */
innerRef?: React.Ref<HTMLInputElement>;
/** Oggetto contenente la nuova mappatura per le classi CSS. */
cssModule?: CSSModule;
testId?: string;
}

export const Video: FC<VideoProps> = ({ label, testId }) => {
let vpInstance:VideoPlayer;
useEffect(() => {
const el = document.querySelector('video');
if (el) {
vpInstance = new VideoPlayer(el);
setTimeout(() => {
console.log(vpInstance.player.log) // Con .player puoi usare play(), stop() ecc ..
}, 3000);
}
});
return (
<div className="row" data-testid={testId}>
<video controls data-bs-video>
<source src="//vjs.zencdn.net/v/oceans.mp4" type="video/mp4" />
<source src="//vjs.zencdn.net/v/oceans.webm" type="video/webm" />
</video>
<div className="vjs-transcription accordion">
<div className="accordion-item">
<h2 className="accordion-header " id="transcription-head1">
<button className="accordion-button collapsed" type="button" data-bs-toggle="collapse" data-bs-target="#transcription1" aria-expanded="true" aria-controls="transcription">
{label}
</button>
</h2>
<div id="transcription1" className="accordion-collapse collapse" role="region" aria-labelledby="transcription-head1">
<div className="accordion-body">
{label}
</div>
</div>
</div>
</div>
</div>
);
};
2 changes: 2 additions & 0 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,7 @@ export { Toggle } from './Toggle/Toggle';
export { Toolbar } from './Toolbar/Toolbar';
export { ToolbarDividerItem } from './Toolbar/ToolbarDividerItem';
export { ToolbarItem } from './Toolbar/ToolbarItem';
export { Video } from './Video/Video'

// Types
export type { AccordionProps } from './Accordion/Accordion';
Expand Down Expand Up @@ -248,6 +249,7 @@ export type { TimelineProps } from './Timeline/TimelineWrapper';
export type { ToggleProps } from './Toggle/Toggle';
export type { ToolbarProps } from './Toolbar/Toolbar';
export type { ToolbarItemBadge, ToolbarItemProps } from './Toolbar/ToolbarItem';
export type { VideoProps } from "./Video/Video"

export type {
BreadcrumbItemProps,
Expand Down
30 changes: 30 additions & 0 deletions stories/Components/Video.stories.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
import type { Meta, StoryObj } from '@storybook/react';
import React from 'react';
import { Video } from '../../src';

const meta: Meta<typeof Video> = {
title: 'Documentazione/Componenti/Video',
component: Video,
parameters: {
docs: {
canvas: { sourceState: 'none' }
}
}
};

export default meta;

type Story = StoryObj<typeof Video>;

const EsempiVideo = () => {
return (
<div className='bd-example tooltip-demo'>
<Video label="boh"></Video>
</div>
);
};

export const Esempi: Story = {
render: () => <EsempiVideo />
};

22 changes: 22 additions & 0 deletions stories/Documentation/Video.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
import { Canvas, Controls, Meta, Story } from '@storybook/blocks';
import { Code } from '@storybook/components';
import { Callout, CalloutText, CalloutTitle } from '../../src';
import * as VideoStories from '../Components/Video.stories';

<Meta of={VideoStories} />

# VIDEO

<Canvas of={VideoStories.Esempi} />

#### Source

```tsx

```



## More

Fare riferimento alla [documentazione Bootstrap per il video](https://italia.github.io/bootstrap-italia/docs/componenti/video-player/)
Loading