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(flat-components): add scenes controller components #886

Merged
Merged
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
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import { Meta, Story } from "@storybook/react";
import React from "react";
import { ScenesController, ScenesControllerProps } from ".";

const storyMeta: Meta = {
title: "ClassroomPage/ScenesController",
component: ScenesController,
};

export default storyMeta;

export const Overview: Story<ScenesControllerProps> = args => <ScenesController {...args} />;
Overview.args = {
currentSceneIndex: 1,
scenesCount: 2,
};
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
import "./style.less";
import addSceneSVG from "./image/add-scene.svg";
import nextScenesDisabledSVG from "./image/next-scene-disabled.svg";
import nextScenesSVG from "./image/next-scene.svg";
import preScenesDisabledSVG from "./image/previous-scene-disabled.svg";
import preScenesSVG from "./image/previous-scene.svg";

import React, { FC, useCallback } from "react";
import classNames from "classnames";

export interface ScenesControllerProps {
addScene: () => void;
preScene: () => void;
nextScene: () => void;
currentSceneIndex: number;
scenesCount: number;
disabled: boolean;
}

export const ScenesController: FC<ScenesControllerProps> = ({
addScene,
preScene,
nextScene,
currentSceneIndex,
scenesCount,
disabled,
}) => {
const isFirstScene = currentSceneIndex === 0;
const isLastScene = currentSceneIndex + 1 === scenesCount;

const warpOnClick = useCallback(
(onClick: () => void) => {
if (disabled) {
return undefined;
}
return onClick;
},
[disabled],
);

return (
<div
className={classNames("scenes-controller-container", {
disabled,
})}
>
<div className="scenes-controller-btn-list">
<div className="scenes-controller-btn" onClick={warpOnClick(addScene)}>
<img src={addSceneSVG} alt="add scene" />
</div>
<div className="scenes-controller-btn" onClick={warpOnClick(preScene)}>
<img
src={isFirstScene ? preScenesDisabledSVG : preScenesSVG}
alt="previous scene"
/>
</div>
<div className="scenes-controller-info">
{currentSceneIndex + 1} / {scenesCount}
</div>
<div className="scenes-controller-btn" onClick={warpOnClick(nextScene)}>
<img
src={isLastScene ? nextScenesDisabledSVG : nextScenesSVG}
alt="next scene"
/>
</div>
</div>
</div>
);
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
.scenes-controller-container {
display: flex;
height: 32px;
padding: 0 4px;
border-radius: 4px;
box-shadow: 0 4px 12px 0 rgb(0 0 0 / 8%);
background-color: white;

&.disabled {
opacity: 0.5;
* {
cursor: not-allowed;
}
}
}

.scenes-controller-btn-list {
display: flex;
flex-direction: row;
align-items: center;
user-select: none;
}

.scenes-controller-btn {
cursor: pointer;

&:hover {
background: rgba(33, 35, 36, 0.1);
}
}

.scenes-controller-info {
margin-left: 8px;
margin-right: 8px;
font-size: 12px;
color: #212324;
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,4 @@ export * from "./TopBar";
export * from "./BigVideoAvatar";
export * from "./SmallVideoAvatar";
export * from "./OneToOneVideoAvatar";
export * from "./ScenesController";