aboutsummaryrefslogtreecommitdiffstats
path: root/src/components/molecules/nav/nav-link/nav-link.tsx
diff options
context:
space:
mode:
Diffstat (limited to 'src/components/molecules/nav/nav-link/nav-link.tsx')
-rw-r--r--src/components/molecules/nav/nav-link/nav-link.tsx44
1 files changed, 44 insertions, 0 deletions
diff --git a/src/components/molecules/nav/nav-link/nav-link.tsx b/src/components/molecules/nav/nav-link/nav-link.tsx
new file mode 100644
index 0000000..f9fc529
--- /dev/null
+++ b/src/components/molecules/nav/nav-link/nav-link.tsx
@@ -0,0 +1,44 @@
+import {
+ type ForwardRefRenderFunction,
+ forwardRef,
+ type ReactNode,
+} from 'react';
+import { Link, type LinkProps } from '../../../atoms';
+import styles from './nav-link.module.scss';
+
+export type NavLinkProps = Omit<LinkProps, 'children' | 'disableTransition'> & {
+ /**
+ * Should the logo and label be inlined?
+ *
+ * @default false
+ */
+ isInline?: boolean;
+ /**
+ * The link label.
+ */
+ label: string;
+ /**
+ * The link logo.
+ */
+ logo?: ReactNode;
+};
+
+const NavLinkWithRef: ForwardRefRenderFunction<
+ HTMLAnchorElement,
+ NavLinkProps
+> = ({ className = '', isInline = false, label, logo, ...props }, ref) => {
+ const linkClass = [
+ styles.link,
+ styles[isInline ? 'link--inline' : 'link--stack'],
+ className,
+ ].join(' ');
+
+ return (
+ <Link {...props} className={linkClass} disableTransition ref={ref}>
+ {logo ? <span className={styles.logo}>{logo}</span> : null}
+ {label}
+ </Link>
+ );
+};
+
+export const NavLink = forwardRef(NavLinkWithRef);