@empoweredvote/ev-ui 0.9.0 → 0.9.1
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 +19 -11
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +19 -11
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
|
@@ -43,7 +43,8 @@ function RadarChartCore({
|
|
|
43
43
|
labelFontSize = 18,
|
|
44
44
|
padding = 80,
|
|
45
45
|
labelOffset = 20,
|
|
46
|
-
tightFit = false
|
|
46
|
+
tightFit = false,
|
|
47
|
+
maxLabelLines = 2
|
|
47
48
|
}) {
|
|
48
49
|
const { isDark } = useTheme();
|
|
49
50
|
const radius = size / 2 - 40;
|
|
@@ -110,7 +111,7 @@ function RadarChartCore({
|
|
|
110
111
|
const labelMeta = spokes.map(([shortTitle], i) => {
|
|
111
112
|
const angle = 2 * Math.PI * i / numSpokes;
|
|
112
113
|
const baseFSize = labelFontSize;
|
|
113
|
-
const lines = wrapLabel(shortTitle, 12);
|
|
114
|
+
const lines = wrapLabel(shortTitle, 12, maxLabelLines);
|
|
114
115
|
const longestLineLen = lines.reduce(
|
|
115
116
|
(max, ln) => ln.length > max ? ln.length : max,
|
|
116
117
|
0
|
|
@@ -153,7 +154,8 @@ function RadarChartCore({
|
|
|
153
154
|
if (y < yMin) yMin = y;
|
|
154
155
|
if (y > yMax) yMax = y;
|
|
155
156
|
}
|
|
156
|
-
const
|
|
157
|
+
const effLabelFSize = adaptiveFontSize(12, labelFontSize);
|
|
158
|
+
const labelMargin = labelOffset + effLabelFSize * 1.1 * maxLabelLines;
|
|
157
159
|
tightTop = yMin - labelMargin;
|
|
158
160
|
tightHeight = yMax + labelMargin - tightTop;
|
|
159
161
|
}
|
|
@@ -205,7 +207,7 @@ function RadarChartCore({
|
|
|
205
207
|
const isTop = cosA > 0.5;
|
|
206
208
|
const isBottom = cosA < -0.5;
|
|
207
209
|
const baseFSize = labelFontSize;
|
|
208
|
-
const lines = wrapLabel(shortTitle, 12);
|
|
210
|
+
const lines = wrapLabel(shortTitle, 12, maxLabelLines);
|
|
209
211
|
const longestLine = lines.reduce(
|
|
210
212
|
(max, ln) => ln.length > max ? ln.length : max,
|
|
211
213
|
0
|
|
@@ -346,7 +348,7 @@ function RadarChartCore({
|
|
|
346
348
|
function adaptiveFontSize(longestLineLen, baseFSize) {
|
|
347
349
|
return Math.max(baseFSize, 10);
|
|
348
350
|
}
|
|
349
|
-
function wrapLabel(label, maxChars = 12) {
|
|
351
|
+
function wrapLabel(label, maxChars = 12, maxLines = 2) {
|
|
350
352
|
const str = String(label);
|
|
351
353
|
let rawWords;
|
|
352
354
|
if (str.includes("/")) {
|
|
@@ -371,9 +373,9 @@ function wrapLabel(label, maxChars = 12) {
|
|
|
371
373
|
}
|
|
372
374
|
}
|
|
373
375
|
if (line) lines.push(line);
|
|
374
|
-
if (lines.length >
|
|
375
|
-
const overflow = lines.splice(
|
|
376
|
-
lines[1] = lines[1] + " " + overflow;
|
|
376
|
+
if (lines.length > maxLines) {
|
|
377
|
+
const overflow = lines.splice(maxLines).join(" ");
|
|
378
|
+
lines[maxLines - 1] = lines[maxLines - 1] + " " + overflow;
|
|
377
379
|
}
|
|
378
380
|
return lines;
|
|
379
381
|
}
|
|
@@ -1868,7 +1870,8 @@ function PoliticianCard({
|
|
|
1868
1870
|
style = {},
|
|
1869
1871
|
badge,
|
|
1870
1872
|
imageFocalPoint,
|
|
1871
|
-
footer
|
|
1873
|
+
footer,
|
|
1874
|
+
imageWidth = "90px"
|
|
1872
1875
|
}) {
|
|
1873
1876
|
const isHorizontal = variant === "horizontal";
|
|
1874
1877
|
const handleCardClick = (e) => {
|
|
@@ -1896,20 +1899,25 @@ function PoliticianCard({
|
|
|
1896
1899
|
...style
|
|
1897
1900
|
},
|
|
1898
1901
|
imageWrapper: {
|
|
1899
|
-
|
|
1902
|
+
// Horizontal: relative box whose height comes from the card (flex stretch),
|
|
1903
|
+
// so the photo fills the card height instead of dictating it. Absolutely
|
|
1904
|
+
// positioned children below mean a wider photo can't inflate the card.
|
|
1905
|
+
position: isHorizontal ? "relative" : void 0,
|
|
1906
|
+
width: isHorizontal ? imageWidth : "100%",
|
|
1900
1907
|
height: isHorizontal ? "100%" : "auto",
|
|
1901
|
-
maxHeight: isHorizontal ? "200px" : void 0,
|
|
1902
1908
|
aspectRatio: isHorizontal ? void 0 : "4/5",
|
|
1903
1909
|
flexShrink: 0,
|
|
1904
1910
|
overflow: "hidden"
|
|
1905
1911
|
},
|
|
1906
1912
|
image: {
|
|
1913
|
+
...isHorizontal ? { position: "absolute", top: 0, left: 0 } : {},
|
|
1907
1914
|
width: "100%",
|
|
1908
1915
|
height: "100%",
|
|
1909
1916
|
objectFit: "cover",
|
|
1910
1917
|
objectPosition: imageFocalPoint != null ? imageFocalPoint : "center 20%"
|
|
1911
1918
|
},
|
|
1912
1919
|
imagePlaceholder: {
|
|
1920
|
+
...isHorizontal ? { position: "absolute", top: 0, left: 0 } : {},
|
|
1913
1921
|
width: "100%",
|
|
1914
1922
|
height: "100%",
|
|
1915
1923
|
backgroundColor: colors.evTeal,
|