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

Add button tooltips to sidebar #1375

Merged
merged 8 commits into from
Jul 29, 2024
Merged
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
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
- Added borehole geometry panel.
- Added secondary header to borehole detail view.
- Added new codelist entries for `casing_type` and `backfill_material`.
- Added tooltips to main side navigation.

### Changed

Expand Down
2 changes: 1 addition & 1 deletion src/client/public/icons/help.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
10 changes: 9 additions & 1 deletion src/client/src/AppTheme.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ export const theme = createTheme({
lightgrey: "#f1f3f5",
darkgrey: "#787878",
dark: "rgba(0, 0, 0, 0.5)",
menuItemActive: "#D92B04",
menuItemActive: "#A65462",
filterItemActive: "#1C2834",
},

Expand Down Expand Up @@ -135,5 +135,13 @@ export const theme = createTheme({
},
},
},
MuiBadge: {
styleOverrides: {
badge: {
backgroundColor: "#FF0000",
color: "#FFFFFF",
},
},
},
},
});
80 changes: 39 additions & 41 deletions src/client/src/commons/menu/mainView/mainSideNav.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { useContext, useEffect, useRef, useState } from "react";
import { useDispatch, useSelector } from "react-redux";
import { useHistory } from "react-router-dom";
import { Badge, IconButton, Stack } from "@mui/material";
import { Badge, Stack } from "@mui/material";
import { ImportErrorModal } from "./menuComponents/importErrorModal";
import FilterIcon from "../../../../public/icons/filter.svg?react";
import AddIcon from "../../../../public/icons/add.svg?react";
Expand All @@ -10,27 +10,13 @@ import SettingsIcon from "../../../../public/icons/settings.svg?react";
import HelpIcon from "../../../../public/icons/help.svg?react";
import LayersIcon from "../../../../public/icons/layers.svg?react";
import { theme } from "../../../AppTheme";
import { styled } from "@mui/system";
import ImportModal from "./actions/importModal";
import { DrawerContentTypes } from "../../../pages/editor/editorComponentInterfaces";
import { ErrorResponse, MainSideNavProps } from "./menuComponents/menuComponentInterfaces";
import { ReduxRootState, User } from "../../../ReduxStateInterfaces";
import { FilterContext } from "../../../components/filter/filterContext";

const StyledIconButton = styled(IconButton)({
padding: "10px",
marginBottom: "25px",
color: theme.palette.neutral.contrastText,
"&:hover": {
backgroundColor: theme.palette.background.lightgrey,
},
borderRadius: "10px",
});

const selectedButtonStyle = {
color: theme.palette.primary.contrastText,
backgroundColor: theme.palette.background.menuItemActive + " !important",
};
import { useTranslation } from "react-i18next";
import { NavButton } from "../../../components/buttons/navButton";

const MainSideNav = ({
toggleDrawer,
Expand All @@ -44,6 +30,7 @@ const MainSideNav = ({
}: MainSideNavProps) => {
const history = useHistory();
const menuRef = useRef(null);
const { t } = useTranslation();
const [creating, setCreating] = useState<boolean>(false);
const [modal, setModal] = useState<boolean>(false);
const [upload, setUpload] = useState<boolean>(false);
Expand Down Expand Up @@ -112,47 +99,58 @@ const MainSideNav = ({
padding: "1em",
flex: "1 1 100%",
}}>
{activeFilterCount > 0 && <Badge color="error" sx={{ margin: "1px" }} badgeContent={activeFilterCount}></Badge>}
<StyledIconButton
{activeFilterCount > 0 && <Badge sx={{ margin: "1px" }} badgeContent={activeFilterCount}></Badge>}
<NavButton
data-cy="show-filter-button"
icon={<FilterIcon />}
label={t("searchfilters")}
selected={isFilterPanelVisible}
onClick={handleToggleFilter}
sx={isFilterPanelVisible ? selectedButtonStyle : {}}>
<FilterIcon />
</StyledIconButton>
<StyledIconButton
/>
<NavButton
data-cy="new-borehole-button"
onClick={handleToggleAdd}
icon={<AddIcon />}
label={t("add")}
selected={isAddPanelVisible}
disabled={user.data.roles.indexOf("EDIT") === -1}
sx={isAddPanelVisible ? selectedButtonStyle : {}}>
<AddIcon />
</StyledIconButton>
<StyledIconButton
onClick={handleToggleAdd}
/>
<NavButton
data-cy="import-borehole-button"
icon={<UploadIcon />}
label={t("upload")}
disabled={user.data.roles.indexOf("EDIT") === -1}
onClick={() => {
toggleDrawer(false);
setModal(true);
setUpload(true);
}}
disabled={user.data.roles.indexOf("EDIT") === -1}>
<UploadIcon />
</StyledIconButton>
<StyledIconButton
/>
<NavButton
data-cy="layers-button"
icon={<LayersIcon />}
label={t("usersMap")}
selected={isLayersPanelVisible}
onClick={handleToggleLayers}
sx={isLayersPanelVisible ? selectedButtonStyle : {}}>
<LayersIcon />
</StyledIconButton>
/>
</Stack>
<Stack
direction="column"
sx={{
padding: "1em",
}}>
<StyledIconButton data-cy="settings-button" onClick={() => history.push(`/setting`)}>
<SettingsIcon />
</StyledIconButton>
<StyledIconButton>
<HelpIcon onClick={() => window.open(`/help`)} />
</StyledIconButton>
<NavButton
data-cy="settings-button"
icon={<SettingsIcon />}
label={t("header_settings")}
onClick={() => history.push(`/setting`)}
/>
<NavButton
data-cy="help-button"
icon={<HelpIcon />}
label={t("header_help")}
onClick={() => window.open(`/help`)}
/>
</Stack>
<ImportModal
creating={creating}
Expand Down
9 changes: 4 additions & 5 deletions src/client/src/commons/search/editor/filterComponent.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ import { FilterContext } from "../../../components/filter/filterContext.tsx";

class FilterComponent extends React.Component {
static contextType = FilterContext;

constructor(props) {
super(props);
this.handleFilterReset = this.handleFilterReset.bind(this);
Expand Down Expand Up @@ -226,7 +227,7 @@ class FilterComponent extends React.Component {
{t("polygon_selection")}
</Typography>
{filterPolygon !== null && (
<Badge data-cy="polygon-filter-badge" color="error" badgeContent={1} sx={{ marginLeft: "18px" }}></Badge>
<Badge data-cy="polygon-filter-badge" badgeContent={1} sx={{ marginLeft: "18px" }} />
)}
</Button>
{this.state?.searchList?.map((filter, idx) => {
Expand All @@ -246,10 +247,8 @@ class FilterComponent extends React.Component {
),
}));
}}>
<Typography variant="h6">
{t(filter?.translationId)}{" "}
<Badge color="error" badgeContent={activeFilterLength} sx={{ marginLeft: "12px" }}></Badge>
</Typography>
<Typography variant="h6">{t(filter?.translationId)} </Typography>
<Badge badgeContent={activeFilterLength} sx={{ marginLeft: "18px", marginTop: "10px" }} />
</AccordionSummary>
{filter?.name === "workgroup" && filter?.isSelected && (
<this.StyledAccordionDetails>
Expand Down
51 changes: 51 additions & 0 deletions src/client/src/components/buttons/navButton.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
import { forwardRef, useState } from "react";
import { ButtonProps } from "./buttonsInterface";
import { IconButton, Stack, Typography } from "@mui/material";
import { theme } from "../../AppTheme";

export interface NavButtonProps extends ButtonProps {
label: string;
icon: JSX.Element;
selected?: boolean;
}

export const NavButton = forwardRef<HTMLButtonElement, NavButtonProps>((props, ref) => {
const [isHovered, setIsHovered] = useState(false);

const handleMouseEnter = () => setIsHovered(true);
const handleMouseLeave = () => setIsHovered(false);

const defaultContent = props.icon;
const hoverContent = (
<>
{props.icon} <Typography>{props.label}</Typography>
</>
);
return (
<IconButton
ref={ref}
{...props}
onMouseEnter={handleMouseEnter}
onMouseLeave={handleMouseLeave}
sx={{
marginBottom: "25px",
padding: "10px 16px",
color: props.selected ? theme.palette.primary.contrastText : theme.palette.neutral.contrastText,
backgroundColor: props.selected ? theme.palette.background.menuItemActive + " !important" : undefined,
borderRadius: "10px",
width: "fit-content",
transition: "background-color 0.3s ease, color 0.3s ease, width 0.3s ease",
"&:hover": {
backgroundColor: `${theme.palette.secondary.main} !important`,
color: `${theme.palette.secondary.contrastText} !important`,
width: "fit-content",
whiteSpace: "nowrap",
zIndex: 6000,
},
}}>
<Stack direction="row" justifyContent={"space-between"} spacing={1} sx={{ margin: 0 }}>
{isHovered ? hoverContent : defaultContent}
</Stack>
</IconButton>
);
});
Loading