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

feat(landing): misc tweaks #156

Merged
merged 3 commits into from
Nov 18, 2021
Merged
Changes from 1 commit
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
Prev Previous commit
Next Next commit
feat: improve clipboard toast
  • Loading branch information
olarclara committed Nov 18, 2021
commit 47a1f599799d67c61aa4d42b5fe11bcd13c8e460
38 changes: 15 additions & 23 deletions website/landing/components/common/Clipboard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,43 +7,33 @@ import { useCallback, useEffect, useState } from "react";
const command = content.commands.install;

const ClipboardToast = styled("div", {
$$toastHeight: "48px",
alignItems: "center",
borderRadius: "72px",
bottom: "30px",
background: "$primary",
display: "flex",
color: "$lightTextPrimary",
gap: "10px",
height: "$$toastHeight",
left: "50%",
opacity: "0",
padding: "0 16px",
padding: "15px 20px",
pointerEvents: "none",
position: "absolute",
top: 0,
transform: "translateY(100vh) translateX(-50%)",
transition: "opacity .5s ease, transform .5s ease",
zIndex: "-1",
position: "fixed",
transform: "translateX(-50%) translateY(calc(100% + 40px)) ",
transition: "transform .5s cubic-bezier(0.190, 1.000, 0.220, 1.000)",
zIndex: "1",

p: {
span: {
fontWeight: "$normal",
fontSize: "18px",
fontSize: "16px",
lineHeight: "22px",
letterSpacing: "-0.025em",
margin: 0,
},

"@bp3": {
$$toastHeight: "64px",
},

variants: {
visible: {
true: {
opacity: "1",
transform:
"translateY(calc(100vh - 2 * $$toastHeight)) translateX(-50%)",
zIndex: "10",
transform: "translateX(-50%) translateY(0) ",
},
},
},
Expand All @@ -53,14 +43,16 @@ export const Clipboard: React.FC = () => {
const [toastVisible, setToastVisible] = useState(false);

const copyToClipboard = useCallback(() => {
navigator.clipboard.writeText(command);
setToastVisible(true);
try {
navigator.clipboard.writeText(command);
setToastVisible(true);
} catch {}
olarclara marked this conversation as resolved.
Show resolved Hide resolved
}, []);

useEffect(() => {
const timeout = setTimeout(() => {
setToastVisible(false);
}, 3000);
}, 2000);

return () => clearTimeout(timeout);
}, [toastVisible]);
Expand Down Expand Up @@ -88,7 +80,7 @@ export const Clipboard: React.FC = () => {
/>
</svg>
</Box>
<p>Copied to clipboard</p>
<span>Copied to clipboard</span>
</ClipboardToast>
<Button
css={{
Expand Down