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