Skip to content

Commit

Permalink
Merge pull request #24 from PelicanPlatform/revert-21-fix-param-anchor
Browse files Browse the repository at this point in the history
Revert "Fix parameter page anchors"
  • Loading branch information
haoming29 authored May 27, 2024
2 parents 2e696c9 + a009401 commit 106faaf
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 19 deletions.
16 changes: 7 additions & 9 deletions components/ParameterBox.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,12 @@ export const ParameterBox: React.FC<{ parameter: ParameterDetail }> = ({ paramet
sx={{ marginTop: ".8em" }}
onMouseEnter={() => setHover(true)}
onMouseLeave={() => setHover(false)}
onClick={async () => {
// Copy link to clipboard
const url = new URL(window.location.href);
url.hash = parameterId;
await navigator.clipboard.writeText(url.toString());
}}
>
<Paper elevation={hover ? 3 : 1} sx={{ padding: "0.7em" }}>
<Box mb={1}>
Expand All @@ -28,15 +34,7 @@ export const ParameterBox: React.FC<{ parameter: ParameterDetail }> = ({ paramet
{parameterName}
</Typography>
{hover && (
<IconButton
size={"small"}
onClick={async (e: React.MouseEvent<HTMLButtonElement>) => {
e.stopPropagation()
// Copy link to clipboard
const url = new URL(window.location.href);
url.hash = parameterId;
await navigator.clipboard.writeText(url.toString());
}}>
<IconButton size={"small"}>
<Link fontSize={"small"}/>
</IconButton>
)}
Expand Down
17 changes: 7 additions & 10 deletions components/Parameters.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,12 @@ const Parameters: React.FC<{ parameters: ParametersArray }> = ({ parameters }) =
key={group}
onMouseEnter={() => setHover(true)}
onMouseLeave={() => setHover(false)}
onClick={async () => {
// Copy link to clipboard
const url = new URL(window.location.href);
url.hash = group
await navigator.clipboard.writeText(url.toString());
}}
>
<Typography
sx={{
Expand All @@ -77,16 +83,7 @@ const Parameters: React.FC<{ parameters: ParametersArray }> = ({ parameters }) =
>
{group}
{hover && group && group !== "" && (
<IconButton
size={"small"}
onClick={async (e: React.MouseEvent<HTMLButtonElement>) => {
e.stopPropagation()
// Copy link to clipboard
const url = new URL(window.location.href);
url.hash = group
await navigator.clipboard.writeText(url.toString());
}}
>
<IconButton size={"small"}>
<Link fontSize={"small"}/>
</IconButton>
)}
Expand Down

0 comments on commit 106faaf

Please sign in to comment.