Skip to content

Commit

Permalink
fix: hovering long dashboard names stretch NavBar
Browse files Browse the repository at this point in the history
  • Loading branch information
Kiryous committed Oct 28, 2024
1 parent f69ad34 commit 13e74f1
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 23 deletions.
51 changes: 30 additions & 21 deletions keep-ui/components/navbar/DashboardLink.tsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { useSortable } from '@dnd-kit/sortable';
import { useSortable } from "@dnd-kit/sortable";
import { Subtitle } from "@tremor/react";
import { FiLayout } from "react-icons/fi";
import { LinkWithIcon } from "components/LinkWithIcon"; // Ensure you import this correctly
import classNames from 'classnames';
import { clsx } from "clsx";

interface Dashboard {
id: string;
Expand All @@ -14,31 +14,40 @@ type DashboardLinkProps = {
dashboard: Dashboard;
pathname: string | null;
deleteDashboard: (id: string) => void;
titleClassName?: string;
};

export const DashboardLink = ({ dashboard, pathname, deleteDashboard }: DashboardLinkProps) => {
export const DashboardLink = ({
dashboard,
pathname,
deleteDashboard,
titleClassName,
}: DashboardLinkProps) => {
const href = `/dashboard/${dashboard.dashboard_name}`;
const isActive = decodeURIComponent(pathname|| "") === href;

const { isDragging } =
useSortable({
id: dashboard.id,
});
const isActive = decodeURIComponent(pathname || "") === href;

const { isDragging } = useSortable({
id: dashboard.id,
});

return (
<LinkWithIcon
href={href}
icon={FiLayout}
isDeletable={true}
onDelete={() => deleteDashboard(dashboard.id)}
>
<Subtitle className={classNames({
"text-orange-400": isActive,
"pointer-events-none cursor-auto": isDragging,
})}>
{dashboard.dashboard_name}
</Subtitle>
</LinkWithIcon>
href={href}
icon={FiLayout}
isDeletable={true}
onDelete={() => deleteDashboard(dashboard.id)}
>
<Subtitle
className={clsx(
{
"text-orange-400": isActive,
"pointer-events-none cursor-auto": isDragging,
},
titleClassName
)}
>
{dashboard.dashboard_name}
</Subtitle>
</LinkWithIcon>
);
};
5 changes: 3 additions & 2 deletions keep-ui/components/navbar/DashboardLinks.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import { DashboardLink } from "./DashboardLink";
import { Subtitle, Button, Badge, Text } from "@tremor/react";
import { Disclosure } from "@headlessui/react";
import { IoChevronUp } from "react-icons/io5";
import classNames from "classnames";
import clsx from "clsx";
import { useDashboards } from "utils/hooks/useDashboards";
import { useApiUrl } from "utils/hooks/useConfig";

Expand Down Expand Up @@ -105,7 +105,7 @@ export const DashboardLinks = ({ session }: DashboardProps) => {
Beta
</Badge>
<IoChevronUp
className={classNames(
className={clsx(
{ "rotate-180": open },
"mr-2 text-slate-400"
)}
Expand All @@ -132,6 +132,7 @@ export const DashboardLinks = ({ session }: DashboardProps) => {
dashboard={dashboard}
pathname={pathname}
deleteDashboard={deleteDashboard}
titleClassName="max-w-[150px] overflow-hidden overflow-ellipsis"
/>
))
) : (
Expand Down

0 comments on commit 13e74f1

Please sign in to comment.