aboutsummaryrefslogtreecommitdiffstats
path: root/src/components/molecules/nav/nav-link/nav-link.tsx
diff options
context:
space:
mode:
authorArmand Philippot <git@armandphilippot.com>2023-10-19 19:30:54 +0200
committerArmand Philippot <git@armandphilippot.com>2023-11-11 18:14:41 +0100
commitc3cde71e60ae22d17c1d162f678f592915ac5398 (patch)
tree770856e0876b8c613a21fa79199d6d40609d73e6 /src/components/molecules/nav/nav-link/nav-link.tsx
parent94448fa278ab352a741ff13f22d6104869571144 (diff)
refactor(components): rewrite NavLink component
* handle style variants to avoid declaring the styles in consumers
Diffstat (limited to 'src/components/molecules/nav/nav-link/nav-link.tsx')
-rw-r--r--src/components/molecules/nav/nav-link/nav-link.tsx34
1 files changed, 28 insertions, 6 deletions
diff --git a/src/components/molecules/nav/nav-link/nav-link.tsx b/src/components/molecules/nav/nav-link/nav-link.tsx
index f9fc529..c2b0f5f 100644
--- a/src/components/molecules/nav/nav-link/nav-link.tsx
+++ b/src/components/molecules/nav/nav-link/nav-link.tsx
@@ -8,33 +8,55 @@ import styles from './nav-link.module.scss';
export type NavLinkProps = Omit<LinkProps, 'children' | 'disableTransition'> & {
/**
- * Should the logo and label be inlined?
+ * Should the logo be above the label?
*
* @default false
*/
- isInline?: boolean;
+ isStack?: boolean;
/**
* The link label.
*/
- label: string;
+ label: ReactNode;
/**
* The link logo.
*/
logo?: ReactNode;
+ /**
+ * The link variant.
+ *
+ * @default 'regular'
+ */
+ variant?: 'block' | 'main' | 'regular';
};
const NavLinkWithRef: ForwardRefRenderFunction<
HTMLAnchorElement,
NavLinkProps
-> = ({ className = '', isInline = false, label, logo, ...props }, ref) => {
+> = (
+ {
+ className = '',
+ isStack = false,
+ label,
+ logo,
+ variant = 'regular',
+ ...props
+ },
+ ref
+) => {
const linkClass = [
styles.link,
- styles[isInline ? 'link--inline' : 'link--stack'],
+ styles[`link--${variant}`],
+ styles[isStack ? 'link--stack' : 'link--inline'],
className,
].join(' ');
return (
- <Link {...props} className={linkClass} disableTransition ref={ref}>
+ <Link
+ {...props}
+ className={linkClass}
+ disableTransition={variant === 'main'}
+ ref={ref}
+ >
{logo ? <span className={styles.logo}>{logo}</span> : null}
{label}
</Link>