MediaViewer: Added description

This commit is contained in:
Akmal Isomadinov 2024-02-02 20:27:23 +05:00
parent 01927114cd
commit 7c09046880
2 changed files with 43 additions and 13 deletions

View File

@ -10,18 +10,18 @@ import i18nextStoryDecorator from "../../.storybook/decorators/i18nextStoryDecor
import { Portal } from "../portal";
import { Button } from "../button";
import { MediaViewer as Media } from "./MediaViewer";
import { MediaViewer } from "./MediaViewer";
import type { MediaViewerProps, PlaylistType } from "./MediaViewer.types";
type MediaViewerType = typeof Media;
type MediaViewerType = typeof MediaViewer;
type Story = StoryObj<MediaViewerType>;
const meta: Meta<MediaViewerType> = {
const meta = {
title: "Components/MediaViewer",
component: Media,
component: MediaViewer,
parameters: {},
decorators: [i18nextStoryDecorator],
};
} satisfies Meta<MediaViewerType>;
export default meta;
@ -95,7 +95,7 @@ const DefaultTemplate = (props: MediaViewerProps) => {
<Portal
visible
element={
<Media
<MediaViewer
{...props}
t={t}
visible={visible}
@ -411,7 +411,7 @@ const files: TFile[] = [
},
];
export const Default: Story = {
export const Default = {
args: {
files,
extsImagePreviewed: [
@ -432,4 +432,4 @@ export const Default: Story = {
render: (props) => {
return <DefaultTemplate {...props} />;
},
};
} satisfies Story;

View File

@ -55,22 +55,33 @@ export type BoundsType = {
export type Point = { x: number; y: number };
export interface MediaViewerProps {
/** Function for translating text. */
t: TranslationType;
/** List of media files to be displayed. */
files: TFile[];
/** Specifies whether the media viewer is visible. */
visible: boolean;
/** Position of the current file in the playlist. */
playlistPos: number;
/** Indicates if the current file is a preview. */
isPreviewFile: boolean;
/** List of playlists. */
playlist: PlaylistType[];
/** List of file extensions that can be previewed as images. */
extsImagePreviewed: string[];
/** ID of the current file. */
currentFileId: NumberOrString;
/** Function to get the icon for a file based on its size and extension. */
getIcon: (size: number, ext: string, ...arg: unknown[]) => string;
/** Type of the current device. */
currentDeviceType?: DeviceType;
/** Specifies whether the delete dialog is visible. */
deleteDialogVisible?: boolean;
/** Specifies whether the user has access. */
userAccess?: boolean;
/** ID of the archive room. */
archiveRoomsId?: number;
/** Context menu items for plugins. */
pluginContextMenuItems?: {
key: string;
value: {
@ -81,27 +92,46 @@ export interface MediaViewerProps {
withActiveItem?: boolean;
};
}[];
/** Callback function called when the media viewer is closed. */
onClose?: VoidFunction;
/** Callback function called when an error occurs. */
onError?: VoidFunction;
/** Callback function to view the next media file. */
nextMedia?: VoidFunction;
/** Callback function to view the previous media file. */
prevMedia?: VoidFunction;
/** Callback function called on move action. */
onMoveAction?: VoidFunction;
/** Callback function called on copy action. */
onCopyAction?: VoidFunction;
/** Callback function called on copy link action. */
onCopyLink?: ContextMenuAction;
/** Callback function called on duplicate action. */
onDuplicate?: ContextMenuAction;
/** Callback function called on "Download As" action. */
onClickDownloadAs?: VoidFunction;
/** Callback function called on delete action. */
onClickDelete?: ContextMenuAction;
/** Callback function called on download action. */
onClickDownload?: ContextMenuAction;
/** Callback function called on an error when the playlist is empty. */
onEmptyPlaylistError?: VoidFunction;
/** Callback function called on delete action for a specific file. */
onDelete?: (id: NumberOrString) => void;
/** Callback function called on download action for a specific file. */
onDownload?: (id: NumberOrString) => void;
/** Callback function called when the URL changes for a specific file. */
onChangeUrl?: (id: NumberOrString) => void;
/** Callback function called on rename action. */
onClickRename?: OmitSecondArg<ContextMenuAction>;
/** Callback function called on preview click action. */
onPreviewClick?: OmitSecondArg<ContextMenuAction>;
/** Callback function called on link edit action. */
onClickLinkEdit?: OmitSecondArg<ContextMenuAction>;
/** Callback function called on show info panel action. */
onShowInfoPanel?: OmitSecondArg<ContextMenuAction>;
/** Function to set the buffer selection for a file. */
setBufferSelection?: (file?: TFile | null) => void;
/** Function to set the active files based on their IDs. */
setActiveFiles?: (files: number[], destId?: number) => void;
}