@oxy.so/bloom 1.0.6 → 1.0.8

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 (73) hide show
  1. package/docs/fab.mdx +6 -0
  2. package/docs/theme.mdx +19 -0
  3. package/docs/user-hover-card.mdx +59 -10
  4. package/lib/commonjs/avatar-group/AvatarGroup.web.js +4 -1
  5. package/lib/commonjs/avatar-group/AvatarGroup.web.js.map +1 -1
  6. package/lib/commonjs/fab/Fab.web.js +21 -10
  7. package/lib/commonjs/fab/Fab.web.js.map +1 -1
  8. package/lib/commonjs/theme/BloomThemeProvider.js +2 -0
  9. package/lib/commonjs/theme/BloomThemeProvider.js.map +1 -1
  10. package/lib/commonjs/theme/apply-dark-class.js +37 -0
  11. package/lib/commonjs/theme/apply-dark-class.js.map +1 -1
  12. package/lib/commonjs/user-hover-card/UserHoverCard.js +33 -12
  13. package/lib/commonjs/user-hover-card/UserHoverCard.js.map +1 -1
  14. package/lib/commonjs/user-hover-card/constants.js +45 -0
  15. package/lib/commonjs/user-hover-card/constants.js.map +1 -0
  16. package/lib/commonjs/user-hover-card/index.js +19 -0
  17. package/lib/commonjs/user-hover-card/index.js.map +1 -1
  18. package/lib/module/avatar-group/AvatarGroup.web.js +5 -2
  19. package/lib/module/avatar-group/AvatarGroup.web.js.map +1 -1
  20. package/lib/module/fab/Fab.web.js +21 -10
  21. package/lib/module/fab/Fab.web.js.map +1 -1
  22. package/lib/module/fab/index.web.js +2 -2
  23. package/lib/module/theme/BloomThemeProvider.js +3 -1
  24. package/lib/module/theme/BloomThemeProvider.js.map +1 -1
  25. package/lib/module/theme/apply-dark-class.js +36 -0
  26. package/lib/module/theme/apply-dark-class.js.map +1 -1
  27. package/lib/module/user-hover-card/UserHoverCard.js +33 -12
  28. package/lib/module/user-hover-card/UserHoverCard.js.map +1 -1
  29. package/lib/module/user-hover-card/constants.js +42 -0
  30. package/lib/module/user-hover-card/constants.js.map +1 -0
  31. package/lib/module/user-hover-card/index.js +1 -0
  32. package/lib/module/user-hover-card/index.js.map +1 -1
  33. package/lib/typescript/commonjs/avatar-group/AvatarGroup.web.d.ts.map +1 -1
  34. package/lib/typescript/commonjs/fab/Fab.web.d.ts.map +1 -1
  35. package/lib/typescript/commonjs/fab/types.d.ts +7 -5
  36. package/lib/typescript/commonjs/fab/types.d.ts.map +1 -1
  37. package/lib/typescript/commonjs/icons/shared.d.ts +4 -4
  38. package/lib/typescript/commonjs/theme/BloomThemeProvider.d.ts.map +1 -1
  39. package/lib/typescript/commonjs/theme/apply-dark-class.d.ts +8 -0
  40. package/lib/typescript/commonjs/theme/apply-dark-class.d.ts.map +1 -1
  41. package/lib/typescript/commonjs/user-hover-card/UserHoverCard.d.ts.map +1 -1
  42. package/lib/typescript/commonjs/user-hover-card/constants.d.ts +35 -0
  43. package/lib/typescript/commonjs/user-hover-card/constants.d.ts.map +1 -0
  44. package/lib/typescript/commonjs/user-hover-card/index.d.ts +1 -0
  45. package/lib/typescript/commonjs/user-hover-card/index.d.ts.map +1 -1
  46. package/lib/typescript/commonjs/user-hover-card/types.d.ts +35 -6
  47. package/lib/typescript/commonjs/user-hover-card/types.d.ts.map +1 -1
  48. package/lib/typescript/module/avatar-group/AvatarGroup.web.d.ts.map +1 -1
  49. package/lib/typescript/module/fab/Fab.web.d.ts.map +1 -1
  50. package/lib/typescript/module/fab/types.d.ts +7 -5
  51. package/lib/typescript/module/fab/types.d.ts.map +1 -1
  52. package/lib/typescript/module/icons/shared.d.ts +4 -4
  53. package/lib/typescript/module/theme/BloomThemeProvider.d.ts.map +1 -1
  54. package/lib/typescript/module/theme/apply-dark-class.d.ts +8 -0
  55. package/lib/typescript/module/theme/apply-dark-class.d.ts.map +1 -1
  56. package/lib/typescript/module/user-hover-card/UserHoverCard.d.ts.map +1 -1
  57. package/lib/typescript/module/user-hover-card/constants.d.ts +35 -0
  58. package/lib/typescript/module/user-hover-card/constants.d.ts.map +1 -0
  59. package/lib/typescript/module/user-hover-card/index.d.ts +1 -0
  60. package/lib/typescript/module/user-hover-card/index.d.ts.map +1 -1
  61. package/lib/typescript/module/user-hover-card/types.d.ts +35 -6
  62. package/lib/typescript/module/user-hover-card/types.d.ts.map +1 -1
  63. package/package.json +1 -1
  64. package/src/avatar-group/AvatarGroup.web.tsx +5 -2
  65. package/src/fab/Fab.web.tsx +20 -9
  66. package/src/fab/index.web.ts +2 -2
  67. package/src/fab/types.ts +7 -5
  68. package/src/theme/BloomThemeProvider.tsx +3 -1
  69. package/src/theme/apply-dark-class.ts +38 -0
  70. package/src/user-hover-card/UserHoverCard.tsx +40 -16
  71. package/src/user-hover-card/constants.ts +40 -0
  72. package/src/user-hover-card/index.ts +5 -0
  73. package/src/user-hover-card/types.ts +35 -6
@@ -12,6 +12,7 @@ import { Card } from '../card';
12
12
  import { VerifiedCheck } from '../icons/VerifiedCheck';
13
13
  import { useTheme } from '../theme/use-theme';
14
14
  import { fontSize, space } from '../styles/tokens';
15
+ import { USER_HOVER_CARD_INSET, USER_HOVER_CARD_WIDTH } from './constants';
15
16
  import type { UserHoverCardProps } from './types';
16
17
 
17
18
  const AVATAR_SIZE = 48;
@@ -27,6 +28,7 @@ const UserHoverCardComponent: React.FC<UserHoverCardProps> = ({
27
28
  verified = false,
28
29
  onPressProfile,
29
30
  action,
31
+ badge,
30
32
  footer,
31
33
  style,
32
34
  testID,
@@ -34,12 +36,14 @@ const UserHoverCardComponent: React.FC<UserHoverCardProps> = ({
34
36
  const theme = useTheme();
35
37
 
36
38
  // Layout only — the chrome (card background, hairline border, `shadow-m`, the
37
- // `radius-16` rung) is `Card`'s. `overflow: 'visible'` restores the RN default
38
- // that `Card` overrides: this card clips nothing, and leaving it hidden would
39
- // change what an Android elevation draws under a rounded, clipped view.
39
+ // `radius-16` rung) is `Card`'s. Both reasons `docs/card.mdx` gives for opting
40
+ // out of its clip apply here: this card carries an Android elevation, AND its
41
+ // two consumer slots may hold something that deliberately overflows (a
42
+ // tooltip, a popover). Clipping would silently truncate slot content instead;
43
+ // the width is published so it does not have to come to that.
40
44
  const layoutStyle: ViewStyle = {
41
- padding: space.lg,
42
- width: 280,
45
+ padding: USER_HOVER_CARD_INSET,
46
+ width: USER_HOVER_CARD_WIDTH,
43
47
  overflow: 'visible',
44
48
  };
45
49
 
@@ -64,13 +68,20 @@ const UserHoverCardComponent: React.FC<UserHoverCardProps> = ({
64
68
  />
65
69
  )}
66
70
  </View>
67
- {username ? (
68
- <Text
69
- numberOfLines={1}
70
- style={[styles.username, { color: theme.colors.textSecondary }]}
71
- >
72
- @{username}
73
- </Text>
71
+ {username || badge != null ? (
72
+ <View style={styles.handleRow}>
73
+ {username ? (
74
+ <Text
75
+ numberOfLines={1}
76
+ style={[styles.username, { color: theme.colors.textSecondary }]}
77
+ >
78
+ @{username}
79
+ </Text>
80
+ ) : null}
81
+ {/* The badge is a fact about the ACCOUNT, not about the handle, so
82
+ it renders even for a user with no handle to sit beside. */}
83
+ {badge != null ? <View style={styles.badge}>{badge}</View> : null}
84
+ </View>
74
85
  ) : null}
75
86
  </View>
76
87
  </View>
@@ -132,9 +143,11 @@ const UserHoverCardComponent: React.FC<UserHoverCardProps> = ({
132
143
  ) : null}
133
144
 
134
145
  {/* The consumer's own content. It is a SIBLING of the identity
135
- `Pressable`, not a child, so a button inside it keeps its own press
136
- instead of firing `onPressProfile`, and assistive technology reads it
137
- as content rather than folding it into the identity button's name. */}
146
+ `Pressable`, not a child: nested, a press on anything in it that is not
147
+ itself pressable would open the profile, and on web it would sit inside
148
+ a real `<button>`, where interactive content is invalid HTML. (The
149
+ card's accessible NAME is not at stake either way — the identity area
150
+ has an explicit label, which wins over contents.) */}
138
151
  {footer != null ? <View style={styles.footer}>{footer}</View> : null}
139
152
  </Card>
140
153
  );
@@ -173,9 +186,20 @@ const styles = StyleSheet.create({
173
186
  verifiedBadge: {
174
187
  flexShrink: 0,
175
188
  },
189
+ handleRow: {
190
+ flexDirection: 'row',
191
+ alignItems: 'center',
192
+ gap: space.xs,
193
+ marginTop: space._2xs,
194
+ },
176
195
  username: {
177
196
  fontSize: fontSize.sm,
178
- marginTop: space._2xs,
197
+ // The handle yields to the badge rather than pushing it out of the card: a
198
+ // long handle truncates (`numberOfLines={1}`), a marker cannot.
199
+ flexShrink: 1,
200
+ },
201
+ badge: {
202
+ flexShrink: 0,
179
203
  },
180
204
  action: {
181
205
  flexShrink: 0,
@@ -0,0 +1,40 @@
1
+ import { space } from '../styles/tokens';
2
+
3
+ /**
4
+ * The card's geometry, in one place, because two of these numbers are now a
5
+ * CONTRACT rather than an implementation detail: the card has two consumer
6
+ * slots, and a consumer cannot size content for a width it has to discover by
7
+ * overflowing.
8
+ *
9
+ * The card does not clip (see `UserHoverCard`), so content wider than
10
+ * {@link USER_HOVER_CARD_CONTENT_WIDTH} paints OUTSIDE the card's border rather
11
+ * than being cut off — the louder failure of the two, and still a failure.
12
+ */
13
+
14
+ /**
15
+ * Usable inner width, and the number a consumer sizes slot content against.
16
+ *
17
+ * This is the DECIDED number; the card's width is derived from it. That is the
18
+ * inversion the slots forced: the family's width was an unexplained `280` from
19
+ * the day it shipped (0.9.0), and the inner width that fell out of it — 248 —
20
+ * missed the first real slot content by ONE pixel. A contribution graph of 18
21
+ * columns at `cellSize={11} gap={3}` is 249px, and 18 columns is what 119 days
22
+ * spans once the leading partial week is counted.
23
+ *
24
+ * 256 is a step up on the 8px grid the spacing scale follows, it is 16× the
25
+ * inset, and it clears that measured requirement with room rather than exactly
26
+ * — a number chosen to be sized against, not nudged to fit one consumer.
27
+ */
28
+ export const USER_HOVER_CARD_CONTENT_WIDTH = 256;
29
+
30
+ /** Padding on all four sides. */
31
+ export const USER_HOVER_CARD_INSET = space.lg;
32
+
33
+ /**
34
+ * Total card width — derived, never the other way round. Anything positioning
35
+ * the card (see `AvatarGroup`'s web hover card) reads this rather than keeping
36
+ * its own copy: two spellings of one number centre the card off its anchor the
37
+ * first time either moves.
38
+ */
39
+ export const USER_HOVER_CARD_WIDTH =
40
+ USER_HOVER_CARD_CONTENT_WIDTH + USER_HOVER_CARD_INSET * 2;
@@ -1,2 +1,7 @@
1
1
  export { UserHoverCard } from './UserHoverCard';
2
+ export {
3
+ USER_HOVER_CARD_CONTENT_WIDTH,
4
+ USER_HOVER_CARD_INSET,
5
+ USER_HOVER_CARD_WIDTH,
6
+ } from './constants';
2
7
  export type { UserHoverCardProps, UserHoverCardStat } from './types';
@@ -40,6 +40,34 @@ export interface UserHoverCardProps {
40
40
  * Bloom does NOT implement follow logic; it only renders the card.
41
41
  */
42
42
  action?: ReactNode;
43
+ /**
44
+ * Marker slot in the handle row, rendered after `@username` — an account-kind
45
+ * or federation marker, the kind of quiet glyph that says what this account
46
+ * IS. Renders even when `username` is absent, because it describes the
47
+ * account rather than the handle. A long handle truncates to make room; the
48
+ * marker never shrinks.
49
+ *
50
+ * UNLIKE {@link UserHoverCardProps.footer}, this slot is INSIDE the identity
51
+ * area, because that is where it has to be to sit beside the handle. What that
52
+ * costs, measured rather than assumed:
53
+ *
54
+ * - The card's accessible name is unaffected. The identity area carries an
55
+ * explicit `accessibilityLabel`, and an explicit label wins over contents in
56
+ * the ARIA name computation — read back from Chrome's own accessibility tree
57
+ * with a badge nested inside: the button's name was exactly its label.
58
+ * - The badge's press does NOT leak into `onPressProfile`, on either platform.
59
+ * react-native-web implements React Native's responder system, so a nested
60
+ * pressable wins there the same way it does natively. No `stopPropagation`
61
+ * is needed, and a doc that told you to add one would be describing a
62
+ * different ancestor: a RAW DOM handler (`onPointerUp` on a plain `View`)
63
+ * does receive the bubbled event.
64
+ * - **Prefer an INERT marker.** When `onPressProfile` is set the identity area
65
+ * is a real `<button>`, so a pressable badge nests a button inside a button
66
+ * — invalid HTML, which Chrome tolerates and other user agents need not. A
67
+ * marker is usually a statement rather than a control anyway; make it
68
+ * pressable only where the answer it opens is worth that.
69
+ */
70
+ badge?: ReactNode;
43
71
  /**
44
72
  * Trailing content region, rendered after the stats row and spanning the full
45
73
  * inner width — the slot for whatever this app knows about a person that Bloom
@@ -47,13 +75,14 @@ export interface UserHoverCardProps {
47
75
  * line). Bloom adds the vertical rhythm and nothing else: no label, no divider,
48
76
  * no clip.
49
77
  *
50
- * It is a SIBLING of the identity area, never a child, so its own pressables
51
- * keep their presses instead of feeding {@link UserHoverCardProps.onPressProfile}
52
- * — and a screen reader reads it as content, not as part of the identity
53
- * button's name.
78
+ * It is a SIBLING of the identity area, never a child. Nested, a press
79
+ * anywhere on it — on a chart, on a line of text, on anything that is not
80
+ * itself pressable — would open the profile through
81
+ * {@link UserHoverCardProps.onPressProfile}.
54
82
  *
55
- * The card is 280px wide with `space.lg` padding, so content has ~248px of
56
- * inner width; the card does not clip, so anything wider paints outside it.
83
+ * Size content against {@link USER_HOVER_CARD_CONTENT_WIDTH}, which is
84
+ * exported for exactly that. The card does not clip, so anything wider paints
85
+ * outside it.
57
86
  */
58
87
  footer?: ReactNode;
59
88
  /** Container style override. */