22
33import { forwardRef , useState } from 'react'
44import { ArrowRight , ChevronRight , Loader2 } from 'lucide-react'
5- import { Button , type ButtonProps as EmcnButtonProps } from '@/components/emcn'
65import { cn } from '@/lib/core/utils/cn'
7- import { useBrandedButtonClass } from '@/hooks/use-branded-button-class '
6+ import { useBrandConfig } from '@/ee/whitelabeling '
87
9- export interface BrandedButtonProps extends Omit < EmcnButtonProps , 'variant' | 'size' > {
10- /** Shows loading spinner and disables button */
8+ export interface BrandedButtonProps extends React . ButtonHTMLAttributes < HTMLButtonElement > {
119 loading ?: boolean
12- /** Text to show when loading (appends "..." automatically) */
1310 loadingText ?: string
14- /** Show arrow animation on hover (default: true) */
1511 showArrow ?: boolean
16- /** Make button full width (default: true) */
1712 fullWidth ?: boolean
1813}
1914
2015/**
2116 * Branded button for auth and status pages.
22- * Automatically detects whitelabel customization and applies appropriate styling.
23- *
24- * @example
25- * ```tsx
26- * // Primary branded button with arrow
27- * <BrandedButton onClick={handleSubmit}>Sign In</BrandedButton>
28- *
29- * // Loading state
30- * <BrandedButton loading loadingText="Signing in">Sign In</BrandedButton>
31- *
32- * // Without arrow animation
33- * <BrandedButton showArrow={false}>Continue</BrandedButton>
34- * ```
17+ * Default: white button matching the landing page "Get started" style.
18+ * Whitelabel: uses the brand's primary color as background with white text.
3519 */
3620export const BrandedButton = forwardRef < HTMLButtonElement , BrandedButtonProps > (
3721 (
@@ -49,7 +33,8 @@ export const BrandedButton = forwardRef<HTMLButtonElement, BrandedButtonProps>(
4933 } ,
5034 ref
5135 ) => {
52- const buttonClass = useBrandedButtonClass ( )
36+ const brand = useBrandConfig ( )
37+ const hasCustomColor = brand . isWhitelabeled && Boolean ( brand . theme ?. primaryColor )
5338 const [ isHovered , setIsHovered ] = useState ( false )
5439
5540 const handleMouseEnter = ( e : React . MouseEvent < HTMLButtonElement > ) => {
@@ -63,15 +48,32 @@ export const BrandedButton = forwardRef<HTMLButtonElement, BrandedButtonProps>(
6348 }
6449
6550 return (
66- < Button
51+ < button
6752 ref = { ref }
68- variant = 'branded'
69- size = 'branded'
53+ { ...props }
7054 disabled = { disabled || loading }
7155 onMouseEnter = { handleMouseEnter }
7256 onMouseLeave = { handleMouseLeave }
73- className = { cn ( buttonClass , 'group' , fullWidth && 'w-full' , className ) }
74- { ...props }
57+ className = { cn (
58+ 'group inline-flex h-[30px] items-center justify-center gap-[7px] rounded-[5px] border px-[9px] text-[13.5px] transition-colors disabled:cursor-not-allowed disabled:opacity-50' ,
59+ ! hasCustomColor &&
60+ 'border-[#FFFFFF] bg-[#FFFFFF] text-black hover:border-[#E0E0E0] hover:bg-[#E0E0E0]' ,
61+ fullWidth && 'w-full' ,
62+ className
63+ ) }
64+ style = {
65+ hasCustomColor
66+ ? {
67+ backgroundColor : isHovered
68+ ? ( brand . theme ?. primaryHoverColor ?? brand . theme ?. primaryColor )
69+ : brand . theme ?. primaryColor ,
70+ borderColor : isHovered
71+ ? ( brand . theme ?. primaryHoverColor ?? brand . theme ?. primaryColor )
72+ : brand . theme ?. primaryColor ,
73+ color : '#FFFFFF' ,
74+ }
75+ : undefined
76+ }
7577 >
7678 { loading ? (
7779 < span className = 'flex items-center gap-2' >
@@ -92,7 +94,7 @@ export const BrandedButton = forwardRef<HTMLButtonElement, BrandedButtonProps>(
9294 ) : (
9395 children
9496 ) }
95- </ Button >
97+ </ button >
9698 )
9799 }
98100)
0 commit comments