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

OV-410: Remove plus button on resize #411

Merged
merged 1 commit into from
Sep 25, 2024
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
14 changes: 13 additions & 1 deletion frontend/src/bundles/studio/components/timeline/item/item.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,19 @@ type Properties = {
span: Span;
children: React.ReactNode;
onClick?: React.MouseEventHandler<HTMLElement>;
onResizeStart?: () => void;
onResizeEnd?: () => void;
};

const Item: React.FC<Properties> = ({ id, type, span, children, onClick }) => {
const Item: React.FC<Properties> = ({
id,
type,
span,
children,
onClick,
onResizeStart = (): void => {},
onResizeEnd = (): void => {},
}) => {
const selectedItem = useAppSelector(({ studio }) => studio.ui.selectedItem);

const {
Expand All @@ -29,6 +39,8 @@ const Item: React.FC<Properties> = ({ id, type, span, children, onClick }) => {
id,
span,
data: { type },
onResizeEnd,
onResizeStart,
});

return (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import {
useAppSelector,
useCallback,
useMemo,
useState,
} from '~/bundles/common/hooks/hooks.js';
import { IconName, IconSize } from '~/bundles/common/icons/icons.js';
import { Control } from '~/bundles/studio/components/components.js';
Expand All @@ -23,6 +24,7 @@ import { Item, Row } from '../components.js';
import styles from './styles.module.css';

const ScenesRow: React.FC = () => {
const [isResizing, setIsResizing] = useState(false);
const scenes = useAppSelector(({ studio }) => studio.scenes);
const scenesWithSpan = useMemo(() => setItemsSpan(scenes), [scenes]);
const { pixelsToValue } = useTimelineContext();
Expand Down Expand Up @@ -70,6 +72,14 @@ const ScenesRow: React.FC = () => {
[dispatch],
);

const handleResizing = useCallback((): void => {
setIsResizing(true);
}, []);

const handleResizingEnd = useCallback((): void => {
setIsResizing(false);
}, []);

return (
<Row
id={RowNames.SCENE}
Expand All @@ -82,6 +92,8 @@ const ScenesRow: React.FC = () => {
type={RowNames.SCENE}
{...item}
onClick={handleItemClick}
onResizeEnd={handleResizingEnd}
onResizeStart={handleResizing}
>
<Badge
className={styles['scene-badge']}
Expand Down Expand Up @@ -118,22 +130,24 @@ const ScenesRow: React.FC = () => {
</Item>
))}

<Item
type={RowNames.BUTTON}
id="Add scene button"
span={{ start: scenesEnd, end: buttonEnd }}
>
<Control
label="Add a scene"
size={IconSize.LARGE}
icon={IconName.ADD}
variant="light"
height="100%"
width="100%"
isRound={false}
onClick={handleAddClick}
/>
</Item>
{!isResizing && (
<Item
type={RowNames.BUTTON}
id="Add scene button"
span={{ start: scenesEnd, end: buttonEnd }}
>
<Control
label="Add a scene"
size={IconSize.LARGE}
icon={IconName.ADD}
variant="light"
height="100%"
width="100%"
isRound={false}
onClick={handleAddClick}
/>
</Item>
)}
</Row>
);
};
Expand Down
Loading