Emails
1 month ago
EngagementChart
2 months ago
MediaHub
1 month ago
Onboarding
2 months ago
Popup
2 months ago
Skeletons
1 month ago
WhatsNew
2 months ago
charts
2 months ago
test
2 months ago
AdminMenuSync.js
2 months ago
ChartEmptyState.js
2 months ago
ChooseDate.js
2 months ago
ColorPicker.js
2 months ago
ExtendPlugins.js
2 months ago
Filters.js
2 months ago
Link.js
2 months ago
Navbar.js
1 month ago
NoFound.js
2 months ago
PageHeader.js
2 months ago
PluginRecommendations.js
2 months ago
PostScheduleField.js
2 months ago
PrestoPlayerIcon.js
2 months ago
ProGateOverlay.js
2 months ago
QuickAccess.js
2 months ago
RankedTable.js
2 months ago
StatCard.js
2 months ago
TopMedia.js
2 months ago
TopPerformingMedia.js
2 months ago
TopUsers.js
2 months ago
TruncatedTitle.js
2 months ago
UpgradeNotice.js
2 months ago
UpgradeToPro.js
2 months ago
VideoModal.js
2 months ago
WelcomeBanner.js
2 months ago
Link.js
26 lines
| 1 | import { Children, cloneElement, isValidElement } from "react"; |
| 2 | import { Text } from "@bsf/force-ui"; |
| 3 | import useLink from "../hooks/useLink"; |
| 4 | |
| 5 | const Link = ({ params, children, ...props }) => { |
| 6 | const { href, onClick } = useLink(params); |
| 7 | |
| 8 | // If a single valid React element is provided, clone it with routing props |
| 9 | if (isValidElement(children) && Children.count(children) === 1) { |
| 10 | return cloneElement(children, { |
| 11 | href, |
| 12 | onClick, |
| 13 | ...props, |
| 14 | }); |
| 15 | } |
| 16 | |
| 17 | // Default fallback: wrap in Force UI Text as anchor |
| 18 | return ( |
| 19 | <Text as="a" href={href} onClick={onClick} className="no-underline hover:no-underline" {...props}> |
| 20 | {children} |
| 21 | </Text> |
| 22 | ); |
| 23 | }; |
| 24 | |
| 25 | export default Link; |
| 26 |