Skip to content

Commit

Permalink
Detect system color theme and add active state to nav button (apache#…
Browse files Browse the repository at this point in the history
…43041)

* Detect system color theme and add active state to nav button

* Clean up navbutton props
  • Loading branch information
bbovenzi authored and Lorin committed Oct 17, 2024
1 parent d8c1edc commit ae5985e
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 10 deletions.
13 changes: 11 additions & 2 deletions airflow/ui/src/layouts/Nav/Nav.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,12 @@ export const Nav = () => {
>
<Icon as={AirflowPin} height="35px" width="35px" />
</Box>
<NavButton icon={<FiHome size="1.75rem" />} isDisabled title="Home" />
<NavButton
icon={<FiHome size="1.75rem" />}
isDisabled
title="Home"
to="/"
/>
<NavButton
icon={<DagIcon height={7} width={7} />}
title="DAGs"
Expand All @@ -78,29 +83,33 @@ export const Nav = () => {
icon={<FiDatabase size="1.75rem" />}
isDisabled
title="Assets"
to="assets"
/>
<NavButton
icon={<FiBarChart2 size="1.75rem" />}
isDisabled
title="DAG Runs"
to="dag_runs"
/>
<NavButton
icon={<FiGlobe size="1.75rem" />}
isDisabled
title="Browse"
to="browse"
/>
<NavButton
icon={<FiSettings size="1.75rem" />}
isDisabled
title="Admin"
to="admin"
/>
</Flex>
<Flex flexDir="column">
<NavButton
as={Link}
href={import.meta.env.VITE_LEGACY_API_URL}
icon={<FiCornerUpLeft size="1.5rem" />}
title="Return to legacy UI"
to={import.meta.env.VITE_LEGACY_API_URL}
/>
<DocsButton />
<UserSettingsButton />
Expand Down
18 changes: 10 additions & 8 deletions airflow/ui/src/layouts/Nav/NavButton.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,21 +18,23 @@
*/
import { Box, Button, type ButtonProps } from "@chakra-ui/react";
import type { ReactElement } from "react";
import { Link as RouterLink } from "react-router-dom";
import { NavLink } from "react-router-dom";

import { navButtonProps } from "./navButtonProps";

type NavButtonProps = {
readonly href?: string;
readonly icon: ReactElement;
readonly target?: string;
readonly title?: string;
readonly to?: string;
readonly to: string;
} & ButtonProps;

export const NavButton = ({ icon, title, to, ...rest }: NavButtonProps) => (
<Button as={RouterLink} to={to} {...navButtonProps} {...rest}>
<Box alignSelf="center">{icon}</Box>
<Box fontSize="xs">{title}</Box>
</Button>
<Box as={NavLink} to={to}>
{({ isActive }: { readonly isActive: boolean }) => (
<Button isActive={isActive} {...navButtonProps} {...rest}>
<Box alignSelf="center">{icon}</Box>
<Box fontSize="xs">{title}</Box>
</Button>
)}
</Box>
);
1 change: 1 addition & 0 deletions airflow/ui/src/theme.ts
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ const theme = extendTheme({
},
},
config: {
initialColorMode: "system",
useSystemColorMode: true,
},
semanticTokens: {
Expand Down

0 comments on commit ae5985e

Please sign in to comment.