Skip to content
17 changes: 17 additions & 0 deletions examples/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -309,6 +309,23 @@ const app = (
<p></p>
</HtmlTooltip>
<br></br>
<br></br>
<br></br>
<HtmlTooltip
placement={"top-start"}
open={true}
title={
<BaseTooltipTitle
tooltip={{
name: "Tooltip With Big Status",
icon: icons.betaStatus,
}}
/>
}
>
<p></p>
</HtmlTooltip>
<br></br>
<Box sx={{ width: "300px" }}>
<Card title={"Example Card"}>
<Typography>This is a basic card.</Typography>
Expand Down
23 changes: 17 additions & 6 deletions src/BaseTooltipTitle.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,21 +6,21 @@ import {
ThemeProvider,
StyledEngineProvider,
} from "@mui/material";

import makeStyles from "@mui/styles/makeStyles";

import SVG from "react-inlinesvg";
import { theme, darkGrey } from "./theme";
import type { Tooltip } from "./tooltips";

type Props = {
tooltip: Omit<Tooltip, "icon">;
tooltip: Tooltip;
};

const useStyles = makeStyles({
mainbox: {
display: "flex",
alignItems: "center",
justifyItems: "space-between",
height: "35px",
"& > div:first-child": {
// Tooltip text
marginLeft: "8px",
Expand Down Expand Up @@ -49,6 +49,7 @@ const useStyles = makeStyles({
lineHeight: "9px !important",
fontWeight: 500,
},
tooltipIcon: { width: "auto", height: "24px" },
});

export const BaseTooltipTitle = ({ tooltip }: Props): ReactElement => {
Expand All @@ -67,7 +68,6 @@ export const BaseTooltipTitle = ({ tooltip }: Props): ReactElement => {
{tooltip.shortcutSymbol.toUpperCase()}
</Typography>
</Avatar>

<Avatar>
<Typography
className={
Expand All @@ -89,9 +89,20 @@ export const BaseTooltipTitle = ({ tooltip }: Props): ReactElement => {
<ThemeProvider theme={theme}>
<Box className={classes.mainbox}>
<Box>
<Typography>{tooltip.name}</Typography>
<Typography
sx={{
whiteSpace: "nowrap",
overflow: "hidden",
textOverflow: "ellipsis",
}}
>
{tooltip.name}
</Typography>
</Box>
{!tooltip.shortcut ? null : hasShortcutSymbol}
{tooltip.shortcut && hasShortcutSymbol}
{tooltip?.icon && (
<SVG src={tooltip?.icon} className={classes.tooltipIcon} />
)}
</Box>
</ThemeProvider>
</StyledEngineProvider>
Expand Down
8 changes: 7 additions & 1 deletion src/Card.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ interface Props extends CardProps {
warningDialog?: boolean;
isPinned?: boolean | null;
handlePin?: () => void;
backgroundColor?: string;
}

const CardIconButton = styled(IconButton)({
Expand All @@ -42,6 +43,7 @@ export function Card(props: Props): JSX.Element {
<MaterialCard
sx={{
borderRadius: "6px",
backgroundColor: props.backgroundColor,
}}
>
<Paper
Expand Down Expand Up @@ -97,7 +99,10 @@ export function Card(props: Props): JSX.Element {

<Paper
elevation={0}
sx={{ p: props.noPadding ? null : "12px 16px 14px" }}
sx={{
p: props.noPadding ? null : "12px 16px 14px",
backgroundColor: "transparent",
}}
>
{props.children}
</Paper>
Expand All @@ -111,4 +116,5 @@ Card.defaultProps = {
warningDialog: null,
isPinned: null,
handlePin: null,
backgroundColor: "#FFFFFF",
};
30 changes: 17 additions & 13 deletions src/Dialog.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ interface Props {
warningDialog?: boolean;
close?: boolean;
afterClose?: () => void;
backgroundColor?: string;
}

export function Dialog({
Expand All @@ -18,6 +19,7 @@ export function Dialog({
close,
warningDialog,
afterClose,
backgroundColor,
}: Props): ReactElement | null {
const [open, setOpen] = useState<boolean>(false);

Expand All @@ -40,17 +42,6 @@ export function Dialog({
}
}, [close]);

const dialogContent = (
<Card
title={title}
handleClose={handleClose}
closeButton
warningDialog={warningDialog}
>
{children}
</Card>
);

return (
<>
{cloneElement(TriggerButton, {
Expand All @@ -60,8 +51,20 @@ export function Dialog({
if (onClick) onClick();
},
})}
<MaterialDialog open={open} onClose={handleClose}>
{dialogContent}
<MaterialDialog
sx={{ "& div": { maxWidth: "unset" } }}
open={open}
onClose={handleClose}
>
<Card
title={title}
handleClose={handleClose}
closeButton
warningDialog={warningDialog}
backgroundColor={backgroundColor}
>
{children}
</Card>
</MaterialDialog>
</>
);
Expand All @@ -72,4 +75,5 @@ Dialog.defaultProps = {
close: null,
afterClose: null,
warningDialog: null,
backgroundColor: "inherit",
};
2 changes: 2 additions & 0 deletions src/IconButton.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ export interface Tooltip {
name: string;
shortcut?: string;
shortcutSymbol?: string;
icon?: string;
}

export interface Props extends ButtonProps {
Expand Down Expand Up @@ -84,6 +85,7 @@ export const IconButton = (props: Props): ReactElement => {
>
<span>
<Button
sx={{ minWidth: "unset" }}
disabled={disabled}
ref={(ref) => {
if (!ref || !setRefCallback) return;
Expand Down
2 changes: 1 addition & 1 deletion src/interface.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
export interface Tooltip {
name: string;
icon: string;
icon?: string;
shortcut?: string;
shortcutSymbol?: string;
}