@humanforest/ui 0.3.2 → 0.3.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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@humanforest/ui",
3
- "version": "0.3.2",
3
+ "version": "0.3.3",
4
4
  "type": "module",
5
5
  "files": [
6
6
  "src",
@@ -9,7 +9,7 @@
9
9
  "preset.gen.js"
10
10
  ],
11
11
  "dependencies": {
12
- "@humanforest/tokens": "^0.3.2",
12
+ "@humanforest/tokens": "^0.3.3",
13
13
  "@internationalized/date": "^3.12.2",
14
14
  "@mapbox/search-js-core": "^1.6.0",
15
15
  "@turf/boolean-point-in-polygon": "^7.4.0",
@@ -117,13 +117,20 @@ const props = withDefaults(
117
117
  * body rather than the card's.
118
118
  */
119
119
  flush?: boolean;
120
+ /**
121
+ * The card fills the height its row gives it instead of hugging its content, so cards in a row
122
+ * end level. Only for content that can take the extra height: an FKpi whose bleed chart is a
123
+ * `fill` sparkline grows into it. A bar, a table or a line of text cannot, and the spare height
124
+ * lands as a gap under it.
125
+ */
126
+ stretch?: boolean;
120
127
 
121
128
  /** Footer action label. `to` makes it a link; without one it is a button. */
122
129
  action?: string;
123
130
  to?: string;
124
131
 
125
132
  }>(),
126
- { gap: 8, outlined: true, bare: false, flush: false },
133
+ { gap: 8, outlined: true, bare: false, flush: false, stretch: false },
127
134
  );
128
135
 
129
136
  const slots = useSlots();
@@ -151,8 +158,11 @@ if (import.meta.env.DEV) {
151
158
  // Set as a var rather than a class so the radius follows it.
152
159
  const style = computed(() => ({ '--forest-card-pad': PAD[props.gap] }));
153
160
 
161
+ // Under `stretch` the body takes whatever height the card is given beyond its strip.
154
162
  const ui = computed(() => ({
155
- body: hasFooter.value ? BODY.footer : hasHeader.value ? BODY.header : BODY.none,
163
+ body: [hasFooter.value ? BODY.footer : hasHeader.value ? BODY.header : BODY.none, props.stretch ? 'flex-1' : '']
164
+ .filter(Boolean)
165
+ .join(' '),
156
166
  header: STRIP.header,
157
167
  footer: STRIP.footer,
158
168
  }));
@@ -175,13 +185,15 @@ const ui = computed(() => ({
175
185
  // ★ `h-fit` IS LOAD-BEARING, not a layout preference. A grid or flex row stretches its children by
176
186
  // default, and a stretched card grows past its content — the extra height lands BELOW the box, so
177
187
  // the even inset turns into a lopsided gap at the bottom and the frame stops reading as a frame.
178
- // The card must hug its content vertically.
188
+ // The card must hug its content vertically. `stretch` drops it for a row whose cards should end
189
+ // level: the card becomes a flex column and its body takes the spare height, which only reads well
190
+ // when the content can grow into it.
179
191
  // ⚠ NOT `self-start`, which was the first cut: `align-self` acts on the CROSS axis, so in a flex
180
192
  // COLUMN it stops the card filling the width instead of capping its height — the card shrank to its
181
193
  // content in every column layout. `h-fit` caps the height and leaves width alone, which is the axis
182
194
  // actually at issue.
183
195
  const rootClass = computed(() =>
184
- ['h-fit', props.outlined ? 'ring ring-[var(--forest-card-ring)]' : ''].filter(Boolean).join(' '),
196
+ [props.stretch ? 'flex flex-col' : 'h-fit', props.outlined ? 'ring ring-[var(--forest-card-ring)]' : ''].filter(Boolean).join(' '),
185
197
  );
186
198
 
187
199
  // ★ THE BOX IS ALWAYS RAISED — there is no ramp option, on purpose. Letting the nesting ladder fill
@@ -197,7 +209,7 @@ const rootClass = computed(() =>
197
209
  // pads at ≥640px. The box keeps its own overflow-hidden either way, which is what clips a flush
198
210
  // child to the rounded corner; a child that must scroll (UTable) already scrolls itself.
199
211
  const boxUi = computed(() => ({
200
- root: `bg-[var(--forest-card-inset)] ${PAD_CLASS[props.gap]}`,
212
+ root: `bg-[var(--forest-card-inset)] ${PAD_CLASS[props.gap]}${props.stretch ? ' h-full' : ''}`,
201
213
  ...(props.flush ? { body: 'p-0 sm:p-0' } : {}),
202
214
  }));
203
215
 
@@ -209,7 +221,7 @@ const boxUi = computed(() => ({
209
221
  // expression, so `visual-fit="bleed"` still zeroes the bottom and meets both edges. A padding
210
222
  // class cannot do this: FKpi merges `ui.root` last, so a `pb-4` here would beat the bleed's `pb-0`.
211
223
  const selfBoxUi = computed(() => ({
212
- root: `bg-[var(--forest-card-inset)] [--forest-kpi-pad:1rem] ${PAD_CLASS[props.gap]}`,
224
+ root: `bg-[var(--forest-card-inset)] [--forest-kpi-pad:1rem] ${PAD_CLASS[props.gap]}${props.stretch ? ' h-full' : ''}`,
213
225
  }));
214
226
  </script>
215
227
 
@@ -22,8 +22,8 @@ export const kpiTheme = tv({
22
22
  // bleed pulls by the same expression, so the graphic meets the edge the padding leaves.
23
23
  //
24
24
  // No row template: the rows are implicit, one per part present, so a tile without a visual has
25
- // no empty track under its caption, and no gap in front of one. A grouped tile takes its rows
26
- // from the group instead (`aligned`).
25
+ // no empty track under its caption, and no gap in front of one. A bleed visual adds a flexible
26
+ // last row (`visualFit`); a grouped tile takes its rows from the group instead (`aligned`).
27
27
  //
28
28
  // One explicit minmax(0,1fr) column: without it the implicit column sizes to max-content, and a
29
29
  // chart with an intrinsic width (Unovis defaults to 300px) makes the tile's own grid wider than
@@ -81,7 +81,10 @@ export const kpiTheme = tv({
81
81
  * `bleed` (the default) is for a graphic that IS data and nothing else, a sparkline being the
82
82
  * case: it runs through the tile's gutter to both side edges and sits on the bottom edge, which
83
83
  * the tile reaches by zeroing its own bottom padding rather than by a negative margin — a
84
- * margin would shrink the grid row and pull the graphic up over the caption.
84
+ * margin would shrink the grid row and pull the graphic up over the caption. Its row is the
85
+ * tile's last and flexible one, and the graphic spans it bottom-aligned: a tile given more
86
+ * height than it needs — a group's shared row, a stretched FInsetCard — grows a `fill`
87
+ * sparkline into the spare height and leaves any other graphic on the bottom edge.
85
88
  *
86
89
  * `inset` is for a graphic carrying text, FDistributionBar's legend being the case. Text set
87
90
  * against the card's edge reads as a mistake, so the padding stays. It also top-aligns, and
@@ -89,7 +92,7 @@ export const kpiTheme = tv({
89
92
  * content keeps the extra height below the graphic rather than spread between its rows.
90
93
  */
91
94
  visualFit: {
92
- bleed: { root: 'pb-0', visual: 'self-end -mx-[var(--forest-kpi-pad,var(--forest-card-pad))]' },
95
+ bleed: { root: 'pb-0 grid-rows-[auto_auto_auto_1fr]', visual: 'self-stretch flex flex-col justify-end -mx-[var(--forest-kpi-pad,var(--forest-card-pad))]' },
93
96
  inset: { root: 'content-start', visual: 'self-start' },
94
97
  },
95
98
  // A grouped tile spans exactly the rows its group declares (kpiGroupRows), so a group with no