From c3cde71e60ae22d17c1d162f678f592915ac5398 Mon Sep 17 00:00:00 2001 From: Armand Philippot Date: Thu, 19 Oct 2023 19:30:54 +0200 Subject: refactor(components): rewrite NavLink component * handle style variants to avoid declaring the styles in consumers --- src/components/molecules/nav/nav-link/nav-link.tsx | 34 ++++++++++++++++++---- 1 file changed, 28 insertions(+), 6 deletions(-) (limited to 'src/components/molecules/nav/nav-link/nav-link.tsx') 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 & { /** - * 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 ( - + {logo ? {logo} : null} {label} -- cgit v1.2.3