@usequeek/theme-kit 0.1.33 → 0.1.34

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@usequeek/theme-kit",
3
- "version": "0.1.33",
3
+ "version": "0.1.34",
4
4
  "private": false,
5
5
  "license": "MIT",
6
6
  "description": "The runtime a Queek storefront theme is built on: hooks, stores, page renderer, navigation, shared blocks and locale strings.",
@@ -1,4 +1,5 @@
1
1
  import type { GalleryBlockData } from '../types/block';
2
+ import { isBlankText } from './blank-text';
2
3
 
3
4
  type HeroSlide = GalleryBlockData['images'][number];
4
5
 
@@ -21,15 +22,38 @@ export function heroImageMode(images: GalleryBlockData['images']): 'zero' | 'sin
21
22
  return images.length === 1 ? 'single' : 'multi';
22
23
  }
23
24
 
25
+ /**
26
+ * A merchant's own slide shows exactly what they typed: a blank title, subtitle or
27
+ * button label renders nothing (busy slide images need bare slides). The store
28
+ * name, slogan and "Shop now" fill in only for the zero-image placeholder hero,
29
+ * where `slide` is undefined. Callers render each part only when it is non-empty.
30
+ */
24
31
  export function resolveHeroContent(
25
32
  slide: HeroSlide | undefined,
26
33
  fallback: HeroFallbacks,
27
34
  ): ResolvedHeroContent {
35
+ const ctaHref = text(slide?.cta_url) || fallback.shopHref;
36
+ const slideHref = text(slide?.link) || null;
37
+
38
+ if (slide === undefined) {
39
+ return {
40
+ title: fallback.title,
41
+ subtitle: text(fallback.subtitle) || null,
42
+ ctaLabel: 'Shop now',
43
+ ctaHref,
44
+ slideHref,
45
+ };
46
+ }
47
+
28
48
  return {
29
- title: slide?.title?.trim() || fallback.title,
30
- subtitle: slide?.subtitle?.trim() || fallback.subtitle?.trim() || null,
31
- ctaLabel: slide?.cta_label?.trim() || 'Shop now',
32
- ctaHref: slide?.cta_url?.trim() || fallback.shopHref,
33
- slideHref: slide?.link?.trim() || null,
49
+ title: text(slide.title),
50
+ subtitle: text(slide.subtitle) || null,
51
+ ctaLabel: text(slide.cta_label),
52
+ ctaHref,
53
+ slideHref,
34
54
  };
35
55
  }
56
+
57
+ function text(value: string | null | undefined): string {
58
+ return isBlankText(value) ? '' : (value as string).trim();
59
+ }