spoko-design-system 0.2.67 → 0.2.69

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/index.ts CHANGED
@@ -25,6 +25,9 @@ export { default as ProductModels } from './src/components/Product/ProductModels
25
25
  export { default as ProductName } from './src/components/Product/ProductName.vue';
26
26
  export { default as ProductPositions } from './src/components/Product/ProductPositions.vue';
27
27
  export { default as ProductNumber } from './src/components/Product/ProductNumber.astro';
28
+ export { default as ProductLink } from './src/components/Product/ProductLink.astro';
29
+ export { default as ProductCarousel } from './src/components/Product/ProductCarousel.astro';
30
+
28
31
 
29
32
  export { default as CategoryLink } from './src/components/Category/CategoryLink.vue';
30
33
  export { default as CategorySidebarToggler } from './src/components/Category/CategorySidebarToggler.vue';
@@ -55,7 +58,7 @@ export { default as getShorterDescription } from './src/utils/seo/getShorterDesc
55
58
  // Utils: Text
56
59
 
57
60
  export { getTranslation, text2paragraphs, countWords, firstSentence, removeSemicolon } from './src/utils/text';
58
- export { apiInfo } from './src/utils/getData';
61
+ export { apiInfo, getData } from './src/utils/getData';
59
62
  export { default as formatDate } from './src/utils/text/formatDate';
60
63
  export { default as formatLocaleNumber } from './src/utils/text/formatLocaleNumber';
61
64
  export { default as formatPad } from './src/utils/text/formatPad';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "spoko-design-system",
3
- "version": "0.2.67",
3
+ "version": "0.2.69",
4
4
  "private": false,
5
5
  "main": "./index.ts",
6
6
  "module": "./index.ts",
@@ -0,0 +1,36 @@
1
+ ---
2
+ import ProductLink from "./ProductLink.astro";
3
+
4
+ // Get the product directly from the prop on render
5
+ const { locale, class: className, products, isShopProduct = false, ...rest } = Astro.props;
6
+
7
+ ---
8
+
9
+
10
+ {
11
+ products && products.length && (
12
+ <swiper-container slides-per-view="auto" space-between="0" class="flex"
13
+ itemscope itemtype="https://schema.org/ItemList">
14
+ {
15
+ products.map((product, index) => (
16
+ <swiper-slide class="product-carousel"
17
+ itemprop="itemListElement" itemscope itemtype="https://schema.org/ListItem" >
18
+ <ProductLink productObject={product} locale={locale} index={index+1} bigTile loading="eager" isShopProduct={isShopProduct} />
19
+ <div class="swiper-lazy-preloader"></div>
20
+ </swiper-slide>
21
+ ))
22
+ }
23
+ </swiper-container>
24
+ )
25
+ }
26
+
27
+ <style>
28
+ .similar-section {
29
+ @apply relative z-20;
30
+
31
+ &:hover {
32
+ content-visibility: visible;
33
+ }
34
+ }
35
+
36
+ </style>
@@ -0,0 +1,101 @@
1
+ ---
2
+ import type { Product } from 'types/index';
3
+
4
+ interface Props {
5
+ productId?: number;
6
+ productObject?: Product;
7
+ locale: string;
8
+ index: number;
9
+ bigTile?: boolean;
10
+ loading?: "eager" | "lazy";
11
+ isShopProduct?: boolean;
12
+ }
13
+
14
+ const {
15
+ productId,
16
+ productObject,
17
+ bigTile,
18
+ locale,
19
+ index,
20
+ loading = "lazy",
21
+ isShopProduct = false,
22
+ } = Astro.props;
23
+
24
+ import { getProductById } from '@utils/product/getProductById';
25
+ import { getShopProductById } from '@utils/product/getShopProductById';
26
+ import { getProductUrl } from "@utils/product/getProductUrl";
27
+ import { getShopProductUrl } from "@utils/product/getShopProductUrl";
28
+ import { getProductTranslation } from "@utils/product/getProductTranslation";
29
+ import { getImageUrl } from '@utils/getImageUrl';
30
+ import i18next, { t } from "i18next";
31
+ import { ProductImage, ProductNumber, removeSemicolon, getPriceFormatted } from "spoko-design-system";
32
+
33
+ // Użycie productObject jeśli przekazane, inaczej pobranie produktu na podstawie productId
34
+ const product = productObject || (productId ? (isShopProduct ? await getShopProductById(productId) : await getProductById(productId)) : null);
35
+
36
+ // Określenie URL miniatury produktu
37
+ const thumb = product ? (
38
+ isShopProduct
39
+ ? await getImageUrl(product.images?.[0]?.path || "", "SHOP")
40
+ : await getImageUrl(product.photo || "", `'ProductLink' ${product.number}`)
41
+ ) : "";
42
+
43
+ // Tłumaczenie nazwy produktu jeśli dostępne
44
+ const productTranslation = i18next.exists(`parts.${product?.number}.name`)
45
+ ? null
46
+ : productId ? await getProductTranslation(productId, product?.number || "") : null;
47
+
48
+ // const productName = product ? (
49
+ // isShopProduct
50
+ // ? (locale === "pl" ? product.name_pl : product.name_en)
51
+ // : productTranslation?.name || t(`parts.${product.number}.name`)
52
+ // ) : "";
53
+
54
+ const productName = product.name || 'NO NAME';
55
+
56
+ const nameFormatted = removeSemicolon(productName.toString());
57
+ ---
58
+
59
+ {product && (
60
+ <div class={bigTile ? 'product-link--big-tile' : 'product-thumb--plp product-thumb--carousel'}>
61
+ {product.photo !== null && thumb ? (
62
+ <ProductImage
63
+ imagesApiUrl="https://api.polo.blue"
64
+ imageObject={{
65
+ src: thumb,
66
+ alt: productName,
67
+ height: '180',
68
+ width: '240',
69
+ loading
70
+ }}
71
+ />
72
+ ) : (
73
+ <img src="/1x1.png" class="bg-gray-100/70" alt={productName} />
74
+ )}
75
+ </div>
76
+
77
+ <div class={bigTile ? '' : 'sm:pl-4'}>
78
+ {product.price_pln && (
79
+ <p class="block mb-2 font-600 font-headbold text-5">
80
+ {getPriceFormatted(product)}
81
+ </p>
82
+ )}
83
+
84
+ <a
85
+ class="product-link--url"
86
+ href={isShopProduct ? getShopProductUrl(product.slug, locale) : getProductUrl(product.number, locale)}
87
+ itemprop="url"
88
+ title={product.number}
89
+ set:html={nameFormatted}
90
+ />
91
+
92
+ <ProductNumber productNumber={product.number} copyDisabled={true} />
93
+
94
+ {index !== null && (
95
+ <>
96
+ <meta itemprop="position" content={index.toString()} />
97
+ <meta itemprop="name" content={nameFormatted} />
98
+ </>
99
+ )}
100
+ </div>
101
+ )}