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
ChartEmptyState.js
145 lines
| 1 | import { Text } from "@bsf/force-ui"; |
| 2 | const { __ } = wp.i18n; |
| 3 | |
| 4 | const FileVideoIcon = () => ( |
| 5 | <svg |
| 6 | width="24" |
| 7 | height="24" |
| 8 | viewBox="0 0 24 24" |
| 9 | fill="none" |
| 10 | xmlns="http://www.w3.org/2000/svg" |
| 11 | aria-hidden="true" |
| 12 | > |
| 13 | <path |
| 14 | d="M14.5 2H6C5.46957 2 4.96086 2.21071 4.58579 2.58579C4.21071 2.96086 4 3.46957 4 4V20C4 20.5304 4.21071 21.0391 4.58579 21.4142C4.96086 21.7893 5.46957 22 6 22H18C18.5304 22 19.0391 21.7893 19.4142 21.4142C19.7893 21.0391 20 20.5304 20 20V7.5L14.5 2Z" |
| 15 | stroke="#111827" |
| 16 | strokeWidth="1.25" |
| 17 | strokeLinecap="round" |
| 18 | strokeLinejoin="round" |
| 19 | /> |
| 20 | <path |
| 21 | d="M14.5 2H6C5.46957 2 4.96086 2.21071 4.58579 2.58579C4.21071 2.96086 4 3.46957 4 4V20C4 20.5304 4.21071 21.0391 4.58579 21.4142C4.96086 21.7893 5.46957 22 6 22H18C18.5304 22 19.0391 21.7893 19.4142 21.4142C19.7893 21.0391 20 20.5304 20 20V7.5L14.5 2Z" |
| 22 | stroke="url(#paint0_linear_chart_empty)" |
| 23 | strokeWidth="1.25" |
| 24 | strokeLinecap="round" |
| 25 | strokeLinejoin="round" |
| 26 | /> |
| 27 | <path |
| 28 | d="M14 2V8H20" |
| 29 | stroke="#111827" |
| 30 | strokeWidth="1.25" |
| 31 | strokeLinecap="round" |
| 32 | strokeLinejoin="round" |
| 33 | /> |
| 34 | <path |
| 35 | d="M14 2V8H20" |
| 36 | stroke="url(#paint1_linear_chart_empty)" |
| 37 | strokeWidth="1.25" |
| 38 | strokeLinecap="round" |
| 39 | strokeLinejoin="round" |
| 40 | /> |
| 41 | <path |
| 42 | d="M10 11L15 14L10 17V11Z" |
| 43 | stroke="#111827" |
| 44 | strokeWidth="1.25" |
| 45 | strokeLinecap="round" |
| 46 | strokeLinejoin="round" |
| 47 | /> |
| 48 | <path |
| 49 | d="M10 11L15 14L10 17V11Z" |
| 50 | stroke="url(#paint2_linear_chart_empty)" |
| 51 | strokeWidth="1.25" |
| 52 | strokeLinecap="round" |
| 53 | strokeLinejoin="round" |
| 54 | /> |
| 55 | <defs> |
| 56 | <linearGradient |
| 57 | id="paint0_linear_chart_empty" |
| 58 | x1="12" |
| 59 | y1="2" |
| 60 | x2="12" |
| 61 | y2="22" |
| 62 | gradientUnits="userSpaceOnUse" |
| 63 | > |
| 64 | <stop stopColor="#9A20F8" /> |
| 65 | <stop offset="1" stopColor="#3058E5" /> |
| 66 | </linearGradient> |
| 67 | <linearGradient |
| 68 | id="paint1_linear_chart_empty" |
| 69 | x1="17" |
| 70 | y1="2" |
| 71 | x2="17" |
| 72 | y2="8" |
| 73 | gradientUnits="userSpaceOnUse" |
| 74 | > |
| 75 | <stop stopColor="#9A20F8" /> |
| 76 | <stop offset="1" stopColor="#3058E5" /> |
| 77 | </linearGradient> |
| 78 | <linearGradient |
| 79 | id="paint2_linear_chart_empty" |
| 80 | x1="12.5" |
| 81 | y1="11" |
| 82 | x2="12.5" |
| 83 | y2="17" |
| 84 | gradientUnits="userSpaceOnUse" |
| 85 | > |
| 86 | <stop stopColor="#9A20F8" /> |
| 87 | <stop offset="1" stopColor="#3058E5" /> |
| 88 | </linearGradient> |
| 89 | </defs> |
| 90 | </svg> |
| 91 | ); |
| 92 | |
| 93 | /** |
| 94 | * Shared empty state for analytics/engagement charts and stats tables. |
| 95 | * Keeps the icon, copy, and layout identical across the dashboard so every |
| 96 | * "no data" moment feels like the same product. |
| 97 | * |
| 98 | * Pass `className` to control the container height/padding per chart — the |
| 99 | * engagement chart gets a tall 256px placeholder while the Top Performing |
| 100 | * widget gets a compact 112px one. Pass `description={null}` to hide the |
| 101 | * secondary line in tight spaces (e.g. the retention mini-chart). |
| 102 | * |
| 103 | * Pass `proGated` for charts that only fill in for Pro users. When the |
| 104 | * current user isn't licensed, an "Unlock with Pro." sentence is appended |
| 105 | * to the description so the empty state reads as gated rather than empty. |
| 106 | * The phrase is intentionally plain text (no link) — the page already has |
| 107 | * upgrade banners and CTAs, and stacking another clickable nudge here was |
| 108 | * deemed too noisy. |
| 109 | */ |
| 110 | const ChartEmptyState = ({ |
| 111 | title = __("No Stats Available", "presto-player"), |
| 112 | description = __( |
| 113 | "You'll find detailed insights here to help you monitor and manage your video performance.", |
| 114 | "presto-player" |
| 115 | ), |
| 116 | className = "", |
| 117 | proGated = false, |
| 118 | }) => { |
| 119 | const isPremium = !!window?.prestoPlayer?.isPremium; |
| 120 | const showUpsell = proGated && !isPremium; |
| 121 | const showText = !!description || showUpsell; |
| 122 | |
| 123 | return ( |
| 124 | <div |
| 125 | className={`flex flex-col gap-4 items-center justify-center text-center px-1 ${className}`} |
| 126 | > |
| 127 | <FileVideoIcon /> |
| 128 | <div className="flex flex-col gap-1 items-center"> |
| 129 | <Text size="sm" className="font-medium text-text-primary m-0"> |
| 130 | {title} |
| 131 | </Text> |
| 132 | {showText && ( |
| 133 | <Text size="sm" className="font-normal text-text-tertiary m-0"> |
| 134 | {description} |
| 135 | {description && showUpsell ? " " : null} |
| 136 | {showUpsell && __("Unlock with Pro.", "presto-player")} |
| 137 | </Text> |
| 138 | )} |
| 139 | </div> |
| 140 | </div> |
| 141 | ); |
| 142 | }; |
| 143 | |
| 144 | export default ChartEmptyState; |
| 145 |