1
0
mirror of https://github.com/lensapp/lens.git synced 2025-05-20 05:10:56 +00:00

Adding generic MaterialTooltip component

Signed-off-by: Alex Andreev <alex.andreev.email@gmail.com>
This commit is contained in:
Alex Andreev 2021-05-06 11:49:30 +03:00
parent e25f7fc655
commit ca83695ca6
2 changed files with 31 additions and 15 deletions

View File

@ -0,0 +1,28 @@
import React from "react";
import { makeStyles, Tooltip, TooltipProps } from "@material-ui/core";
const useStyles = makeStyles(() => ({
arrow: {
color: "#18191c",
},
tooltip: {
fontSize: 12,
backgroundColor: "#18191c",
color: "#fff",
padding: 8,
boxShadow: "0 8px 16px rgba(0,0,0,0.24)"
},
}));
export function MaterialTooltip(props: TooltipProps) {
const classes = useStyles();
return (
<Tooltip classes={classes} {...props}/>
);
}
MaterialTooltip.defaultProps = {
arrow: true
};

View File

@ -2,43 +2,31 @@ import "./hotbar-selector.scss";
import React from "react";
import { Icon } from "../icon";
import { Badge } from "../badge";
import { makeStyles, Tooltip } from "@material-ui/core";
import { Hotbar, HotbarStore } from "../../../common/hotbar-store";
import { CommandOverlay } from "../command-palette";
import { HotbarSwitchCommand } from "./hotbar-switch-command";
import { MaterialTooltip } from "../+catalog/material-tooltip/material-tooltip";
interface Props {
hotbar: Hotbar;
}
const useStyles = makeStyles(() => ({
arrow: {
color: "#222",
},
tooltip: {
fontSize: 12,
backgroundColor: "#222",
},
}));
export function HotbarSelector({ hotbar }: Props) {
const store = HotbarStore.getInstance();
const activeIndexDisplay = store.activeHotbarIndex + 1;
const classes = useStyles();
return (
<div className="HotbarSelector flex align-center">
<Icon material="play_arrow" className="previous box" onClick={() => store.switchToPrevious()} />
<div className="box grow flex align-center">
<Tooltip arrow title={hotbar.name} classes={classes}>
<MaterialTooltip arrow title={hotbar.name}>
<Badge
id="hotbarIndex"
small
label={activeIndexDisplay}
onClick={() => CommandOverlay.open(<HotbarSwitchCommand />)}
/>
</Tooltip>
</MaterialTooltip>
</div>
<Icon material="play_arrow" className="next box" onClick={() => store.switchToNext()} />
</div>