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