UPDATE: Better active states on Sheet Nav + Double click to rename sheets
This commit is contained in:
committed by
Nicolás Hatcher Andrés
parent
f214070299
commit
a5919d837f
@@ -1,6 +1,7 @@
|
|||||||
import { Button, Menu, MenuItem, styled } from "@mui/material";
|
import { Button, Menu, MenuItem, styled } from "@mui/material";
|
||||||
import { ChevronDown } from "lucide-react";
|
import { ChevronDown } from "lucide-react";
|
||||||
import { useRef, useState } from "react";
|
import { useRef, useState } from "react";
|
||||||
|
import { theme } from "../../theme";
|
||||||
import ColorPicker from "../colorPicker";
|
import ColorPicker from "../colorPicker";
|
||||||
import { isInReferenceMode } from "../editor/util";
|
import { isInReferenceMode } from "../editor/util";
|
||||||
import type { WorkbookState } from "../workbookState";
|
import type { WorkbookState } from "../workbookState";
|
||||||
@@ -38,8 +39,9 @@ function SheetTab(props: SheetTabProps) {
|
|||||||
};
|
};
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
<Wrapper
|
<TabWrapper
|
||||||
style={{ borderBottomColor: color, fontWeight: selected ? 600 : 400 }}
|
$color={color}
|
||||||
|
$selected={selected}
|
||||||
onClick={(event) => {
|
onClick={(event) => {
|
||||||
onSelected();
|
onSelected();
|
||||||
event.stopPropagation();
|
event.stopPropagation();
|
||||||
@@ -55,11 +57,11 @@ function SheetTab(props: SheetTabProps) {
|
|||||||
}}
|
}}
|
||||||
ref={colorButton}
|
ref={colorButton}
|
||||||
>
|
>
|
||||||
<Name>{name}</Name>
|
<Name onDoubleClick={handleOpenRenameDialog}>{name}</Name>
|
||||||
<StyledButton onClick={handleOpen}>
|
<StyledButton onClick={handleOpen}>
|
||||||
<ChevronDown />
|
<ChevronDown />
|
||||||
</StyledButton>
|
</StyledButton>
|
||||||
</Wrapper>
|
</TabWrapper>
|
||||||
<StyledMenu
|
<StyledMenu
|
||||||
anchorEl={anchorEl}
|
anchorEl={anchorEl}
|
||||||
open={open}
|
open={open}
|
||||||
@@ -146,16 +148,17 @@ const StyledMenuItem = styled(MenuItem)`
|
|||||||
height: 32px;
|
height: 32px;
|
||||||
`;
|
`;
|
||||||
|
|
||||||
const MenuItemWrapper = styled(MenuItem)`
|
const TabWrapper = styled("div")<{ $color: string; $selected: boolean }>`
|
||||||
display: flex;
|
display: flex;
|
||||||
justify-content: space-between;
|
margin-right: 12px;
|
||||||
font-size: 12px;
|
border-bottom: 3px solid ${(props) => props.$color};
|
||||||
width: calc(100% - 8px);
|
line-height: 37px;
|
||||||
min-width: 172px;
|
padding: 0px 4px;
|
||||||
margin: 0px 4px;
|
align-items: center;
|
||||||
border-radius: 4px;
|
cursor: pointer;
|
||||||
padding: 8px;
|
font-weight: ${(props) => (props.$selected ? 600 : 400)};
|
||||||
height: 32px;
|
background-color: ${(props) =>
|
||||||
|
props.$selected ? `${theme.palette.grey[50]}80` : "transparent"};
|
||||||
`;
|
`;
|
||||||
|
|
||||||
const StyledButton = styled(Button)`
|
const StyledButton = styled(Button)`
|
||||||
@@ -165,26 +168,27 @@ const StyledButton = styled(Button)`
|
|||||||
padding: 0px;
|
padding: 0px;
|
||||||
color: inherit;
|
color: inherit;
|
||||||
font-weight: inherit;
|
font-weight: inherit;
|
||||||
|
&:hover {
|
||||||
|
background-color: transparent;
|
||||||
|
}
|
||||||
|
&:active {
|
||||||
|
background-color: transparent;
|
||||||
|
}
|
||||||
svg {
|
svg {
|
||||||
width: 15px;
|
width: 15px;
|
||||||
height: 15px;
|
height: 15px;
|
||||||
|
transition: transform 0.2s;
|
||||||
|
}
|
||||||
|
&:hover svg {
|
||||||
|
transform: translateY(2px);
|
||||||
}
|
}
|
||||||
`;
|
|
||||||
|
|
||||||
const Wrapper = styled("div")`
|
|
||||||
display: flex;
|
|
||||||
margin-left: 20px;
|
|
||||||
border-bottom: 3px solid;
|
|
||||||
border-top: 3px solid white;
|
|
||||||
line-height: 34px;
|
|
||||||
align-items: center;
|
|
||||||
cursor: pointer;
|
|
||||||
`;
|
`;
|
||||||
|
|
||||||
const Name = styled("div")`
|
const Name = styled("div")`
|
||||||
font-size: 12px;
|
font-size: 12px;
|
||||||
margin-right: 5px;
|
margin-right: 5px;
|
||||||
text-wrap: nowrap;
|
text-wrap: nowrap;
|
||||||
|
user-select: none;
|
||||||
`;
|
`;
|
||||||
|
|
||||||
export default SheetTab;
|
export default SheetTab;
|
||||||
|
|||||||
@@ -35,6 +35,7 @@ function SheetTabBar(props: SheetTabBarProps) {
|
|||||||
|
|
||||||
return (
|
return (
|
||||||
<Container>
|
<Container>
|
||||||
|
<LeftButtonsContainer>
|
||||||
<StyledButton
|
<StyledButton
|
||||||
title={t("navigation.add_sheet")}
|
title={t("navigation.add_sheet")}
|
||||||
$pressed={false}
|
$pressed={false}
|
||||||
@@ -49,6 +50,8 @@ function SheetTabBar(props: SheetTabBarProps) {
|
|||||||
>
|
>
|
||||||
<Menu />
|
<Menu />
|
||||||
</StyledButton>
|
</StyledButton>
|
||||||
|
</LeftButtonsContainer>
|
||||||
|
<VerticalDivider />
|
||||||
<Sheets>
|
<Sheets>
|
||||||
<SheetInner>
|
<SheetInner>
|
||||||
{sheets.map((tab, index) => (
|
{sheets.map((tab, index) => (
|
||||||
@@ -92,6 +95,8 @@ function SheetTabBar(props: SheetTabBarProps) {
|
|||||||
|
|
||||||
// Note I have to specify the font-family in every component that can be considered stand-alone
|
// Note I have to specify the font-family in every component that can be considered stand-alone
|
||||||
const Container = styled("div")`
|
const Container = styled("div")`
|
||||||
|
display: flex;
|
||||||
|
flex-direction: row;
|
||||||
position: absolute;
|
position: absolute;
|
||||||
bottom: 0px;
|
bottom: 0px;
|
||||||
left: 0px;
|
left: 0px;
|
||||||
@@ -99,10 +104,10 @@ const Container = styled("div")`
|
|||||||
display: flex;
|
display: flex;
|
||||||
height: ${NAVIGATION_HEIGHT}px;
|
height: ${NAVIGATION_HEIGHT}px;
|
||||||
align-items: center;
|
align-items: center;
|
||||||
padding-left: 12px;
|
padding: 0px 12px;
|
||||||
font-family: Inter;
|
font-family: Inter;
|
||||||
background-color: #fff;
|
background-color: ${theme.palette.common.white};
|
||||||
border-top: 1px solid #e0e0e0;
|
border-top: 1px solid ${theme.palette.grey["300"]};
|
||||||
`;
|
`;
|
||||||
|
|
||||||
const Sheets = styled("div")`
|
const Sheets = styled("div")`
|
||||||
@@ -110,6 +115,9 @@ const Sheets = styled("div")`
|
|||||||
overflow: hidden;
|
overflow: hidden;
|
||||||
overflow-x: auto;
|
overflow-x: auto;
|
||||||
scrollbar-width: none;
|
scrollbar-width: none;
|
||||||
|
padding-left: 12px;
|
||||||
|
display: flex;
|
||||||
|
flex-direction: row;
|
||||||
`;
|
`;
|
||||||
|
|
||||||
const SheetInner = styled("div")`
|
const SheetInner = styled("div")`
|
||||||
@@ -119,8 +127,8 @@ const SheetInner = styled("div")`
|
|||||||
const Advert = styled("a")`
|
const Advert = styled("a")`
|
||||||
display: flex;
|
display: flex;
|
||||||
align-items: center;
|
align-items: center;
|
||||||
color: #f2994a;
|
color: ${theme.palette.primary.main};
|
||||||
padding: 0px 12px;
|
padding: 0px 0px 0px 12px;
|
||||||
font-size: 12px;
|
font-size: 12px;
|
||||||
text-decoration: none;
|
text-decoration: none;
|
||||||
border-left: 1px solid ${theme.palette.grey["300"]};
|
border-left: 1px solid ${theme.palette.grey["300"]};
|
||||||
@@ -133,4 +141,19 @@ const Advert = styled("a")`
|
|||||||
}
|
}
|
||||||
`;
|
`;
|
||||||
|
|
||||||
|
const LeftButtonsContainer = styled("div")`
|
||||||
|
display: flex;
|
||||||
|
flex-direction: row;
|
||||||
|
gap: 4px;
|
||||||
|
padding-right: 12px;
|
||||||
|
`;
|
||||||
|
|
||||||
|
const VerticalDivider = styled("div")`
|
||||||
|
height: 100%;
|
||||||
|
width: 0px;
|
||||||
|
@media (max-width: 769px) {
|
||||||
|
border-right: 1px solid ${theme.palette.grey["200"]};
|
||||||
|
}
|
||||||
|
`;
|
||||||
|
|
||||||
export default SheetTabBar;
|
export default SheetTabBar;
|
||||||
|
|||||||
Reference in New Issue
Block a user