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

NU-1870 move left toolbar #7151

Open
wants to merge 2 commits into
base: staging
Choose a base branch
from
Open
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
16 changes: 13 additions & 3 deletions designer/client/src/components/SidePanelToggleButton.tsx
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
import { Fade, IconButton, styled } from "@mui/material";
import { Fade, IconButton, styled, Theme } from "@mui/material";
import React from "react";
import { useTranslation } from "react-i18next";
import LeftIcon from "../assets/img/arrows/arrow-left.svg";
import RightIcon from "../assets/img/arrows/arrow-right.svg";
import { PanelSide } from "../actions/nk";
import { useSidePanel } from "./sidePanels/SidePanelsContext";
import { SxProps } from "@mui/system";

const IconWrapper = styled(IconButton)(({ theme }) => ({
borderRadius: 0,
Expand All @@ -16,17 +17,26 @@ const IconWrapper = styled(IconButton)(({ theme }) => ({

type Props = {
type: PanelSide;
handleStyle?: (isOpened: boolean) => SxProps<Theme>;
};

export function SidePanelToggleButton({ type, ...props }: Props) {
export function SidePanelToggleButton({ type, handleStyle, ...props }: Props) {
const { t } = useTranslation();
const { isOpened, switchVisible, toggleCollapse } = useSidePanel(type);
const left = type === PanelSide.Left ? isOpened : !isOpened;
const title = type === PanelSide.Left ? t("panel.toggle.left", "toggle left panel") : t("panel.toggle.right", "toggle right panel");

return (
<Fade in={switchVisible}>
<IconWrapper title={title} onClick={toggleCollapse} disableFocusRipple color="inherit" size="small" {...props}>
<IconWrapper
title={title}
onClick={toggleCollapse}
disableFocusRipple
color="inherit"
size="small"
sx={handleStyle?.(isOpened)}
{...props}
>
{left ? <LeftIcon /> : <RightIcon />}
</IconWrapper>
</Fade>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,12 @@ const ToolbarsLayer = (props: ToolbarsLayerProps): JSX.Element => {
<Overlay gridArea="top/left / top/right" position="relative">
{children}
</Overlay>
<Box component={SidePanelToggleButton} type={PanelSide.Left} gridArea="bottom/left" />
<Box
component={SidePanelToggleButton}
type={PanelSide.Left}
gridArea="bottom/left"
handleStyle={(isOpened) => ({ marginLeft: isOpened ? "unset" : "32px" })}
/>
<Box component={SidePanelToggleButton} type={PanelSide.Right} gridArea="bottom/right" />
</OverlayGrid9>

Expand Down
Loading