Skip to content

Commit 07c3558

Browse files
authored
feat: Add tooltips to various UI elements (fixes #148). (#160)
1 parent 044b637 commit 07c3558

File tree

10 files changed

+145
-83
lines changed

10 files changed

+145
-83
lines changed
Lines changed: 17 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import {
22
IconButton,
33
IconButtonProps,
4+
Tooltip,
45
} from "@mui/joy";
56

67
import "./PanelTitleButton.css";
@@ -10,16 +11,24 @@ import "./PanelTitleButton.css";
1011
* Renders an IconButton for use in sidebar tab titles.
1112
*
1213
* @param props
14+
* @param props.className
15+
* @param props.title
16+
* @param props.rest
1317
* @return
1418
*/
15-
const PanelTitleButton = (props: IconButtonProps) => {
16-
const {className, ...rest} = props;
17-
return (
18-
<IconButton
19-
className={`tab-panel-title-button ${className ?? ""}`}
20-
{...rest}/>
21-
);
22-
};
19+
const PanelTitleButton = ({
20+
className,
21+
title,
22+
...rest
23+
}: IconButtonProps) => (
24+
<Tooltip title={title}>
25+
<span>
26+
<IconButton
27+
className={`tab-panel-title-button ${className ?? ""}`}
28+
{...rest}/>
29+
</span>
30+
</Tooltip>
31+
);
2332

2433

2534
export default PanelTitleButton;

src/components/CentralContainer/Sidebar/SidebarTabs/SearchTabPanel/index.tsx

Lines changed: 39 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ import {
1010
LinearProgress,
1111
Textarea,
1212
ToggleButtonGroup,
13+
Tooltip,
1314
} from "@mui/joy";
1415

1516
import UnfoldLessIcon from "@mui/icons-material/UnfoldLess";
@@ -67,6 +68,10 @@ const SearchTabPanel = () => {
6768
const [queryOptions, setQueryOptions] = useState<QUERY_OPTION[]>([]);
6869
const [queryString, setQueryString] = useState<string>("");
6970

71+
const handleCollapseAllButtonClick = () => {
72+
setIsAllExpanded((v) => !v);
73+
};
74+
7075
const handleQuerySubmit = (newArgs: Partial<QueryArgs>) => {
7176
startQuery({
7277
isCaseSensitive: getIsCaseSensitive(queryOptions),
@@ -92,12 +97,19 @@ const SearchTabPanel = () => {
9297
});
9398
};
9499

100+
const isQueryInputBoxDisabled = isDisabled(uiState, UI_ELEMENT.QUERY_INPUT_BOX);
101+
95102
return (
96103
<CustomTabPanel
97104
tabName={TAB_NAME.SEARCH}
98105
title={TAB_DISPLAY_NAMES[TAB_NAME.SEARCH]}
99106
titleButtons={
100-
<PanelTitleButton onClick={() => { setIsAllExpanded((v) => !v); }}>
107+
<PanelTitleButton
108+
title={isAllExpanded ?
109+
"Collapse all" :
110+
"Expand all"}
111+
onClick={handleCollapseAllButtonClick}
112+
>
101113
{isAllExpanded ?
102114
<UnfoldLessIcon/> :
103115
<UnfoldMoreIcon/>}
@@ -108,34 +120,46 @@ const SearchTabPanel = () => {
108120
<div className={"query-input-box-with-progress"}>
109121
<Textarea
110122
className={"query-input-box"}
111-
disabled={isDisabled(uiState, UI_ELEMENT.QUERY_INPUT_BOX)}
112123
maxRows={7}
113124
placeholder={"Search"}
114125
size={"sm"}
115126
endDecorator={
116127
<ToggleButtonGroup
128+
disabled={isQueryInputBoxDisabled}
117129
size={"sm"}
118130
spacing={0.25}
119131
value={queryOptions}
120132
variant={"plain"}
121133
onChange={handleQueryOptionsChange}
122134
>
123-
<IconButton
124-
className={"query-option-button"}
125-
value={QUERY_OPTION.IS_CASE_SENSITIVE}
126-
>
127-
Aa
128-
</IconButton>
129-
<IconButton
130-
className={"query-option-button"}
131-
value={QUERY_OPTION.IS_REGEX}
132-
>
133-
.*
134-
</IconButton>
135+
<Tooltip title={"Match case"}>
136+
<span>
137+
<IconButton
138+
className={"query-option-button"}
139+
value={QUERY_OPTION.IS_CASE_SENSITIVE}
140+
>
141+
Aa
142+
</IconButton>
143+
</span>
144+
</Tooltip>
145+
146+
<Tooltip title={"Use regular expression"}>
147+
<span>
148+
<IconButton
149+
className={"query-option-button"}
150+
value={QUERY_OPTION.IS_REGEX}
151+
>
152+
.*
153+
</IconButton>
154+
</span>
155+
</Tooltip>
135156
</ToggleButtonGroup>
136157
}
137158
slotProps={{
138-
textarea: {className: "query-input-box-textarea"},
159+
textarea: {
160+
className: "query-input-box-textarea",
161+
disabled: isQueryInputBoxDisabled,
162+
},
139163
endDecorator: {className: "query-input-box-end-decorator"},
140164
}}
141165
onChange={handleQueryInputChange}/>

src/components/CentralContainer/Sidebar/SidebarTabs/TabButton.tsx

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,11 +34,9 @@ const TabButton = ({tabName, Icon, onTabButtonClick}: TabButtonProps) => {
3434

3535
return (
3636
<Tooltip
37-
arrow={true}
3837
key={tabName}
3938
placement={"right"}
4039
title={TAB_DISPLAY_NAMES[tabName]}
41-
variant={"outlined"}
4240
>
4341
<Tab
4442
className={"sidebar-tab-button"}

src/components/MenuBar/ExportLogsButton.tsx

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ import {
1717
ignorePointerIfFastLoading,
1818
isDisabled,
1919
} from "../../utils/states";
20-
import SmallIconButton from "./SmallIconButton";
20+
import MenuBarIconButton from "./MenuBarIconButton";
2121

2222

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

3131
return (
32-
<SmallIconButton
32+
<MenuBarIconButton
3333
className={ignorePointerIfFastLoading(uiState)}
34+
title={"Export logs"}
3435
disabled={
3536
(null !== exportProgress && EXPORT_LOG_PROGRESS_VALUE_MAX !== exportProgress) ||
3637
isDisabled(uiState, UI_ELEMENT.EXPORT_LOGS_BUTTON)
@@ -56,7 +57,7 @@ const ExportLogsButton = () => {
5657
{Math.ceil(exportProgress * 100)}
5758
</Typography>}
5859
</CircularProgress>}
59-
</SmallIconButton>
60+
</MenuBarIconButton>
6061
);
6162
};
6263

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
import {
2+
IconButton,
3+
IconButtonProps,
4+
Tooltip,
5+
TooltipTypeMap,
6+
} from "@mui/joy";
7+
8+
9+
interface MenuBarIconButtonProps extends IconButtonProps {
10+
tooltipPlacement?: TooltipTypeMap["props"]["placement"];
11+
}
12+
13+
/**
14+
* An icon button for use in the menu bar.
15+
*
16+
* @param props
17+
* @param props.title Tooltip title.
18+
* @param props.tooltipPlacement
19+
* @param props.rest
20+
* @return
21+
*/
22+
const MenuBarIconButton = ({
23+
tooltipPlacement,
24+
title,
25+
...rest
26+
}: MenuBarIconButtonProps) => (
27+
<Tooltip
28+
placement={tooltipPlacement ?? "bottom"}
29+
title={title}
30+
>
31+
<span>
32+
<IconButton
33+
size={"sm"}
34+
{...rest}/>
35+
</span>
36+
</Tooltip>
37+
);
38+
39+
export default MenuBarIconButton;

src/components/MenuBar/NavigationBar.tsx

Lines changed: 14 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,6 @@
11
import React, {useContext} from "react";
22

3-
import {
4-
ButtonGroup,
5-
IconButton,
6-
} from "@mui/joy";
3+
import {ButtonGroup} from "@mui/joy";
74

85
import NavigateBefore from "@mui/icons-material/NavigateBefore";
96
import NavigateNext from "@mui/icons-material/NavigateNext";
@@ -17,6 +14,7 @@ import {
1714
ignorePointerIfFastLoading,
1815
isDisabled,
1916
} from "../../utils/states";
17+
import MenuBarIconButton from "./MenuBarIconButton";
2018
import PageNumInput from "./PageNumInput";
2119

2220

@@ -46,37 +44,40 @@ const NavigationBar = () => {
4644
<ButtonGroup
4745
className={ignorePointerIfFastLoading(uiState)}
4846
disabled={isDisabled(uiState, UI_ELEMENT.NAVIGATION_BAR)}
49-
size={"sm"}
5047
spacing={0.01}
5148
variant={"plain"}
5249
>
53-
<IconButton
50+
<MenuBarIconButton
5451
data-action-name={ACTION_NAME.FIRST_PAGE}
52+
title={"First page"}
5553
onClick={handleNavButtonClick}
5654
>
5755
<SkipPrevious/>
58-
</IconButton>
59-
<IconButton
56+
</MenuBarIconButton>
57+
<MenuBarIconButton
6058
data-action-name={ACTION_NAME.PREV_PAGE}
59+
title={"Previous page"}
6160
onClick={handleNavButtonClick}
6261
>
6362
<NavigateBefore/>
64-
</IconButton>
63+
</MenuBarIconButton>
6564

6665
<PageNumInput/>
6766

68-
<IconButton
67+
<MenuBarIconButton
6968
data-action-name={ACTION_NAME.NEXT_PAGE}
69+
title={"Next page"}
7070
onClick={handleNavButtonClick}
7171
>
7272
<NavigateNext/>
73-
</IconButton>
74-
<IconButton
73+
</MenuBarIconButton>
74+
<MenuBarIconButton
7575
data-action-name={ACTION_NAME.LAST_PAGE}
76+
title={"Last page"}
7677
onClick={handleNavButtonClick}
7778
>
7879
<SkipNext/>
79-
</IconButton>
80+
</MenuBarIconButton>
8081
</ButtonGroup>
8182
);
8283
};

src/components/MenuBar/SmallIconButton.tsx

Lines changed: 0 additions & 16 deletions
This file was deleted.

src/components/MenuBar/index.tsx

Lines changed: 7 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,8 @@ import {useContext} from "react";
33
import {
44
Box,
55
Divider,
6-
IconButton,
76
LinearProgress,
87
Sheet,
9-
Tooltip,
108
Typography,
119
} from "@mui/joy";
1210

@@ -18,6 +16,7 @@ import {CURSOR_CODE} from "../../typings/worker";
1816
import {openFile} from "../../utils/file";
1917
import {isDisabled} from "../../utils/states";
2018
import ExportLogsButton from "./ExportLogsButton";
19+
import MenuBarIconButton from "./MenuBarIconButton";
2120
import NavigationBar from "./NavigationBar";
2221

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

5049
<Divider orientation={"vertical"}/>
51-
<Tooltip
52-
arrow={true}
53-
placement={"right"}
50+
<MenuBarIconButton
51+
disabled={isDisabled(uiState, UI_ELEMENT.OPEN_FILE_BUTTON)}
5452
title={"Open file"}
55-
variant={"outlined"}
53+
tooltipPlacement={"bottom-start"}
54+
onClick={handleOpenFile}
5655
>
57-
<IconButton
58-
disabled={isDisabled(uiState, UI_ELEMENT.OPEN_FILE_BUTTON)}
59-
size={"sm"}
60-
onClick={handleOpenFile}
61-
>
62-
<FolderOpenIcon className={"menu-bar-open-file-icon"}/>
63-
</IconButton>
64-
</Tooltip>
56+
<FolderOpenIcon className={"menu-bar-open-file-icon"}/>
57+
</MenuBarIconButton>
6558
<Divider orientation={"vertical"}/>
6659

6760
<Box

src/components/StatusBar/index.tsx

Lines changed: 19 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import {useContext} from "react";
33
import {
44
Button,
55
Sheet,
6+
Tooltip,
67
Typography,
78
} from "@mui/joy";
89

@@ -39,18 +40,24 @@ const StatusBar = () => {
3940
<Typography className={"status-message"}>
4041
{/* This is left blank intentionally until status messages are implemented. */}
4142
</Typography>
42-
<Button
43-
color={"primary"}
44-
disabled={isDisabled(uiState, UI_ELEMENT.LOG_EVENT_NUM_DISPLAY)}
45-
size={"sm"}
46-
variant={"soft"}
47-
onClick={handleCopyLinkButtonClick}
48-
>
49-
{"Log Event "}
50-
{logEventNum}
51-
{" / "}
52-
{numEvents}
53-
</Button>
43+
44+
<Tooltip title={"Copy link to clipboard"}>
45+
<span>
46+
<Button
47+
color={"primary"}
48+
disabled={isDisabled(uiState, UI_ELEMENT.LOG_EVENT_NUM_DISPLAY)}
49+
size={"sm"}
50+
variant={"soft"}
51+
onClick={handleCopyLinkButtonClick}
52+
>
53+
{"Log Event "}
54+
{logEventNum}
55+
{" / "}
56+
{numEvents}
57+
</Button>
58+
</span>
59+
</Tooltip>
60+
5461
<LogLevelSelect/>
5562
</Sheet>
5663
);

0 commit comments

Comments
 (0)