PluginProbe ʕ •ᴥ•ʔ
Presto Player / 4.3.2
Presto Player v4.3.2
4.3.2 4.3.1 4.3.0 4.2.4 4.2.3 4.2.2 4.2.0 4.2.1 trunk 1.10.0 1.10.1 1.10.2 1.11.0 1.12.0 1.13.0 1.14.0 1.14.1 1.5.10 1.5.11 1.5.12 1.5.13 1.5.14 1.5.15 1.5.5 1.5.6 1.5.7 1.5.8 1.5.9 1.6.0 1.6.1 1.6.10 1.6.11 1.6.12 1.6.13 1.6.2 1.6.3 1.6.4 1.6.5 1.6.6 1.6.7 1.6.8 1.6.9 1.7.0 1.7.1 1.7.2 1.8.0 1.8.1 1.8.2 1.8.3 1.8.4 1.8.5 1.8.6 1.9.0 1.9.1 1.9.10 1.9.11 1.9.12 1.9.13 1.9.14 1.9.2 1.9.3 1.9.4 1.9.5 1.9.6 1.9.7 1.9.8 1.9.9 2.0.0 2.0.1 2.0.10 2.0.11 2.0.12 2.0.13 2.0.14 2.0.15 2.0.16 2.0.2 2.0.3 2.0.4 2.0.5 2.0.6 2.0.7 2.0.8 2.0.9 2.1.0 2.2.0 2.2.1 2.2.2 2.2.3 2.2.3-beta1 2.3.0 2.3.1 2.3.2 2.3.3 3.0.0 3.0.0-beta1 3.0.1 3.0.2 3.0.3 3.0.4 3.0.5 3.0.6 3.0.7 3.0.8 3.1.0 3.1.1 3.1.2 3.1.3 4.0.0 4.0.1 4.0.2 4.0.3 4.0.4 4.0.5 4.0.6 4.0.7 4.0.8 4.1.0 4.1.1 4.1.2 4.1.3 4.1.4
presto-player / src / admin / dashboard / components / EngagementChart / ChartSummary.js
presto-player / src / admin / dashboard / components / EngagementChart Last commit date
Chart.js 2 months ago ChartAreaChart.js 2 months ago ChartContext.js 2 months ago ChartDateFilter.js 2 months ago ChartKPI.js 2 months ago ChartSummary.js 2 months ago ChartTabs.js 2 months ago index.js 2 months ago
ChartSummary.js
71 lines
1 import { memo } from "@wordpress/element";
2 import { Container, Text } from "@bsf/force-ui";
3 import { __ } from "@wordpress/i18n";
4 import { humanSeconds } from "../../utils";
5 import { CHART_COLOR, ALL_TIME_CHART_COLOR } from "../charts";
6 import { useChartContext } from "./ChartContext";
7
8 const StatCard = memo(({ label, value, indicatorColor }) => (
9 <Container.Item className="flex flex-col items-start justify-center flex-1 p-4 text-left rounded-md shadow-sm bg-background-primary">
10 <div className="flex items-center gap-2">
11 {indicatorColor && (
12 <div
13 className="w-3 h-3 rounded-sm"
14 style={{ backgroundColor: indicatorColor }}
15 />
16 )}
17 <Text className="text-sm font-medium text-text-primary">
18 {label}
19 </Text>
20 </div>
21 <Text className="mt-2 text-2xl font-semibold text-text-primary tabular-nums">
22 {value}
23 </Text>
24 </Container.Item>
25 ));
26
27 const ChartSummary = () => {
28 const { total, allTimeViews, allTimeWatchTime, isWatchTime, chartData } =
29 useChartContext();
30
31 // Only render when there is chart data and all-time data available
32 const hasAllTimeData = allTimeViews !== null || allTimeWatchTime !== null;
33 if (!chartData.length || !hasAllTimeData) return null;
34
35 const formatCount = (n) =>
36 typeof n === "number" ? n.toLocaleString() : n;
37
38 const currentLabel = isWatchTime
39 ? __("Watch Time", "presto-player")
40 : __("Views", "presto-player");
41 const currentValue = isWatchTime ? humanSeconds(total) : formatCount(total);
42
43 const allTimeLabel = isWatchTime
44 ? __("All Time Watch Time", "presto-player")
45 : __("All Time Views", "presto-player");
46 const allTimeValue = isWatchTime
47 ? humanSeconds(allTimeWatchTime)
48 : formatCount(allTimeViews);
49
50 return (
51 <Container
52 containerType="flex"
53 direction="column"
54 className="w-[30%] gap-1 bg-background-secondary rounded-lg"
55 >
56 <StatCard
57 label={currentLabel}
58 value={currentValue}
59 indicatorColor={CHART_COLOR}
60 />
61 <StatCard
62 label={allTimeLabel}
63 value={allTimeValue}
64 indicatorColor={ALL_TIME_CHART_COLOR}
65 />
66 </Container>
67 );
68 };
69
70 export default ChartSummary;
71