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

Added tooltip position and action workflow for deployment #15

Open
wants to merge 4 commits into
base: main
Choose a base branch
from
Open
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
29 changes: 29 additions & 0 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
name: CI
on:
push:
branches: [ master, dewanshrawat15-patch* ]
pull_request:
branches: [ master ]

jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Checkout 🛎️
uses: actions/checkout@v2.3.1
with:
persist-credentials: false

- name: Install and Build 🔧
run: |
npm install
npm run build
npm run demo:prod

- name: Deploy 🚀
uses: JamesIves/github-pages-deploy-action@3.6.2
with:
GITHUB_TOKEN: ${{ secrets.Devfolio_Token }}
BRANCH: gh-pages
FOLDER: dist
CLEAN: true
4 changes: 2 additions & 2 deletions src/demo/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ const App = () => (
style={{ display: "flex", alignItems: "center", flexDirection: "column" }}
>
<h1 style={{ marginBottom: "50px" }}>Copy email address to clipboard</h1>
<CopyMailTo email="email@domain.com" />
<CopyMailTo email="email@domain.com" pos="below" />
</div>
);

ReactDOM.render(<App />, document.getElementById("app"));
ReactDOM.render(<App />, document.getElementById("app"));
20 changes: 11 additions & 9 deletions src/lib/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@ const containerBaseStyles: React.CSSProperties = {
position: "relative",
};

const tooltipBaseStyles: React.CSSProperties = {
bottom: "26px",
const tooltipBaseStyles = (pos: string): React.CSSProperties => ({
[pos === "above" ? "bottom" : "top"]: "26px",
maxWidth: "fit-content",
position: "absolute",
width: "auto",
Expand All @@ -41,10 +41,10 @@ const tooltipBaseStyles: React.CSSProperties = {
padding: "6px 8px",
borderRadius: "5px",
opacity: 0,
transform: "translateY(-5px)",
transform: `translateY(${pos === "above" ? "-5px": "5px"})`,
visibility: "hidden",
transition: "all 0.2s ease-in-out",
};
});

const toolTipVisibleStyles: React.CSSProperties = {
opacity: 1,
Expand All @@ -60,6 +60,7 @@ const CopyMailTo = ({
containerStyles = {},
tooltipStyles = {},
anchorStyles = {},
pos = "above",
}: {
email: string;
children?: React.ReactNode;
Expand All @@ -68,6 +69,7 @@ const CopyMailTo = ({
containerStyles?: React.CSSProperties;
tooltipStyles?: React.CSSProperties;
anchorStyles?: React.CSSProperties;
pos?: string;
}): JSX.Element => {
const [showCopied, setShowCopied] = React.useState(false);
const [showTooltip, setShowTooltip] = React.useState(false);
Expand Down Expand Up @@ -101,10 +103,10 @@ const CopyMailTo = ({
};

const allTooltipStyles = {
...tooltipBaseStyles,
...tooltipStyles,
...(showTooltip && toolTipVisibleStyles),
};
...tooltipBaseStyles(pos),
...tooltipStyles,
...(showTooltip && toolTipVisibleStyles),
};

return (
<span style={allContainerStyles}>
Expand All @@ -127,4 +129,4 @@ const CopyMailTo = ({
);
};

export default CopyMailTo;
export default CopyMailTo;