Skip to content

Commit

Permalink
Add onClick prop to VuiTopicButton.
Browse files Browse the repository at this point in the history
  • Loading branch information
cjcenizal committed Nov 10, 2023
1 parent b690086 commit 5a8aa24
Showing 1 changed file with 22 additions and 5 deletions.
27 changes: 22 additions & 5 deletions src/lib/components/topicButton/TopicButton.tsx
Original file line number Diff line number Diff line change
@@ -1,17 +1,20 @@
import classNames from "classnames";
import { VuiSpacer } from "../spacer/Spacer";
import { VuiTextColor } from "../typography/TextColor";
import { VuiTitle } from "../typography/Title";

type Props = {
children?: React.ReactNode;
className?: string;
href: string;
href?: string;
onClick: () => void;
title?: string;
};

export const VuiTopicButton = ({ children, className, href, title, ...rest }: Props) => {
return (
<a className="vuiTopicButton" href={href} {...rest}>
export const VuiTopicButton = ({ children, className, href, onClick, title, ...rest }: Props) => {
const classes = classNames("vuiTopicButton", className);
const content = (
<>
{title && (
<>
<VuiTitle size="s">
Expand All @@ -25,6 +28,20 @@ export const VuiTopicButton = ({ children, className, href, title, ...rest }: Pr
)}

{children}
</a>
</>
);

if (href) {
return (
<a className={classes} href={href} onClick={onClick} {...rest}>
{content}
</a>
);
}

return (
<button className={classes} onClick={onClick} {...rest}>
{content}
</button>
);
};

0 comments on commit 5a8aa24

Please sign in to comment.