From 2fc4d7442cfdc64a37fd302a23c7739636c2203d Mon Sep 17 00:00:00 2001 From: Legrand Thomas Date: Sun, 7 Jun 2026 17:39:58 +0200 Subject: [PATCH] feat: ajout d'un composant Strapi video --- .gitignore | 1 + backend/src/components/video/video-embed.json | 25 +++++++++++++++++++ .../BannerVideo/BannerVideo.stories.tsx | 19 +++++++++----- .../molecules/BannerVideo/BannerVideo.tsx | 19 ++++++++++++-- frontend/src/lib/strapi-types.d.ts | 6 +++++ 5 files changed, 62 insertions(+), 8 deletions(-) create mode 100644 backend/src/components/video/video-embed.json diff --git a/.gitignore b/.gitignore index ff90eacd..1f4576d6 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,3 @@ **node_modules/ .DS_Store +.factory/settings.json diff --git a/backend/src/components/video/video-embed.json b/backend/src/components/video/video-embed.json new file mode 100644 index 00000000..748ca394 --- /dev/null +++ b/backend/src/components/video/video-embed.json @@ -0,0 +1,25 @@ +{ + "collectionName": "components_video_video_embeds", + "info": { + "displayName": "video_embed", + "icon": "play", + "description": "" + }, + "options": {}, + "attributes": { + "url": { + "type": "string" + }, + "embed": { + "type": "text" + }, + "orientation": { + "type": "enumeration", + "enum": [ + "horizontal", + "vertical" + ], + "default": "horizontal" + } + } +} diff --git a/frontend/src/components/molecules/BannerVideo/BannerVideo.stories.tsx b/frontend/src/components/molecules/BannerVideo/BannerVideo.stories.tsx index 27750cfa..44c20d51 100644 --- a/frontend/src/components/molecules/BannerVideo/BannerVideo.stories.tsx +++ b/frontend/src/components/molecules/BannerVideo/BannerVideo.stories.tsx @@ -12,33 +12,40 @@ const meta: Meta = { video: { control: { type: 'text' }, }, + format: { + control: { type: 'select' }, + options: ['horizontal', 'vertical'], + }, }, }; export default meta; type Story = StoryObj; -// Story avec contenu principal -export const Default: Story = { +export const Horizontal: Story = { args: { video: ``, + format: 'horizontal', }, }; -export const YoutubeVideo: Story = { +export const Vertical: Story = { args: { - video: ``, + video: ``, + format: 'vertical', }, }; -export const VimeoVideo: Story = { +export const VimeoHorizontal: Story = { args: { video: `
`, + format: 'horizontal', }, }; -export const DailymotionVideo: Story = { +export const DailymotionHorizontal: Story = { args: { video: `
`, + format: 'horizontal', }, }; diff --git a/frontend/src/components/molecules/BannerVideo/BannerVideo.tsx b/frontend/src/components/molecules/BannerVideo/BannerVideo.tsx index f15b8ab0..05c2f4a6 100644 --- a/frontend/src/components/molecules/BannerVideo/BannerVideo.tsx +++ b/frontend/src/components/molecules/BannerVideo/BannerVideo.tsx @@ -3,12 +3,14 @@ import clsx from 'clsx'; export type BannerVideoProps = { video?: string; altVideo?: string; + format?: 'horizontal' | 'vertical'; className?: string; }; const BannerVideo: React.FC = ({ video, altVideo, + format = 'horizontal', className, ...props }) => { @@ -19,12 +21,25 @@ const BannerVideo: React.FC = ({ return (
-
+
iframe]:w-full [&>iframe]:h-full', + { + 'aspect-video': format === 'horizontal', + 'aspect-[9/16]': format === 'vertical', + }, + )} + dangerouslySetInnerHTML={{ __html: `${video}` }} + />
); }; diff --git a/frontend/src/lib/strapi-types.d.ts b/frontend/src/lib/strapi-types.d.ts index 576f1bfe..c15cb228 100644 --- a/frontend/src/lib/strapi-types.d.ts +++ b/frontend/src/lib/strapi-types.d.ts @@ -3199,6 +3199,12 @@ export interface components { stat?: string; description?: string; }; + VideoVideoEmbedComponent: { + id?: number; + url?: string; + embed?: string; + orientation?: "horizontal" | "vertical"; + }; BlogRequest: { data: { title?: string;