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