From 2ecdbd1719fe8daf768c6855387c51b392b33d0d Mon Sep 17 00:00:00 2001 From: Ivan <8611739+IRBorisov@users.noreply.github.com> Date: Wed, 13 Aug 2025 16:20:30 +0300 Subject: [PATCH] F: Rework video embedding. Add VK Video --- .vscode/settings.json | 1 + rsconcept/frontend/src/app/global-dialogs.tsx | 5 ++ rsconcept/frontend/src/components/icons.tsx | 1 + .../src/components/view/embed-vkvideo.tsx | 42 ++++++++++++ .../features/help/components/badge-video.tsx | 30 +++++++++ .../dialogs/dlg-show-video/dlg-show-video.tsx | 64 +++++++++++++++++++ .../help/dialogs/dlg-show-video/index.tsx | 1 + .../help/dialogs/dlg-show-video/tab-vk.tsx | 10 +++ .../dialogs/dlg-show-video/tab-youtube.tsx | 10 +++ .../src/features/help/items/help-main.tsx | 7 +- .../src/features/help/items/help-rslang.tsx | 21 +----- rsconcept/frontend/src/stores/dialogs.ts | 7 +- rsconcept/frontend/src/stores/preferences.ts | 17 ++++- rsconcept/frontend/src/utils/constants.ts | 22 +++++-- 14 files changed, 210 insertions(+), 28 deletions(-) create mode 100644 rsconcept/frontend/src/components/view/embed-vkvideo.tsx create mode 100644 rsconcept/frontend/src/features/help/components/badge-video.tsx create mode 100644 rsconcept/frontend/src/features/help/dialogs/dlg-show-video/dlg-show-video.tsx create mode 100644 rsconcept/frontend/src/features/help/dialogs/dlg-show-video/index.tsx create mode 100644 rsconcept/frontend/src/features/help/dialogs/dlg-show-video/tab-vk.tsx create mode 100644 rsconcept/frontend/src/features/help/dialogs/dlg-show-video/tab-youtube.tsx diff --git a/.vscode/settings.json b/.vscode/settings.json index b6c6bf6d..329f582d 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -177,6 +177,7 @@ "Upvote", "Viewset", "viewsets", + "vkvideo", "wordform", "Wordforms", "XCSDATN", diff --git a/rsconcept/frontend/src/app/global-dialogs.tsx b/rsconcept/frontend/src/app/global-dialogs.tsx index bf40d824..d2d2981e 100644 --- a/rsconcept/frontend/src/app/global-dialogs.tsx +++ b/rsconcept/frontend/src/app/global-dialogs.tsx @@ -4,6 +4,9 @@ import React from 'react'; import { DialogType, useDialogsStore } from '@/stores/dialogs'; +const DlgShowVideo = React.lazy(() => + import('@/features/help/dialogs/dlg-show-video').then(module => ({ default: module.DlgShowVideo })) +); const DlgChangeInputSchema = React.lazy(() => import('@/features/oss/dialogs/dlg-change-input-schema').then(module => ({ default: module.DlgChangeInputSchema })) ); @@ -161,6 +164,8 @@ export const GlobalDialogs = () => { return null; } switch (active) { + case DialogType.SHOW_VIDEO: + return ; case DialogType.CONSTITUENTA_TEMPLATE: return ; case DialogType.CREATE_CONSTITUENTA: diff --git a/rsconcept/frontend/src/components/icons.tsx b/rsconcept/frontend/src/components/icons.tsx index 1fb83dd0..aff85178 100644 --- a/rsconcept/frontend/src/components/icons.tsx +++ b/rsconcept/frontend/src/components/icons.tsx @@ -39,6 +39,7 @@ export { RiMenuFoldFill as IconMenuFold } from 'react-icons/ri'; export { RiMenuUnfoldFill as IconMenuUnfold } from 'react-icons/ri'; export { LuMoon as IconDarkTheme } from 'react-icons/lu'; export { LuSun as IconLightTheme } from 'react-icons/lu'; +export { IoVideocamOutline as IconVideo } from 'react-icons/io5'; export { LuFolderTree as IconFolderTree } from 'react-icons/lu'; export { LuFolder as IconFolder } from 'react-icons/lu'; export { LuFolderSearch as IconFolderSearch } from 'react-icons/lu'; diff --git a/rsconcept/frontend/src/components/view/embed-vkvideo.tsx b/rsconcept/frontend/src/components/view/embed-vkvideo.tsx new file mode 100644 index 00000000..be5450b5 --- /dev/null +++ b/rsconcept/frontend/src/components/view/embed-vkvideo.tsx @@ -0,0 +1,42 @@ +interface EmbedVKVideoProps { + /** Video ID to embed. */ + videoID: string; + + /** Display height in pixels. */ + pxHeight: number; + + /** Display width in pixels. */ + pxWidth?: number; +} + +/** + * Embeds a YouTube video into the page using the given video ID and dimensions. + */ +export function EmbedVKVideo({ videoID, pxHeight, pxWidth }: EmbedVKVideoProps) { + if (!pxWidth) { + pxWidth = (pxHeight * 16) / 9; + } + return ( +
+