@luxfi/ui 5.5.2 → 5.6.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/accordion.cjs +213 -0
- package/dist/accordion.js +186 -0
- package/dist/alert.cjs +553 -0
- package/dist/alert.js +531 -0
- package/dist/avatar.cjs +149 -0
- package/dist/avatar.js +125 -0
- package/dist/badge.cjs +611 -0
- package/dist/badge.js +589 -0
- package/dist/button.cjs +689 -0
- package/dist/button.js +664 -0
- package/dist/checkbox.cjs +265 -0
- package/dist/checkbox.js +241 -0
- package/dist/close-button.cjs +73 -0
- package/dist/close-button.js +51 -0
- package/dist/collapsible.cjs +702 -0
- package/dist/collapsible.js +679 -0
- package/dist/color-mode.cjs +96 -0
- package/dist/color-mode.js +72 -0
- package/dist/dialog.cjs +279 -0
- package/dist/dialog.js +246 -0
- package/dist/drawer.cjs +207 -0
- package/dist/drawer.js +175 -0
- package/dist/empty-state.cjs +93 -0
- package/dist/empty-state.js +71 -0
- package/dist/field.cjs +183 -0
- package/dist/field.js +160 -0
- package/dist/heading.cjs +46 -0
- package/dist/heading.js +40 -0
- package/dist/icon-button.cjs +491 -0
- package/dist/icon-button.js +470 -0
- package/dist/image.cjs +572 -0
- package/dist/image.js +551 -0
- package/dist/index.cjs +5779 -0
- package/dist/index.js +5619 -0
- package/dist/input-group.cjs +155 -0
- package/dist/input-group.js +133 -0
- package/dist/input.cjs +65 -0
- package/dist/input.js +59 -0
- package/dist/link.cjs +630 -0
- package/dist/link.js +606 -0
- package/dist/menu.cjs +305 -0
- package/dist/menu.js +269 -0
- package/dist/pin-input.cjs +182 -0
- package/dist/pin-input.js +160 -0
- package/dist/popover.cjs +327 -0
- package/dist/popover.js +294 -0
- package/dist/progress-circle.cjs +152 -0
- package/dist/progress-circle.js +128 -0
- package/dist/progress.cjs +117 -0
- package/dist/progress.js +94 -0
- package/dist/provider.cjs +62 -0
- package/dist/provider.js +40 -0
- package/dist/radio.cjs +177 -0
- package/dist/radio.js +153 -0
- package/dist/rating.cjs +80 -0
- package/dist/rating.js +58 -0
- package/dist/select.cjs +791 -0
- package/dist/select.js +757 -0
- package/dist/separator.cjs +57 -0
- package/dist/separator.js +51 -0
- package/dist/skeleton.cjs +370 -0
- package/dist/skeleton.js +346 -0
- package/dist/slider.cjs +138 -0
- package/dist/slider.js +115 -0
- package/dist/switch.cjs +163 -0
- package/dist/switch.js +140 -0
- package/dist/table.cjs +1044 -0
- package/dist/table.js +1013 -0
- package/dist/tabs.cjs +240 -0
- package/dist/tabs.js +213 -0
- package/dist/tag.cjs +651 -0
- package/dist/tag.js +628 -0
- package/dist/textarea.cjs +65 -0
- package/dist/textarea.js +59 -0
- package/dist/toaster.cjs +99 -0
- package/dist/toaster.js +96 -0
- package/dist/tooltip.cjs +171 -0
- package/dist/tooltip.js +148 -0
- package/dist/utils.cjs +11 -0
- package/dist/utils.js +9 -0
- package/package.json +270 -66
- package/src/accordion.tsx +285 -0
- package/src/alert.tsx +221 -0
- package/src/avatar.tsx +174 -0
- package/src/badge.tsx +158 -0
- package/src/button.tsx +411 -0
- package/src/checkbox.tsx +307 -0
- package/src/close-button.tsx +51 -0
- package/src/collapsible.tsx +126 -0
- package/src/color-mode.tsx +125 -0
- package/src/dialog.tsx +356 -0
- package/src/drawer.tsx +186 -0
- package/src/empty-state.tsx +97 -0
- package/src/field.tsx +202 -0
- package/src/heading.tsx +55 -0
- package/src/icon-button.tsx +192 -0
- package/src/image.tsx +280 -0
- package/src/index.ts +192 -0
- package/src/input-group.tsx +159 -0
- package/src/input.tsx +60 -0
- package/src/link.tsx +326 -0
- package/src/menu.tsx +471 -0
- package/src/pin-input.tsx +187 -0
- package/src/popover.tsx +400 -0
- package/src/progress-circle.tsx +180 -0
- package/src/progress.tsx +109 -0
- package/src/provider.tsx +12 -0
- package/src/radio.tsx +175 -0
- package/src/rating.tsx +79 -0
- package/src/select.tsx +696 -0
- package/src/separator.tsx +59 -0
- package/src/skeleton.tsx +302 -0
- package/src/slider.tsx +152 -0
- package/src/switch.tsx +158 -0
- package/src/table.tsx +621 -0
- package/src/tabs.tsx +354 -0
- package/src/tag.tsx +159 -0
- package/src/textarea.tsx +60 -0
- package/src/toaster.tsx +117 -0
- package/src/tokens.css +438 -0
- package/src/tooltip.tsx +184 -0
- package/src/utils/cn.ts +7 -0
- package/src/utils.ts +6 -0
- package/tokens.css +438 -0
- package/commerce/ui/conf.ts +0 -13
- package/commerce/ui/context.tsx +0 -123
- package/commerce/ui/store.ts +0 -295
- package/components/access-code-input.tsx +0 -71
- package/components/analytics.tsx +0 -23
- package/components/auth/auth-listener.tsx +0 -29
- package/components/auth/auth-token/clear-auth-token.tsx +0 -12
- package/components/auth/auth-token/set-auth-token.tsx +0 -16
- package/components/auth/common-auth-domains.ts +0 -17
- package/components/auth/login-panel.tsx +0 -111
- package/components/auth/mobile-login-button.tsx +0 -107
- package/components/auth/signup-panel.tsx +0 -113
- package/components/back-button.tsx +0 -49
- package/components/chat-widget.tsx +0 -85
- package/components/commerce/bag-button.tsx +0 -98
- package/components/commerce/buy-button.tsx +0 -34
- package/components/commerce/checkout-button.tsx +0 -129
- package/components/commerce/checkout-panel/cart-accordian.tsx +0 -66
- package/components/commerce/checkout-panel/checkout-panel-props.ts +0 -10
- package/components/commerce/checkout-panel/desktop-bag-carousel.tsx +0 -36
- package/components/commerce/checkout-panel/desktop-cp.tsx +0 -83
- package/components/commerce/checkout-panel/index.tsx +0 -126
- package/components/commerce/checkout-panel/mobile-cp.tsx +0 -67
- package/components/commerce/checkout-panel/policy-links.tsx +0 -29
- package/components/commerce/checkout-panel/steps-indicator.tsx +0 -39
- package/components/commerce/checkout-panel/thank-you.tsx +0 -18
- package/components/commerce/desktop-bag-popup.tsx +0 -78
- package/components/commerce/drawer/index.tsx +0 -88
- package/components/commerce/drawer/micro.tsx +0 -145
- package/components/commerce/drawer/shell.tsx +0 -85
- package/components/contact-dialog/contact-form.tsx +0 -116
- package/components/contact-dialog/disclaimer.tsx +0 -13
- package/components/contact-dialog/index.tsx +0 -64
- package/components/copyright.tsx +0 -21
- package/components/drawer-margin.tsx +0 -28
- package/components/footer.tsx +0 -78
- package/components/header/desktop-nav-menu.tsx +0 -204
- package/components/header/desktop.tsx +0 -65
- package/components/header/index.tsx +0 -50
- package/components/header/mobile-bag-drawer.tsx +0 -51
- package/components/header/mobile-menu-toggle-button.tsx +0 -35
- package/components/header/mobile-nav-menu-ai.tsx +0 -51
- package/components/header/mobile-nav-menu-item.tsx +0 -47
- package/components/header/mobile-nav-menu.tsx +0 -102
- package/components/header/mobile.tsx +0 -170
- package/components/header/theme-toggle.tsx +0 -26
- package/components/icons/avatar.tsx +0 -11
- package/components/icons/bag-icon.tsx +0 -10
- package/components/icons/index.ts +0 -6
- package/components/icons/left-arrow.tsx +0 -11
- package/components/icons/lux-logo.tsx +0 -10
- package/components/icons/right-arrow.tsx +0 -10
- package/components/icons/social-icon.tsx +0 -35
- package/components/icons/social-svg.css +0 -3
- package/components/index.ts +0 -26
- package/components/logo.tsx +0 -92
- package/components/main.tsx +0 -27
- package/components/mini-chart/index.tsx +0 -8
- package/components/mini-chart/mini-chart-props.ts +0 -44
- package/components/mini-chart/mini-chart.tsx +0 -85
- package/components/mini-chart/wrapper.tsx +0 -23
- package/components/not-found/index.tsx +0 -28
- package/components/not-found/not-found-content.mdx +0 -5
- package/components/tooltip.tsx +0 -31
- package/environment.d.ts +0 -6
- package/next/analytics/fpixel.ts +0 -16
- package/next/analytics/google-analytics.ts +0 -14
- package/next/analytics/index.ts +0 -3
- package/next/analytics/pixel-analytics.tsx +0 -55
- package/next/font/get-app-router-font-classes.ts +0 -17
- package/next/font/load-and-return-lux-next-fonts-on-import.ts +0 -68
- package/next/font/local/Druk-Wide-Bold.ttf +0 -0
- package/next/font/local/Druk-Wide-Medium.ttf +0 -0
- package/next/font/local/InterVariable-Italic.ttf +0 -0
- package/next/font/local/InterVariable-Italic.woff2 +0 -0
- package/next/font/local/InterVariable.ttf +0 -0
- package/next/font/local/InterVariable.woff2 +0 -0
- package/next/font/next-font-desc.ts +0 -28
- package/next/font/pages-router-font-vars.tsx +0 -18
- package/next/head-metadata/from-next/metadata-types.ts +0 -158
- package/next/head-metadata/from-next/opengraph-types.ts +0 -267
- package/next/head-metadata/from-next/twitter-types.ts +0 -92
- package/next/head-metadata/index.tsx +0 -208
- package/next/index.ts +0 -2
- package/next/middleware/determine-device-mw.ts +0 -29
- package/root-layout/WHY_THIS_IS_SEPARATE.txt +0 -2
- package/root-layout/index.tsx +0 -111
- package/server/auth-wrapper.ts +0 -24
- package/server-actions/TO-DO.txt +0 -1
- package/server-actions/firebase-app.ts +0 -29
- package/server-actions/index.ts +0 -5
- package/server-actions/store-contact.ts +0 -66
- package/site-def/footer/community.tsx +0 -61
- package/site-def/footer/company.ts +0 -37
- package/site-def/footer/ecosystem.ts +0 -37
- package/site-def/footer/index.tsx +0 -26
- package/site-def/footer/legal.ts +0 -28
- package/site-def/footer/network.ts +0 -45
- package/site-def/footer/svg/warpcast-logo.svg +0 -12
- package/site-def/index.ts +0 -4
- package/site-def/main-nav.tsx +0 -460
- package/style/cart-animation.css +0 -29
- package/style/checkout-animation.css +0 -23
- package/style/drawer-handle-overrides.css +0 -160
- package/style/fonts/COPY_TO_PUBLIC_FOR_NON_NEXT.txt +0 -0
- package/style/fonts/Druk-Wide-Bold.ttf +0 -0
- package/style/fonts/Druk-Wide-Medium.ttf +0 -0
- package/style/fonts/InterVariable-Italic.ttf +0 -0
- package/style/fonts/InterVariable-Italic.woff2 +0 -0
- package/style/fonts/InterVariable.ttf +0 -0
- package/style/fonts/InterVariable.woff2 +0 -0
- package/style/lux-colors.css +0 -85
- package/style/lux-fonts.css +0 -30
- package/style/lux-global-non-next.css +0 -52
- package/style/lux-global.css +0 -51
- package/tailwind/fontFamily.tailwind.lux.ts +0 -18
- package/tailwind/index.ts +0 -2
- package/tailwind/lux-tw-fonts.ts +0 -40
- package/tailwind/tailwind.config.lux-preset.ts +0 -10
- package/tsconfig.json +0 -15
- package/types/chatbot-config.ts +0 -7
- package/types/chatbot-suggested-question.ts +0 -7
- package/types/contact-info.ts +0 -11
- package/types/index.ts +0 -4
- package/types/site-def.ts +0 -46
package/src/link.tsx
ADDED
|
@@ -0,0 +1,326 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
|
|
3
|
+
import { cn } from './utils';
|
|
4
|
+
|
|
5
|
+
// Inline external link arrow icon
|
|
6
|
+
const ArrowIcon = ({ className, style }: { readonly className?: string; readonly style?: React.CSSProperties }) => (
|
|
7
|
+
<svg className={ className } style={ style } viewBox="0 0 20 20" fill="none" xmlns="http://www.w3.org/2000/svg">
|
|
8
|
+
<path d="M11 3h6v6M17 3L7 13M14 11v6H3V6h6" stroke="currentColor" strokeWidth="1.5" strokeLinecap="round" strokeLinejoin="round"/>
|
|
9
|
+
</svg>
|
|
10
|
+
);
|
|
11
|
+
|
|
12
|
+
// Strip UTM params for privacy (standalone, no config dependency)
|
|
13
|
+
function stripUtmParams(url: string): string {
|
|
14
|
+
try {
|
|
15
|
+
const urlObj = new URL(url);
|
|
16
|
+
for (const param of [ 'utm_source', 'utm_medium', 'utm_campaign', 'utm_term', 'utm_content' ]) {
|
|
17
|
+
urlObj.searchParams.delete(param);
|
|
18
|
+
}
|
|
19
|
+
return urlObj.toString();
|
|
20
|
+
} catch {
|
|
21
|
+
return url;
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
import { Skeleton } from './skeleton';
|
|
26
|
+
|
|
27
|
+
type LinkVariant = 'primary' | 'secondary' | 'subtle' | 'underlaid' | 'menu' | 'navigation' | 'plain';
|
|
28
|
+
|
|
29
|
+
export interface LinkProps
|
|
30
|
+
extends Omit<React.AnchorHTMLAttributes<HTMLAnchorElement>, 'href'> {
|
|
31
|
+
readonly href?: string;
|
|
32
|
+
readonly loading?: boolean;
|
|
33
|
+
readonly external?: boolean;
|
|
34
|
+
readonly iconColor?: string;
|
|
35
|
+
readonly noIcon?: boolean;
|
|
36
|
+
readonly disabled?: boolean;
|
|
37
|
+
readonly variant?: LinkVariant;
|
|
38
|
+
readonly asChild?: boolean;
|
|
39
|
+
// Next.js-specific props accepted for compatibility (ignored by base <a>)
|
|
40
|
+
readonly shallow?: boolean;
|
|
41
|
+
readonly prefetch?: boolean;
|
|
42
|
+
readonly scroll?: boolean;
|
|
43
|
+
// Legacy Chakra style-prop shims
|
|
44
|
+
readonly fontWeight?: string | number;
|
|
45
|
+
readonly whiteSpace?: string;
|
|
46
|
+
readonly wordBreak?: string;
|
|
47
|
+
readonly textStyle?: string;
|
|
48
|
+
readonly ml?: number | string | Record<string, string | number>;
|
|
49
|
+
readonly mr?: number | string;
|
|
50
|
+
readonly display?: string;
|
|
51
|
+
readonly alignItems?: string;
|
|
52
|
+
readonly flexShrink?: number;
|
|
53
|
+
readonly minW?: number | string;
|
|
54
|
+
readonly justifyContent?: string;
|
|
55
|
+
readonly position?: string;
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
const VARIANT_CLASSES: Record<LinkVariant, string> = {
|
|
59
|
+
primary: cn(
|
|
60
|
+
'text-[var(--color-link-primary)]',
|
|
61
|
+
'hover:no-underline hover:text-[var(--color-link-primary-hover)]',
|
|
62
|
+
'data-[hover]:no-underline data-[hover]:text-[var(--color-link-primary-hover)]',
|
|
63
|
+
),
|
|
64
|
+
secondary: cn(
|
|
65
|
+
'text-[var(--color-link-secondary)]',
|
|
66
|
+
'hover:no-underline hover:text-[var(--color-hover)]',
|
|
67
|
+
'data-[hover]:no-underline data-[hover]:text-[var(--color-hover)]',
|
|
68
|
+
),
|
|
69
|
+
subtle: cn(
|
|
70
|
+
'text-[var(--color-link-subtle)]',
|
|
71
|
+
'hover:text-[var(--color-link-subtle-hover)] hover:underline hover:decoration-[var(--color-link-subtle-hover)]',
|
|
72
|
+
'data-[hover]:text-[var(--color-link-subtle-hover)] data-[hover]:underline data-[hover]:decoration-[var(--color-link-subtle-hover)]',
|
|
73
|
+
),
|
|
74
|
+
underlaid: cn(
|
|
75
|
+
'text-[var(--color-link-primary)] bg-[var(--color-link-underlaid-bg)]',
|
|
76
|
+
'px-2 py-1.5 rounded-md text-sm',
|
|
77
|
+
'hover:text-[var(--color-link-primary-hover)] hover:no-underline',
|
|
78
|
+
'data-[hover]:text-[var(--color-link-primary-hover)] data-[hover]:no-underline',
|
|
79
|
+
),
|
|
80
|
+
menu: cn(
|
|
81
|
+
'text-[var(--color-link-menu)]',
|
|
82
|
+
'hover:text-[var(--color-hover)] hover:no-underline',
|
|
83
|
+
'data-[hover]:text-[var(--color-hover)] data-[hover]:no-underline',
|
|
84
|
+
),
|
|
85
|
+
navigation: cn(
|
|
86
|
+
'text-[var(--color-link-nav-fg)] bg-transparent',
|
|
87
|
+
'hover:text-[var(--color-link-nav-fg-hover)] hover:no-underline',
|
|
88
|
+
'data-[hover]:text-[var(--color-link-nav-fg-hover)] data-[hover]:no-underline',
|
|
89
|
+
'data-[selected]:text-[var(--color-link-nav-fg-selected)] data-[selected]:bg-[var(--color-link-nav-bg-selected)]',
|
|
90
|
+
'data-[active]:text-[var(--color-link-nav-fg-active)]',
|
|
91
|
+
),
|
|
92
|
+
plain: cn(
|
|
93
|
+
'text-inherit',
|
|
94
|
+
'hover:no-underline',
|
|
95
|
+
'data-[hover]:no-underline',
|
|
96
|
+
),
|
|
97
|
+
};
|
|
98
|
+
|
|
99
|
+
const BASE_CLASSES = 'inline-flex items-center gap-0 cursor-pointer data-[disabled]:cursor-not-allowed';
|
|
100
|
+
|
|
101
|
+
export const LinkExternalIcon = ({ color }: { color?: string }) => (
|
|
102
|
+
<ArrowIcon
|
|
103
|
+
className={ cn(
|
|
104
|
+
'size-3 align-middle shrink-0',
|
|
105
|
+
'group-hover:text-inherit',
|
|
106
|
+
) }
|
|
107
|
+
style={ color ? { color } : { color: 'var(--color-icon-secondary)' } }
|
|
108
|
+
aria-hidden="true"
|
|
109
|
+
/>
|
|
110
|
+
);
|
|
111
|
+
|
|
112
|
+
const SPACING = 4;
|
|
113
|
+
|
|
114
|
+
function resolveSpacing(v: number | string | Record<string, string | number> | undefined): string | undefined {
|
|
115
|
+
if (v === undefined) return undefined;
|
|
116
|
+
if (typeof v === 'number') return `${ v * SPACING }px`;
|
|
117
|
+
if (typeof v === 'string') return v;
|
|
118
|
+
// Responsive object - use base value
|
|
119
|
+
if (typeof v === 'object' && v !== null) {
|
|
120
|
+
const base = (v as Record<string, string | number>).base;
|
|
121
|
+
if (base !== undefined) return typeof base === 'number' ? `${ base * SPACING }px` : base;
|
|
122
|
+
const lg = (v as Record<string, string | number>).lg;
|
|
123
|
+
if (lg !== undefined) return typeof lg === 'number' ? `${ lg * SPACING }px` : lg;
|
|
124
|
+
}
|
|
125
|
+
return undefined;
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
export const Link = React.forwardRef<HTMLAnchorElement, LinkProps>(
|
|
129
|
+
function Link(props, ref) {
|
|
130
|
+
const {
|
|
131
|
+
external,
|
|
132
|
+
loading,
|
|
133
|
+
href,
|
|
134
|
+
children,
|
|
135
|
+
disabled,
|
|
136
|
+
noIcon,
|
|
137
|
+
iconColor,
|
|
138
|
+
variant = 'primary',
|
|
139
|
+
className,
|
|
140
|
+
asChild: _asChild,
|
|
141
|
+
// Strip Next.js-specific props (accepted for compat, not used)
|
|
142
|
+
shallow: _shallow,
|
|
143
|
+
prefetch: _prefetch,
|
|
144
|
+
scroll: _scroll,
|
|
145
|
+
// Strip Chakra style props
|
|
146
|
+
fontWeight: _fontWeight,
|
|
147
|
+
whiteSpace: _whiteSpace,
|
|
148
|
+
wordBreak: _wordBreak,
|
|
149
|
+
textStyle: _textStyle,
|
|
150
|
+
ml: _ml,
|
|
151
|
+
mr: _mr,
|
|
152
|
+
display: _display,
|
|
153
|
+
alignItems: _alignItems,
|
|
154
|
+
flexShrink: _flexShrink,
|
|
155
|
+
minW: _minW,
|
|
156
|
+
justifyContent: _justifyContent,
|
|
157
|
+
position: _position,
|
|
158
|
+
...rest
|
|
159
|
+
} = props;
|
|
160
|
+
|
|
161
|
+
// Build inline style from Chakra style props
|
|
162
|
+
const shimStyle: React.CSSProperties = {};
|
|
163
|
+
if (_fontWeight !== undefined) shimStyle.fontWeight = _fontWeight;
|
|
164
|
+
if (_whiteSpace) shimStyle.whiteSpace = _whiteSpace as React.CSSProperties['whiteSpace'];
|
|
165
|
+
if (_wordBreak) shimStyle.wordBreak = _wordBreak as React.CSSProperties['wordBreak'];
|
|
166
|
+
if (_ml !== undefined) shimStyle.marginLeft = resolveSpacing(_ml);
|
|
167
|
+
if (_mr !== undefined) shimStyle.marginRight = resolveSpacing(_mr);
|
|
168
|
+
if (_display) shimStyle.display = _display;
|
|
169
|
+
if (_alignItems) shimStyle.alignItems = _alignItems;
|
|
170
|
+
if (_flexShrink !== undefined) shimStyle.flexShrink = _flexShrink;
|
|
171
|
+
if (_minW !== undefined) shimStyle.minWidth = typeof _minW === 'number' ? `${ _minW * SPACING }px` : _minW;
|
|
172
|
+
if (_justifyContent) shimStyle.justifyContent = _justifyContent;
|
|
173
|
+
if (_position) shimStyle.position = _position as React.CSSProperties['position'];
|
|
174
|
+
|
|
175
|
+
const linkClasses = cn(BASE_CLASSES, VARIANT_CLASSES[variant], className);
|
|
176
|
+
const linkStyle = Object.keys(shimStyle).length > 0 ? shimStyle : undefined;
|
|
177
|
+
|
|
178
|
+
if (external) {
|
|
179
|
+
const processedHref = typeof href === 'string' ? stripUtmParams(href) : href;
|
|
180
|
+
|
|
181
|
+
return (
|
|
182
|
+
<Skeleton loading={ loading } ref={ ref as React.ForwardedRef<HTMLDivElement> } asChild>
|
|
183
|
+
<a
|
|
184
|
+
href={ processedHref }
|
|
185
|
+
className={ cn('group', linkClasses) }
|
|
186
|
+
style={ linkStyle }
|
|
187
|
+
target="_blank"
|
|
188
|
+
rel="noopener noreferrer"
|
|
189
|
+
{ ...(disabled ? { 'data-disabled': true } : {}) }
|
|
190
|
+
{ ...rest }
|
|
191
|
+
>
|
|
192
|
+
{ children }
|
|
193
|
+
{ !noIcon && <LinkExternalIcon color={ iconColor }/> }
|
|
194
|
+
</a>
|
|
195
|
+
</Skeleton>
|
|
196
|
+
);
|
|
197
|
+
}
|
|
198
|
+
|
|
199
|
+
// Internal link: render a plain <a> tag. Framework-specific routing
|
|
200
|
+
// (e.g. Next.js Link) should be provided by the consuming app's wrapper.
|
|
201
|
+
if (href) {
|
|
202
|
+
return (
|
|
203
|
+
<Skeleton loading={ loading } ref={ ref as React.ForwardedRef<HTMLDivElement> } asChild>
|
|
204
|
+
<a
|
|
205
|
+
href={ href }
|
|
206
|
+
className={ linkClasses }
|
|
207
|
+
style={ linkStyle }
|
|
208
|
+
{ ...(disabled ? { 'data-disabled': true } : {}) }
|
|
209
|
+
{ ...rest }
|
|
210
|
+
>
|
|
211
|
+
{ children }
|
|
212
|
+
</a>
|
|
213
|
+
</Skeleton>
|
|
214
|
+
);
|
|
215
|
+
}
|
|
216
|
+
|
|
217
|
+
return (
|
|
218
|
+
<Skeleton loading={ loading } ref={ ref as React.ForwardedRef<HTMLDivElement> } asChild>
|
|
219
|
+
<span
|
|
220
|
+
className={ linkClasses }
|
|
221
|
+
{ ...(disabled ? { 'data-disabled': true } : {}) }
|
|
222
|
+
{ ...rest as React.HTMLAttributes<HTMLSpanElement> }
|
|
223
|
+
>
|
|
224
|
+
{ children }
|
|
225
|
+
</span>
|
|
226
|
+
</Skeleton>
|
|
227
|
+
);
|
|
228
|
+
},
|
|
229
|
+
);
|
|
230
|
+
|
|
231
|
+
export const LinkBox = React.forwardRef<HTMLDivElement, React.HTMLAttributes<HTMLDivElement>>(
|
|
232
|
+
function LinkBox(props, ref) {
|
|
233
|
+
const { className, ...rest } = props;
|
|
234
|
+
return (
|
|
235
|
+
<div
|
|
236
|
+
ref={ ref }
|
|
237
|
+
className={ cn('relative', className) }
|
|
238
|
+
{ ...rest }
|
|
239
|
+
/>
|
|
240
|
+
);
|
|
241
|
+
},
|
|
242
|
+
);
|
|
243
|
+
|
|
244
|
+
export const LinkOverlay = React.forwardRef<HTMLAnchorElement, LinkProps>(
|
|
245
|
+
function LinkOverlay(props, ref) {
|
|
246
|
+
const {
|
|
247
|
+
children,
|
|
248
|
+
external,
|
|
249
|
+
loading,
|
|
250
|
+
href,
|
|
251
|
+
noIcon,
|
|
252
|
+
iconColor,
|
|
253
|
+
variant = 'primary',
|
|
254
|
+
className,
|
|
255
|
+
disabled,
|
|
256
|
+
asChild: _asChild2,
|
|
257
|
+
shallow: _shallow2,
|
|
258
|
+
prefetch: _prefetch2,
|
|
259
|
+
scroll: _scroll2,
|
|
260
|
+
fontWeight: _fw2, whiteSpace: _ws2, wordBreak: _wb2, textStyle: _ts2,
|
|
261
|
+
ml: _ml2, mr: _mr2, display: _d2, alignItems: _ai2, flexShrink: _fs2,
|
|
262
|
+
minW: _mw2, justifyContent: _jc2, position: _p2,
|
|
263
|
+
...rest
|
|
264
|
+
} = props;
|
|
265
|
+
|
|
266
|
+
const overlayClasses = cn(
|
|
267
|
+
BASE_CLASSES,
|
|
268
|
+
VARIANT_CLASSES[variant],
|
|
269
|
+
// Static positioning with a ::before pseudo-element that covers the LinkBox
|
|
270
|
+
'static',
|
|
271
|
+
'before:absolute before:inset-0 before:z-0 before:content-[""]',
|
|
272
|
+
className,
|
|
273
|
+
);
|
|
274
|
+
|
|
275
|
+
if (external) {
|
|
276
|
+
const processedHref = typeof href === 'string' ? stripUtmParams(href) : href;
|
|
277
|
+
|
|
278
|
+
return (
|
|
279
|
+
<a
|
|
280
|
+
ref={ ref }
|
|
281
|
+
href={ loading ? undefined : processedHref }
|
|
282
|
+
className={ overlayClasses }
|
|
283
|
+
target="_blank"
|
|
284
|
+
rel="noopener noreferrer"
|
|
285
|
+
{ ...rest }
|
|
286
|
+
>
|
|
287
|
+
{ (children || (!noIcon && href)) && (
|
|
288
|
+
<Skeleton display="inline-flex" alignItems="center" loading={ loading } maxW="100%" h="100%">
|
|
289
|
+
{ children }
|
|
290
|
+
{ !noIcon && href && <LinkExternalIcon color={ iconColor }/> }
|
|
291
|
+
</Skeleton>
|
|
292
|
+
) }
|
|
293
|
+
</a>
|
|
294
|
+
);
|
|
295
|
+
}
|
|
296
|
+
|
|
297
|
+
const content = children ? (
|
|
298
|
+
<Skeleton display="inline-flex" alignItems="center" loading={ loading } maxW="100%" h="100%">
|
|
299
|
+
{ children }
|
|
300
|
+
</Skeleton>
|
|
301
|
+
) : null;
|
|
302
|
+
|
|
303
|
+
if (href) {
|
|
304
|
+
return (
|
|
305
|
+
<a
|
|
306
|
+
ref={ ref }
|
|
307
|
+
href={ href }
|
|
308
|
+
className={ overlayClasses }
|
|
309
|
+
{ ...rest }
|
|
310
|
+
>
|
|
311
|
+
{ content }
|
|
312
|
+
</a>
|
|
313
|
+
);
|
|
314
|
+
}
|
|
315
|
+
|
|
316
|
+
return (
|
|
317
|
+
<span
|
|
318
|
+
ref={ ref as React.ForwardedRef<HTMLDivElement> }
|
|
319
|
+
className={ overlayClasses }
|
|
320
|
+
{ ...rest as React.HTMLAttributes<HTMLSpanElement> }
|
|
321
|
+
>
|
|
322
|
+
{ content }
|
|
323
|
+
</span>
|
|
324
|
+
);
|
|
325
|
+
},
|
|
326
|
+
);
|