@garagem-ai/site-sdk 0.4.0 → 0.4.2

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.
@@ -7,6 +7,7 @@ import { formatAreaM2 } from "../presentation";
7
7
  import { toListingCardModel } from "../listing-card-model";
8
8
  import type { Listing } from "../types";
9
9
  import { cn } from "./cn";
10
+ import { SearchChromeStyles } from "./styles";
10
11
  import type { ListingCardProps } from "./types";
11
12
 
12
13
  function isListing(value: ListingCardProps["listing"]): value is Listing {
@@ -26,118 +27,72 @@ export function ListingCard({
26
27
  const model = isListing(listing) ? toListingCardModel(listing) : listing;
27
28
  const target = href ?? model.href;
28
29
  const areaLabel = formatAreaM2(model.areaM2);
29
-
30
30
  return (
31
- <article
32
- data-slot="listing-card"
33
- className={cn(
34
- "group overflow-hidden rounded-[var(--garagem-listing-card-radius,0.75rem)] border border-border bg-background",
35
- className,
36
- classNames?.root
37
- )}
38
- style={style}
39
- >
40
- <Link
41
- href={target}
42
- className="block cursor-pointer"
43
- data-slot="listing-card-link"
31
+ <>
32
+ <SearchChromeStyles />
33
+ <article
34
+ data-slot="listing-card"
35
+ className={cn(className, classNames?.root)}
36
+ style={style}
44
37
  >
45
- <div
46
- data-slot="listing-card-media"
47
- className={cn(
48
- "relative w-full overflow-hidden bg-muted",
49
- classNames?.media
50
- )}
51
- style={{ aspectRatio: "var(--garagem-listing-media-ratio, 4 / 3)" }}
52
- >
53
- {slots?.media ??
54
- (model.coverSrc ? (
55
- <img
56
- src={model.coverSrc}
57
- alt={model.coverAlt}
58
- className="h-full w-full object-cover transition-transform duration-300 group-hover:scale-105"
59
- />
60
- ) : (
61
- <div className="flex h-full w-full items-center justify-center text-xs text-muted-foreground">
62
- Sem foto
63
- </div>
64
- ))}
65
- {slots?.badge ?? (
66
- <span
67
- data-slot="listing-card-badge"
68
- className={cn(
69
- "absolute left-3 top-3 rounded-full bg-background/90 px-2 py-1 text-xs font-medium",
70
- classNames?.badge
71
- )}
72
- >
73
- {model.businessLabel}
74
- </span>
75
- )}
76
- </div>
77
- <div
78
- data-slot="listing-card-body"
79
- className={cn("p-4", classNames?.body)}
80
- >
81
- <div className="flex items-baseline justify-between gap-2">
38
+ <Link href={target} data-slot="listing-card-link">
39
+ <div data-slot="listing-card-media" className={classNames?.media}>
40
+ {slots?.media ??
41
+ (model.coverSrc ? (
42
+ <img src={model.coverSrc} alt={model.coverAlt} />
43
+ ) : (
44
+ <div data-slot="listing-card-empty">Sem foto</div>
45
+ ))}
46
+ {slots?.badge ?? (
47
+ <span
48
+ data-slot="listing-card-badge"
49
+ className={classNames?.badge}
50
+ >
51
+ {model.businessLabel}
52
+ </span>
53
+ )}
54
+ </div>
55
+ <div data-slot="listing-card-body" className={classNames?.body}>
56
+ <div data-slot="listing-card-price-row">
57
+ <p data-slot="listing-card-price" className={classNames?.price}>
58
+ {model.priceLabel}
59
+ </p>
60
+ {model.pricePeriod ? (
61
+ <span data-slot="listing-card-period">{model.pricePeriod}</span>
62
+ ) : null}
63
+ </div>
64
+ <h3 data-slot="listing-card-title" className={classNames?.title}>
65
+ {model.title}
66
+ </h3>
82
67
  <p
83
- data-slot="listing-card-price"
84
- className={cn("font-semibold tracking-tight", classNames?.price)}
85
- style={{
86
- fontSize: "var(--garagem-listing-price-size, 1.125rem)",
87
- }}
68
+ data-slot="listing-card-location"
69
+ className={classNames?.location}
88
70
  >
89
- {model.priceLabel}
71
+ {model.locationLabel || model.propertyType || ""}
90
72
  </p>
91
- {model.pricePeriod ? (
92
- <span className="text-xs text-muted-foreground">
93
- {model.pricePeriod}
94
- </span>
73
+ <ul
74
+ data-slot="listing-card-features"
75
+ className={classNames?.features}
76
+ >
77
+ {model.bedrooms != null ? (
78
+ <li>{model.bedrooms} quartos</li>
79
+ ) : null}
80
+ {model.bathrooms != null ? (
81
+ <li>{model.bathrooms} banheiros</li>
82
+ ) : null}
83
+ {model.parkingSpaces != null ? (
84
+ <li>{model.parkingSpaces} vagas</li>
85
+ ) : null}
86
+ {areaLabel ? <li>{areaLabel}</li> : null}
87
+ </ul>
88
+ {slots?.cta ? (
89
+ <div data-slot="listing-card-cta" className={classNames?.cta}>
90
+ {slots.cta}
91
+ </div>
95
92
  ) : null}
96
93
  </div>
97
- <h3
98
- data-slot="listing-card-title"
99
- className={cn(
100
- "mt-1 line-clamp-1 text-sm font-medium",
101
- classNames?.title
102
- )}
103
- >
104
- {model.title}
105
- </h3>
106
- <p
107
- data-slot="listing-card-location"
108
- className={cn(
109
- "mt-0.5 line-clamp-1 text-xs text-muted-foreground",
110
- classNames?.location
111
- )}
112
- >
113
- {model.locationLabel || model.propertyType || ""}
114
- </p>
115
- <ul
116
- data-slot="listing-card-features"
117
- className={cn(
118
- "mt-3 flex flex-wrap items-center gap-x-4 gap-y-1 text-xs text-muted-foreground",
119
- classNames?.features
120
- )}
121
- >
122
- {model.bedrooms != null ? <li>{model.bedrooms} quartos</li> : null}
123
- {model.bathrooms != null ? (
124
- <li>{model.bathrooms} banheiros</li>
125
- ) : null}
126
- {model.parkingSpaces != null ? (
127
- <li>{model.parkingSpaces} vagas</li>
128
- ) : null}
129
- {areaLabel ? <li>{areaLabel}</li> : null}
130
- </ul>
131
- {slots?.cta ? (
132
- <div
133
- data-slot="listing-card-cta"
134
- className={cn("mt-3", classNames?.cta)}
135
- >
136
- {slots.cta}
137
- </div>
138
- ) : null}
139
- </div>
140
- </Link>
141
- </article>
94
+ </Link>
95
+ </article>
96
+ </>
142
97
  );
143
98
  }
@@ -3,7 +3,7 @@
3
3
  import type { ReactElement } from "react";
4
4
 
5
5
  import { searchSortOptions } from "../search-engine";
6
- import { cn } from "./cn";
6
+ import { SearchChromeStyles } from "./styles";
7
7
 
8
8
  export type SearchSortSelectProps = {
9
9
  value: string;
@@ -20,13 +20,13 @@ export function SearchSortSelect({
20
20
  }: SearchSortSelectProps): ReactElement {
21
21
  const options = searchSortOptions(sorts);
22
22
  return (
23
- <label className={cn("text-sm", className)}>
24
- <span className="mb-1 block text-muted-foreground">Ordenar</span>
23
+ <label data-slot="search-sort" className={className}>
24
+ <span data-slot="search-label">Ordenar</span>
25
25
  <select
26
26
  id="garagem-search-sort"
27
+ data-slot="search-sort-trigger"
27
28
  value={value}
28
29
  onChange={(event) => onChange(event.target.value || null)}
29
- className="min-h-10 cursor-pointer rounded-lg border border-border bg-background px-3"
30
30
  >
31
31
  {options.map((sort) => (
32
32
  <option key={sort.id || "relevance"} value={sort.id}>
@@ -44,29 +44,32 @@ export function ResultsSkeleton({
44
44
  className?: string;
45
45
  }): ReactElement {
46
46
  return (
47
- <div
48
- data-slot="search-skeleton"
49
- className={cn(
50
- "grid grid-cols-1 gap-[var(--garagem-listing-card-gap,1.5rem)] sm:grid-cols-2 lg:grid-cols-3",
51
- className
52
- )}
53
- >
54
- {Array.from({ length: 6 }, (_, i) => (
55
- <div
56
- key={i}
57
- className="overflow-hidden rounded-[var(--garagem-listing-card-radius,0.75rem)] border border-border"
58
- >
59
- <div
60
- className="animate-pulse bg-muted"
61
- style={{ aspectRatio: "4 / 3" }}
62
- />
63
- <div className="space-y-2 p-4">
64
- <div className="h-5 w-1/2 animate-pulse rounded bg-muted" />
65
- <div className="h-4 w-3/4 animate-pulse rounded bg-muted" />
66
- <div className="h-3 w-2/3 animate-pulse rounded bg-muted" />
47
+ <>
48
+ <SearchChromeStyles />
49
+ <div data-slot="search-skeleton" className={className}>
50
+ {Array.from({ length: 6 }, (_, i) => (
51
+ <div key={i} data-slot="search-skeleton-card">
52
+ <div data-slot="search-skeleton-block" data-kind="media" />
53
+ <div data-slot="search-skeleton-body">
54
+ <div data-slot="search-skeleton-block" data-kind="line-lg" />
55
+ <div data-slot="search-skeleton-block" data-kind="line-md" />
56
+ <div data-slot="search-skeleton-block" data-kind="line-sm" />
57
+ </div>
67
58
  </div>
68
- </div>
69
- ))}
70
- </div>
59
+ ))}
60
+ </div>
61
+ </>
62
+ );
63
+ }
64
+
65
+ export function SearchPageFallback({
66
+ className,
67
+ }: {
68
+ className?: string;
69
+ }): ReactElement {
70
+ return (
71
+ <main data-slot="search-page">
72
+ <ResultsSkeleton className={className} />
73
+ </main>
71
74
  );
72
75
  }