@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.
- package/dist/build/export-map.json +1 -1
- package/dist/{case-study-card-K6HYMHL6.cjs → case-study-card-MEWJNF4N.cjs} +5 -5
- package/dist/{chunk-MII4RDO4.cjs → chunk-2NVIGBJC.cjs} +80 -80
- package/dist/{chunk-6JVNUGN3.cjs → chunk-3EPG56RK.cjs} +8 -8
- package/dist/{chunk-UYGXJ5SQ.cjs → chunk-3WNCFZGN.cjs} +2 -2
- package/dist/{chunk-2JCY5KQL.cjs → chunk-4W77VLQV.cjs} +4 -4
- package/dist/{chunk-HVWMPUXK.cjs → chunk-55TGW6BF.cjs} +6 -6
- package/dist/{chunk-IYWX4GOG.cjs → chunk-66ZQ7LDR.cjs} +38 -35
- package/dist/{chunk-H4T3YHYH.cjs → chunk-6JRQ57DU.cjs} +585 -599
- package/dist/{chunk-XOFGPSNP.cjs → chunk-6UGNFMZB.cjs} +36 -36
- package/dist/{chunk-Y5XHMEBB.cjs → chunk-76NE67PK.cjs} +5 -5
- package/dist/{chunk-VKSO3UYU.cjs → chunk-AC5EBHAX.cjs} +28 -28
- package/dist/{chunk-OG4XH6C5.cjs → chunk-AZJYMTBS.cjs} +33 -33
- package/dist/{chunk-HEMZOHNB.cjs → chunk-BVSZTKI3.cjs} +34 -21
- package/dist/{chunk-TVAU56UU.cjs → chunk-F2VN3UUB.cjs} +473 -508
- package/dist/{chunk-TELXF5WD.cjs → chunk-FLW2VL5W.cjs} +16 -16
- package/dist/{chunk-FS4TVAE7.cjs → chunk-FQ4LYYBI.cjs} +52 -52
- package/dist/{chunk-VVLL37EM.cjs → chunk-GAHXURKJ.cjs} +6 -6
- package/dist/{chunk-2X3N6MSR.cjs → chunk-JLKGLPDC.cjs} +21 -21
- package/dist/{chunk-3NGJ7NPT.cjs → chunk-KVJKKVB3.cjs} +7 -7
- package/dist/{chunk-YKQGYAG5.cjs → chunk-LZIQXGAW.cjs} +91 -88
- package/dist/{chunk-T7B3FJY6.cjs → chunk-MEDSJCEX.cjs} +4 -4
- package/dist/{chunk-FFRFKWTZ.cjs → chunk-MHH7CHNI.cjs} +17 -14
- package/dist/{chunk-IE3CPPHJ.cjs → chunk-NBLQFJ4I.cjs} +100 -99
- package/dist/{chunk-KVL3QRFX.cjs → chunk-NXJ3O4WO.cjs} +15 -15
- package/dist/{chunk-YBTORXFY.cjs → chunk-PRCGRDHV.cjs} +40 -25
- package/dist/{chunk-JTDOBGKE.cjs → chunk-QPBP7FKI.cjs} +52 -52
- package/dist/{chunk-ZPVFFPQM.cjs → chunk-RIRIA3FO.cjs} +4 -4
- package/dist/{chunk-XR323UBY.cjs → chunk-STLJCAIZ.cjs} +6 -3
- package/dist/{chunk-6UKH22NQ.cjs → chunk-TGOJHOQR.cjs} +2 -1
- package/dist/{chunk-FAUVDMH4.cjs → chunk-THY2XVGY.cjs} +198 -164
- package/dist/{chunk-6GCXQIUU.cjs → chunk-TT64NRFU.cjs} +4 -4
- package/dist/{chunk-CACULEQS.cjs → chunk-TTERV57X.cjs} +4 -4
- package/dist/{chunk-NNQXP2ZM.cjs → chunk-UCBR27JM.cjs} +13 -13
- package/dist/{chunk-KVGWOJCX.cjs → chunk-V3T5MDJV.cjs} +2 -2
- package/dist/{chunk-5RGGUQ4Y.cjs → chunk-VXXOUM2K.cjs} +67 -1
- package/dist/{chunk-I4BODSPV.cjs → chunk-WSKMV2QS.cjs} +3 -3
- package/dist/{chunk-MBZIARIL.cjs → chunk-XXARXK62.cjs} +26 -26
- package/dist/{chunk-HATRCNXJ.cjs → chunk-XYZBN6D7.cjs} +2 -2
- package/dist/{chunk-QFBRQ22U.cjs → chunk-Z6Y5X5SF.cjs} +41 -41
- package/dist/{cloud-tenants-GKCZSLEV.cjs → cloud-tenants-LRXMISV4.cjs} +19 -19
- package/dist/components/agent-mark.d.ts.map +1 -1
- package/dist/components/agent-mark.js +2 -2
- package/dist/components/case-studies/index.cjs +35 -35
- package/dist/components/chat/chat-message-row.d.ts.map +1 -1
- package/dist/components/chat/chat-message-row.js +3 -2
- package/dist/components/chat/entity-cards/admin-content-card.d.ts.map +1 -1
- package/dist/components/chat/entity-cards/admin-content-card.js +2 -1
- package/dist/components/chat/entity-cards/blog-card.d.ts.map +1 -1
- package/dist/components/chat/entity-cards/blog-card.js +6 -6
- package/dist/components/chat/entity-cards/blog-image-placeholder.d.ts.map +1 -1
- package/dist/components/chat/entity-cards/blog-image-placeholder.js +2 -1
- package/dist/components/chat/entity-cards/case-study-card.d.ts.map +1 -1
- package/dist/components/chat/entity-cards/case-study-card.js +10 -9
- package/dist/components/chat/entity-cards/customer-interview-card.d.ts.map +1 -1
- package/dist/components/chat/entity-cards/customer-interview-card.js +8 -7
- package/dist/components/chat/entity-cards/dispatch.d.ts.map +1 -1
- package/dist/components/chat/entity-cards/dispatch.js +12 -1
- package/dist/components/chat/entity-cards/employee-entry-card.d.ts.map +1 -1
- package/dist/components/chat/entity-cards/employee-entry-card.js +3 -2
- package/dist/components/chat/entity-cards/entity-portrait-card.d.ts.map +1 -1
- package/dist/components/chat/entity-cards/entity-portrait-card.js +7 -5
- package/dist/components/chat/entity-cards/investor-update-card.d.ts.map +1 -1
- package/dist/components/chat/entity-cards/investor-update-card.js +2 -1
- package/dist/components/chat/entity-cards/onboarding-guide-card.d.ts.map +1 -1
- package/dist/components/chat/entity-cards/onboarding-guide-card.js +13 -2
- package/dist/components/chat/entity-cards/program-card.d.ts.map +1 -1
- package/dist/components/chat/entity-cards/program-card.js +17 -5
- package/dist/components/chat/entity-cards/roadmap-card.d.ts.map +1 -1
- package/dist/components/chat/entity-cards/roadmap-card.js +5 -4
- package/dist/components/chat/index.cjs +15 -15
- package/dist/components/chat/mingo-info-card.d.ts.map +1 -1
- package/dist/components/chat/mingo-info-card.js +3 -2
- package/dist/components/contact/index.cjs +20 -20
- package/dist/components/docs/index.cjs +23 -23
- package/dist/components/embeds/index.cjs +20 -20
- package/dist/components/embeds/markdown-image.d.ts.map +1 -1
- package/dist/components/embeds/markdown-image.js +2 -1
- package/dist/components/embeds/og-link-preview.d.ts.map +1 -1
- package/dist/components/embeds/og-link-preview.js +17 -6
- package/dist/components/embeds/twitter-embed-client.d.ts.map +1 -1
- package/dist/components/embeds/twitter-embed-client.js +3 -2
- package/dist/components/faq/index.cjs +21 -21
- package/dist/components/features/index.cjs +19 -19
- package/dist/components/features/media-gallery-manager.d.ts.map +1 -1
- package/dist/components/features/media-gallery-manager.js +2 -1
- package/dist/components/features/notifications/notification-tile.d.ts.map +1 -1
- package/dist/components/features/notifications/notification-tile.js +3 -2
- package/dist/components/features/parallax-image-showcase.d.ts.map +1 -1
- package/dist/components/features/parallax-image-showcase.js +9 -35
- package/dist/components/features/select-button.d.ts.map +1 -1
- package/dist/components/features/select-button.js +3 -2
- package/dist/components/features/video-hover-preview.d.ts +1 -1
- package/dist/components/features/video-hover-preview.d.ts.map +1 -1
- package/dist/components/features/video-hover-preview.js +2 -1
- package/dist/components/features/video.d.ts.map +1 -1
- package/dist/components/features/video.js +13 -1
- package/dist/components/features/walkthrough-video.d.ts.map +1 -1
- package/dist/components/features/walkthrough-video.js +3 -3
- package/dist/components/help-center-pages/index.cjs +121 -121
- package/dist/components/hero-image-uploader.d.ts.map +1 -1
- package/dist/components/hero-image-uploader.js +12 -1
- package/dist/components/icon-display.d.ts.map +1 -1
- package/dist/components/icon-display.js +2 -1
- package/dist/components/index.cjs +137 -91
- package/dist/components/media-carousel.d.ts.map +1 -1
- package/dist/components/media-carousel.js +2 -1
- package/dist/components/meeting-scheduler/index.cjs +85 -85
- package/dist/components/navigation/index.cjs +22 -22
- package/dist/components/onboarding-guides/index.cjs +22 -22
- package/dist/components/platform/ScriptInfoSection.d.ts.map +1 -1
- package/dist/components/platform/ScriptInfoSection.js +12 -1
- package/dist/components/product-demo/index.cjs +30 -30
- package/dist/components/related-content/index.cjs +11 -11
- package/dist/components/shared/media-gallery-strip.d.ts.map +1 -1
- package/dist/components/shared/media-gallery-strip.js +3 -2
- package/dist/components/shared/product-release/product-release-card.d.ts.map +1 -1
- package/dist/components/shared/product-release/product-release-card.js +13 -2
- package/dist/components/tickets/index.cjs +26 -26
- package/dist/components/ui/avatar-stack.d.ts.map +1 -1
- package/dist/components/ui/avatar-stack.js +4 -4
- package/dist/components/ui/entity-image.d.ts.map +1 -1
- package/dist/components/ui/entity-image.js +3 -2
- package/dist/components/ui/image-gallery-modal.d.ts.map +1 -1
- package/dist/components/ui/image-gallery-modal.js +2 -1
- package/dist/components/ui/image-uploader.d.ts.map +1 -1
- package/dist/components/ui/image-uploader.js +2 -1
- package/dist/components/ui/index.cjs +37 -19
- package/dist/components/ui/index.d.ts +1 -0
- package/dist/components/ui/index.d.ts.map +1 -1
- package/dist/components/ui/index.js +1 -0
- package/dist/components/ui/markdown/base-components.d.ts.map +1 -1
- package/dist/components/ui/markdown/base-components.js +2 -1
- package/dist/components/ui/photo-wall.d.ts +7 -3
- package/dist/components/ui/photo-wall.d.ts.map +1 -1
- package/dist/components/ui/photo-wall.js +3 -4
- package/dist/components/ui/square-avatar.d.ts +4 -1
- package/dist/components/ui/square-avatar.d.ts.map +1 -1
- package/dist/components/ui/square-avatar.js +2 -1
- package/dist/components/user-summary-stub.d.ts +1 -1
- package/dist/components/user-summary-stub.d.ts.map +1 -1
- package/dist/components/user-summary-stub.js +16 -6
- package/dist/components/vendor-display-button.d.ts.map +1 -1
- package/dist/components/vendor-display-button.js +13 -3
- package/dist/components/vendor-icon.d.ts +7 -4
- package/dist/components/vendor-icon.d.ts.map +1 -1
- package/dist/components/vendor-icon.js +22 -71
- package/dist/{devices-XIXLFYRJ.cjs → devices-CETR72XY.cjs} +20 -20
- package/dist/{embeddable-chat-SVDMLAER.cjs → embeddable-chat-GHBCX2BY.cjs} +84 -84
- package/dist/hooks/index.cjs +6 -6
- package/dist/hooks/ui/use-image-edge-color.d.ts.map +1 -1
- package/dist/hooks/ui/use-image-edge-color.js +4 -3
- package/dist/index.cjs +43 -25
- package/dist/{knowledge-3DKG5QG2.cjs → knowledge-A2MWEF23.cjs} +20 -20
- package/dist/{logs-RIU2TTRZ.cjs → logs-47JODA6C.cjs} +27 -27
- package/dist/{policies-F2ZB2J4L.cjs → policies-OPIDR6XF.cjs} +23 -23
- package/dist/{remote-session-GBMM5UPQ.cjs → remote-session-IQTPEG63.cjs} +8 -8
- package/dist/{scripts-XX5LMCRA.cjs → scripts-4MQGJWFP.cjs} +26 -26
- package/dist/{software-update-VYBM7SC6.cjs → software-update-MQIGPBZ6.cjs} +23 -23
- package/dist/styles/image-sizes.cjs +68 -0
- package/dist/styles/image-sizes.d.ts +110 -0
- package/dist/styles/image-sizes.d.ts.map +1 -0
- package/dist/styles/image-sizes.js +66 -0
- package/dist/{tickets-board-5QIIA24E.cjs → tickets-board-QF5JNSH2.cjs} +11 -11
- package/eslint-config/base.js +12 -0
- package/eslint-config/image-sizes.js +51 -0
- package/package.json +8 -2
- package/src/components/agent-mark.tsx +3 -4
- package/src/components/chat/chat-message-row.tsx +3 -2
- package/src/components/chat/entity-cards/admin-content-card.tsx +2 -1
- package/src/components/chat/entity-cards/blog-card.tsx +6 -6
- package/src/components/chat/entity-cards/blog-image-placeholder.tsx +2 -1
- package/src/components/chat/entity-cards/case-study-card.tsx +10 -9
- package/src/components/chat/entity-cards/customer-interview-card.tsx +8 -7
- package/src/components/chat/entity-cards/dispatch.tsx +9 -1
- package/src/components/chat/entity-cards/employee-entry-card.tsx +3 -2
- package/src/components/chat/entity-cards/entity-portrait-card.tsx +7 -5
- package/src/components/chat/entity-cards/investor-update-card.tsx +2 -1
- package/src/components/chat/entity-cards/onboarding-guide-card.tsx +10 -2
- package/src/components/chat/entity-cards/program-card.tsx +14 -5
- package/src/components/chat/entity-cards/roadmap-card.tsx +5 -4
- package/src/components/chat/mingo-info-card.tsx +3 -2
- package/src/components/embeds/markdown-image.tsx +2 -1
- package/src/components/embeds/og-link-preview.tsx +14 -6
- package/src/components/embeds/twitter-embed-client.tsx +3 -2
- package/src/components/features/media-gallery-manager.tsx +2 -2
- package/src/components/features/notifications/notification-tile.tsx +3 -2
- package/src/components/features/parallax-image-showcase.tsx +9 -26
- package/src/components/features/select-button.tsx +3 -2
- package/src/components/features/video-hover-preview.tsx +3 -2
- package/src/components/features/video.tsx +10 -1
- package/src/components/features/walkthrough-video.tsx +7 -10
- package/src/components/hero-image-uploader.tsx +9 -1
- package/src/components/icon-display.tsx +2 -1
- package/src/components/media-carousel.tsx +2 -1
- package/src/components/platform/ScriptInfoSection.tsx +9 -1
- package/src/components/shared/media-gallery-strip.tsx +4 -2
- package/src/components/shared/product-release/product-release-card.tsx +10 -2
- package/src/components/ui/avatar-stack.tsx +6 -6
- package/src/components/ui/entity-image.tsx +3 -2
- package/src/components/ui/image-gallery-modal.tsx +2 -1
- package/src/components/ui/image-uploader.tsx +2 -1
- package/src/components/ui/index.ts +1 -0
- package/src/components/ui/markdown/base-components.tsx +2 -1
- package/src/components/ui/photo-wall.tsx +10 -14
- package/src/components/ui/square-avatar.tsx +6 -3
- package/src/components/user-summary-stub.tsx +14 -7
- package/src/components/vendor-display-button.tsx +10 -3
- package/src/components/vendor-icon.tsx +31 -97
- package/src/hooks/ui/use-image-edge-color.ts +8 -4
- package/src/styles/image-sizes.ts +114 -0
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
'use client';
|
|
2
2
|
|
|
3
|
-
import
|
|
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 {
|
|
8
|
-
import {
|
|
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
|
-
|
|
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
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
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
|
-
*
|
|
83
|
-
*
|
|
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
|
|
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
|
-
<
|
|
113
|
-
{logoUrl ?
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
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
|
-
|
|
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
|
-
/**
|
|
8
|
-
|
|
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 =
|
|
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,
|
|
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
|
+
}
|