FIX[WebApp]: Rename navigation => SheetTabBar

Also rename all widgets in that folder to more standard names
This commit is contained in:
Nicolás Hatcher
2024-12-14 22:26:15 +01:00
committed by Nicolás Hatcher Andrés
parent fb764fed1c
commit 98dc1f3b06
8 changed files with 18 additions and 19 deletions

View File

@@ -4,8 +4,8 @@ import { useTranslation } from "react-i18next";
import { theme } from "../../theme"; import { theme } from "../../theme";
interface SheetRenameDialogProps { interface SheetRenameDialogProps {
isOpen: boolean; open: boolean;
close: () => void; onClose: () => void;
onNameChanged: (name: string) => void; onNameChanged: (name: string) => void;
defaultName: string; defaultName: string;
} }
@@ -14,10 +14,10 @@ const SheetRenameDialog = (properties: SheetRenameDialogProps) => {
const { t } = useTranslation(); const { t } = useTranslation();
const [name, setName] = useState(properties.defaultName); const [name, setName] = useState(properties.defaultName);
const handleClose = () => { const handleClose = () => {
properties.close(); properties.onClose();
}; };
return ( return (
<Dialog open={properties.isOpen} onClose={properties.close}> <Dialog open={properties.open} onClose={properties.onClose}>
<StyledDialogTitle> <StyledDialogTitle>
{t("sheet_rename.title")} {t("sheet_rename.title")}
<Cross onClick={handleClose} onKeyDown={() => {}}> <Cross onClick={handleClose} onKeyDown={() => {}}>
@@ -53,7 +53,7 @@ const SheetRenameDialog = (properties: SheetRenameDialogProps) => {
event.stopPropagation(); event.stopPropagation();
if (event.key === "Enter") { if (event.key === "Enter") {
properties.onNameChanged(name); properties.onNameChanged(name);
properties.close(); properties.onClose();
} }
}} }}
onChange={(event) => { onChange={(event) => {

View File

@@ -6,7 +6,7 @@ import { isInReferenceMode } from "../editor/util";
import type { WorkbookState } from "../workbookState"; import type { WorkbookState } from "../workbookState";
import SheetRenameDialog from "./SheetRenameDialog"; import SheetRenameDialog from "./SheetRenameDialog";
interface SheetProps { interface SheetTabProps {
name: string; name: string;
color: string; color: string;
selected: boolean; selected: boolean;
@@ -17,7 +17,7 @@ interface SheetProps {
workbookState: WorkbookState; workbookState: WorkbookState;
} }
function Sheet(props: SheetProps) { function SheetTab(props: SheetTabProps) {
const { name, color, selected, workbookState, onSelected } = props; const { name, color, selected, workbookState, onSelected } = props;
const [anchorEl, setAnchorEl] = useState<null | HTMLButtonElement>(null); const [anchorEl, setAnchorEl] = useState<null | HTMLButtonElement>(null);
const [colorPickerOpen, setColorPickerOpen] = useState(false); const [colorPickerOpen, setColorPickerOpen] = useState(false);
@@ -100,8 +100,8 @@ function Sheet(props: SheetProps) {
</StyledMenuItem> </StyledMenuItem>
</StyledMenu> </StyledMenu>
<SheetRenameDialog <SheetRenameDialog
isOpen={renameDialogOpen} open={renameDialogOpen}
close={handleCloseRenameDialog} onClose={handleCloseRenameDialog}
defaultName={name} defaultName={name}
onNameChanged={(newName) => { onNameChanged={(newName) => {
props.onRenamed(newName); props.onRenamed(newName);
@@ -159,4 +159,4 @@ const Name = styled("div")`
text-wrap: nowrap; text-wrap: nowrap;
`; `;
export default Sheet; export default SheetTab;

View File

@@ -7,10 +7,10 @@ import { NAVIGATION_HEIGHT } from "../constants";
import { StyledButton } from "../toolbar"; import { StyledButton } from "../toolbar";
import type { WorkbookState } from "../workbookState"; import type { WorkbookState } from "../workbookState";
import SheetListMenu from "./SheetListMenu"; import SheetListMenu from "./SheetListMenu";
import Sheet from "./sheet"; import SheetTab from "./SheetTab";
import type { SheetOptions } from "./types"; import type { SheetOptions } from "./types";
export interface NavigationProps { export interface SheetTabBarProps {
sheets: SheetOptions[]; sheets: SheetOptions[];
selectedIndex: number; selectedIndex: number;
workbookState: WorkbookState; workbookState: WorkbookState;
@@ -21,7 +21,7 @@ export interface NavigationProps {
onSheetDeleted: () => void; onSheetDeleted: () => void;
} }
function Navigation(props: NavigationProps) { function SheetTabBar(props: SheetTabBarProps) {
const { t } = useTranslation(); const { t } = useTranslation();
const { workbookState, onSheetSelected, sheets, selectedIndex } = props; const { workbookState, onSheetSelected, sheets, selectedIndex } = props;
const [anchorEl, setAnchorEl] = useState<null | HTMLButtonElement>(null); const [anchorEl, setAnchorEl] = useState<null | HTMLButtonElement>(null);
@@ -52,7 +52,7 @@ function Navigation(props: NavigationProps) {
<Sheets> <Sheets>
<SheetInner> <SheetInner>
{sheets.map((tab, index) => ( {sheets.map((tab, index) => (
<Sheet <SheetTab
key={tab.sheetId} key={tab.sheetId}
name={tab.name} name={tab.name}
color={tab.color} color={tab.color}
@@ -133,4 +133,4 @@ const Advert = styled("a")`
} }
`; `;
export default Navigation; export default SheetTabBar;

View File

@@ -0,0 +1 @@
export { default } from "./SheetTabBar";

View File

@@ -1,2 +0,0 @@
export { default } from "./navigation";
export type { NavigationProps } from "./navigation";

View File

@@ -6,6 +6,7 @@ import type {
} from "@ironcalc/wasm"; } from "@ironcalc/wasm";
import { styled } from "@mui/material/styles"; import { styled } from "@mui/material/styles";
import { useCallback, useEffect, useRef, useState } from "react"; import { useCallback, useEffect, useRef, useState } from "react";
import SheetTabBar from "./SheetTabBar/SheetTabBar";
import { import {
COLUMN_WIDTH_SCALE, COLUMN_WIDTH_SCALE,
LAST_COLUMN, LAST_COLUMN,
@@ -16,7 +17,6 @@ import {
getNewClipboardId, getNewClipboardId,
} from "./clipboard"; } from "./clipboard";
import FormulaBar from "./formulabar"; import FormulaBar from "./formulabar";
import Navigation from "./navigation/navigation";
import Toolbar from "./toolbar"; import Toolbar from "./toolbar";
import useKeyboardNavigation from "./useKeyboardNavigation"; import useKeyboardNavigation from "./useKeyboardNavigation";
import { type NavigationKey, getCellAddress } from "./util"; import { type NavigationKey, getCellAddress } from "./util";
@@ -572,7 +572,7 @@ const Workbook = (props: { model: Model; workbookState: WorkbookState }) => {
}} }}
/> />
<Navigation <SheetTabBar
sheets={info} sheets={info}
selectedIndex={model.getSelectedSheet()} selectedIndex={model.getSelectedSheet()}
workbookState={workbookState} workbookState={workbookState}