Add VideoGrid storybook
This commit is contained in:
@@ -1,4 +1,5 @@
|
|||||||
const svgrPlugin = require("vite-plugin-svgr");
|
const svgrPlugin = require("vite-plugin-svgr");
|
||||||
|
const path = require("path");
|
||||||
|
|
||||||
module.exports = {
|
module.exports = {
|
||||||
stories: ["../src/**/*.stories.mdx", "../src/**/*.stories.@(js|jsx|ts|tsx)"],
|
stories: ["../src/**/*.stories.mdx", "../src/**/*.stories.@(js|jsx|ts|tsx)"],
|
||||||
@@ -9,6 +10,14 @@ module.exports = {
|
|||||||
},
|
},
|
||||||
async viteFinal(config) {
|
async viteFinal(config) {
|
||||||
config.plugins.push(svgrPlugin());
|
config.plugins.push(svgrPlugin());
|
||||||
|
config.resolve = config.resolve || {};
|
||||||
|
config.resolve.alias = config.resolve.alias || {};
|
||||||
|
config.resolve.alias["$(res)"] = path.resolve(
|
||||||
|
__dirname,
|
||||||
|
"../node_modules/matrix-react-sdk/res"
|
||||||
|
);
|
||||||
|
config.resolve.dedupe = config.resolve.dedupe || [];
|
||||||
|
config.resolve.dedupe.push("react", "react-dom", "matrix-js-sdk");
|
||||||
return config;
|
return config;
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
import React from "react";
|
import React from "react";
|
||||||
import { GridLayoutMenu } from "./GridLayoutMenu";
|
import { GridLayoutMenu } from "./room/GridLayoutMenu";
|
||||||
import {
|
import {
|
||||||
Header,
|
Header,
|
||||||
HeaderLogo,
|
HeaderLogo,
|
||||||
|
|||||||
@@ -10,6 +10,7 @@ import { Header, LeftNav, RightNav, RoomHeaderInfo } from "../Header";
|
|||||||
import VideoGrid, {
|
import VideoGrid, {
|
||||||
useVideoGridLayout,
|
useVideoGridLayout,
|
||||||
} from "matrix-react-sdk/src/components/views/voip/GroupCallView/VideoGrid";
|
} from "matrix-react-sdk/src/components/views/voip/GroupCallView/VideoGrid";
|
||||||
|
import { VideoTileContainer } from "matrix-react-sdk/src/components/views/voip/GroupCallView/VideoTileContainer";
|
||||||
import SimpleVideoGrid from "matrix-react-sdk/src/components/views/voip/GroupCallView/SimpleVideoGrid";
|
import SimpleVideoGrid from "matrix-react-sdk/src/components/views/voip/GroupCallView/SimpleVideoGrid";
|
||||||
import "matrix-react-sdk/res/css/views/voip/GroupCallView/_VideoGrid.scss";
|
import "matrix-react-sdk/res/css/views/voip/GroupCallView/_VideoGrid.scss";
|
||||||
import { getAvatarUrl } from "../matrix-utils";
|
import { getAvatarUrl } from "../matrix-utils";
|
||||||
@@ -140,10 +141,18 @@ export function InCallView({
|
|||||||
<VideoGrid
|
<VideoGrid
|
||||||
items={items}
|
items={items}
|
||||||
layout={layout}
|
layout={layout}
|
||||||
getAvatar={renderAvatar}
|
|
||||||
onFocusTile={onFocusTile}
|
onFocusTile={onFocusTile}
|
||||||
disableAnimations={isSafari}
|
disableAnimations={isSafari}
|
||||||
/>
|
>
|
||||||
|
{({ item, ...rest }) => (
|
||||||
|
<VideoTileContainer
|
||||||
|
key={item.id}
|
||||||
|
callFeed={item.callFeed}
|
||||||
|
getAvatar={renderAvatar}
|
||||||
|
{...rest}
|
||||||
|
/>
|
||||||
|
)}
|
||||||
|
</VideoGrid>
|
||||||
)}
|
)}
|
||||||
<div className={styles.footer}>
|
<div className={styles.footer}>
|
||||||
<MicButton muted={microphoneMuted} onPress={toggleMicrophoneMuted} />
|
<MicButton muted={microphoneMuted} onPress={toggleMicrophoneMuted} />
|
||||||
|
|||||||
45
src/video-grid/VideoGrid.stories.jsx
Normal file
45
src/video-grid/VideoGrid.stories.jsx
Normal file
@@ -0,0 +1,45 @@
|
|||||||
|
import React, { useState } from "react";
|
||||||
|
import VideoGrid from "matrix-react-sdk/src/components/views/voip/GroupCallView/VideoGrid";
|
||||||
|
import VideoTile from "matrix-react-sdk/src/components/views/voip/GroupCallView/VideoTile";
|
||||||
|
import "matrix-react-sdk/res/css/views/voip/GroupCallView/_VideoGrid.scss";
|
||||||
|
import { useMemo } from "react";
|
||||||
|
|
||||||
|
export default {
|
||||||
|
title: "VideoGrid",
|
||||||
|
parameters: {
|
||||||
|
layout: "fullscreen",
|
||||||
|
},
|
||||||
|
argTypes: {
|
||||||
|
layout: {
|
||||||
|
options: ["freedom", "spotlight"],
|
||||||
|
control: { type: "radio" },
|
||||||
|
},
|
||||||
|
},
|
||||||
|
};
|
||||||
|
|
||||||
|
export const ParticipantsTest = ({ layout, participantCount }) => {
|
||||||
|
const items = useMemo(
|
||||||
|
() =>
|
||||||
|
new Array(participantCount).fill(undefined).map((_, i) => ({
|
||||||
|
id: (i + 1).toString(),
|
||||||
|
focused: false,
|
||||||
|
presenter: false,
|
||||||
|
})),
|
||||||
|
[participantCount]
|
||||||
|
);
|
||||||
|
|
||||||
|
return (
|
||||||
|
<div style={{ display: "flex", width: "100vw", height: "100vh" }}>
|
||||||
|
<VideoGrid layout={layout} items={items}>
|
||||||
|
{({ item, ...rest }) => (
|
||||||
|
<VideoTile key={item.id} name={`User ${item.id}`} {...rest} />
|
||||||
|
)}
|
||||||
|
</VideoGrid>
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
|
ParticipantsTest.args = {
|
||||||
|
layout: "freedom",
|
||||||
|
participantCount: 1,
|
||||||
|
};
|
||||||
Reference in New Issue
Block a user