@empoweredvote/ev-ui 0.9.1 → 0.9.3
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/index.js +21 -15
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +21 -15
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -137,7 +137,9 @@ function RadarChartCore({
|
|
|
137
137
|
padding = 80,
|
|
138
138
|
labelOffset = 20,
|
|
139
139
|
tightFit = false,
|
|
140
|
-
maxLabelLines = 2
|
|
140
|
+
maxLabelLines = 2,
|
|
141
|
+
showLabels = true,
|
|
142
|
+
dotRadius = 5
|
|
141
143
|
}) {
|
|
142
144
|
const { isDark } = useTheme();
|
|
143
145
|
const radius = size / 2 - 40;
|
|
@@ -203,6 +205,9 @@ function RadarChartCore({
|
|
|
203
205
|
});
|
|
204
206
|
const labelMeta = spokes.map(([shortTitle], i) => {
|
|
205
207
|
const angle = 2 * Math.PI * i / numSpokes;
|
|
208
|
+
const sinA = Math.sin(angle);
|
|
209
|
+
const side = sinA < -0.1 ? "left" : sinA > 0.1 ? "right" : "center";
|
|
210
|
+
if (!showLabels) return { estimatedWidth: 0, side };
|
|
206
211
|
const baseFSize = labelFontSize;
|
|
207
212
|
const lines = wrapLabel(shortTitle, 12, maxLabelLines);
|
|
208
213
|
const longestLineLen = lines.reduce(
|
|
@@ -211,13 +216,11 @@ function RadarChartCore({
|
|
|
211
216
|
);
|
|
212
217
|
const fSize = adaptiveFontSize(longestLineLen, baseFSize);
|
|
213
218
|
const estimatedWidth = longestLineLen * fSize * 0.6;
|
|
214
|
-
const sinA = Math.sin(angle);
|
|
215
|
-
const side = sinA < -0.1 ? "left" : sinA > 0.1 ? "right" : "center";
|
|
216
219
|
return { estimatedWidth, side };
|
|
217
220
|
});
|
|
218
221
|
const leftLabelWidths = labelMeta.filter((m) => m.side === "left").map((m) => m.estimatedWidth);
|
|
219
222
|
const rightLabelWidths = labelMeta.filter((m) => m.side === "right").map((m) => m.estimatedWidth);
|
|
220
|
-
const minPadding = 40;
|
|
223
|
+
const minPadding = showLabels ? 40 : 10;
|
|
221
224
|
const maxPadding = padding * 2;
|
|
222
225
|
const rawLeftPadding = Math.min(
|
|
223
226
|
Math.max(
|
|
@@ -248,7 +251,7 @@ function RadarChartCore({
|
|
|
248
251
|
if (y > yMax) yMax = y;
|
|
249
252
|
}
|
|
250
253
|
const effLabelFSize = adaptiveFontSize(12, labelFontSize);
|
|
251
|
-
const labelMargin = labelOffset + effLabelFSize * 1.1 * maxLabelLines;
|
|
254
|
+
const labelMargin = showLabels ? labelOffset + effLabelFSize * 1.1 * maxLabelLines : 8;
|
|
252
255
|
tightTop = yMin - labelMargin;
|
|
253
256
|
tightHeight = yMax + labelMargin - tightTop;
|
|
254
257
|
}
|
|
@@ -293,7 +296,7 @@ function RadarChartCore({
|
|
|
293
296
|
}
|
|
294
297
|
);
|
|
295
298
|
}),
|
|
296
|
-
spokes.map(([shortTitle], i) => {
|
|
299
|
+
showLabels && spokes.map(([shortTitle], i) => {
|
|
297
300
|
const angle = 2 * Math.PI * i / numSpokes;
|
|
298
301
|
const anchor = angle > Math.PI ? "end" : angle < Math.PI && angle > 0 ? "start" : "middle";
|
|
299
302
|
const cosA = Math.cos(angle);
|
|
@@ -367,7 +370,7 @@ function RadarChartCore({
|
|
|
367
370
|
key: `user-dot-${i}`,
|
|
368
371
|
cx,
|
|
369
372
|
cy,
|
|
370
|
-
r: matches ? 8 :
|
|
373
|
+
r: matches ? dotRadius * (8 / 7) : dotRadius,
|
|
371
374
|
fill: matches ? "#fed12e" : "#7C6B9E",
|
|
372
375
|
stroke: "#FFFFFF",
|
|
373
376
|
strokeWidth: 3
|
|
@@ -409,7 +412,7 @@ function RadarChartCore({
|
|
|
409
412
|
key: `compare-dot-${i}`,
|
|
410
413
|
cx,
|
|
411
414
|
cy,
|
|
412
|
-
r: matches ? 8 :
|
|
415
|
+
r: matches ? dotRadius * (8 / 7) : dotRadius,
|
|
413
416
|
fill: matches ? "#fed12e" : "#5A9A6E",
|
|
414
417
|
stroke: "#FFFFFF",
|
|
415
418
|
strokeWidth: 3
|
|
@@ -1964,9 +1967,12 @@ function PoliticianCard({
|
|
|
1964
1967
|
badge,
|
|
1965
1968
|
imageFocalPoint,
|
|
1966
1969
|
footer,
|
|
1967
|
-
imageWidth = "90px"
|
|
1970
|
+
imageWidth = "90px",
|
|
1971
|
+
contentStyle = {}
|
|
1968
1972
|
}) {
|
|
1969
1973
|
const isHorizontal = variant === "horizontal";
|
|
1974
|
+
const imageWidthPx = parseInt(imageWidth, 10) || 90;
|
|
1975
|
+
const imageMinHeight = isHorizontal ? Math.ceil(imageWidthPx * 4 / 3) : void 0;
|
|
1970
1976
|
const handleCardClick = (e) => {
|
|
1971
1977
|
if (e.target.closest(".ev-compass-button")) return;
|
|
1972
1978
|
onClick == null ? void 0 : onClick();
|
|
@@ -1987,15 +1993,14 @@ function PoliticianCard({
|
|
|
1987
1993
|
cursor: onClick ? "pointer" : "default",
|
|
1988
1994
|
transition: "box-shadow 0.2s ease, transform 0.2s ease",
|
|
1989
1995
|
position: "relative",
|
|
1990
|
-
minHeight:
|
|
1996
|
+
minHeight: imageMinHeight,
|
|
1991
1997
|
height: "100%",
|
|
1992
1998
|
...style
|
|
1993
1999
|
},
|
|
1994
2000
|
imageWrapper: {
|
|
1995
|
-
// Horizontal:
|
|
1996
|
-
//
|
|
1997
|
-
|
|
1998
|
-
position: isHorizontal ? "relative" : void 0,
|
|
2001
|
+
// Horizontal: fixed width with 3:4 aspect ratio so portrait photos look
|
|
2002
|
+
// consistent regardless of card content height.
|
|
2003
|
+
position: "relative",
|
|
1999
2004
|
width: isHorizontal ? imageWidth : "100%",
|
|
2000
2005
|
height: isHorizontal ? "100%" : "auto",
|
|
2001
2006
|
aspectRatio: isHorizontal ? void 0 : "4/5",
|
|
@@ -2028,7 +2033,8 @@ function PoliticianCard({
|
|
|
2028
2033
|
padding: isHorizontal ? `${spacing[2]} ${spacing[3]}` : spacing[3],
|
|
2029
2034
|
minWidth: 0,
|
|
2030
2035
|
display: "flex",
|
|
2031
|
-
flexDirection: "column"
|
|
2036
|
+
flexDirection: "column",
|
|
2037
|
+
...contentStyle
|
|
2032
2038
|
},
|
|
2033
2039
|
name: {
|
|
2034
2040
|
fontFamily: fonts.primary,
|