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

fix menus offsets #440

Merged
merged 3 commits into from
Oct 16, 2023
Merged
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
124 changes: 71 additions & 53 deletions src/components/HelpMenu/index.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import * as React from "react";
import { useLocation, Link } from "react-router-dom";
import { Menu, Dropdown, Button } from "antd";
import { Dropdown, Button, MenuProps } from "antd";

import { TUTORIAL_PATHNAME } from "../../routes";
import { DownArrow } from "../Icons";
Expand All @@ -16,6 +16,8 @@ import styles from "./style.css";
import VersionModal from "../VersionModal";

const HelpMenu = (): JSX.Element => {
const [modalVisible, setModalVisible] = React.useState(false);

const location = useLocation();
const tutorialLink =
location.pathname === "/viewer" ? (
Expand All @@ -30,66 +32,82 @@ const HelpMenu = (): JSX.Element => {
<Link to={TUTORIAL_PATHNAME}>Quick start</Link>
);

const [modalVisible, setModalVisible] = React.useState(false);

const menu = (
<Menu theme="dark" className={styles.menu}>
{modalVisible && (
<VersionModal setModalVisible={setModalVisible} />
)}
<Menu.Item key="tutorial">{tutorialLink}</Menu.Item>
<Menu.Item key="forum">
const items: MenuProps["items"] = [
{
key: "tutorial",
label: tutorialLink,
},
{
key: "forum",
label: (
<a href={FORUM_URL} target="_blank" rel="noopener noreferrer">
Forum
</a>
</Menu.Item>
<Menu.Item key="github">
),
},
{
key: "github",
label: (
<a href={GITHUB_URL} target="_blank" rel="noopener noreferrer">
GitHub
</a>
</Menu.Item>
<Menu.SubMenu
title="Submit issue"
popupClassName={styles.submenu}
popupOffset={[-0.45, -4]}
key="submit-issue"
>
<Menu.Item key="submit-issue-github">
<a
href={ISSUE_URL}
target="_blank"
rel="noopener noreferrer"
>
via GitHub (preferred)
</a>
</Menu.Item>
<Menu.Item key="web-form">
<a
href={FORUM_BUG_REPORT_URL}
target="_blank"
rel="noopener noreferrer"
>
via Forum (for non-GitHub users)
</a>
</Menu.Item>
</Menu.SubMenu>
<Menu.Item
key="version"
onClick={() => {
setModalVisible(!modalVisible);
}}
>
<>Version info</>
</Menu.Item>
</Menu>
);
),
},
{
key: "submit-issue",
label: "Submit issue",
popupClassName: styles.submenu,
popupOffset: [-0.45, -4],
children: [
{
key: "via-github",
label: (
<a
href={ISSUE_URL}
target="_blank"
rel="noopener noreferrer"
>
via GitHub (preferred)
</a>
),
},
{
key: "via-forum",
label: (
<a
href={FORUM_BUG_REPORT_URL}
target="_blank"
rel="noopener noreferrer"
>
via Forum (for non-GitHub users)
</a>
),
},
],
},
{
key: "version",
label: (
<a
onClick={() => {
setModalVisible(!modalVisible);
}}
>
Version info
</a>
),
},
];

return (
<Dropdown overlay={menu} placement="bottomRight">
<Button onClick={(e) => e.preventDefault()} type="ghost">
Help {DownArrow}
</Button>
</Dropdown>
<>
<Dropdown menu={{ items, theme: "dark", className: styles.menu }}>
<Button onClick={(e) => e.preventDefault()} type="ghost">
Help {DownArrow}
</Button>
</Dropdown>
{modalVisible && <VersionModal setModalVisible={setModalVisible} />}
</>
);
};

Expand Down
2 changes: 0 additions & 2 deletions src/components/HelpMenu/style.css
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,6 @@
box-shadow: 0 1px 3px black;
padding: 0;
width: fit-content;
right: 160px !important;
left: auto !important;
}

.menu :global(.ant-dropdown-menu-item-active){
Expand Down
2 changes: 0 additions & 2 deletions src/components/LoadFileMenu/style.css
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,4 @@
box-shadow: 0 1px 3px black;
padding: 0;
width: fit-content;
right: 300px !important;
left: auto !important;
}