@oxy.so/bloom 22.1.4 → 22.1.5

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.
Files changed (45) hide show
  1. package/docs/adoption-matrix.mdx +3 -3
  2. package/docs/list.mdx +2 -0
  3. package/docs/page-header.mdx +7 -5
  4. package/docs/task-catalog.json +1 -1
  5. package/docs/task-catalog.mdx +1 -1
  6. package/docs/verification.mdx +27 -0
  7. package/lib/commonjs/list/ListItemBase.js +18 -2
  8. package/lib/commonjs/list/ListItemBase.js.map +1 -1
  9. package/lib/commonjs/page-footer/PageFooter.js +1 -0
  10. package/lib/commonjs/page-footer/PageFooter.js.map +1 -1
  11. package/lib/commonjs/page-header/EdgeScrim.js +38 -10
  12. package/lib/commonjs/page-header/EdgeScrim.js.map +1 -1
  13. package/lib/commonjs/page-header/PageHeader.js +1 -0
  14. package/lib/commonjs/page-header/PageHeader.js.map +1 -1
  15. package/lib/module/list/ListItemBase.js +19 -3
  16. package/lib/module/list/ListItemBase.js.map +1 -1
  17. package/lib/module/page-footer/PageFooter.js +2 -1
  18. package/lib/module/page-footer/PageFooter.js.map +1 -1
  19. package/lib/module/page-header/EdgeScrim.js +37 -9
  20. package/lib/module/page-header/EdgeScrim.js.map +1 -1
  21. package/lib/module/page-header/PageHeader.js +2 -1
  22. package/lib/module/page-header/PageHeader.js.map +1 -1
  23. package/lib/typescript/commonjs/list/ListItemBase.d.ts.map +1 -1
  24. package/lib/typescript/commonjs/page-footer/PageFooter.d.ts.map +1 -1
  25. package/lib/typescript/commonjs/page-footer/types.d.ts +1 -1
  26. package/lib/typescript/commonjs/page-header/EdgeScrim.d.ts +14 -6
  27. package/lib/typescript/commonjs/page-header/EdgeScrim.d.ts.map +1 -1
  28. package/lib/typescript/commonjs/page-header/PageHeader.d.ts.map +1 -1
  29. package/lib/typescript/commonjs/page-header/types.d.ts +1 -1
  30. package/lib/typescript/commonjs/page-header/types.d.ts.map +1 -1
  31. package/lib/typescript/module/list/ListItemBase.d.ts.map +1 -1
  32. package/lib/typescript/module/page-footer/PageFooter.d.ts.map +1 -1
  33. package/lib/typescript/module/page-footer/types.d.ts +1 -1
  34. package/lib/typescript/module/page-header/EdgeScrim.d.ts +14 -6
  35. package/lib/typescript/module/page-header/EdgeScrim.d.ts.map +1 -1
  36. package/lib/typescript/module/page-header/PageHeader.d.ts.map +1 -1
  37. package/lib/typescript/module/page-header/types.d.ts +1 -1
  38. package/lib/typescript/module/page-header/types.d.ts.map +1 -1
  39. package/package.json +1 -1
  40. package/src/list/ListItemBase.tsx +21 -3
  41. package/src/page-footer/PageFooter.tsx +2 -1
  42. package/src/page-footer/types.ts +1 -1
  43. package/src/page-header/EdgeScrim.tsx +49 -10
  44. package/src/page-header/PageHeader.tsx +2 -1
  45. package/src/page-header/types.ts +1 -1
@@ -30,12 +30,13 @@ import { withAlpha } from '../theme/color-utils';
30
30
  *
31
31
  * ── THE STOPS ───────────────────────────────────────────────────────────────
32
32
  *
33
- * Four of them, shaped as an ease-out rather than a straight line. A LINEAR
33
+ * Four of them describe the fading portion, after any opaque chrome region.
34
+ * They are shaped as an ease-out rather than a straight line. A LINEAR
34
35
  * ramp of opacity is perceptually not linear: it holds too much colour through
35
36
  * the middle and then falls off visibly in the last fifth, which puts a soft
36
37
  * but findable band across the content. Weighting the fall earlier spends the
37
- * gradient's height where the eye is looking — the region behind the title —
38
- * and arrives at zero gently.
38
+ * fading portion's height and arrives at zero gently. Header/footer chrome
39
+ * stays opaque before that portion so scrolling text cannot cross its labels.
39
40
  *
40
41
  * `TAIL_RATIO` extends the ramp BELOW the header's own box. The header is as
41
42
  * tall as its islands plus its padding; the fade needs room after that, or it
@@ -75,12 +76,13 @@ import { withAlpha } from '../theme/color-utils';
75
76
 
76
77
  /** How far past the header's own height the fade continues, as a ratio of it. */
77
78
  export const SCRIM_TAIL_RATIO = 0.55;
79
+ /** Measured chrome occupies this fraction of its chrome + external tail box. */
80
+ export const SCRIM_CHROME_FRACTION = 1 / (1 + SCRIM_TAIL_RATIO);
78
81
 
79
82
  /**
80
83
  * Offset down the ramp -> how much of the page colour survives there.
81
84
  *
82
- * Read as: solid behind the title, nine tenths gone by three quarters of the
83
- * way down, nothing at the bottom.
85
+ * Applied to the fading portion only; any opaque chrome region precedes it.
84
86
  */
85
87
  export const SCRIM_STOPS = [
86
88
  { offset: 0, opacity: 1 },
@@ -105,9 +107,34 @@ export interface EdgeScrimProps {
105
107
  edge?: 'top' | 'bottom';
106
108
  /** Smooth legibility curve by default; linear has only the opaque and transparent endpoints. */
107
109
  falloff?: 'smooth' | 'linear';
110
+ /**
111
+ * Fraction of the gradient box kept opaque from its anchored edge, in [0, 1].
112
+ * Defaults to 0 for a full-box fade. Header/footer supply their measured
113
+ * chrome's share of the box; the curve then occupies only the external tail.
114
+ */
115
+ opaqueFraction?: number;
108
116
  testID?: string;
109
117
  }
110
118
 
119
+ /** Both renderers use the same normalized positions, including the solid region. */
120
+ function scrimStops(falloff: 'smooth' | 'linear', opaqueFraction: number) {
121
+ const fraction = Number.isFinite(opaqueFraction) ? Math.max(0, Math.min(1, opaqueFraction)) : 0;
122
+ const stops = falloff === 'linear' ? LINEAR_STOPS : SCRIM_STOPS;
123
+ if (fraction === 0) return stops;
124
+ if (fraction === 1)
125
+ return [
126
+ { offset: 0, opacity: 1 },
127
+ { offset: 1, opacity: 1 },
128
+ ];
129
+ return [
130
+ { offset: 0, opacity: 1 },
131
+ ...stops.map((stop) => ({
132
+ offset: fraction + (1 - fraction) * stop.offset,
133
+ opacity: stop.opacity,
134
+ })),
135
+ ];
136
+ }
137
+
111
138
  /**
112
139
  * The ramp as a CSS gradient, for Android's own `experimental_backgroundImage`.
113
140
  *
@@ -122,9 +149,11 @@ export function edgeScrimGradient(
122
149
  color: string,
123
150
  edge: 'top' | 'bottom',
124
151
  falloff: 'smooth' | 'linear' = 'smooth',
152
+ opaqueFraction = 0,
125
153
  ): string {
126
- const stops = (falloff === 'linear' ? LINEAR_STOPS : SCRIM_STOPS)
127
- .map((stop) => `${withAlpha(color, stop.opacity)} ${Math.round(stop.offset * 100)}%`)
154
+ const stops = scrimStops(falloff, opaqueFraction)
155
+ // Keep fractional positions: rounding down can expose the last chrome pixels.
156
+ .map((stop) => `${withAlpha(color, stop.opacity)} ${stop.offset * 100}%`)
128
157
  .join(', ');
129
158
  return `linear-gradient(to ${edge === 'bottom' ? 'top' : 'bottom'}, ${stops})`;
130
159
  }
@@ -133,6 +162,7 @@ const EdgeScrimComponent: React.FC<EdgeScrimProps> = ({
133
162
  color,
134
163
  edge = 'top',
135
164
  falloff = 'smooth',
165
+ opaqueFraction = 0,
136
166
  testID,
137
167
  }) => {
138
168
  if (Platform.OS === 'android') {
@@ -141,18 +171,27 @@ const EdgeScrimComponent: React.FC<EdgeScrimProps> = ({
141
171
  testID={testID}
142
172
  style={[
143
173
  StyleSheet.absoluteFill,
144
- { experimental_backgroundImage: edgeScrimGradient(color, edge, falloff) },
174
+ { experimental_backgroundImage: edgeScrimGradient(color, edge, falloff, opaqueFraction) },
145
175
  ]}
146
176
  />
147
177
  );
148
178
  }
149
- return <SvgEdgeScrim color={color} edge={edge} falloff={falloff} testID={testID} />;
179
+ return (
180
+ <SvgEdgeScrim
181
+ color={color}
182
+ edge={edge}
183
+ falloff={falloff}
184
+ opaqueFraction={opaqueFraction}
185
+ testID={testID}
186
+ />
187
+ );
150
188
  };
151
189
 
152
190
  const SvgEdgeScrim: React.FC<EdgeScrimProps> = ({
153
191
  color,
154
192
  edge = 'top',
155
193
  falloff = 'smooth',
194
+ opaqueFraction = 0,
156
195
  testID,
157
196
  }) => {
158
197
  const id = `${useSvgIdPrefix('bloom-page-header-scrim')}gradient`;
@@ -167,7 +206,7 @@ const SvgEdgeScrim: React.FC<EdgeScrimProps> = ({
167
206
  x2="0"
168
207
  y2={fromBottom ? '0' : '1'}
169
208
  >
170
- {(falloff === 'linear' ? LINEAR_STOPS : SCRIM_STOPS).map((stop) => (
209
+ {scrimStops(falloff, opaqueFraction).map((stop) => (
171
210
  <Stop
172
211
  key={stop.offset}
173
212
  offset={String(stop.offset)}
@@ -59,7 +59,7 @@ import { useSurfaceFillRecipe } from '../styles/surface-levels';
59
59
  import { Title, Subtitle } from '../typography';
60
60
  import { Surface } from '../surface/Surface';
61
61
  import { PageHeaderIdentity } from './PageHeaderIdentity';
62
- import { EdgeScrim, SCRIM_TAIL_RATIO } from './EdgeScrim';
62
+ import { EdgeScrim, SCRIM_CHROME_FRACTION, SCRIM_TAIL_RATIO } from './EdgeScrim';
63
63
  import type { PageHeaderProps } from './types';
64
64
  import { useCommonMessages } from '../locale/common-messages';
65
65
  import { useCssSafeAreaInsets } from '../hooks/use-css-safe-area-insets';
@@ -886,6 +886,7 @@ function PageHeaderComponent({
886
886
  // falling back to the page. Explicit scrimColor remains an override.
887
887
  color={scrimColor ?? (imageScrim ? '#000000' : surfaceFill)}
888
888
  falloff={scrimFalloff}
889
+ opaqueFraction={tone !== 'onImage' && scrimFalloff === 'smooth' ? SCRIM_CHROME_FRACTION : 0}
889
890
  testID={testID ? `${testID}-scrim-gradient` : undefined}
890
891
  />
891
892
  </Animated.View>
@@ -170,7 +170,7 @@ export interface PageHeaderProps {
170
170
  transparent?: boolean;
171
171
  /** `presentation="floating"` only. Default `auto`. */
172
172
  scrim?: PageHeaderScrim;
173
- /** Floating gradient curve. Default smooth; linear fades uniformly from opaque to transparent. */
173
+ /** Default smooth protects measured chrome and fades outside it; linear/onImage fade across the full box. */
174
174
  scrimFalloff?: 'smooth' | 'linear';
175
175
  /**
176
176
  * The colour the edge effect fades FROM. Defaults to `theme.colors.background`