@podoba/react 0.0.19 → 0.0.21

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": "@podoba/react",
3
- "version": "0.0.19",
3
+ "version": "0.0.21",
4
4
  "type": "module",
5
5
  "description": "podoba React components — React Aria Components + Tailwind primitives + layout, built with uic.",
6
6
  "repository": {
@@ -25,8 +25,8 @@
25
25
  "typecheck": "tsc --build"
26
26
  },
27
27
  "dependencies": {
28
- "@podoba/tokens": "^0.0.19",
29
- "@podoba/tailwind": "^0.0.19",
28
+ "@podoba/tokens": "^0.0.21",
29
+ "@podoba/tailwind": "^0.0.21",
30
30
  "react-aria-components": "1.18.0",
31
31
  "class-variance-authority": "0.7.1",
32
32
  "clsx": "2.1.1",
@@ -40,6 +40,15 @@ export type StatsCardProps = {
40
40
  children?: ReactNode
41
41
  /** Dark/inverted surface (gs's dark "Cloud" tile). */
42
42
  dark?: boolean
43
+ /**
44
+ * Vertical placement of the value band. `center` (default) is gs's
45
+ * `contentAlign="center"` hero-count tile (value fills + centres, footer pinned
46
+ * bottom). `top` sits the value directly under the eyebrow (gs's dark "Summary"
47
+ * data tile) with the footer pushed to the bottom.
48
+ */
49
+ align?: 'center' | 'top'
50
+ /** Mute the value colour (gs's Summary tile — a descriptive title, not a hero count). */
51
+ subtleValue?: boolean
43
52
  /** Accessible label for the clickable card (defaults to nothing — title is read). */
44
53
  'aria-label'?: string
45
54
  className?: string
@@ -61,7 +70,11 @@ function StatsCardBody({
61
70
  badge,
62
71
  description,
63
72
  dark,
64
- }: Pick<StatsCardProps, 'title' | 'value' | 'footer' | 'badge' | 'description' | 'dark'>) {
73
+ align = 'center',
74
+ subtleValue = false,
75
+ }: Pick<StatsCardProps, 'title' | 'value' | 'footer' | 'badge' | 'description' | 'dark' | 'align' | 'subtleValue'>) {
76
+ const isTop = align === 'top'
77
+ const valueTone = dark ? (subtleValue ? 'text-white/60' : 'text-white') : subtleValue ? 'text-fg-muted' : 'text-fg'
65
78
  return (
66
79
  <>
67
80
  <div className="flex items-center justify-between gap-2">
@@ -76,21 +89,27 @@ function StatsCardBody({
76
89
  </span>
77
90
  ) : null}
78
91
  {/*
79
- * gs Tile `contentAlign="center"`: the value sits in the CENTRE band of the
80
- * three-band tile (title top / value centred / footer bottom). The `flex-1`
81
- * band grows to fill the 208px tile and vertically centres the value, pushing
82
- * any footer to the bottom (no `mt-auto` needed). Value ramp = gs label-1
83
- * (1.875rem / 500 / 2rem line). Letter-spacing tracks gs 1:1: light tiles use
84
- * -0.56px via `tracking-wide`; the dark "Cloud" count tile uses gs's em-based
92
+ * `center` (gs `contentAlign="center"`): the value sits in the CENTRE band
93
+ * `flex-1` grows to fill the tile and vertically centres it, pushing any footer
94
+ * to the bottom. `top`: the value sits directly under the eyebrow (no grow) and
95
+ * the footer takes `mt-auto` to stay pinned at the bottom. Value ramp = gs
96
+ * label-1 (1.875rem / 500 / 2rem line). Letter-spacing tracks gs 1:1: light
97
+ * tiles use -0.56px via `tracking-wide`; the dark count tile uses gs's em-based
85
98
  * `-0.02em` (`AssetsTile.module.scss .count`).
86
99
  */}
87
100
  <span
88
- className={`flex flex-1 items-center text-display font-medium leading-[2rem] ${dark ? 'tracking-normal text-white' : 'tracking-wide text-fg'}`}
101
+ className={`flex ${isTop ? 'items-start pt-5' : 'flex-1 items-center'} text-display font-medium leading-[2rem] ${dark ? 'tracking-normal' : 'tracking-wide'} ${valueTone}`}
89
102
  >
90
- {value}
103
+ {/*
104
+ * Inner wrapper is deliberate: the band is a flex container, and flex
105
+ * TRIMS the leading whitespace of an anonymous text run — so a value of
106
+ * `<CountUp/> {' '} unit` collapses to "1version". Nesting the value in one
107
+ * inline span makes it a single flex item, preserving the internal space.
108
+ */}
109
+ <span>{value}</span>
91
110
  </span>
92
111
  {footer ? (
93
- <span className={`pt-4 text-compact leading-4 ${dark ? 'text-white/50' : 'text-fg-muted'}`}>
112
+ <span className={`${isTop ? 'mt-auto ' : ''}pt-4 text-small leading-5 ${dark ? 'text-white/50' : 'text-fg-muted'}`}>
94
113
  {footer}
95
114
  </span>
96
115
  ) : null}
@@ -126,6 +145,8 @@ export function StatsCard({
126
145
  asChild,
127
146
  children,
128
147
  dark,
148
+ align,
149
+ subtleValue,
129
150
  className,
130
151
  ...rest
131
152
  }: StatsCardProps) {
@@ -136,7 +157,7 @@ export function StatsCard({
136
157
  const cardClass = [baseSurface, dark ? darkSkin : lightSkin, anchorInteractive, child.props.className, className]
137
158
  .filter(Boolean)
138
159
  .join(' ')
139
- return cloneElement(child, { className: cardClass } as { className: string }, <StatsCardBody title={title} value={value} footer={footer} badge={badge} description={description} dark={dark} />)
160
+ return cloneElement(child, { className: cardClass } as { className: string }, <StatsCardBody title={title} value={value} footer={footer} badge={badge} description={description} dark={dark} align={align} subtleValue={subtleValue} />)
140
161
  }
141
162
 
142
163
  if (onPress) {
@@ -148,13 +169,13 @@ export function StatsCard({
148
169
  className={[dark ? darkSkin : '', className].filter(Boolean).join(' ')}
149
170
  aria-label={rest['aria-label']}
150
171
  >
151
- <StatsCardBody title={title} value={value} footer={footer} badge={badge} description={description} dark={dark} />
172
+ <StatsCardBody title={title} value={value} footer={footer} badge={badge} description={description} dark={dark} align={align} subtleValue={subtleValue} />
152
173
  </PressableCard>
153
174
  )
154
175
  }
155
176
  return (
156
177
  <div className={[baseSurface, dark ? darkSkin : lightSkin, className].filter(Boolean).join(' ')}>
157
- <StatsCardBody title={title} value={value} footer={footer} badge={badge} description={description} dark={dark} />
178
+ <StatsCardBody title={title} value={value} footer={footer} badge={badge} description={description} dark={dark} align={align} subtleValue={subtleValue} />
158
179
  </div>
159
180
  )
160
181
  }