@geekapps/silo-elements-nextjs 0.2.58 → 0.2.59
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/VideoPlayer.js +22 -6
- package/dist/VideoPlayer.js.map +1 -1
- package/dist/index.js +22 -6
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -1280,6 +1280,12 @@ function Video({
|
|
|
1280
1280
|
const [storyboardCues, setStoryboardCues] = useState(
|
|
1281
1281
|
[]
|
|
1282
1282
|
);
|
|
1283
|
+
const [ratingCounts, setRatingCounts] = useState(
|
|
1284
|
+
() => ({ LOVE: parsed.rating?.counts?.LOVE ?? 0, LIKE: parsed.rating?.counts?.LIKE ?? 0, DISLIKE: parsed.rating?.counts?.DISLIKE ?? 0 })
|
|
1285
|
+
);
|
|
1286
|
+
const [userReaction, setUserReaction] = useState(parsed.rating?.userReaction ?? null);
|
|
1287
|
+
const onReactRef = useRef(parsed.rating?.onReact);
|
|
1288
|
+
onReactRef.current = parsed.rating?.onReact;
|
|
1283
1289
|
const [preview, setPreview] = useState(null);
|
|
1284
1290
|
const [duration, setDuration] = useState(0);
|
|
1285
1291
|
const [currentTime, setCurrentTime] = useState(0);
|
|
@@ -2782,23 +2788,33 @@ function Video({
|
|
|
2782
2788
|
] }),
|
|
2783
2789
|
/* @__PURE__ */ jsxs("div", { className: "flex items-center gap-0.5 @sm:gap-1", children: [
|
|
2784
2790
|
parsed.rating && (() => {
|
|
2785
|
-
const
|
|
2786
|
-
const reactions = [
|
|
2791
|
+
const REACTIONS = [
|
|
2787
2792
|
{ key: "LOVE", emoji: "\u2764\uFE0F" },
|
|
2788
2793
|
{ key: "LIKE", emoji: "\u{1F44D}" },
|
|
2789
2794
|
{ key: "DISLIKE", emoji: "\u{1F44E}" }
|
|
2790
2795
|
];
|
|
2791
2796
|
return /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
2792
|
-
|
|
2793
|
-
const count =
|
|
2794
|
-
const active =
|
|
2797
|
+
REACTIONS.map(({ key, emoji }) => {
|
|
2798
|
+
const count = ratingCounts[key] ?? 0;
|
|
2799
|
+
const active = userReaction === key;
|
|
2795
2800
|
return /* @__PURE__ */ jsxs(
|
|
2796
2801
|
"button",
|
|
2797
2802
|
{
|
|
2798
2803
|
type: "button",
|
|
2799
2804
|
onClick: (e) => {
|
|
2800
2805
|
e.stopPropagation();
|
|
2801
|
-
|
|
2806
|
+
const next = active ? null : key;
|
|
2807
|
+
setUserReaction(next);
|
|
2808
|
+
setRatingCounts((prev) => {
|
|
2809
|
+
const updated = { ...prev };
|
|
2810
|
+
if (active) updated[key] = Math.max(0, (updated[key] ?? 0) - 1);
|
|
2811
|
+
else {
|
|
2812
|
+
if (userReaction) updated[userReaction] = Math.max(0, (updated[userReaction] ?? 0) - 1);
|
|
2813
|
+
updated[key] = (updated[key] ?? 0) + 1;
|
|
2814
|
+
}
|
|
2815
|
+
return updated;
|
|
2816
|
+
});
|
|
2817
|
+
onReactRef.current?.(next);
|
|
2802
2818
|
},
|
|
2803
2819
|
className: `flex items-center gap-0.5 rounded px-1.5 py-1 text-[11px] transition hover:bg-white/10 ${active ? "opacity-100" : "opacity-50 hover:opacity-80"}`,
|
|
2804
2820
|
"aria-label": key.toLowerCase(),
|