@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 CHANGED
@@ -136,7 +136,8 @@ function RadarChartCore({
136
136
  labelFontSize = 18,
137
137
  padding = 80,
138
138
  labelOffset = 20,
139
- tightFit = false
139
+ tightFit = false,
140
+ maxLabelLines = 2
140
141
  }) {
141
142
  const { isDark } = useTheme();
142
143
  const radius = size / 2 - 40;
@@ -203,7 +204,7 @@ function RadarChartCore({
203
204
  const labelMeta = spokes.map(([shortTitle], i) => {
204
205
  const angle = 2 * Math.PI * i / numSpokes;
205
206
  const baseFSize = labelFontSize;
206
- const lines = wrapLabel(shortTitle, 12);
207
+ const lines = wrapLabel(shortTitle, 12, maxLabelLines);
207
208
  const longestLineLen = lines.reduce(
208
209
  (max, ln) => ln.length > max ? ln.length : max,
209
210
  0
@@ -246,7 +247,8 @@ function RadarChartCore({
246
247
  if (y < yMin) yMin = y;
247
248
  if (y > yMax) yMax = y;
248
249
  }
249
- const labelMargin = labelOffset + labelFontSize * 1.4 + labelFontSize * 1.1;
250
+ const effLabelFSize = adaptiveFontSize(12, labelFontSize);
251
+ const labelMargin = labelOffset + effLabelFSize * 1.1 * maxLabelLines;
250
252
  tightTop = yMin - labelMargin;
251
253
  tightHeight = yMax + labelMargin - tightTop;
252
254
  }
@@ -298,7 +300,7 @@ function RadarChartCore({
298
300
  const isTop = cosA > 0.5;
299
301
  const isBottom = cosA < -0.5;
300
302
  const baseFSize = labelFontSize;
301
- const lines = wrapLabel(shortTitle, 12);
303
+ const lines = wrapLabel(shortTitle, 12, maxLabelLines);
302
304
  const longestLine = lines.reduce(
303
305
  (max, ln) => ln.length > max ? ln.length : max,
304
306
  0
@@ -439,7 +441,7 @@ function RadarChartCore({
439
441
  function adaptiveFontSize(longestLineLen, baseFSize) {
440
442
  return Math.max(baseFSize, 10);
441
443
  }
442
- function wrapLabel(label, maxChars = 12) {
444
+ function wrapLabel(label, maxChars = 12, maxLines = 2) {
443
445
  const str = String(label);
444
446
  let rawWords;
445
447
  if (str.includes("/")) {
@@ -464,9 +466,9 @@ function wrapLabel(label, maxChars = 12) {
464
466
  }
465
467
  }
466
468
  if (line) lines.push(line);
467
- if (lines.length > 2) {
468
- const overflow = lines.splice(2).join(" ");
469
- lines[1] = lines[1] + " " + overflow;
469
+ if (lines.length > maxLines) {
470
+ const overflow = lines.splice(maxLines).join(" ");
471
+ lines[maxLines - 1] = lines[maxLines - 1] + " " + overflow;
470
472
  }
471
473
  return lines;
472
474
  }
@@ -1961,7 +1963,8 @@ function PoliticianCard({
1961
1963
  style = {},
1962
1964
  badge,
1963
1965
  imageFocalPoint,
1964
- footer
1966
+ footer,
1967
+ imageWidth = "90px"
1965
1968
  }) {
1966
1969
  const isHorizontal = variant === "horizontal";
1967
1970
  const handleCardClick = (e) => {
@@ -1989,20 +1992,25 @@ function PoliticianCard({
1989
1992
  ...style
1990
1993
  },
1991
1994
  imageWrapper: {
1992
- width: isHorizontal ? "90px" : "100%",
1995
+ // Horizontal: relative box whose height comes from the card (flex stretch),
1996
+ // so the photo fills the card height instead of dictating it. Absolutely
1997
+ // positioned children below mean a wider photo can't inflate the card.
1998
+ position: isHorizontal ? "relative" : void 0,
1999
+ width: isHorizontal ? imageWidth : "100%",
1993
2000
  height: isHorizontal ? "100%" : "auto",
1994
- maxHeight: isHorizontal ? "200px" : void 0,
1995
2001
  aspectRatio: isHorizontal ? void 0 : "4/5",
1996
2002
  flexShrink: 0,
1997
2003
  overflow: "hidden"
1998
2004
  },
1999
2005
  image: {
2006
+ ...isHorizontal ? { position: "absolute", top: 0, left: 0 } : {},
2000
2007
  width: "100%",
2001
2008
  height: "100%",
2002
2009
  objectFit: "cover",
2003
2010
  objectPosition: imageFocalPoint != null ? imageFocalPoint : "center 20%"
2004
2011
  },
2005
2012
  imagePlaceholder: {
2013
+ ...isHorizontal ? { position: "absolute", top: 0, left: 0 } : {},
2006
2014
  width: "100%",
2007
2015
  height: "100%",
2008
2016
  backgroundColor: colors.evTeal,