@logora/debate 0.4.109 → 0.4.110
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.
|
@@ -1,38 +1,38 @@
|
|
|
1
|
-
import { jsxs as i, jsx as t, Fragment as
|
|
2
|
-
import
|
|
1
|
+
import { jsxs as i, jsx as t, Fragment as g } from "react/jsx-runtime";
|
|
2
|
+
import B from "classnames";
|
|
3
3
|
import "react";
|
|
4
|
-
import { useIntl as
|
|
4
|
+
import { useIntl as w, FormattedMessage as N } from "react-intl";
|
|
5
5
|
import a from "./DebateBox.module.scss.js";
|
|
6
|
-
import { useConfig as
|
|
7
|
-
import { useRoutes as
|
|
8
|
-
import { useResponsive as
|
|
9
|
-
import { useTranslatedContent as
|
|
6
|
+
import { useConfig as M } from "../../data/config_provider/useConfig.js";
|
|
7
|
+
import { useRoutes as S } from "../../data/config_provider/useRoutes.js";
|
|
8
|
+
import { useResponsive as P } from "../../hooks/use_responsive/useResponsive.js";
|
|
9
|
+
import { useTranslatedContent as f } from "../../translation/translated_content/useTranslatedContent.js";
|
|
10
10
|
import { Link as c } from "../../action/link/Link.js";
|
|
11
|
-
import { Icon as
|
|
12
|
-
import { Tooltip as
|
|
13
|
-
import { Avatar as
|
|
14
|
-
const
|
|
15
|
-
const
|
|
11
|
+
import { Icon as y } from "../../icons/icon/Icon.js";
|
|
12
|
+
import { Tooltip as D } from "../../dialog/tooltip/Tooltip.js";
|
|
13
|
+
import { Avatar as C } from "../../user/avatar/Avatar.js";
|
|
14
|
+
const H = ({ debate: e }) => {
|
|
15
|
+
const m = M(), d = S(), r = w(), { isMobile: v } = P(), l = e.votes_count ?? {}, p = l.total || Object.values(l).reduce(
|
|
16
16
|
(o, s) => o + Number.parseFloat(s),
|
|
17
17
|
0
|
|
18
|
-
) || 0,
|
|
19
|
-
(o, s) => Number.parseInt(
|
|
20
|
-
),
|
|
18
|
+
) || 0, h = e.group_context?.positions ?? [], n = h.length ? h.reduce(
|
|
19
|
+
(o, s) => Number.parseInt(l[s.id]) > Number.parseInt(l[o.id]) ? s : o
|
|
20
|
+
) : void 0, u = f(
|
|
21
21
|
e.name,
|
|
22
22
|
e.language,
|
|
23
23
|
"name",
|
|
24
24
|
e.translation_entries
|
|
25
|
-
),
|
|
26
|
-
n
|
|
27
|
-
n
|
|
25
|
+
), _ = f(
|
|
26
|
+
n?.name,
|
|
27
|
+
n?.language,
|
|
28
28
|
"name",
|
|
29
|
-
n
|
|
30
|
-
),
|
|
29
|
+
n?.translation_entries
|
|
30
|
+
), b = (o, s) => s == 0 || o == 0 ? 0 : Math.round(100 * (o / s)), x = (o, s) => /* @__PURE__ */ t("div", { className: a.debateParticipantItem, children: /* @__PURE__ */ t(
|
|
31
31
|
c,
|
|
32
32
|
{
|
|
33
|
-
to:
|
|
33
|
+
to: d.userShowLocation.toUrl({ userSlug: o.hash_id }),
|
|
34
34
|
children: /* @__PURE__ */ t(
|
|
35
|
-
|
|
35
|
+
C,
|
|
36
36
|
{
|
|
37
37
|
avatarUrl: o.image_url,
|
|
38
38
|
userName: o.full_name,
|
|
@@ -48,7 +48,7 @@ const R = ({ debate: e }) => {
|
|
|
48
48
|
/* @__PURE__ */ t(
|
|
49
49
|
c,
|
|
50
50
|
{
|
|
51
|
-
to:
|
|
51
|
+
to: d.debateShowLocation.toUrl({ debateSlug: e.slug }),
|
|
52
52
|
className: a.imageLink,
|
|
53
53
|
children: /* @__PURE__ */ t(
|
|
54
54
|
"img",
|
|
@@ -58,11 +58,11 @@ const R = ({ debate: e }) => {
|
|
|
58
58
|
className: a.debateBoxImage,
|
|
59
59
|
src: e.banner_image_url,
|
|
60
60
|
height: 200,
|
|
61
|
-
alt: e?.image_alt ? e.image_alt :
|
|
61
|
+
alt: e?.image_alt ? e.image_alt : r.formatMessage({
|
|
62
62
|
id: "debate.debate_box.alt_debate_image",
|
|
63
63
|
defaultMessage: "Debate image"
|
|
64
64
|
}),
|
|
65
|
-
title: e?.image_alt ? e.image_alt :
|
|
65
|
+
title: e?.image_alt ? e.image_alt : r.formatMessage({
|
|
66
66
|
id: "debate.debate_box.alt_debate_image",
|
|
67
67
|
defaultMessage: "Debate image"
|
|
68
68
|
})
|
|
@@ -71,7 +71,7 @@ const R = ({ debate: e }) => {
|
|
|
71
71
|
}
|
|
72
72
|
),
|
|
73
73
|
e.is_active === !1 && /* @__PURE__ */ t("div", { className: a.inactiveDebate, children: /* @__PURE__ */ t(
|
|
74
|
-
|
|
74
|
+
N,
|
|
75
75
|
{
|
|
76
76
|
id: "debate.debate_box.debate_is_inactive",
|
|
77
77
|
defaultMessage: "Debate is ended"
|
|
@@ -79,10 +79,10 @@ const R = ({ debate: e }) => {
|
|
|
79
79
|
) })
|
|
80
80
|
] }),
|
|
81
81
|
e.group_context.author && e.group_context.author.is_admin === !1 && /* @__PURE__ */ i("div", { className: a.debateSuggestion, children: [
|
|
82
|
-
/* @__PURE__ */ t(
|
|
82
|
+
/* @__PURE__ */ t(y, { name: "suggestion", width: 15, height: 15 }),
|
|
83
83
|
/* @__PURE__ */ i("span", { className: a.authorSuggestion, children: [
|
|
84
84
|
/* @__PURE__ */ t(
|
|
85
|
-
|
|
85
|
+
N,
|
|
86
86
|
{
|
|
87
87
|
id: "debate.debate_box.suggestion_author_short",
|
|
88
88
|
defaultMessage: "Suggested by"
|
|
@@ -93,15 +93,15 @@ const R = ({ debate: e }) => {
|
|
|
93
93
|
] })
|
|
94
94
|
] }),
|
|
95
95
|
/* @__PURE__ */ i("div", { className: a.debateBoxBody, children: [
|
|
96
|
-
/* @__PURE__ */ i("div", { className: a.debateBoxTitle, title:
|
|
97
|
-
|
|
96
|
+
/* @__PURE__ */ i("div", { className: a.debateBoxTitle, title: u.translatedContent, children: [
|
|
97
|
+
m?.actions?.allowDebateBranding === !0 && e.sub_application?.logo && /* @__PURE__ */ i("span", { className: a.subApplication, children: [
|
|
98
98
|
/* @__PURE__ */ t(
|
|
99
99
|
"img",
|
|
100
100
|
{
|
|
101
101
|
"data-tid": "view_debate_image",
|
|
102
102
|
loading: "lazy",
|
|
103
103
|
src: e.sub_application.logo,
|
|
104
|
-
alt: `Logo ${
|
|
104
|
+
alt: `Logo ${m.display_name}`
|
|
105
105
|
}
|
|
106
106
|
),
|
|
107
107
|
e.sub_application.name
|
|
@@ -109,47 +109,47 @@ const R = ({ debate: e }) => {
|
|
|
109
109
|
/* @__PURE__ */ t(
|
|
110
110
|
c,
|
|
111
111
|
{
|
|
112
|
-
to:
|
|
113
|
-
children: /* @__PURE__ */ t(
|
|
112
|
+
to: d.debateShowLocation.toUrl({ debateSlug: e.slug }),
|
|
113
|
+
children: /* @__PURE__ */ t(g, { children: v ? /* @__PURE__ */ t(
|
|
114
114
|
"div",
|
|
115
115
|
{
|
|
116
116
|
"data-tid": "view_debate_title",
|
|
117
|
-
className:
|
|
118
|
-
children:
|
|
117
|
+
className: B(a.debateTitle, a.debateTitleMobile),
|
|
118
|
+
children: u.translatedContent
|
|
119
119
|
}
|
|
120
120
|
) : /* @__PURE__ */ t(
|
|
121
121
|
"div",
|
|
122
122
|
{
|
|
123
123
|
"data-tid": "view_debate_title",
|
|
124
124
|
className: a.debateTitle,
|
|
125
|
-
children:
|
|
125
|
+
children: u.translatedContent
|
|
126
126
|
}
|
|
127
127
|
) })
|
|
128
128
|
}
|
|
129
129
|
)
|
|
130
130
|
] }),
|
|
131
131
|
/* @__PURE__ */ i("div", { className: a.debateBoxFooter, children: [
|
|
132
|
-
/* @__PURE__ */ t("div", { className: a.debateParticipantsBox, children: e.participants.length === 0 ? /* @__PURE__ */ t("span", { className: a.debateParticipantsEmpty, children:
|
|
132
|
+
/* @__PURE__ */ t("div", { className: a.debateParticipantsBox, children: e.participants.length === 0 ? /* @__PURE__ */ t("span", { className: a.debateParticipantsEmpty, children: r.formatMessage({
|
|
133
133
|
id: "debate.debate_box.fallback_no_participants",
|
|
134
134
|
defaultMessage: "No participants"
|
|
135
|
-
}) }) : /* @__PURE__ */ i(
|
|
136
|
-
e.participants.map(
|
|
135
|
+
}) }) : /* @__PURE__ */ i(g, { children: [
|
|
136
|
+
e.participants.map(x),
|
|
137
137
|
e.participants_count > 3 && /* @__PURE__ */ t("div", { className: a.debateParticipantItem, children: /* @__PURE__ */ t(
|
|
138
|
-
|
|
138
|
+
D,
|
|
139
139
|
{
|
|
140
|
-
text:
|
|
140
|
+
text: r.formatMessage({
|
|
141
141
|
id: "debate.debate_box.participants_count",
|
|
142
142
|
defaultMessage: "Number of debaters"
|
|
143
143
|
}),
|
|
144
144
|
children: /* @__PURE__ */ t(
|
|
145
145
|
c,
|
|
146
146
|
{
|
|
147
|
-
to:
|
|
147
|
+
to: d.debateShowLocation.toUrl({
|
|
148
148
|
debateSlug: e.slug
|
|
149
149
|
}),
|
|
150
150
|
children: /* @__PURE__ */ i("div", { className: a.participantsCountBox, children: [
|
|
151
151
|
"+",
|
|
152
|
-
|
|
152
|
+
r.formatNumber(e.participants_count - 3, {
|
|
153
153
|
notation: "compact",
|
|
154
154
|
maximumFractionDigits: 1,
|
|
155
155
|
roundingMode: "floor"
|
|
@@ -160,21 +160,21 @@ const R = ({ debate: e }) => {
|
|
|
160
160
|
}
|
|
161
161
|
) })
|
|
162
162
|
] }) }),
|
|
163
|
-
|
|
163
|
+
m.modules.votes === !1 || e.allow_votes === !1 ? null : /* @__PURE__ */ t("div", { className: a.debateBoxNumbers, children: /* @__PURE__ */ t(
|
|
164
164
|
"div",
|
|
165
165
|
{
|
|
166
166
|
className: a.debateBoxNumbersText,
|
|
167
|
-
title: n ? `${
|
|
168
|
-
children: n && /* @__PURE__ */ i(
|
|
167
|
+
title: n ? `${b(l[n.id] || 0, p)} % ${_.translatedContent}` : void 0,
|
|
168
|
+
children: n && /* @__PURE__ */ i(g, { children: [
|
|
169
169
|
/* @__PURE__ */ i("span", { className: a.debateBoxPercentage, children: [
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
170
|
+
b(
|
|
171
|
+
l[n.id] || 0,
|
|
172
|
+
p
|
|
173
173
|
),
|
|
174
174
|
" ",
|
|
175
175
|
"%"
|
|
176
176
|
] }),
|
|
177
|
-
/* @__PURE__ */ t("span", { className: a.debateBoxPositionName, children:
|
|
177
|
+
/* @__PURE__ */ t("span", { className: a.debateBoxPositionName, children: _.translatedContent })
|
|
178
178
|
] })
|
|
179
179
|
}
|
|
180
180
|
) })
|
|
@@ -183,5 +183,5 @@ const R = ({ debate: e }) => {
|
|
|
183
183
|
] });
|
|
184
184
|
};
|
|
185
185
|
export {
|
|
186
|
-
|
|
186
|
+
H as DebateBox
|
|
187
187
|
};
|