Skip to content

Commit 6951304

Browse files
authored
Allow appSideNavLink iconAfter to be positioned at the end (right) (#326)
Allow appSideNavLink to be positioned at the end
1 parent 00b2d68 commit 6951304

File tree

3 files changed

+36
-6
lines changed

3 files changed

+36
-6
lines changed

src/docs/pages/app/Layout.tsx

Lines changed: 25 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,16 @@
11
import { useState } from "react";
2-
import { BiBook, BiCreditCard, BiData, BiKey, BiLineChart, BiLogOut, BiRightArrowAlt, BiUser } from "react-icons/bi";
2+
import {
3+
BiBook,
4+
BiCreditCard,
5+
BiData,
6+
BiError,
7+
BiHeart,
8+
BiKey,
9+
BiLineChart,
10+
BiLogOut,
11+
BiRightArrowAlt,
12+
BiUser
13+
} from "react-icons/bi";
314
import {
415
VuiAppSideNav,
516
VuiAppSideNavLink,
@@ -63,9 +74,9 @@ const AccountButton = () => {
6374

6475
export const Layout = ({ children }: { children: React.ReactNode }) => {
6576
const [isOpen, setIsOpen] = useState(false);
66-
const [activeItem, setActiveItem] = useState<"corpora" | "apiKeys" | "team" | "usage" | "billing" | "docs">(
67-
"corpora"
68-
);
77+
const [activeItem, setActiveItem] = useState<
78+
"corpora" | "apiKeys" | "team" | "usage" | "billing" | "health" | "docs"
79+
>("corpora");
6980

7081
const navContent = (
7182
<>
@@ -109,6 +120,16 @@ export const Layout = ({ children }: { children: React.ReactNode }) => {
109120
isSelected={activeItem === "billing"}
110121
/>
111122

123+
<VuiAppSideNavLink
124+
name="Health"
125+
iconBefore={<BiHeart />}
126+
data-testid="navHealth"
127+
iconAfterAlignEnd
128+
iconAfter={<BiError />}
129+
onClick={() => setActiveItem("health")}
130+
isSelected={activeItem === "health"}
131+
/>
132+
112133
<VuiPopover
113134
anchorSide="rightUp"
114135
isOpen={isOpen}

src/lib/components/app/appSideNav/AppSideNavLink.tsx

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,11 @@ import { forwardRef } from "react";
88

99
type Props = Pick<TreeItem, "name" | "path" | "iconBefore" | "iconAfter" | "isSelected" | "className"> & {
1010
onClick?: React.MouseEventHandler<HTMLAnchorElement>;
11+
iconAfterAlignEnd?: boolean;
1112
};
1213

1314
export const VuiAppSideNavLink = forwardRef<HTMLAnchorElement | null, Props>(
14-
({ path, onClick, name, iconBefore, iconAfter, isSelected, className, ...rest }: Props, ref) => {
15+
({ path, onClick, name, iconBefore, iconAfter, isSelected, className, iconAfterAlignEnd, ...rest }: Props, ref) => {
1516
const { createLink, getPath } = useVuiContext();
1617

1718
const classes = classNames(
@@ -36,7 +37,11 @@ export const VuiAppSideNavLink = forwardRef<HTMLAnchorElement | null, Props>(
3637
</VuiFlexItem>
3738

3839
{iconAfter && (
39-
<VuiFlexItem grow={false} shrink={false}>
40+
<VuiFlexItem
41+
grow={false}
42+
shrink={false}
43+
className={iconAfterAlignEnd ? "vuiAppSideNavLink__iconAfter--alignEnd" : undefined}
44+
>
4045
<VuiIcon size="s">{iconAfter}</VuiIcon>
4146
</VuiFlexItem>
4247
)}

src/lib/components/app/appSideNav/appSideNav.scss

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,10 @@
7474
background-color: var(--vui-color-light-shade);
7575
}
7676

77+
.vuiAppSideNavLink__iconAfter--alignEnd {
78+
margin-left: auto;
79+
}
80+
7781
.vuiAppSideNav--m {
7882
.vuiAppSideNav__inner {
7983
padding: 28px 32px 32px 33px;

0 commit comments

Comments
 (0)