@geekapps/silo-elements-nextjs 0.2.58 → 0.2.60
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 +25 -6
- package/dist/VideoPlayer.js.map +1 -1
- package/dist/index.js +25 -6
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/VideoPlayer.js
CHANGED
|
@@ -153,6 +153,14 @@ function Video({
|
|
|
153
153
|
const [storyboardCues, setStoryboardCues] = useState(
|
|
154
154
|
[]
|
|
155
155
|
);
|
|
156
|
+
const [ratingCounts, setRatingCounts] = useState(
|
|
157
|
+
() => ({ LOVE: parsed.rating?.counts?.LOVE ?? 0, LIKE: parsed.rating?.counts?.LIKE ?? 0, DISLIKE: parsed.rating?.counts?.DISLIKE ?? 0 })
|
|
158
|
+
);
|
|
159
|
+
const [userReaction, setUserReaction] = useState(parsed.rating?.userReaction ?? null);
|
|
160
|
+
const userReactionRef = useRef(userReaction);
|
|
161
|
+
userReactionRef.current = userReaction;
|
|
162
|
+
const onReactRef = useRef(parsed.rating?.onReact);
|
|
163
|
+
onReactRef.current = parsed.rating?.onReact;
|
|
156
164
|
const [preview, setPreview] = useState(null);
|
|
157
165
|
const [duration, setDuration] = useState(0);
|
|
158
166
|
const [currentTime, setCurrentTime] = useState(0);
|
|
@@ -1655,23 +1663,34 @@ function Video({
|
|
|
1655
1663
|
] }),
|
|
1656
1664
|
/* @__PURE__ */ jsxs("div", { className: "flex items-center gap-0.5 @sm:gap-1", children: [
|
|
1657
1665
|
parsed.rating && (() => {
|
|
1658
|
-
const
|
|
1659
|
-
const reactions = [
|
|
1666
|
+
const REACTIONS = [
|
|
1660
1667
|
{ key: "LOVE", emoji: "\u2764\uFE0F" },
|
|
1661
1668
|
{ key: "LIKE", emoji: "\u{1F44D}" },
|
|
1662
1669
|
{ key: "DISLIKE", emoji: "\u{1F44E}" }
|
|
1663
1670
|
];
|
|
1664
1671
|
return /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
1665
|
-
|
|
1666
|
-
const count =
|
|
1667
|
-
const active =
|
|
1672
|
+
REACTIONS.map(({ key, emoji }) => {
|
|
1673
|
+
const count = ratingCounts[key] ?? 0;
|
|
1674
|
+
const active = userReaction === key;
|
|
1668
1675
|
return /* @__PURE__ */ jsxs(
|
|
1669
1676
|
"button",
|
|
1670
1677
|
{
|
|
1671
1678
|
type: "button",
|
|
1672
1679
|
onClick: (e) => {
|
|
1673
1680
|
e.stopPropagation();
|
|
1674
|
-
|
|
1681
|
+
const next = active ? null : key;
|
|
1682
|
+
setUserReaction(next);
|
|
1683
|
+
setRatingCounts((prev) => {
|
|
1684
|
+
const updated = { ...prev };
|
|
1685
|
+
const prev_reaction = userReactionRef.current;
|
|
1686
|
+
if (active) updated[key] = Math.max(0, (updated[key] ?? 0) - 1);
|
|
1687
|
+
else {
|
|
1688
|
+
if (prev_reaction) updated[prev_reaction] = Math.max(0, (updated[prev_reaction] ?? 0) - 1);
|
|
1689
|
+
updated[key] = (updated[key] ?? 0) + 1;
|
|
1690
|
+
}
|
|
1691
|
+
return updated;
|
|
1692
|
+
});
|
|
1693
|
+
onReactRef.current?.(next);
|
|
1675
1694
|
},
|
|
1676
1695
|
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"}`,
|
|
1677
1696
|
"aria-label": key.toLowerCase(),
|