@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.mjs
CHANGED
|
@@ -44,7 +44,8 @@ function RadarChartCore({
|
|
|
44
44
|
padding = 80,
|
|
45
45
|
labelOffset = 20,
|
|
46
46
|
tightFit = false,
|
|
47
|
-
maxLabelLines = 2
|
|
47
|
+
maxLabelLines = 2,
|
|
48
|
+
showLabels = true
|
|
48
49
|
}) {
|
|
49
50
|
const { isDark } = useTheme();
|
|
50
51
|
const radius = size / 2 - 40;
|
|
@@ -110,6 +111,9 @@ function RadarChartCore({
|
|
|
110
111
|
});
|
|
111
112
|
const labelMeta = spokes.map(([shortTitle], i) => {
|
|
112
113
|
const angle = 2 * Math.PI * i / numSpokes;
|
|
114
|
+
const sinA = Math.sin(angle);
|
|
115
|
+
const side = sinA < -0.1 ? "left" : sinA > 0.1 ? "right" : "center";
|
|
116
|
+
if (!showLabels) return { estimatedWidth: 0, side };
|
|
113
117
|
const baseFSize = labelFontSize;
|
|
114
118
|
const lines = wrapLabel(shortTitle, 12, maxLabelLines);
|
|
115
119
|
const longestLineLen = lines.reduce(
|
|
@@ -118,13 +122,11 @@ function RadarChartCore({
|
|
|
118
122
|
);
|
|
119
123
|
const fSize = adaptiveFontSize(longestLineLen, baseFSize);
|
|
120
124
|
const estimatedWidth = longestLineLen * fSize * 0.6;
|
|
121
|
-
const sinA = Math.sin(angle);
|
|
122
|
-
const side = sinA < -0.1 ? "left" : sinA > 0.1 ? "right" : "center";
|
|
123
125
|
return { estimatedWidth, side };
|
|
124
126
|
});
|
|
125
127
|
const leftLabelWidths = labelMeta.filter((m) => m.side === "left").map((m) => m.estimatedWidth);
|
|
126
128
|
const rightLabelWidths = labelMeta.filter((m) => m.side === "right").map((m) => m.estimatedWidth);
|
|
127
|
-
const minPadding = 40;
|
|
129
|
+
const minPadding = showLabels ? 40 : 10;
|
|
128
130
|
const maxPadding = padding * 2;
|
|
129
131
|
const rawLeftPadding = Math.min(
|
|
130
132
|
Math.max(
|
|
@@ -155,7 +157,7 @@ function RadarChartCore({
|
|
|
155
157
|
if (y > yMax) yMax = y;
|
|
156
158
|
}
|
|
157
159
|
const effLabelFSize = adaptiveFontSize(12, labelFontSize);
|
|
158
|
-
const labelMargin = labelOffset + effLabelFSize * 1.1 * maxLabelLines;
|
|
160
|
+
const labelMargin = showLabels ? labelOffset + effLabelFSize * 1.1 * maxLabelLines : 8;
|
|
159
161
|
tightTop = yMin - labelMargin;
|
|
160
162
|
tightHeight = yMax + labelMargin - tightTop;
|
|
161
163
|
}
|
|
@@ -200,7 +202,7 @@ function RadarChartCore({
|
|
|
200
202
|
}
|
|
201
203
|
);
|
|
202
204
|
}),
|
|
203
|
-
spokes.map(([shortTitle], i) => {
|
|
205
|
+
showLabels && spokes.map(([shortTitle], i) => {
|
|
204
206
|
const angle = 2 * Math.PI * i / numSpokes;
|
|
205
207
|
const anchor = angle > Math.PI ? "end" : angle < Math.PI && angle > 0 ? "start" : "middle";
|
|
206
208
|
const cosA = Math.cos(angle);
|
|
@@ -1871,9 +1873,12 @@ function PoliticianCard({
|
|
|
1871
1873
|
badge,
|
|
1872
1874
|
imageFocalPoint,
|
|
1873
1875
|
footer,
|
|
1874
|
-
imageWidth = "90px"
|
|
1876
|
+
imageWidth = "90px",
|
|
1877
|
+
contentStyle = {}
|
|
1875
1878
|
}) {
|
|
1876
1879
|
const isHorizontal = variant === "horizontal";
|
|
1880
|
+
const imageWidthPx = parseInt(imageWidth, 10) || 90;
|
|
1881
|
+
const imageMinHeight = isHorizontal ? Math.ceil(imageWidthPx * 4 / 3) : void 0;
|
|
1877
1882
|
const handleCardClick = (e) => {
|
|
1878
1883
|
if (e.target.closest(".ev-compass-button")) return;
|
|
1879
1884
|
onClick == null ? void 0 : onClick();
|
|
@@ -1894,15 +1899,14 @@ function PoliticianCard({
|
|
|
1894
1899
|
cursor: onClick ? "pointer" : "default",
|
|
1895
1900
|
transition: "box-shadow 0.2s ease, transform 0.2s ease",
|
|
1896
1901
|
position: "relative",
|
|
1897
|
-
minHeight:
|
|
1902
|
+
minHeight: imageMinHeight,
|
|
1898
1903
|
height: "100%",
|
|
1899
1904
|
...style
|
|
1900
1905
|
},
|
|
1901
1906
|
imageWrapper: {
|
|
1902
|
-
// Horizontal:
|
|
1903
|
-
//
|
|
1904
|
-
|
|
1905
|
-
position: isHorizontal ? "relative" : void 0,
|
|
1907
|
+
// Horizontal: fixed width with 3:4 aspect ratio so portrait photos look
|
|
1908
|
+
// consistent regardless of card content height.
|
|
1909
|
+
position: "relative",
|
|
1906
1910
|
width: isHorizontal ? imageWidth : "100%",
|
|
1907
1911
|
height: isHorizontal ? "100%" : "auto",
|
|
1908
1912
|
aspectRatio: isHorizontal ? void 0 : "4/5",
|
|
@@ -1935,7 +1939,8 @@ function PoliticianCard({
|
|
|
1935
1939
|
padding: isHorizontal ? `${spacing[2]} ${spacing[3]}` : spacing[3],
|
|
1936
1940
|
minWidth: 0,
|
|
1937
1941
|
display: "flex",
|
|
1938
|
-
flexDirection: "column"
|
|
1942
|
+
flexDirection: "column",
|
|
1943
|
+
...contentStyle
|
|
1939
1944
|
},
|
|
1940
1945
|
name: {
|
|
1941
1946
|
fontFamily: fonts.primary,
|