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: Add tooltips to various UI elements (fixes #148). #160

Merged
merged 12 commits into from
Jan 12, 2025
Merged
Show file tree
Hide file tree
Changes from 7 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
Expand Up @@ -34,11 +34,9 @@ const TabButton = ({tabName, Icon, onTabButtonClick}: TabButtonProps) => {

return (
<Tooltip
arrow={true}
key={tabName}
placement={"right"}
title={TAB_DISPLAY_NAMES[tabName]}
variant={"outlined"}
>
<Tab
className={"sidebar-tab-button"}
Expand Down
7 changes: 4 additions & 3 deletions src/components/MenuBar/ExportLogsButton.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ import {
ignorePointerIfFastLoading,
isDisabled,
} from "../../utils/states";
import SmallIconButton from "./SmallIconButton";
import MenuBarIconButton from "./MenuBarIconButton";


/**
Expand All @@ -29,8 +29,9 @@ const ExportLogsButton = () => {
const {exportLogs, exportProgress, uiState} = useContext(StateContext);

return (
<SmallIconButton
<MenuBarIconButton
className={ignorePointerIfFastLoading(uiState)}
title={"Export logs"}
disabled={
(null !== exportProgress && EXPORT_LOG_PROGRESS_VALUE_MAX !== exportProgress) ||
isDisabled(uiState, UI_ELEMENT.EXPORT_LOGS_BUTTON)
Expand All @@ -56,7 +57,7 @@ const ExportLogsButton = () => {
{Math.ceil(exportProgress * 100)}
</Typography>}
</CircularProgress>}
</SmallIconButton>
</MenuBarIconButton>
);
};

Expand Down
39 changes: 39 additions & 0 deletions src/components/MenuBar/MenuBarIconButton.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
import {
IconButton,
IconButtonProps,
Tooltip,
TooltipTypeMap,
} from "@mui/joy";


interface MenuBarIconButtonProps extends IconButtonProps {
tooltipPlacement?: TooltipTypeMap["props"]["placement"];
}

/**
* An icon button for use in the menu bar.
*
* @param props
* @param props.title Tooltip title.
* @param props.tooltipPlacement
* @param props.rest
* @return
*/
const MenuBarIconButton = ({
tooltipPlacement,
title,
...rest
}: MenuBarIconButtonProps) => (
<Tooltip
placement={tooltipPlacement ?? "bottom-end"}
title={title}
>
<span>
<IconButton
size={"sm"}
{...rest}/>
</span>
</Tooltip>
);

export default MenuBarIconButton;
27 changes: 14 additions & 13 deletions src/components/MenuBar/NavigationBar.tsx
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
import React, {useContext} from "react";

import {
ButtonGroup,
IconButton,
} from "@mui/joy";
import {ButtonGroup} from "@mui/joy";

import NavigateBefore from "@mui/icons-material/NavigateBefore";
import NavigateNext from "@mui/icons-material/NavigateNext";
Expand All @@ -17,6 +14,7 @@ import {
ignorePointerIfFastLoading,
isDisabled,
} from "../../utils/states";
import MenuBarIconButton from "./MenuBarIconButton";
import PageNumInput from "./PageNumInput";


Expand Down Expand Up @@ -46,37 +44,40 @@ const NavigationBar = () => {
<ButtonGroup
className={ignorePointerIfFastLoading(uiState)}
disabled={isDisabled(uiState, UI_ELEMENT.NAVIGATION_BAR)}
size={"sm"}
spacing={0.01}
variant={"plain"}
>
<IconButton
<MenuBarIconButton
data-action-name={ACTION_NAME.FIRST_PAGE}
title={"First page"}
onClick={handleNavButtonClick}
>
<SkipPrevious/>
</IconButton>
<IconButton
</MenuBarIconButton>
<MenuBarIconButton
data-action-name={ACTION_NAME.PREV_PAGE}
title={"Previous page"}
onClick={handleNavButtonClick}
>
<NavigateBefore/>
</IconButton>
</MenuBarIconButton>

<PageNumInput/>

<IconButton
<MenuBarIconButton
data-action-name={ACTION_NAME.NEXT_PAGE}
title={"Next page"}
onClick={handleNavButtonClick}
>
<NavigateNext/>
</IconButton>
<IconButton
</MenuBarIconButton>
<MenuBarIconButton
data-action-name={ACTION_NAME.LAST_PAGE}
title={"Last page"}
onClick={handleNavButtonClick}
>
<SkipNext/>
</IconButton>
</MenuBarIconButton>
</ButtonGroup>
);
};
Expand Down
16 changes: 0 additions & 16 deletions src/components/MenuBar/SmallIconButton.tsx

This file was deleted.

21 changes: 7 additions & 14 deletions src/components/MenuBar/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,8 @@ import {useContext} from "react";
import {
Box,
Divider,
IconButton,
LinearProgress,
Sheet,
Tooltip,
Typography,
} from "@mui/joy";

Expand All @@ -18,6 +16,7 @@ import {CURSOR_CODE} from "../../typings/worker";
import {openFile} from "../../utils/file";
import {isDisabled} from "../../utils/states";
import ExportLogsButton from "./ExportLogsButton";
import MenuBarIconButton from "./MenuBarIconButton";
import NavigationBar from "./NavigationBar";

import "./index.css";
Expand Down Expand Up @@ -48,20 +47,14 @@ const MenuBar = () => {
</div>

<Divider orientation={"vertical"}/>
<Tooltip
arrow={true}
placement={"right"}
<MenuBarIconButton
disabled={isDisabled(uiState, UI_ELEMENT.OPEN_FILE_BUTTON)}
title={"Open file"}
variant={"outlined"}
tooltipPlacement={"bottom-start"}
onClick={handleOpenFile}
>
<IconButton
disabled={isDisabled(uiState, UI_ELEMENT.OPEN_FILE_BUTTON)}
size={"sm"}
onClick={handleOpenFile}
>
<FolderOpenIcon className={"menu-bar-open-file-icon"}/>
</IconButton>
</Tooltip>
<FolderOpenIcon className={"menu-bar-open-file-icon"}/>
</MenuBarIconButton>
<Divider orientation={"vertical"}/>

<Box
Expand Down
31 changes: 19 additions & 12 deletions src/components/StatusBar/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import {useContext} from "react";
import {
Button,
Sheet,
Tooltip,
Typography,
} from "@mui/joy";

Expand Down Expand Up @@ -39,18 +40,24 @@ const StatusBar = () => {
<Typography className={"status-message"}>
{/* This is left blank intentionally until status messages are implemented. */}
</Typography>
<Button
color={"primary"}
disabled={isDisabled(uiState, UI_ELEMENT.LOG_EVENT_NUM_DISPLAY)}
size={"sm"}
variant={"soft"}
onClick={handleCopyLinkButtonClick}
>
{"Log Event "}
{logEventNum}
{" / "}
{numEvents}
</Button>

<Tooltip title={"Copy link to clipboard"}>
<span>
<Button
color={"primary"}
disabled={isDisabled(uiState, UI_ELEMENT.LOG_EVENT_NUM_DISPLAY)}
size={"sm"}
variant={"soft"}
onClick={handleCopyLinkButtonClick}
>
{"Log Event "}
{logEventNum}
{" / "}
{numEvents}
</Button>
</span>
</Tooltip>

<LogLevelSelect/>
</Sheet>
);
Expand Down
6 changes: 6 additions & 0 deletions src/components/theme.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,12 @@ const APP_THEME = extendTheme({
}),
},
},
JoyTooltip: {
defaultProps: {
variant: "outlined",
arrow: true,
},
},
},
fontFamily: {
body: "var(--ylv-ui-font-family)",
Expand Down
Loading