@flamingo-stack/openframe-frontend-core 0.0.803 → 0.0.805

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 (211) hide show
  1. package/dist/build/export-map.json +1 -1
  2. package/dist/{case-study-card-K6HYMHL6.cjs → case-study-card-MEWJNF4N.cjs} +5 -5
  3. package/dist/{chunk-MII4RDO4.cjs → chunk-2NVIGBJC.cjs} +80 -80
  4. package/dist/{chunk-6JVNUGN3.cjs → chunk-3EPG56RK.cjs} +8 -8
  5. package/dist/{chunk-UYGXJ5SQ.cjs → chunk-3WNCFZGN.cjs} +2 -2
  6. package/dist/{chunk-2JCY5KQL.cjs → chunk-4W77VLQV.cjs} +4 -4
  7. package/dist/{chunk-HVWMPUXK.cjs → chunk-55TGW6BF.cjs} +6 -6
  8. package/dist/{chunk-IYWX4GOG.cjs → chunk-66ZQ7LDR.cjs} +38 -35
  9. package/dist/{chunk-H4T3YHYH.cjs → chunk-6JRQ57DU.cjs} +585 -599
  10. package/dist/{chunk-XOFGPSNP.cjs → chunk-6UGNFMZB.cjs} +36 -36
  11. package/dist/{chunk-Y5XHMEBB.cjs → chunk-76NE67PK.cjs} +5 -5
  12. package/dist/{chunk-VKSO3UYU.cjs → chunk-AC5EBHAX.cjs} +28 -28
  13. package/dist/{chunk-OG4XH6C5.cjs → chunk-AZJYMTBS.cjs} +33 -33
  14. package/dist/{chunk-HEMZOHNB.cjs → chunk-BVSZTKI3.cjs} +34 -21
  15. package/dist/{chunk-TVAU56UU.cjs → chunk-F2VN3UUB.cjs} +473 -508
  16. package/dist/{chunk-TELXF5WD.cjs → chunk-FLW2VL5W.cjs} +16 -16
  17. package/dist/{chunk-FS4TVAE7.cjs → chunk-FQ4LYYBI.cjs} +52 -52
  18. package/dist/{chunk-VVLL37EM.cjs → chunk-GAHXURKJ.cjs} +6 -6
  19. package/dist/{chunk-2X3N6MSR.cjs → chunk-JLKGLPDC.cjs} +21 -21
  20. package/dist/{chunk-3NGJ7NPT.cjs → chunk-KVJKKVB3.cjs} +7 -7
  21. package/dist/{chunk-YKQGYAG5.cjs → chunk-LZIQXGAW.cjs} +91 -88
  22. package/dist/{chunk-T7B3FJY6.cjs → chunk-MEDSJCEX.cjs} +4 -4
  23. package/dist/{chunk-FFRFKWTZ.cjs → chunk-MHH7CHNI.cjs} +17 -14
  24. package/dist/{chunk-IE3CPPHJ.cjs → chunk-NBLQFJ4I.cjs} +100 -99
  25. package/dist/{chunk-KVL3QRFX.cjs → chunk-NXJ3O4WO.cjs} +15 -15
  26. package/dist/{chunk-YBTORXFY.cjs → chunk-PRCGRDHV.cjs} +40 -25
  27. package/dist/{chunk-JTDOBGKE.cjs → chunk-QPBP7FKI.cjs} +52 -52
  28. package/dist/{chunk-ZPVFFPQM.cjs → chunk-RIRIA3FO.cjs} +4 -4
  29. package/dist/{chunk-XR323UBY.cjs → chunk-STLJCAIZ.cjs} +6 -3
  30. package/dist/{chunk-6UKH22NQ.cjs → chunk-TGOJHOQR.cjs} +2 -1
  31. package/dist/{chunk-FAUVDMH4.cjs → chunk-THY2XVGY.cjs} +198 -164
  32. package/dist/{chunk-6GCXQIUU.cjs → chunk-TT64NRFU.cjs} +4 -4
  33. package/dist/{chunk-CACULEQS.cjs → chunk-TTERV57X.cjs} +4 -4
  34. package/dist/{chunk-NNQXP2ZM.cjs → chunk-UCBR27JM.cjs} +13 -13
  35. package/dist/{chunk-KVGWOJCX.cjs → chunk-V3T5MDJV.cjs} +2 -2
  36. package/dist/{chunk-5RGGUQ4Y.cjs → chunk-VXXOUM2K.cjs} +67 -1
  37. package/dist/{chunk-I4BODSPV.cjs → chunk-WSKMV2QS.cjs} +3 -3
  38. package/dist/{chunk-MBZIARIL.cjs → chunk-XXARXK62.cjs} +26 -26
  39. package/dist/{chunk-HATRCNXJ.cjs → chunk-XYZBN6D7.cjs} +2 -2
  40. package/dist/{chunk-QFBRQ22U.cjs → chunk-Z6Y5X5SF.cjs} +41 -41
  41. package/dist/{cloud-tenants-GKCZSLEV.cjs → cloud-tenants-LRXMISV4.cjs} +19 -19
  42. package/dist/components/agent-mark.d.ts.map +1 -1
  43. package/dist/components/agent-mark.js +2 -2
  44. package/dist/components/case-studies/index.cjs +35 -35
  45. package/dist/components/chat/chat-message-row.d.ts.map +1 -1
  46. package/dist/components/chat/chat-message-row.js +3 -2
  47. package/dist/components/chat/entity-cards/admin-content-card.d.ts.map +1 -1
  48. package/dist/components/chat/entity-cards/admin-content-card.js +2 -1
  49. package/dist/components/chat/entity-cards/blog-card.d.ts.map +1 -1
  50. package/dist/components/chat/entity-cards/blog-card.js +6 -6
  51. package/dist/components/chat/entity-cards/blog-image-placeholder.d.ts.map +1 -1
  52. package/dist/components/chat/entity-cards/blog-image-placeholder.js +2 -1
  53. package/dist/components/chat/entity-cards/case-study-card.d.ts.map +1 -1
  54. package/dist/components/chat/entity-cards/case-study-card.js +10 -9
  55. package/dist/components/chat/entity-cards/customer-interview-card.d.ts.map +1 -1
  56. package/dist/components/chat/entity-cards/customer-interview-card.js +8 -7
  57. package/dist/components/chat/entity-cards/dispatch.d.ts.map +1 -1
  58. package/dist/components/chat/entity-cards/dispatch.js +12 -1
  59. package/dist/components/chat/entity-cards/employee-entry-card.d.ts.map +1 -1
  60. package/dist/components/chat/entity-cards/employee-entry-card.js +3 -2
  61. package/dist/components/chat/entity-cards/entity-portrait-card.d.ts.map +1 -1
  62. package/dist/components/chat/entity-cards/entity-portrait-card.js +7 -5
  63. package/dist/components/chat/entity-cards/investor-update-card.d.ts.map +1 -1
  64. package/dist/components/chat/entity-cards/investor-update-card.js +2 -1
  65. package/dist/components/chat/entity-cards/onboarding-guide-card.d.ts.map +1 -1
  66. package/dist/components/chat/entity-cards/onboarding-guide-card.js +13 -2
  67. package/dist/components/chat/entity-cards/program-card.d.ts.map +1 -1
  68. package/dist/components/chat/entity-cards/program-card.js +17 -5
  69. package/dist/components/chat/entity-cards/roadmap-card.d.ts.map +1 -1
  70. package/dist/components/chat/entity-cards/roadmap-card.js +5 -4
  71. package/dist/components/chat/index.cjs +15 -15
  72. package/dist/components/chat/mingo-info-card.d.ts.map +1 -1
  73. package/dist/components/chat/mingo-info-card.js +3 -2
  74. package/dist/components/contact/index.cjs +20 -20
  75. package/dist/components/docs/index.cjs +23 -23
  76. package/dist/components/embeds/index.cjs +20 -20
  77. package/dist/components/embeds/markdown-image.d.ts.map +1 -1
  78. package/dist/components/embeds/markdown-image.js +2 -1
  79. package/dist/components/embeds/og-link-preview.d.ts.map +1 -1
  80. package/dist/components/embeds/og-link-preview.js +17 -6
  81. package/dist/components/embeds/twitter-embed-client.d.ts.map +1 -1
  82. package/dist/components/embeds/twitter-embed-client.js +3 -2
  83. package/dist/components/faq/index.cjs +21 -21
  84. package/dist/components/features/index.cjs +19 -19
  85. package/dist/components/features/media-gallery-manager.d.ts.map +1 -1
  86. package/dist/components/features/media-gallery-manager.js +2 -1
  87. package/dist/components/features/notifications/notification-tile.d.ts.map +1 -1
  88. package/dist/components/features/notifications/notification-tile.js +3 -2
  89. package/dist/components/features/parallax-image-showcase.d.ts.map +1 -1
  90. package/dist/components/features/parallax-image-showcase.js +9 -35
  91. package/dist/components/features/select-button.d.ts.map +1 -1
  92. package/dist/components/features/select-button.js +3 -2
  93. package/dist/components/features/video-hover-preview.d.ts +1 -1
  94. package/dist/components/features/video-hover-preview.d.ts.map +1 -1
  95. package/dist/components/features/video-hover-preview.js +2 -1
  96. package/dist/components/features/video.d.ts.map +1 -1
  97. package/dist/components/features/video.js +13 -1
  98. package/dist/components/features/walkthrough-video.d.ts.map +1 -1
  99. package/dist/components/features/walkthrough-video.js +3 -3
  100. package/dist/components/help-center-pages/index.cjs +121 -121
  101. package/dist/components/hero-image-uploader.d.ts.map +1 -1
  102. package/dist/components/hero-image-uploader.js +12 -1
  103. package/dist/components/icon-display.d.ts.map +1 -1
  104. package/dist/components/icon-display.js +2 -1
  105. package/dist/components/index.cjs +137 -91
  106. package/dist/components/media-carousel.d.ts.map +1 -1
  107. package/dist/components/media-carousel.js +2 -1
  108. package/dist/components/meeting-scheduler/index.cjs +85 -85
  109. package/dist/components/navigation/index.cjs +22 -22
  110. package/dist/components/onboarding-guides/index.cjs +22 -22
  111. package/dist/components/platform/ScriptInfoSection.d.ts.map +1 -1
  112. package/dist/components/platform/ScriptInfoSection.js +12 -1
  113. package/dist/components/product-demo/index.cjs +30 -30
  114. package/dist/components/related-content/index.cjs +11 -11
  115. package/dist/components/shared/media-gallery-strip.d.ts.map +1 -1
  116. package/dist/components/shared/media-gallery-strip.js +3 -2
  117. package/dist/components/shared/product-release/product-release-card.d.ts.map +1 -1
  118. package/dist/components/shared/product-release/product-release-card.js +13 -2
  119. package/dist/components/tickets/index.cjs +26 -26
  120. package/dist/components/ui/avatar-stack.d.ts.map +1 -1
  121. package/dist/components/ui/avatar-stack.js +4 -4
  122. package/dist/components/ui/entity-image.d.ts.map +1 -1
  123. package/dist/components/ui/entity-image.js +3 -2
  124. package/dist/components/ui/image-gallery-modal.d.ts.map +1 -1
  125. package/dist/components/ui/image-gallery-modal.js +2 -1
  126. package/dist/components/ui/image-uploader.d.ts.map +1 -1
  127. package/dist/components/ui/image-uploader.js +2 -1
  128. package/dist/components/ui/index.cjs +37 -19
  129. package/dist/components/ui/index.d.ts +1 -0
  130. package/dist/components/ui/index.d.ts.map +1 -1
  131. package/dist/components/ui/index.js +1 -0
  132. package/dist/components/ui/markdown/base-components.d.ts.map +1 -1
  133. package/dist/components/ui/markdown/base-components.js +2 -1
  134. package/dist/components/ui/photo-wall.d.ts +7 -3
  135. package/dist/components/ui/photo-wall.d.ts.map +1 -1
  136. package/dist/components/ui/photo-wall.js +3 -4
  137. package/dist/components/ui/square-avatar.d.ts +4 -1
  138. package/dist/components/ui/square-avatar.d.ts.map +1 -1
  139. package/dist/components/ui/square-avatar.js +2 -1
  140. package/dist/components/user-summary-stub.d.ts +1 -1
  141. package/dist/components/user-summary-stub.d.ts.map +1 -1
  142. package/dist/components/user-summary-stub.js +16 -6
  143. package/dist/components/vendor-display-button.d.ts.map +1 -1
  144. package/dist/components/vendor-display-button.js +13 -3
  145. package/dist/components/vendor-icon.d.ts +7 -4
  146. package/dist/components/vendor-icon.d.ts.map +1 -1
  147. package/dist/components/vendor-icon.js +22 -71
  148. package/dist/{devices-XIXLFYRJ.cjs → devices-CETR72XY.cjs} +20 -20
  149. package/dist/{embeddable-chat-SVDMLAER.cjs → embeddable-chat-GHBCX2BY.cjs} +84 -84
  150. package/dist/hooks/index.cjs +6 -6
  151. package/dist/hooks/ui/use-image-edge-color.d.ts.map +1 -1
  152. package/dist/hooks/ui/use-image-edge-color.js +4 -3
  153. package/dist/index.cjs +43 -25
  154. package/dist/{knowledge-3DKG5QG2.cjs → knowledge-A2MWEF23.cjs} +20 -20
  155. package/dist/{logs-RIU2TTRZ.cjs → logs-47JODA6C.cjs} +27 -27
  156. package/dist/{policies-F2ZB2J4L.cjs → policies-OPIDR6XF.cjs} +23 -23
  157. package/dist/{remote-session-GBMM5UPQ.cjs → remote-session-IQTPEG63.cjs} +8 -8
  158. package/dist/{scripts-XX5LMCRA.cjs → scripts-4MQGJWFP.cjs} +26 -26
  159. package/dist/{software-update-VYBM7SC6.cjs → software-update-MQIGPBZ6.cjs} +23 -23
  160. package/dist/styles/image-sizes.cjs +68 -0
  161. package/dist/styles/image-sizes.d.ts +110 -0
  162. package/dist/styles/image-sizes.d.ts.map +1 -0
  163. package/dist/styles/image-sizes.js +66 -0
  164. package/dist/{tickets-board-5QIIA24E.cjs → tickets-board-QF5JNSH2.cjs} +11 -11
  165. package/eslint-config/base.js +12 -0
  166. package/eslint-config/image-sizes.js +51 -0
  167. package/package.json +8 -2
  168. package/src/components/agent-mark.tsx +3 -4
  169. package/src/components/chat/chat-message-row.tsx +3 -2
  170. package/src/components/chat/entity-cards/admin-content-card.tsx +2 -1
  171. package/src/components/chat/entity-cards/blog-card.tsx +6 -6
  172. package/src/components/chat/entity-cards/blog-image-placeholder.tsx +2 -1
  173. package/src/components/chat/entity-cards/case-study-card.tsx +10 -9
  174. package/src/components/chat/entity-cards/customer-interview-card.tsx +8 -7
  175. package/src/components/chat/entity-cards/dispatch.tsx +9 -1
  176. package/src/components/chat/entity-cards/employee-entry-card.tsx +3 -2
  177. package/src/components/chat/entity-cards/entity-portrait-card.tsx +7 -5
  178. package/src/components/chat/entity-cards/investor-update-card.tsx +2 -1
  179. package/src/components/chat/entity-cards/onboarding-guide-card.tsx +10 -2
  180. package/src/components/chat/entity-cards/program-card.tsx +14 -5
  181. package/src/components/chat/entity-cards/roadmap-card.tsx +5 -4
  182. package/src/components/chat/mingo-info-card.tsx +3 -2
  183. package/src/components/embeds/markdown-image.tsx +2 -1
  184. package/src/components/embeds/og-link-preview.tsx +14 -6
  185. package/src/components/embeds/twitter-embed-client.tsx +3 -2
  186. package/src/components/features/media-gallery-manager.tsx +2 -2
  187. package/src/components/features/notifications/notification-tile.tsx +3 -2
  188. package/src/components/features/parallax-image-showcase.tsx +9 -26
  189. package/src/components/features/select-button.tsx +3 -2
  190. package/src/components/features/video-hover-preview.tsx +3 -2
  191. package/src/components/features/video.tsx +10 -1
  192. package/src/components/features/walkthrough-video.tsx +7 -10
  193. package/src/components/hero-image-uploader.tsx +9 -1
  194. package/src/components/icon-display.tsx +2 -1
  195. package/src/components/media-carousel.tsx +2 -1
  196. package/src/components/platform/ScriptInfoSection.tsx +9 -1
  197. package/src/components/shared/media-gallery-strip.tsx +4 -2
  198. package/src/components/shared/product-release/product-release-card.tsx +10 -2
  199. package/src/components/ui/avatar-stack.tsx +6 -6
  200. package/src/components/ui/entity-image.tsx +3 -2
  201. package/src/components/ui/image-gallery-modal.tsx +2 -1
  202. package/src/components/ui/image-uploader.tsx +2 -1
  203. package/src/components/ui/index.ts +1 -0
  204. package/src/components/ui/markdown/base-components.tsx +2 -1
  205. package/src/components/ui/photo-wall.tsx +10 -14
  206. package/src/components/ui/square-avatar.tsx +6 -3
  207. package/src/components/user-summary-stub.tsx +14 -7
  208. package/src/components/vendor-display-button.tsx +10 -3
  209. package/src/components/vendor-icon.tsx +31 -97
  210. package/src/hooks/ui/use-image-edge-color.ts +8 -4
  211. package/src/styles/image-sizes.ts +114 -0
@@ -1,11 +1,11 @@
1
1
  'use client';
2
2
 
3
- import Image from '../embed-shims/next-image';
3
+ import type { AvatarSize } from '../styles/component-sizes';
4
4
  import { cn } from '../utils/cn';
5
5
  import { getVendorLogo, type VendorWithMedia } from '../utils/vendor-media-stub';
6
6
  import { useProxiedImageUrl } from './chat/hooks/use-proxied-image-url';
7
- import { UnifiedSkeleton } from './loading/unified-skeleton';
8
- import { loadingItemProps, useLoadingScope } from './ui/loading-scope';
7
+ import { loadingItemProps } from './ui/loading-scope';
8
+ import { SquareAvatar } from './ui/square-avatar';
9
9
 
10
10
  interface VendorIconProps {
11
11
  vendor: VendorWithMedia & {
@@ -14,120 +14,54 @@ interface VendorIconProps {
14
14
  slug?: string;
15
15
  logo?: string | null;
16
16
  };
17
- size?: 'xs' | 'sm' | 'md' | 'lg' | 'l' | 'xl';
17
+ /** A step of the shared avatar scale: the tile's box and the picture it fetches. */
18
+ size?: AvatarSize;
18
19
  className?: string;
20
+ /** On a background the logo sits padded on its tile; without one it fills the tile. */
19
21
  showBackground?: boolean;
20
22
  backgroundStyle?: 'dark' | 'light' | 'white';
21
23
  /** The vendor is still being read: the icon draws its skeleton, the tile's own box. A loading scope does the same. */
22
24
  loading?: boolean;
23
25
  }
24
26
 
25
- const sizeClasses = {
26
- xs: 'w-6 h-6',
27
- sm: 'w-8 h-8',
28
- md: 'w-10 h-10',
29
- lg: 'w-12 h-12',
30
- l: 'w-14 h-14',
31
- xl: 'w-16 h-16',
32
- };
33
-
34
- const imageSizeMap = {
35
- xs: { width: 16, height: 16 },
36
- sm: { width: 20, height: 20 },
37
- md: { width: 32, height: 32 },
38
- lg: { width: 40, height: 40 },
39
- l: { width: 38, height: 38 },
40
- xl: { width: 40, height: 40 },
41
- };
42
-
43
- /**
44
- * Tile px per size (the `sizeClasses` box). With `showBackground={false}`
45
- * the image FILLS the tile (`h-full w-full`), so it must be requested at the
46
- * tile's size: requesting the padded `imageSizeMap` size there served a
47
- * 32px bitmap stretched over a 40-64px tile, blurry on every display.
48
- */
49
- const tilePxMap = {
50
- xs: 24,
51
- sm: 32,
52
- md: 40,
53
- lg: 48,
54
- l: 56,
55
- xl: 64,
56
- };
57
-
58
- const backgroundClasses = {
59
- dark: 'bg-ods-bg border border-ods-border',
60
- light: 'bg-ods-card border border-ods-border',
61
- white: 'bg-white border border-[#E5E5E5]',
62
- };
63
-
64
- /** A vendor's logo while it is read: the tile's own box. Carries the icon's `data-*` markers (`loadingItemProps`). */
65
- function VendorIconSkeleton({
66
- size = 'md',
67
- className,
68
- ...props
69
- }: {
70
- size?: VendorIconProps['size'];
71
- className?: string;
72
- }) {
73
- return (
74
- <UnifiedSkeleton
75
- className={cn(sizeClasses[size], 'flex-shrink-0 rounded-lg', className)}
76
- {...loadingItemProps(props)}
77
- />
78
- );
79
- }
27
+ /** The tile's surface per background, over the avatar's own (`dark` is the avatar's). */
28
+ const BACKGROUND_CLASS = {
29
+ dark: '',
30
+ light: 'bg-ods-card',
31
+ white: 'bg-white border-[#E5E5E5] [--ods-avatar-initials:#333333]',
32
+ } as const;
80
33
 
81
34
  /**
82
- * Common VendorIcon component for displaying vendor logos consistently across the platform
83
- * Extracted from vendor-card.tsx for reuse in comparison tables, dropdowns, etc.
35
+ * A vendor's logo on its tile, for comparison tables, dropdowns and cards: the lib's `SquareAvatar` (the shared avatar
36
+ * scale, a `contain` fit, the initials fallback and the skeleton), so a vendor logo is sized like every other avatar.
84
37
  */
85
38
  export function VendorIcon({
86
39
  vendor,
87
40
  size = 'md',
88
- className = '',
41
+ className,
89
42
  showBackground = true,
90
43
  backgroundStyle = 'dark',
91
- loading: loadingProp,
44
+ loading,
92
45
  ...props
93
46
  }: VendorIconProps) {
94
- const loading = useLoadingScope() || !!loadingProp;
95
47
  const logoUrl = getVendorLogo(vendor);
96
48
  const logoSrc = useProxiedImageUrl(logoUrl, { directHttps: false });
97
- const { width, height } = showBackground ? imageSizeMap[size] : { width: tilePxMap[size], height: tilePxMap[size] };
98
-
99
- const containerClasses = cn(
100
- sizeClasses[size],
101
- 'flex flex-shrink-0 items-center justify-center rounded-lg',
102
- showBackground && backgroundClasses[backgroundStyle],
103
- !showBackground && 'overflow-hidden',
104
- className,
105
- );
106
-
107
- // A list's markers (`data-loading-item`) ride on the icon in both forms.
108
- const markers = loadingItemProps(props);
109
- if (loading) return <VendorIconSkeleton size={size} className={className} {...markers} />;
110
-
111
49
  return (
112
- <div className={containerClasses} {...markers}>
113
- {logoUrl ? (
114
- <Image
115
- src={logoSrc}
116
- alt={`${vendor.title} logo`}
117
- width={width}
118
- height={height}
119
- className={cn('object-contain', showBackground ? 'p-1' : 'h-full w-full')}
120
- />
121
- ) : (
122
- <div
123
- className={cn(
124
- 'flex items-center justify-center uppercase text-h6',
125
- backgroundStyle === 'white' ? 'text-[#333333]' : 'text-ods-text-secondary',
126
- )}
127
- >
128
- {vendor.title?.substring(0, 2) || '??'}
129
- </div>
50
+ <SquareAvatar
51
+ src={logoUrl ? logoSrc || undefined : undefined}
52
+ alt={`${vendor.title} logo`}
53
+ fallback={vendor.title}
54
+ size={size}
55
+ fit="contain"
56
+ padded={showBackground}
57
+ loading={loading}
58
+ initialsClassName="uppercase text-h6"
59
+ className={cn(
60
+ 'rounded-lg',
61
+ showBackground ? BACKGROUND_CLASS[backgroundStyle] : 'border-0 bg-transparent',
62
+ className,
130
63
  )}
131
- </div>
64
+ {...loadingItemProps(props)}
65
+ />
132
66
  );
133
67
  }
@@ -3,9 +3,13 @@
3
3
  import { useState, useEffect } from 'react';
4
4
  import { useLoadingScope } from '../../components/ui/loading-scope';
5
5
  import { resizedImageUrl } from '../../embed-shims/next-image';
6
+ import { IMAGE_FIXED_WIDTHS } from '../../styles/image-sizes';
6
7
 
7
- /** The sample is drawn 100px at most, so that is all of the picture that is downloaded. */
8
- const EDGE_SAMPLE_WIDTH_PX = 100;
8
+ /**
9
+ * The sample is drawn this wide at most, so that is all of the picture that is downloaded. A width of the image-size
10
+ * table's fixed ladder (128), so the sample is a cached file a thumbnail of the same picture already asked for.
11
+ */
12
+ const EDGE_SAMPLE_WIDTH = IMAGE_FIXED_WIDTHS[2];
9
13
 
10
14
  /**
11
15
  * Extract the dominant edge color from an image using color bucketing.
@@ -18,7 +22,7 @@ function extractEdgeColor(img: HTMLImageElement): string {
18
22
  const ctx = canvas.getContext('2d');
19
23
  if (!ctx) return '#000000';
20
24
 
21
- const maxSize = EDGE_SAMPLE_WIDTH_PX;
25
+ const maxSize = EDGE_SAMPLE_WIDTH;
22
26
  const scale = Math.min(maxSize / img.naturalWidth, maxSize / img.naturalHeight);
23
27
  const w = Math.round(img.naturalWidth * scale);
24
28
  const h = Math.round(img.naturalHeight * scale);
@@ -135,7 +139,7 @@ export function useImageEdgeColor(givenUrl: string | undefined | null, fallback
135
139
  // The picture is asked for at the sample's size (a card's cover is often a
136
140
  // multi-hundred-KB original, and this is a second request for it). When the
137
141
  // host cannot serve that size, the original is tried once.
138
- const sampleUrl = resizedImageUrl(imageUrl, EDGE_SAMPLE_WIDTH_PX);
142
+ const sampleUrl = resizedImageUrl(imageUrl, EDGE_SAMPLE_WIDTH);
139
143
  let triedOriginal = sampleUrl === imageUrl;
140
144
  img.onerror = () => {
141
145
  if (cancelled) return;
@@ -0,0 +1,114 @@
1
+ /**
2
+ * THE sizes every picture is fetched at: the one table, read by every component that draws a picture, by the host's
3
+ * image settings (a Next host's `images.deviceSizes`, `images.imageSizes` and `images.qualities` are derived from it,
4
+ * never typed) and by the code that makes pictures on the server (link-preview cards, emails, video posters).
5
+ *
6
+ * Why one table: a resized picture is cached by its exact address, so every width, quality and fit a component picks
7
+ * on its own is another copy the image host makes and caches separately. With eight widths per picture, three
8
+ * qualities and ad-hoc pixel sizes, a blog post's cover almost never had a cached copy when a reader arrived, and
9
+ * waited for a fresh resize (measured 2026-10-26: 19 of 20 blog covers, ~0.6 s each; Google's field data showed the
10
+ * cover's download time going from 0.47 s to 1.18 s). A short ladder of widths and one quality keep the copies few, so
11
+ * the ones that exist are reused.
12
+ *
13
+ * What a component chooses is the SLOT (how wide the picture is drawn), never a width or a quality: a responsive
14
+ * picture states `sizes={IMAGE_SLOT.card}`, a fixed-size one states its box from `IMAGE_FIXED_PX` (or the avatar
15
+ * scale). The browser then picks a width from the ladder. Import-free, so a host's config can read it.
16
+ */
17
+
18
+ /**
19
+ * The widths a responsive picture is offered at (a `srcset`): every responsive picture, of every kind, picks from
20
+ * this ladder. Covers a phone (828, and 1200 at 3x), a desktop column (1200) and a retina desktop (1920).
21
+ */
22
+ export const IMAGE_WIDTHS = [640, 828, 1200, 1920] as const;
23
+
24
+ /**
25
+ * The widths a fixed-size picture (an avatar, a logo, a thumbnail) is fetched at: its 1x and 2x, rounded up to this
26
+ * ladder. Any box up to 192 px lands on one of these four files.
27
+ */
28
+ export const IMAGE_FIXED_WIDTHS = [32, 64, 128, 256, 384] as const;
29
+
30
+ /** The quality every resized picture is encoded at. One value: a second quality is a second copy of every picture. */
31
+ export const IMAGE_QUALITY = 75;
32
+
33
+ /** The widest a picture is ever stored or fetched: the top of {@link IMAGE_WIDTHS}. Uploads are capped to it. */
34
+ export const IMAGE_MAX_WIDTH = IMAGE_WIDTHS[IMAGE_WIDTHS.length - 1];
35
+
36
+ /**
37
+ * How wide a responsive picture is drawn, relative to the window: its `sizes`. One entry per kind of slot; a new
38
+ * layout picks the closest slot (a few pixels' difference picks the same file from the ladder anyway).
39
+ */
40
+ export const IMAGE_SLOT = {
41
+ /** The whole window (a background, a lightbox). */
42
+ full: '100vw',
43
+ /** An article's or a page's main picture, up to its 1200 px column. */
44
+ hero: '(max-width: 1200px) 100vw, 1200px',
45
+ /** Half the page from a laptop up, the whole width below (a split hero, a program cover). */
46
+ half: '(min-width: 1024px) 50vw, 100vw',
47
+ /** A card in a two- or three-column grid. */
48
+ card: '(max-width: 768px) 100vw, (max-width: 1519px) 50vw, 33vw',
49
+ /** A card in a three- or four-column grid. */
50
+ cardSmall: '(max-width: 768px) 50vw, (max-width: 1024px) 33vw, 25vw',
51
+ /** A column of a photo wall: a quarter of the page, half on a phone. */
52
+ wall: '(min-width: 1024px) 25vw, 50vw',
53
+ /** A fixed column up to 400 px (a side panel, a preview). */
54
+ panel: '(max-width: 768px) 100vw, 400px',
55
+ /** A picture in running text, up to 400 px (a markdown image), the whole width only on the narrowest phones. */
56
+ inline: '(max-width: 400px) 100vw, 400px',
57
+ /** A cover beside text, up to 256 px (a release card's cover), the whole width on a phone. */
58
+ aside: '(max-width: 768px) 100vw, 256px',
59
+ /** A wide column up to 768 px (a modal's media, a reading column). */
60
+ column: '(max-width: 768px) 100vw, 768px',
61
+ } as const;
62
+
63
+ export type ImageSlot = keyof typeof IMAGE_SLOT;
64
+
65
+ /**
66
+ * The boxes a fixed-size picture is drawn in, in CSS pixels: its `width`/`height` attributes. Avatars use the avatar
67
+ * scale (`AVATAR_SIZE_PX`); everything else fixed (a logo, a thumbnail, a tile's picture) uses one of these.
68
+ */
69
+ export const IMAGE_FIXED_PX = {
70
+ icon: 16,
71
+ glyph: 20,
72
+ logo: 32,
73
+ logoLg: 40,
74
+ tile: 56,
75
+ thumb: 64,
76
+ mark: 96,
77
+ feature: 128,
78
+ preview: 192,
79
+ cover: 240,
80
+ } as const;
81
+
82
+ export type ImageFixedSize = keyof typeof IMAGE_FIXED_PX;
83
+
84
+ /** The `sizes` of a `fill` picture drawn in a fixed box (`"56px"`), from {@link IMAGE_FIXED_PX}. */
85
+ export function fixedImageSlot(size: ImageFixedSize): `${number}px` {
86
+ return `${IMAGE_FIXED_PX[size]}px`;
87
+ }
88
+
89
+ /**
90
+ * Pictures made on the server, at one size each (they are files, not a `srcset`): the link-preview card, an email's
91
+ * pictures, a video's poster.
92
+ */
93
+ export const IMAGE_FRAME = {
94
+ /** The 1200×630 card every link preview (Open Graph, X, Slack, LinkedIn) is drawn at. */
95
+ social: { width: 1200, height: 630 },
96
+ /** An email's lead picture, at 2x its 560 px column. */
97
+ emailHero: { width: 1120, height: 630 },
98
+ /** An email's card picture, at 2x its 120 px box. */
99
+ emailCard: { width: 240, height: 160 },
100
+ /** A video's poster when the caller states no size. */
101
+ poster: { width: 560, height: 315 },
102
+ } as const;
103
+
104
+ export type ImageFrame = keyof typeof IMAGE_FRAME;
105
+
106
+ /**
107
+ * The ladder width to fetch for a picture drawn `drawnPx` wide (already multiplied for the screen's density): the
108
+ * smallest width of {@link IMAGE_WIDTHS} that covers it, else the widest. For code that measures a slot itself (a
109
+ * photo wall's column) and asks for one URL, so it lands on a file the `srcset` pictures share.
110
+ */
111
+ export function imageWidthFor(drawnPx: number): number {
112
+ for (const width of IMAGE_WIDTHS) if (width >= drawnPx) return width;
113
+ return IMAGE_MAX_WIDTH;
114
+ }