Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
… into feature/bump-ant
  • Loading branch information
interim17 committed Nov 1, 2024
2 parents fe7126a + 696f7bd commit b77d699
Show file tree
Hide file tree
Showing 11 changed files with 169 additions and 102 deletions.
40 changes: 40 additions & 0 deletions src/components/CustomDropdown/index.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
import React, { ReactNode } from "react";
import { Dropdown, DropDownProps, MenuProps } from "antd";
import { ButtonClass } from "../../constants/interfaces";
import NavButton from "../NavButton";

import styles from "./style.css";

interface CustomDropdownProps {
items: MenuProps["items"];
titleText: string;
icon: ReactNode;
buttonType: ButtonClass;
placement?: DropDownProps["placement"];
disabled?: boolean;
}

const CustomDropdown: React.FC<CustomDropdownProps> = ({
items,
titleText,
icon,
buttonType,
placement,
disabled,
}) => {
return (
<Dropdown
menu={{ items, theme: "dark", className: styles.menu }}
placement={placement}
disabled={disabled}
>
<NavButton
titleText={titleText}
icon={icon}
buttonType={buttonType}
/>
</Dropdown>
);
};

export default CustomDropdown;
44 changes: 44 additions & 0 deletions src/components/CustomDropdown/style.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
.menu {
width: fit-content;
background-color: var(--dark-theme-dropdown-menu-bg);
border-radius: 3px;
padding: 8px;
}

.menu svg {
fill: var(--dark-theme-menu-text-color);
}

.menu :global(.ant-dropdown-menu-item),
.menu :global(.ant-dropdown-menu-submenu) {
border: 2px solid var(--dark-theme-dropdown-menu-item-bg);
border-radius: 4px;
height: 32px;
}

.menu :global(.ant-dropdown-menu-item) :global(.ant-btn) {
color: var(--dark-theme-dropdown-menu-item-color);
padding: 0px;
}

.menu :global(.ant-dropdown-menu-item):hover,
.menu :global(.ant-dropdown-menu-submenu):hover {
background-color: var(--dark-theme-dropdown-menu-item-hover-bg);
}

.menu :global(.ant-dropdown-menu-item):hover *,
.menu :global(.ant-dropdown-menu-submenu):hover * {
color: var(--dark-theme-dropdown-menu-item-hover-color);
fill: var(--dark-theme-dropdown-menu-item-hover-color);
}

.menu :global(.ant-dropdown-menu-item):focus-within,
.menu :global(.ant-dropdown-menu-submenu):focus-within {
z-index: 1000;
background-color: var(--dark-theme-dropdown-menu-item-focus-bg);
outline: 1px solid var(--dark-theme-dropdown-menu-item-focus-outline);
}

.menu :global(.ant-dropdown-menu-item) *:focus-visible {
color: var(--dark-theme-dropdown-menu-item-focus-color);
}
29 changes: 13 additions & 16 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 { Dropdown, MenuProps } from "antd";
import { MenuProps } from "antd";

import { TUTORIAL_PATHNAME } from "../../routes";
import {
Expand All @@ -13,8 +13,7 @@ import { ButtonClass } from "../../constants/interfaces";
import { DownArrow } from "../Icons";
import VersionModal from "../VersionModal";
import NavButton from "../NavButton";

import styles from "./style.css";
import CustomDropdown from "../CustomDropdown";

const HelpMenu = (): JSX.Element => {
const [modalVisible, setModalVisible] = React.useState(false);
Expand Down Expand Up @@ -57,7 +56,6 @@ const HelpMenu = (): JSX.Element => {
{
key: "submit-issue",
label: "Submit issue",
popupClassName: styles.submenu,
popupOffset: [-0.45, -4],
children: [
{
Expand Down Expand Up @@ -89,26 +87,25 @@ const HelpMenu = (): JSX.Element => {
{
key: "version",
label: (
<a
onClick={() => {
<NavButton
titleText={"Version info"}
clickHandler={() => {
setModalVisible(!modalVisible);
}}
>
Version info
</a>
buttonType={ButtonClass.DropdownItem}
/>
),
},
];

return (
<>
<Dropdown menu={{ items, theme: "dark", className: styles.menu }}>
<NavButton
titleText={"Help "}
icon={DownArrow}
buttonType={ButtonClass.Secondary}
/>
</Dropdown>
<CustomDropdown
items={items}
titleText={"Help"}
icon={DownArrow}
buttonType={ButtonClass.Secondary}
/>
{modalVisible && <VersionModal setModalVisible={setModalVisible} />}
</>
);
Expand Down
19 changes: 0 additions & 19 deletions src/components/HelpMenu/style.css

This file was deleted.

29 changes: 13 additions & 16 deletions src/components/LoadFileMenu/index.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import React, { useState } from "react";
import { Link, useLocation, useHistory } from "react-router-dom";
import { ActionCreator } from "redux";
import { Dropdown, Button, MenuProps } from "antd";
import { MenuProps } from "antd";

import TRAJECTORIES from "../../constants/networked-trajectories";
import { URL_PARAM_KEY_FILE_NAME } from "../../constants";
Expand All @@ -21,8 +21,7 @@ import { VIEWER_PATHNAME } from "../../routes";
import { DownArrow } from "../Icons";
import FileUploadModal from "../FileUploadModal";
import NavButton from "../NavButton";

import styles from "./style.css";
import CustomDropdown from "../CustomDropdown";

interface LoadFileMenuProps {
isBuffering: boolean;
Expand Down Expand Up @@ -73,7 +72,6 @@ const LoadFileMenu = ({
{
key: "from-examples",
label: "Example models",
popupClassName: styles.submenu,
popupOffset: [-0.45, -4],
children: TRAJECTORIES.map((trajectory) => ({
key: trajectory.id,
Expand All @@ -94,8 +92,11 @@ const LoadFileMenu = ({
{
key: "file-upload",
label: (
// to do ant5: "ghost" type depecrecated and removed, update styling
<Button onClick={showModal}>Simularium file</Button>
<NavButton
titleText={"Simularium file"}
clickHandler={showModal}
buttonType={ButtonClass.DropdownItem}
/>
),
},
{
Expand All @@ -116,18 +117,14 @@ const LoadFileMenu = ({

return (
<>
<Dropdown
menu={{ items, theme: "dark", className: styles.menu }}
<CustomDropdown
items={items}
titleText={"Load model"}
icon={DownArrow}
buttonType={ButtonClass.Primary}
placement="bottomRight"
disabled={isDisabled}
>
<NavButton
titleText={"Load model"}
icon={DownArrow}
buttonType={ButtonClass.Primary}
isDisabled={isDisabled}
/>
</Dropdown>
/>
{/*
Conditionally rendering the modal this way instead of as a `visible` prop
forces it to re-render every time it is opened, resetting the form inside.
Expand Down
37 changes: 0 additions & 37 deletions src/components/LoadFileMenu/style.css

This file was deleted.

37 changes: 30 additions & 7 deletions src/components/NavButton/style.css
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,18 @@
background-color: var(--dark-theme-action-button-bg);
border: none;
color: var(--dark-theme-action-button-color);
padding: 0px;
padding: 4px 8px;
}

.nav-button.action-button:global(.ant-btn:hover),
.nav-button.action-button:global(.ant-btn:focus) {
.nav-button.action-button:global(.ant-btn:hover) {
color: var(--dark-theme-action-button-hover-color);
}

.nav-button.action-button:global(.ant-btn:focus-visible) {
color: var(--dark-theme-action-button-focus-color);
outline: 1px solid var(--dark-theme-primary-button-focus-outline);
}

.nav-button.action-button:global(.ant-btn).disabled {
color: var(--dark-theme-action-button-disabled-color);
cursor: not-allowed;
Expand All @@ -26,13 +30,20 @@
color: var(--dark-theme-primary-button-color);
}

.nav-button.primary-button:global(.ant-btn:hover),
.nav-button.primary-button:global(.ant-btn:focus) {
.nav-button.primary-button:global(.ant-btn:hover) {
color: var(--dark-theme-primary-button-hover-color);
background-color: var(--dark-theme-primary-button-hover-bg);
border-color: var(--dark-theme-primary-button-hover-border);
}

.nav-button.primary-button:global(.ant-btn:focus-visible) {
color: var(--dark-theme-primary-button-focus-color);
background-color: var(--dark-theme-primary-button-focus-bg);
border-color: var(--dark-theme-primary-button-focus-border);
outline: 1px solid var(--dark-theme-primary-button-focus-outline);
outline-offset: 2px;
}

.nav-button.primary-button:global(.ant-btn).disabled {
color: var(--dark-theme-primary-button-disabled-color);
background-color: var(--dark-theme-primary-button-disabled-bg);
Expand All @@ -47,16 +58,28 @@
color: var(--dark-theme-secondary-button-color);
}

.nav-button.secondary-button:global(.ant-btn:hover),
.nav-button.secondary-button:global(.ant-btn:focus) {
.nav-button.secondary-button:global(.ant-btn:hover) {
color: var(--dark-theme-secondary-button-hover-color);
background-color: var(--dark-theme-secondary-button-hover-bg);
border-color: var(--dark-theme-secondary-button-hover-border);
}

.nav-button.secondary-button:global(.ant-btn:focus-visible) {
color: var(--dark-theme-secondary-button-focus-color);
background-color: var(--dark-theme-secondary-button-focus-bg);
border-color: var(--dark-theme-secondary-button-focus-border);
outline: 1px solid var(--dark-theme-secondary-button-focus-outline);
outline-offset: 2px;
}

.nav-button.secondary-button:global(.ant-btn).disabled {
color: var(--dark-theme-secondary-button-disabled-color);
background-color: var(--dark-theme-secondary-button-disabled-bg);
border-color: var(--dark-theme-secondary-button-disabled-border);
cursor: not-allowed;
}

.nav-button.dropdown-item-button:global(.ant-btn) {
background-color: inherit;
border: inherit;
}
1 change: 1 addition & 0 deletions src/constants/interfaces.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ export enum ButtonClass {
Primary = "primary-button",
Secondary = "secondary-button",
Action = "action-button",
DropdownItem = "dropdown-item-button",
}

export enum IconGlyphs {
Expand Down
9 changes: 9 additions & 0 deletions src/containers/AppHeader/style.css
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,15 @@
margin-right: 2em;
}

.left-links img {
padding: 6px;
border-radius: 6px;
}

.left-links a:focus-visible img {
outline: 1px solid var(--dark-theme-primary-button-focus-outline);
}

.home {
margin-left: 2px;
margin-right: 20px;
Expand Down
7 changes: 0 additions & 7 deletions src/styles/ant-vars.less
Original file line number Diff line number Diff line change
Expand Up @@ -73,13 +73,6 @@ https://github.com/ant-design/ant-design/blob/master/components/style/themes/def
@layout-trigger-background-light: #fff;
@layout-trigger-color-light : @text-color;

//Dropdown
@dropdown-menu-bg: @dark-four;
@dropdown-vertical-padding: 5px;
@dropdown-edge-child-vertical-padding: 4px;
@dropdown-font-size: @font-size-base;
@dropdown-line-height: 22px;

// Buttons
@btn-font-weight : 400;
@btn-border-radius-base : 3px;
Expand Down
Loading

0 comments on commit b77d699

Please sign in to comment.