Skip to content

Commit b494e37

Browse files
fix: header styles
1 parent c39db24 commit b494e37

File tree

6 files changed

+40
-18
lines changed

6 files changed

+40
-18
lines changed

src/components/PopoverDropdown.tsx

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import type { PropsWithChildren, ReactNode } from "react";
44
import { containerElAtom } from "../atoms";
55
import { useAtomValue } from "jotai";
66
import { Flex } from "@radix-ui/themes";
7+
import { maxZIndex } from "../consts";
78

89
interface PopoverDropdownProps {
910
content: ReactNode;
@@ -28,6 +29,9 @@ export default function PopoverDropdown({
2829
<Popover.Portal container={containerEl}>
2930
<Popover.Content
3031
className={styles.popoverContent}
32+
style={{
33+
zIndex: maxZIndex,
34+
}}
3135
sideOffset={5}
3236
tabIndex={undefined}
3337
>

src/consts.ts

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,17 +11,19 @@ export const defaultMaxComputeUnits = 50_000_000;
1111
export const clusterIndicatorHeight = 5;
1212

1313
export const headerHeight = 48;
14-
export const headerBottomSpacing = 17;
1514
export const headerSpacing = 13;
1615
export const navToggleHeight = 21;
1716
export const largeNavToggleHeight = 28;
1817
export const slotsNavSpacing = 5;
19-
export const epochThumbPadding = slotsNavSpacing;
2018

2119
export const logoWidth = 21;
2220
export const logoRightSpacing = 8;
21+
export const epochThumbPadding = logoRightSpacing;
22+
2323
export const slotsListWidth = 122;
24-
export const slotNavWidth = logoWidth + logoRightSpacing + slotsListWidth;
24+
export const slotNavWithoutListWidth = logoWidth + logoRightSpacing;
25+
export const slotNavWidth =
26+
slotNavWithoutListWidth + slotsListWidth + slotsNavSpacing;
2527

2628
export const narrowNavMedia = "(max-width: 768px)";
2729

src/features/Header/Nav.tsx

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ import { useAtomValue } from "jotai";
1616
import type { RouteLabel } from "../../hooks/useCurrentRoute";
1717
import { RouteLabelToPath, useCurrentRoute } from "../../hooks/useCurrentRoute";
1818
import useNavigateLeaderSlot from "../../hooks/useNavigateLeaderSlot";
19-
import { slotsNavSpacing } from "../../consts";
19+
import { maxZIndex, slotsNavSpacing } from "../../consts";
2020
import { clusterAtom } from "../../api/atoms";
2121
import { getClusterColor } from "../../utils";
2222
import { navButtonTextColor } from "../../colors";
@@ -126,7 +126,12 @@ export function DropdownNav() {
126126
</DropdownMenu.Trigger>
127127

128128
<DropdownMenu.Portal container={containerEl}>
129-
<DropdownMenu.Content className={styles.navDropdownContent}>
129+
<DropdownMenu.Content
130+
side="bottom"
131+
sideOffset={5}
132+
className={styles.navDropdownContent}
133+
style={{ zIndex: maxZIndex }}
134+
>
130135
{Object.keys(RouteLabelToPath).map((label) => {
131136
const routeLabel = label as RouteLabel;
132137
if (routeLabel === currentRoute) return;

src/features/Header/index.tsx

Lines changed: 19 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,11 @@ import { DropdownNav, NavHandler, NavLinks } from "./Nav";
44
import { useMedia } from "react-use";
55
import {
66
epochThumbPadding,
7-
headerBottomSpacing,
87
headerHeight,
98
headerSpacing,
109
logoRightSpacing,
1110
maxZIndex,
11+
slotNavWithoutListWidth,
1212
slotsNavSpacing,
1313
} from "../../consts";
1414
import Logo from "./Logo";
@@ -18,13 +18,28 @@ import { isNavCollapsedAtom } from "../../atoms";
1818
import { useAtomValue } from "jotai";
1919
import NavBlur from "../Navigation/NavBlur";
2020
import { slotNavBackgroundColor } from "../../colors";
21+
import { useCurrentRoute } from "../../hooks/useCurrentRoute";
22+
import { useMemo } from "react";
2123

2224
export default function Header() {
2325
const showDropdownNav = useMedia("(max-width: 900px)");
2426
const isXNarrow = useMedia("(max-width: 401px)");
2527
const isNarrow = useMedia("(max-width: 768px)");
2628
const isNavCollapsed = useAtomValue(isNavCollapsedAtom);
2729

30+
const currentRoute = useCurrentRoute();
31+
const isSchedule = currentRoute === "Schedule";
32+
33+
const leftBackground = useMemo(() => {
34+
if (isNavCollapsed) return undefined;
35+
if (isSchedule) {
36+
// only color the epoch bar portion
37+
const width = `${slotNavWithoutListWidth + epochThumbPadding}px`;
38+
return `linear-gradient(to right, ${slotNavBackgroundColor} 0px ${width}, transparent ${width} 100%)`;
39+
}
40+
return slotNavBackgroundColor;
41+
}, [isNavCollapsed, isSchedule]);
42+
2843
const useExtraNarrowGap = isNavCollapsed && isXNarrow;
2944
const extraNarrowGap = "3px";
3045

@@ -47,13 +62,11 @@ export default function Header() {
4762
gapX={useExtraNarrowGap ? extraNarrowGap : `${logoRightSpacing}px`}
4863
// slots nav background color boundary
4964
pr={useExtraNarrowGap ? extraNarrowGap : `${slotsNavSpacing}px`}
50-
pb={`${headerBottomSpacing}`}
5165
style={{
52-
marginLeft: -slotsNavSpacing,
53-
backgroundColor: isNavCollapsed
54-
? undefined
55-
: slotNavBackgroundColor,
66+
background: leftBackground,
5667
}}
68+
// align with epoch bar thumb overflow padding
69+
ml={`${-epochThumbPadding}px`}
5770
pl={`${epochThumbPadding}px`}
5871
>
5972
{isNarrow && isNavCollapsed && (
@@ -78,7 +91,6 @@ export default function Header() {
7891
: // blur color boundary
7992
`${headerSpacing - slotsNavSpacing}px`
8093
}
81-
pb={`${headerBottomSpacing}`}
8294
>
8395
<NavHandler />
8496
{showDropdownNav ? <DropdownNav /> : <NavLinks />}

src/features/Header/nav.module.css

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,6 @@
3434
flex-direction: column;
3535
background-color: #1c2129;
3636
border: 1px solid rgba(250, 250, 250, 0.08);
37-
border-bottom-left-radius: 5px;
38-
border-bottom-right-radius: 5px;
37+
border-radius: 5px;
38+
min-width: var(--radix-dropdown-menu-trigger-width);
3939
}

src/features/Navigation/index.tsx

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@ import {
1414
maxZIndex,
1515
slotsListWidth,
1616
epochThumbPadding,
17+
slotNavWidth,
18+
slotNavWithoutListWidth,
1719
} from "../../consts";
1820
import { StatusIndicator } from "./Status";
1921
import AutoSizer from "react-virtualized-auto-sizer";
@@ -43,10 +45,7 @@ export default function Navigation() {
4345

4446
const currentRoute = useCurrentRoute();
4547
const width = useMemo(() => {
46-
const noListWidth = logoWidth + logoRightSpacing;
47-
return currentRoute === "Schedule"
48-
? noListWidth
49-
: noListWidth + slotsListWidth + slotsNavSpacing;
48+
return currentRoute === "Schedule" ? slotNavWithoutListWidth : slotNavWidth;
5049
}, [currentRoute]);
5150

5251
return (

0 commit comments

Comments
 (0)