diff --git a/frontend/src/metabase/components/Link.tsx b/frontend/src/metabase/components/Link.tsx index dc968bb55c0da2da77157c6fde3a85906069ee68..7fa9625c114a9e7f8cb078cf0990e6a99394e9a9 100644 --- a/frontend/src/metabase/components/Link.tsx +++ b/frontend/src/metabase/components/Link.tsx @@ -6,7 +6,7 @@ import { color, display, hover, space } from "styled-system"; import Tooltip from "metabase/components/Tooltip"; import { stripLayoutProps } from "metabase/lib/utils"; -interface Props extends HTMLProps<HTMLAnchorElement> { +export interface LinkProps extends HTMLProps<HTMLAnchorElement> { to: string; disabled?: boolean; className?: string; @@ -24,7 +24,7 @@ function BaseLink({ disabled, tooltip, ...props -}: Props) { +}: LinkProps) { const link = ( <ReactRouterLink to={to} diff --git a/frontend/src/metabase/css/admin.css b/frontend/src/metabase/css/admin.css index 27e4977a45fe8bf7fa45e12140ce5c9b5b8bb1f2..eaa724c3dc7713baaf7aaf2d2477024735d7d480 100644 --- a/frontend/src/metabase/css/admin.css +++ b/frontend/src/metabase/css/admin.css @@ -6,47 +6,12 @@ --page-header-padding: 2.375rem; } -.AdminNav { - background: var(--color-admin-navbar); - color: var(--color-text-white); - font-size: 0.85rem; -} - -.AdminNav .NavItem { - color: color-mod(var(--color-text-white) alpha(-37%)); -} - -.AdminNav .NavItem:hover, -.AdminNav .NavItem.is--selected { - color: var(--color-text-white); -} - -/* TODO: this feels itchy. should refactor .NavItem.is--selected to be less cascadey */ -.AdminNav .NavItem:hover:after, -.AdminNav .NavItem.is--selected:after { - display: none; -} - -.AdminNav .NavDropdown.open .NavDropdown-button, -.AdminNav .NavDropdown .NavDropdown-content-layer { - background-color: var(--color-bg-dark); -} - -.AdminNav .Dropdown-item:hover { - background-color: var(--color-bg-dark); -} - /* utility to get a simple common hover state for admin items */ -.HoverItem:hover, -.AdminHoverItem:hover { +.HoverItem:hover { background-color: var(--color-bg-medium); transition: background 0.2s linear; } -.AdminNav .Dropdown-chevron { - color: var(--color-text-white); -} - .Actions-group { margin-bottom: 2em; } diff --git a/frontend/src/metabase/nav/components/AdminNavbar/AdminNavItem.styled.tsx b/frontend/src/metabase/nav/components/AdminNavbar/AdminNavItem.styled.tsx new file mode 100644 index 0000000000000000000000000000000000000000..4188f56f94571affd1f426298129ab31aa4f7a3c --- /dev/null +++ b/frontend/src/metabase/nav/components/AdminNavbar/AdminNavItem.styled.tsx @@ -0,0 +1,13 @@ +import styled from "styled-components"; +import Link, { LinkProps } from "metabase/components/Link"; +import { alpha, color } from "metabase/lib/colors"; + +interface AdminNavLinkProps extends LinkProps { + isSelected?: boolean; +} + +export const AdminNavLink = styled<AdminNavLinkProps>(Link)` + padding: 0.5rem 1rem; + text-decoration: none; + color: ${props => (props.isSelected ? color("white") : alpha("white", 0.63))}; +`; diff --git a/frontend/src/metabase/nav/components/AdminNavbar/AdminNavItem.tsx b/frontend/src/metabase/nav/components/AdminNavbar/AdminNavItem.tsx index 0fa28dc4665cfaa7e39ccb15490e9afde20a7435..c39bf531123fd398010dcb32f58f446e976fa9d0 100644 --- a/frontend/src/metabase/nav/components/AdminNavbar/AdminNavItem.tsx +++ b/frontend/src/metabase/nav/components/AdminNavbar/AdminNavItem.tsx @@ -1,6 +1,7 @@ import React from "react"; import cx from "classnames"; import Link from "metabase/components/Link"; +import { AdminNavLink } from "./AdminNavItem.styled"; interface AdminNavItem { name: string; @@ -10,14 +11,12 @@ interface AdminNavItem { export const AdminNavItem = ({ name, path, currentPath }: AdminNavItem) => ( <li> - <Link + <AdminNavLink to={path} data-metabase-event={`NavBar;${name}`} - className={cx("NavItem py1 px2 no-decoration", { - "is--selected": currentPath.startsWith(path), - })} + isSelected={currentPath.startsWith(path)} > {name} - </Link> + </AdminNavLink> </li> ); diff --git a/frontend/src/metabase/nav/components/AdminNavbar/AdminNavbar.tsx b/frontend/src/metabase/nav/components/AdminNavbar/AdminNavbar.tsx index 5603c7ee5cceb95ee2332ea5c545af04742eafce..9f59a424eca54b46ea766bbd3239bfa2f8f3a3c9 100644 --- a/frontend/src/metabase/nav/components/AdminNavbar/AdminNavbar.tsx +++ b/frontend/src/metabase/nav/components/AdminNavbar/AdminNavbar.tsx @@ -3,7 +3,6 @@ import { t } from "ttag"; import { PLUGIN_ADMIN_NAV_ITEMS } from "metabase/plugins"; import MetabaseSettings from "metabase/lib/settings"; import { AdminNavItem } from "./AdminNavItem"; -import Link from "metabase/components/Link"; import StoreLink from "../StoreLink"; import LogoIcon from "metabase/components/LogoIcon"; import {