@asteby/storefront-react 0.10.0 → 0.11.0

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.
@@ -5,9 +5,9 @@ import { ShippingRate, PickupOption, Money } from '@asteby/storefront';
5
5
  type BrandMarkProps = {
6
6
  /** Provider identifier (`fedex`, `oxxo`, `mercadopago`, `7eleven`…). Unknown keys get a neutral monogram. */
7
7
  brand: string | null | undefined;
8
- /** Licensed logo sent by the provider (`PaymentPoint.logo_url`…). Only `https:`; it wins over the badge. */
8
+ /** Licensed logo sent by the provider (`PaymentPoint.logo_url`…). Only `https:`; it wins over the bundled logo and the badge. */
9
9
  logoUrl?: string | null;
10
- /** Height in px. The badge is 3:2 (width = 1.5 × height). Default 24. */
10
+ /** Height in px of the box. Badges are 3:2 (width = 1.5 × height); real logos get a width that follows their shape. Default 24. */
11
11
  size?: number;
12
12
  /**
13
13
  * Accessible name. Omit it when the brand name is already written next to the mark (the usual case): the mark is then
@@ -16,16 +16,25 @@ type BrandMarkProps = {
16
16
  title?: string;
17
17
  className?: string;
18
18
  };
19
+ /** What the mark ended up drawing: the provider's logo, the bundled real logo, or the typographic fallback. */
20
+ type BrandMarkSource = 'provider' | 'logo' | 'badge';
19
21
  /**
20
- * The mark of a carrier, card network, wallet or cash point: an inline SVG badge in the brand color with its short
21
- * wordmark (no network request, same size on the server and in the browser, so no layout shift). With `logoUrl` it
22
- * draws the provider's licensed logo instead, lazily, with fixed dimensions.
22
+ * The mark of a carrier, card network, wallet or cash point. Precedence: the provider's `logoUrl` (https, lazy) > the
23
+ * real logo bundled with the package (inline data URI: no network request, same size on the server and in the browser)
24
+ * > a typographic badge in the brand color for the brands without an available logo.
23
25
  *
24
- * The badge carries its own background, so it keeps its contrast on light and dark themes; a hairline
25
- * (`--sf-brand-mark-ring`) separates it from the page.
26
+ * Logos are never recolored; they sit on a white plate with a hairline (`--sf-brand-mark-ring`, plate color
27
+ * `--sf-brand-mark-plate`) so they keep their contrast on light and dark themes. The element carries
28
+ * `data-sf-brand-mark="<key>"` and `data-sf-brand-source="provider|logo|badge"`.
26
29
  */
27
30
  declare function BrandMark({ brand, logoUrl, size, title, className }: BrandMarkProps): react.JSX.Element;
28
31
 
32
+ type LogoAsset = {
33
+ src: string;
34
+ ar: number;
35
+ mono: boolean;
36
+ };
37
+
29
38
  /**
30
39
  * Shared catalog of the brands a checkout names: parcel carriers, card networks, wallets and cash payment points.
31
40
  *
@@ -33,10 +42,12 @@ declare function BrandMark({ brand, logoUrl, size, title, className }: BrandMark
33
42
  * `PaymentPoint.payment_point` or `id` of the payment addon, a `PaymentMethod.key`). Nothing here decides what a shop
34
43
  * offers: the server lists the rates and methods; this only gives each one its commercial name and a mark.
35
44
  *
36
- * Marks are typographic badges drawn by `<BrandMark>` (brand color + short wordmark): no third-party logo files are
37
- * bundled, so there is no licensing question and no extra request. A provider that holds a licensed logo sends it as
38
- * `logo_url` and it wins over the badge. Colors are close approximations of each brand's public color.
45
+ * Marks are drawn by `<BrandMark>` with this precedence: the provider's `logo_url` > the real logo bundled in
46
+ * `brands/assets` (inline data URI, no request; provenance in `brands/LOGOS.md`) > a typographic badge (brand color +
47
+ * short wordmark) for the brands without an available logo. The `bg`/`fg` colors here are close approximations of each
48
+ * brand's public color and only paint that fallback badge.
39
49
  */
50
+
40
51
  type BrandKind = 'carrier' | 'card' | 'wallet' | 'cash' | 'bank';
41
52
  type Brand = {
42
53
  key: string;
@@ -63,6 +74,10 @@ declare function findBrand(raw: string | null | undefined): Brand | null;
63
74
  declare function brandName(raw: string | null | undefined): string | null;
64
75
  /** Every brand of the catalog (for docs, previews and tests). */
65
76
  declare function listBrands(kind?: BrandKind): Brand[];
77
+ /** Real logo bundled for a provider identifier (inline data URI), or `null` when the brand only has the fallback badge. */
78
+ declare function brandLogo(raw: string | null | undefined): (LogoAsset & {
79
+ key: string;
80
+ }) | null;
66
81
 
67
82
  /**
68
83
  * Pure helpers for the "Delivery" step: how to name a carrier rate, its arrival time, which rate is the cheapest or the
@@ -194,4 +209,4 @@ type DeliveryOptionsProps = {
194
209
  */
195
210
  declare function DeliveryOptions(props: DeliveryOptionsProps): react.JSX.Element;
196
211
 
197
- export { type Brand, type BrandKind, BrandMark, type BrandMarkProps, type DeliveryMessages, DeliveryOptions, type DeliveryOptionsClassNames, type DeliveryOptionsProps, type QuoteNote, type RateBadge, brandKey, brandName, deliveryMessages, findBrand, isQuoteChange, listBrands, matchRate, quoteDeadline, quoteNote, rateBadges, rateCarrier, rateEta, rateService };
212
+ export { type Brand, type BrandKind, BrandMark, type BrandMarkProps, type BrandMarkSource, type DeliveryMessages, DeliveryOptions, type DeliveryOptionsClassNames, type DeliveryOptionsProps, type QuoteNote, type RateBadge, brandKey, brandLogo, brandName, deliveryMessages, findBrand, isQuoteChange, listBrands, matchRate, quoteDeadline, quoteNote, rateBadges, rateCarrier, rateEta, rateService };
@@ -5,9 +5,9 @@ import { ShippingRate, PickupOption, Money } from '@asteby/storefront';
5
5
  type BrandMarkProps = {
6
6
  /** Provider identifier (`fedex`, `oxxo`, `mercadopago`, `7eleven`…). Unknown keys get a neutral monogram. */
7
7
  brand: string | null | undefined;
8
- /** Licensed logo sent by the provider (`PaymentPoint.logo_url`…). Only `https:`; it wins over the badge. */
8
+ /** Licensed logo sent by the provider (`PaymentPoint.logo_url`…). Only `https:`; it wins over the bundled logo and the badge. */
9
9
  logoUrl?: string | null;
10
- /** Height in px. The badge is 3:2 (width = 1.5 × height). Default 24. */
10
+ /** Height in px of the box. Badges are 3:2 (width = 1.5 × height); real logos get a width that follows their shape. Default 24. */
11
11
  size?: number;
12
12
  /**
13
13
  * Accessible name. Omit it when the brand name is already written next to the mark (the usual case): the mark is then
@@ -16,16 +16,25 @@ type BrandMarkProps = {
16
16
  title?: string;
17
17
  className?: string;
18
18
  };
19
+ /** What the mark ended up drawing: the provider's logo, the bundled real logo, or the typographic fallback. */
20
+ type BrandMarkSource = 'provider' | 'logo' | 'badge';
19
21
  /**
20
- * The mark of a carrier, card network, wallet or cash point: an inline SVG badge in the brand color with its short
21
- * wordmark (no network request, same size on the server and in the browser, so no layout shift). With `logoUrl` it
22
- * draws the provider's licensed logo instead, lazily, with fixed dimensions.
22
+ * The mark of a carrier, card network, wallet or cash point. Precedence: the provider's `logoUrl` (https, lazy) > the
23
+ * real logo bundled with the package (inline data URI: no network request, same size on the server and in the browser)
24
+ * > a typographic badge in the brand color for the brands without an available logo.
23
25
  *
24
- * The badge carries its own background, so it keeps its contrast on light and dark themes; a hairline
25
- * (`--sf-brand-mark-ring`) separates it from the page.
26
+ * Logos are never recolored; they sit on a white plate with a hairline (`--sf-brand-mark-ring`, plate color
27
+ * `--sf-brand-mark-plate`) so they keep their contrast on light and dark themes. The element carries
28
+ * `data-sf-brand-mark="<key>"` and `data-sf-brand-source="provider|logo|badge"`.
26
29
  */
27
30
  declare function BrandMark({ brand, logoUrl, size, title, className }: BrandMarkProps): react.JSX.Element;
28
31
 
32
+ type LogoAsset = {
33
+ src: string;
34
+ ar: number;
35
+ mono: boolean;
36
+ };
37
+
29
38
  /**
30
39
  * Shared catalog of the brands a checkout names: parcel carriers, card networks, wallets and cash payment points.
31
40
  *
@@ -33,10 +42,12 @@ declare function BrandMark({ brand, logoUrl, size, title, className }: BrandMark
33
42
  * `PaymentPoint.payment_point` or `id` of the payment addon, a `PaymentMethod.key`). Nothing here decides what a shop
34
43
  * offers: the server lists the rates and methods; this only gives each one its commercial name and a mark.
35
44
  *
36
- * Marks are typographic badges drawn by `<BrandMark>` (brand color + short wordmark): no third-party logo files are
37
- * bundled, so there is no licensing question and no extra request. A provider that holds a licensed logo sends it as
38
- * `logo_url` and it wins over the badge. Colors are close approximations of each brand's public color.
45
+ * Marks are drawn by `<BrandMark>` with this precedence: the provider's `logo_url` > the real logo bundled in
46
+ * `brands/assets` (inline data URI, no request; provenance in `brands/LOGOS.md`) > a typographic badge (brand color +
47
+ * short wordmark) for the brands without an available logo. The `bg`/`fg` colors here are close approximations of each
48
+ * brand's public color and only paint that fallback badge.
39
49
  */
50
+
40
51
  type BrandKind = 'carrier' | 'card' | 'wallet' | 'cash' | 'bank';
41
52
  type Brand = {
42
53
  key: string;
@@ -63,6 +74,10 @@ declare function findBrand(raw: string | null | undefined): Brand | null;
63
74
  declare function brandName(raw: string | null | undefined): string | null;
64
75
  /** Every brand of the catalog (for docs, previews and tests). */
65
76
  declare function listBrands(kind?: BrandKind): Brand[];
77
+ /** Real logo bundled for a provider identifier (inline data URI), or `null` when the brand only has the fallback badge. */
78
+ declare function brandLogo(raw: string | null | undefined): (LogoAsset & {
79
+ key: string;
80
+ }) | null;
66
81
 
67
82
  /**
68
83
  * Pure helpers for the "Delivery" step: how to name a carrier rate, its arrival time, which rate is the cheapest or the
@@ -194,4 +209,4 @@ type DeliveryOptionsProps = {
194
209
  */
195
210
  declare function DeliveryOptions(props: DeliveryOptionsProps): react.JSX.Element;
196
211
 
197
- export { type Brand, type BrandKind, BrandMark, type BrandMarkProps, type DeliveryMessages, DeliveryOptions, type DeliveryOptionsClassNames, type DeliveryOptionsProps, type QuoteNote, type RateBadge, brandKey, brandName, deliveryMessages, findBrand, isQuoteChange, listBrands, matchRate, quoteDeadline, quoteNote, rateBadges, rateCarrier, rateEta, rateService };
212
+ export { type Brand, type BrandKind, BrandMark, type BrandMarkProps, type BrandMarkSource, type DeliveryMessages, DeliveryOptions, type DeliveryOptionsClassNames, type DeliveryOptionsProps, type QuoteNote, type RateBadge, brandKey, brandLogo, brandName, deliveryMessages, findBrand, isQuoteChange, listBrands, matchRate, quoteDeadline, quoteNote, rateBadges, rateCarrier, rateEta, rateService };
package/dist/checkout.js CHANGED
@@ -1,5 +1,5 @@
1
- import { brandName, BrandMark } from './chunk-DSZVJ2PW.js';
2
- export { BrandMark, brandKey, brandName, findBrand, listBrands } from './chunk-DSZVJ2PW.js';
1
+ import { brandName, BrandMark } from './chunk-3ZJTDFHE.js';
2
+ export { BrandMark, brandKey, brandLogo, brandName, findBrand, listBrands } from './chunk-3ZJTDFHE.js';
3
3
  import { useResolvedLocale } from './chunk-T52H5HL3.js';
4
4
  import './chunk-DQBL2DFJ.js';
5
5
  import { useMemo, useSyncExternalStore } from 'react';