Skip to content

Commit

Permalink
feat(nav-item): href optional
Browse files Browse the repository at this point in the history
  • Loading branch information
k-tada committed Sep 6, 2024
1 parent bf9aa89 commit 356ac28
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ type Props<T extends ElementType> = BaseProps & {
onTogglePopupLocking?: (lock: boolean) => void;
} & (
| {
href: string;
href?: string;
as?: never;
asProps?: never;
}
Expand Down Expand Up @@ -89,8 +89,8 @@ const NavigationItem = <T extends ElementType>({
onTogglePopup,
...props
}: Props<T>) => {
const isAnchor = "href" in props;
const LinkComponent = isAnchor ? "a" : props.as;
const isAnchor = "href" in props && props.as === undefined;
const LinkComponent = props.as || "a";
const isExternalLink = !!props?.href?.startsWith("http");
const linkProps = isAnchor
? {
Expand All @@ -101,7 +101,7 @@ const NavigationItem = <T extends ElementType>({
...props.asProps,
style: {
cursor: disabled ? "not-allowed" : "pointer",
...props.asProps.style,
...props.asProps?.style,
},
};
const popupAnchor = useRef<HTMLDivElement>(null);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,3 +69,12 @@ export const WithToolTip: Story = {
</div>
),
};

export const WithoutHref: Story = {
...Template,
args: {
icon: WizIDashboard,
label: "Home",
active: false,
},
};

0 comments on commit 356ac28

Please sign in to comment.