Skip to content

Commit 091d220

Browse files
committed
Added tooltip to bottom feature.
Fixes #7
1 parent 42e390e commit 091d220

File tree

2 files changed

+7
-4
lines changed

2 files changed

+7
-4
lines changed

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,7 @@ You can customize almost every aspect of this component using the below props, o
5858
| containerStyles | style object | none | The styles to be applied to the container. |
5959
| tooltipStyles | style object | none | The styles to be applied to the tooltip. |
6060
| anchorStyles | style object | none | The styles to be applied to the anchor. |
61+
| showTooltipAtBottom | boolean | false | This is use to position tooltip to bottom. |
6162

6263
## Development
6364

src/lib/index.tsx

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,8 @@ const containerBaseStyles: React.CSSProperties = {
2727
position: "relative",
2828
};
2929

30-
const tooltipBaseStyles = (theme: string): React.CSSProperties => ({
31-
bottom: "26px",
30+
const tooltipBaseStyles = (theme: string, showTooltipAtBottom: boolean): React.CSSProperties => ({
31+
[ showTooltipAtBottom ? "top": "bottom" ]: "26px",
3232
maxWidth: "fit-content",
3333
position: "absolute",
3434
width: "auto",
@@ -43,7 +43,7 @@ const tooltipBaseStyles = (theme: string): React.CSSProperties => ({
4343
padding: "6px 8px",
4444
borderRadius: "5px",
4545
opacity: 0,
46-
transform: "translateY(-5px)",
46+
transform: `translateY(${showTooltipAtBottom ? "": "-"}5px)`,
4747
visibility: "hidden",
4848
transition: "all 0.2s ease-in-out",
4949
});
@@ -63,6 +63,7 @@ const CopyMailTo = ({
6363
containerStyles = {},
6464
tooltipStyles = {},
6565
anchorStyles = {},
66+
showTooltipAtBottom = false,
6667
}: {
6768
email: string;
6869
theme?: theme;
@@ -72,6 +73,7 @@ const CopyMailTo = ({
7273
containerStyles?: React.CSSProperties;
7374
tooltipStyles?: React.CSSProperties;
7475
anchorStyles?: React.CSSProperties;
76+
showTooltipAtBottom?: boolean;
7577
}): JSX.Element => {
7678
const [showCopied, setShowCopied] = React.useState(false);
7779
const [showTooltip, setShowTooltip] = React.useState(false);
@@ -103,7 +105,7 @@ const CopyMailTo = ({
103105
};
104106

105107
const allTooltipStyles = {
106-
...tooltipBaseStyles(theme),
108+
...tooltipBaseStyles(theme, showTooltipAtBottom),
107109
...tooltipStyles,
108110
...(showTooltip && toolTipVisibleStyles)
109111
};

0 commit comments

Comments
 (0)