Emails
1 month ago
EngagementChart
1 month ago
MediaHub
1 month ago
Onboarding
1 month ago
Popup
1 month ago
Skeletons
1 week ago
WhatsNew
1 month ago
charts
1 month ago
test
1 month ago
AdminMenuSync.js
1 month ago
ChartEmptyState.js
1 month ago
ChooseDate.js
1 month ago
ColorPicker.js
1 month ago
ExtendPlugins.js
1 month ago
Filters.js
1 month ago
Link.js
1 month ago
Navbar.js
1 week ago
NoFound.js
1 month ago
PageHeader.js
1 month ago
PluginRecommendations.js
1 month ago
PostScheduleField.js
1 month ago
PrestoPlayerIcon.js
1 month ago
ProGateOverlay.js
1 month ago
QuickAccess.js
1 month ago
RankedTable.js
1 month ago
StatCard.js
1 month ago
TopMedia.js
1 month ago
TopPerformingMedia.js
1 month ago
TopUsers.js
1 month ago
TruncatedTitle.js
1 month ago
UpgradeNotice.js
1 month ago
UpgradeToPro.js
1 month ago
VideoModal.js
1 month ago
WelcomeBanner.js
1 month ago
TruncatedTitle.js
39 lines
| 1 | import { Tooltip, Text } from "@bsf/force-ui"; |
| 2 | |
| 3 | const MAX_TITLE_CHARS = 60; |
| 4 | |
| 5 | /** |
| 6 | * Single-line text that truncates by character count and shows a tooltip with |
| 7 | * the full value only when truncation actually occurs. Mirrors the Media Hub |
| 8 | * row pattern so behavior stays consistent across dashboard tables. |
| 9 | */ |
| 10 | const TruncatedTitle = ({ |
| 11 | title, |
| 12 | className = "", |
| 13 | maxChars = MAX_TITLE_CHARS, |
| 14 | }) => { |
| 15 | const str = title || ""; |
| 16 | if (!str) return null; |
| 17 | |
| 18 | const textClass = `text-text-secondary ${className}`.trim(); |
| 19 | |
| 20 | if (str.length <= maxChars) { |
| 21 | return ( |
| 22 | <Text as="span" size="sm" className={textClass}> |
| 23 | {str} |
| 24 | </Text> |
| 25 | ); |
| 26 | } |
| 27 | |
| 28 | return ( |
| 29 | <Text as="span" size="sm" className={textClass}> |
| 30 | {str.slice(0, maxChars - 1)} |
| 31 | <Tooltip placement="top" content={str} arrow> |
| 32 | <span className="inline-block">…</span> |
| 33 | </Tooltip> |
| 34 | </Text> |
| 35 | ); |
| 36 | }; |
| 37 | |
| 38 | export default TruncatedTitle; |
| 39 |