From ff8cc9ef72751a84314db8b8ede6a74ee2853eb3 Mon Sep 17 00:00:00 2001
From: Wesley B <62723358+wesleyboar@users.noreply.github.com>
Date: Tue, 3 Dec 2024 16:16:15 -0600
Subject: [PATCH 1/9] refactor: WP-791 dropdown button menu
- remove most of the redundant code
- use Dropdown not ButtonDropdown
- fix layout of menu and button in DataFilesSidebar
- clean up our .dropdown-menu styles
- use variables for arrow and border
---
.../DataFilesBreadcrumbs.scss | 16 -----
.../DataFilesSidebar/DataFilesSidebar.jsx | 10 ++--
.../DataFilesSidebar.module.scss | 2 +-
.../DataFilesSidebar/DataFilesSidebar.scss | 58 ++++---------------
.../src/styles/components/dropdown-menu.css | 37 ++++++------
5 files changed, 34 insertions(+), 89 deletions(-)
diff --git a/client/src/components/DataFiles/DataFilesBreadcrumbs/DataFilesBreadcrumbs.scss b/client/src/components/DataFiles/DataFilesBreadcrumbs/DataFilesBreadcrumbs.scss
index e06f9db5c..21683effe 100644
--- a/client/src/components/DataFiles/DataFilesBreadcrumbs/DataFilesBreadcrumbs.scss
+++ b/client/src/components/DataFiles/DataFilesBreadcrumbs/DataFilesBreadcrumbs.scss
@@ -42,32 +42,16 @@
padding-left: var(--horizontal-buffer);
}
-/* Nested to prevent styles from affecting CMS header dropdown */
/* HACK: Using ID to increase specificity (until source of problem is fixed) */
/* HELP: Why does DataFilesSidebar not need such specificity? */
/* .go-to-button-dropdown { */
#go-to-button-dropdown {
- /* To fix menu not showing */
- /* HELP: Why does DataFilesSidebar not need this fix? */
- .dropdown-menu {
- opacity: 1 !important;
- pointer-events: auto !important;
- }
- /* To restyle */
.dropdown-menu {
margin-top: 38px;
}
.dropdown-menu::before,
.dropdown-menu::after {
left: 23px;
- margin-left: 0;
- }
- .dropdown-menu::after {
- top: -9px;
- }
-
- .dropdown-item {
- display: inline-block;
}
}
diff --git a/client/src/components/DataFiles/DataFilesSidebar/DataFilesSidebar.jsx b/client/src/components/DataFiles/DataFilesSidebar/DataFilesSidebar.jsx
index e4976bb7b..d898b126e 100644
--- a/client/src/components/DataFiles/DataFilesSidebar/DataFilesSidebar.jsx
+++ b/client/src/components/DataFiles/DataFilesSidebar/DataFilesSidebar.jsx
@@ -5,7 +5,7 @@ import {
Nav,
NavItem,
NavLink,
- ButtonDropdown,
+ Dropdown,
DropdownMenu,
DropdownToggle,
DropdownItem,
@@ -67,8 +67,8 @@ const DataFilesAddButton = ({ readOnly }) => {
const writeItemStyle = disabled ? 'read-only' : '';
return (
-
-
+ <>
+
{
-
-
+
+ >
);
};
diff --git a/client/src/components/DataFiles/DataFilesSidebar/DataFilesSidebar.module.scss b/client/src/components/DataFiles/DataFilesSidebar/DataFilesSidebar.module.scss
index b6ca1a642..bf7514796 100644
--- a/client/src/components/DataFiles/DataFilesSidebar/DataFilesSidebar.module.scss
+++ b/client/src/components/DataFiles/DataFilesSidebar/DataFilesSidebar.module.scss
@@ -13,5 +13,5 @@
.add-button-item {
padding-bottom: 20px;
- padding-left: 20px;
+ padding-inline: var(--global-space--section-left);
}
diff --git a/client/src/components/DataFiles/DataFilesSidebar/DataFilesSidebar.scss b/client/src/components/DataFiles/DataFilesSidebar/DataFilesSidebar.scss
index b2c09a31a..30e022c08 100644
--- a/client/src/components/DataFiles/DataFilesSidebar/DataFilesSidebar.scss
+++ b/client/src/components/DataFiles/DataFilesSidebar/DataFilesSidebar.scss
@@ -10,65 +10,27 @@
border-radius: 0;
}
-#add-button-wrapper {
- padding-left: var(--horizontal-buffer);
-}
#data-files-add {
- width: 174px;
+ width: 100%;
}
.data-files-nav {
padding-top: 20px;
}
-/* Nested to prevent styles from affecting CMS header dropdown */
.data-files-sidebar {
.dropdown-menu {
- border-color: var(--global-color-accent--normal);
- border-radius: 0;
- margin: 11px 3px 0;
- width: 200px;
- vertical-align: top;
- }
- .dropdown-menu::before {
- position: absolute;
- top: -10px;
- left: 67px;
- border-right: 10px solid transparent;
- border-bottom: 10px solid var(--global-color-accent--normal);
- border-left: 10px solid transparent;
- margin-left: 20px;
- content: '';
+ /* To make menu wider than button yet still centered */
+ width: calc(
+ 100% + var(--global-space--section-left)
+ );
+ left: calc(
+ var(--global-space--section-left) / -2
+ ) !important; /* to override `inset` from Popper via Reactstrap */
}
+ .dropdown-menu::before,
.dropdown-menu::after {
- top: -9px;
- left: 68px;
- border-right: 9px solid transparent;
- border-bottom: 9px solid #ffffff;
- border-left: 9px solid transparent;
- margin-left: 20px;
- content: '';
- }
-
- .dropdown-item {
- padding: 10px 6px;
- color: var(--global-color-primary--x-dark);
- font-size: 14px;
- i {
- padding-right: 19px;
- font-size: 20px;
- vertical-align: middle;
- }
- &:hover {
- color: var(--global-color-primary--x-dark);
- }
- }
- .dropdown-item:focus,
- .dropdown-item:hover {
- /* FAQ: Before FP-1083, value was #E6E0FB, which matched Design
- and was `--global-color-accent` at 25% opacity on white…
- which is what `--global-color-accent--weak` is now */
- background-color: var(--global-color-accent--weak);
+ left: calc(50% - var(--arrow-size));
}
}
diff --git a/client/src/styles/components/dropdown-menu.css b/client/src/styles/components/dropdown-menu.css
index 3a8cb8040..86a77d582 100644
--- a/client/src/styles/components/dropdown-menu.css
+++ b/client/src/styles/components/dropdown-menu.css
@@ -6,32 +6,34 @@ A menu of navigation elements.
Styleguide Components.Dropdown
*/
-/* Nested to prevent styles from affecting CMS header dropdown */
-.workbench-wrapper {
+.workbench-wrapper /* nested so CMS header dropdown is unaffected */ {
.dropdown-menu {
- border-color: var(--global-color-accent--normal);
- border-radius: 0;
- margin-top: 11px;
- padding: 0;
- min-width: 200px;
- width: auto;
- vertical-align: top;
+ --border-width: 1px;
+ --border-color: var(--global-color-accent--normal);
+ --arrow-size: 10px;
+
+ margin-top: var(--arrow-size); /* to make space for arrow */
+
+ padding-block: unset; /* to undo Bootstrap */
+ border-radius: unset; /* to undo Bootstrap */
+
+ border: var(--border-width) solid var(--border-color);
}
.dropdown-menu::before,
.dropdown-menu::after {
position: absolute;
- left: 65px;
- border-right: 10px solid transparent;
- border-bottom: 10px solid var(--global-color-accent--normal);
- border-left: 10px solid transparent;
- margin-left: 20px;
+
+ border-right: var(--arrow-size) solid transparent;
+ border-bottom: var(--arrow-size) solid var(--global-color-accent--normal);
+ border-left: var(--arrow-size) solid transparent;
+
content: '';
}
.dropdown-menu::before {
- top: -10px;
+ top: calc( var(--arrow-size) * -1 );
}
.dropdown-menu::after {
- top: -9px;
+ top: calc(( var(--arrow-size) - var(--border-width)) * -1 );
border-bottom-color: var(--global-color-primary--xx-light);
}
@@ -50,9 +52,6 @@ Styleguide Components.Dropdown
}
.dropdown-item:focus,
.dropdown-item:hover {
- /* FAQ: Before FP-1083, value was #E6E0FB, which matched Design
- and was `--global-color-accent` at 25% opacity on white…
- which is what `--global-color-accent--weak` is now */
background-color: var(--global-color-accent--weak);
}
}
From bb73411cb9817ea4e89fdce6efc09b1effde86de Mon Sep 17 00:00:00 2001
From: Wesley B <62723358+wesleyboar@users.noreply.github.com>
Date: Tue, 3 Dec 2024 17:08:22 -0600
Subject: [PATCH 2/9] =?UTF-8?q?refactor:=20WP-791=20DataFilesBread?=
=?UTF-8?q?=E2=80=A6=20dropdown=20menu?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
`….scss`:
- use class not ID
- position via `top` not `margin-top`
- explain menu position's "magic" value
- explain why positioning is necessary[^1]
`….jsx`:
- use class not ID
use Dropdown not ButtonDropdown[^2]
[^1]: Not desired, but necessary if we use our custom