@faststore/core 2.0.130-alpha.0 → 2.0.133-alpha.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.
Files changed (51) hide show
  1. package/.turbo/turbo-build.log +16 -15
  2. package/CHANGELOG.md +12 -0
  3. package/cms/faststore/sections.json +1 -1
  4. package/lighthouserc.js +1 -0
  5. package/next.config.js +2 -0
  6. package/package.json +4 -4
  7. package/src/components/cms/GlobalSections.tsx +4 -3
  8. package/src/components/common/Footer/Footer.tsx +23 -118
  9. package/src/components/common/Footer/FooterLinks.tsx +23 -97
  10. package/src/components/common/Footer/FooterSocial.tsx +42 -0
  11. package/src/components/common/Footer/index.ts +6 -1
  12. package/src/components/common/Toast/Toast.tsx +5 -3
  13. package/src/components/common/Toast/section.module.scss +7 -0
  14. package/src/components/product/ProductCard/ProductCard.tsx +13 -7
  15. package/src/components/product/ProductGrid/ProductGrid.tsx +5 -0
  16. package/src/components/region/RegionButton/RegionButton.tsx +2 -2
  17. package/src/components/sections/BannerNewsletter/BannerNewsletter.tsx +1 -0
  18. package/src/components/sections/BannerNewsletter/section.module.scss +1 -0
  19. package/src/components/sections/EmptyState/EmptyState.tsx +28 -0
  20. package/src/components/sections/EmptyState/index.ts +2 -0
  21. package/src/components/sections/EmptyState/section.module.scss +8 -0
  22. package/src/components/sections/Footer/Footer.tsx +87 -0
  23. package/src/components/sections/Footer/index.ts +1 -0
  24. package/src/components/{common → sections}/Footer/section.module.scss +1 -0
  25. package/src/components/sections/Hero/Hero.tsx +0 -1
  26. package/src/components/sections/Incentives/Incentives.tsx +19 -0
  27. package/src/components/sections/Incentives/index.ts +1 -0
  28. package/src/components/sections/ProductDetails/section.module.scss +1 -0
  29. package/src/components/sections/ProductGallery/section.module.scss +1 -0
  30. package/src/components/sections/ProductShelf/ProductShelf.tsx +12 -4
  31. package/src/components/sections/ProductTiles/ProductTiles.tsx +21 -0
  32. package/src/components/ui/Button/ButtonSignIn/ButtonSignIn.tsx +1 -1
  33. package/src/components/ui/Image/Image.tsx +7 -18
  34. package/src/components/ui/Image/loader.ts +16 -0
  35. package/src/components/ui/ImageGallery/ImageGallery.tsx +7 -14
  36. package/src/components/ui/Incentives/Incentives.tsx +11 -7
  37. package/src/components/ui/Incentives/index.ts +1 -1
  38. package/src/components/ui/SkuSelector/Selectors.tsx +4 -17
  39. package/src/pages/404.tsx +5 -4
  40. package/src/pages/500.tsx +19 -5
  41. package/src/pages/[...slug].tsx +0 -1
  42. package/src/pages/index.tsx +2 -2
  43. package/src/pages/login.tsx +5 -3
  44. package/src/utils/utilities.ts +13 -0
  45. package/src/components/common/Footer/FooterFlags.tsx +0 -26
  46. package/src/components/sections/IncentivesHeader/IncentivesHeader.tsx +0 -24
  47. package/src/components/sections/IncentivesHeader/index.ts +0 -1
  48. package/src/components/ui/Image/thumborUrlBuilder.ts +0 -103
  49. package/src/components/ui/Image/useImage.ts +0 -46
  50. package/src/components/ui/Incentives/incentivesMock.ts +0 -27
  51. /package/src/components/sections/{IncentivesHeader → Incentives}/section.module.scss +0 -0
@@ -1 +0,0 @@
1
- export { default } from './IncentivesHeader'
@@ -1,103 +0,0 @@
1
- import storeConfig from 'faststore.config'
2
-
3
- export type FilterValue = boolean | string | string[] | number[]
4
-
5
- export interface Box {
6
- top: number
7
- bottom: number
8
- left: number
9
- right: number
10
- }
11
-
12
- export interface ThumborOptions {
13
- flipHorizontal?: boolean
14
- flipVertical?: boolean
15
- trim?: boolean
16
- fitIn?: boolean
17
- horizontalAlign?: 'left' | 'center' | 'right'
18
- verticalAlign?: 'top' | 'middle' | 'bottom'
19
- smart?: boolean
20
- filters?: Record<string, FilterValue>
21
- manualCrop?: Box | false
22
- }
23
-
24
- const THUMBOR_SERVER = `https://${storeConfig.api.storeId}.vtexassets.com`
25
-
26
- const cropSection = ({ left, top, right, bottom }: Box) =>
27
- `${left}x${top}:${right}x${bottom}`
28
-
29
- function filtersURIComponent(filters: Record<string, FilterValue>) {
30
- const elements = ['filters']
31
-
32
- Object.keys(filters).forEach((name) => {
33
- const parameters = filters[name]
34
- let stringParameters
35
-
36
- // If we have several parameters, they were passed as an array
37
- // and now they need to be comma separated, otherwise there is just one to convert to a string
38
- if (Array.isArray(parameters)) {
39
- stringParameters = parameters.join(',')
40
- }
41
- // If true, we don't even need to do anything, we just have an empty string and insert ()
42
- // Ex: {grayscale: true} => grayscale()
43
- else if (parameters === true) {
44
- stringParameters = ''
45
- } else {
46
- stringParameters = String(parameters)
47
- }
48
-
49
- elements.push(`${name}(${stringParameters})`)
50
- })
51
-
52
- return elements.join(':')
53
- }
54
-
55
- export const urlBuilder = (baseUrl: string, options: ThumborOptions) => {
56
- const preSizeComponents = [THUMBOR_SERVER, 'unsafe']
57
- const postSizeComponents: string[] = []
58
-
59
- // Add the trim parameter after unsafe if appliable
60
- options.trim && preSizeComponents.push('trim')
61
-
62
- // Add the crop parameter if any
63
- options.manualCrop && preSizeComponents.push(cropSection(options.manualCrop))
64
-
65
- // Add the fit-in parameter after crop if appliable
66
- options.fitIn && preSizeComponents.push('fit-in')
67
-
68
- // Adds the horizontal alignement after the size
69
- postSizeComponents.push(options.horizontalAlign ?? 'center')
70
-
71
- // Adds the vertical alignement after the size
72
- postSizeComponents.push(options.verticalAlign ?? 'middle')
73
-
74
- // Adds the smart parameter if appliable
75
- options.smart && postSizeComponents.push('smart')
76
-
77
- // Compile the filters and add them right before the URI
78
- const { filters } = options
79
-
80
- filters && postSizeComponents.push(filtersURIComponent(filters))
81
-
82
- // Finally, adds the real image uri
83
- postSizeComponents.push(encodeURIComponent(baseUrl))
84
-
85
- return (width: number, height: number) => {
86
- // Adds the final size parameter
87
- let finalSize = ''
88
-
89
- if (options.flipHorizontal) {
90
- finalSize += '-'
91
- }
92
-
93
- finalSize += `${width}x`
94
-
95
- if (options.flipVertical) {
96
- finalSize += '-'
97
- }
98
-
99
- finalSize += `${height}`
100
-
101
- return [...preSizeComponents, finalSize, ...postSizeComponents].join('/')
102
- }
103
- }
@@ -1,46 +0,0 @@
1
- import { useMemo } from 'react'
2
- import type { ImgHTMLAttributes } from 'react'
3
-
4
- import { urlBuilder } from './thumborUrlBuilder'
5
- import type { ThumborOptions } from './thumborUrlBuilder'
6
-
7
- export interface ImageOptions extends ImgHTMLAttributes<HTMLImageElement> {
8
- src: string
9
- width: number
10
- height: number
11
- options?: ThumborOptions
12
- }
13
-
14
- const FACTORS = [1, 2, 3]
15
- const LARGE_FACTOR = FACTORS[FACTORS.length - 1]
16
-
17
- export const useImage = ({
18
- src: baseUrl,
19
- width,
20
- height,
21
- options = {},
22
- ...rest
23
- }: ImageOptions): ImgHTMLAttributes<HTMLImageElement> => {
24
- const { srcSet, src } = useMemo(() => {
25
- const builder = urlBuilder(baseUrl, options)
26
-
27
- const srcs = FACTORS.map((factor) => {
28
- const rescaledWidth = width * factor
29
-
30
- return `${builder(rescaledWidth, height * factor)} ${rescaledWidth}w`
31
- })
32
-
33
- return {
34
- src: builder(width * LARGE_FACTOR, height * LARGE_FACTOR),
35
- srcSet: srcs.join(', '),
36
- }
37
- }, [height, options, baseUrl, width])
38
-
39
- return {
40
- src,
41
- srcSet,
42
- width: `${width}px`,
43
- height: `${height}px`,
44
- ...rest,
45
- }
46
- }
@@ -1,27 +0,0 @@
1
- export const incentivesMockFooter = [
2
- {
3
- icon: 'ShieldCheck',
4
- firstLineText: 'Trusted',
5
- secondLineText: 'by Safecon',
6
- },
7
- {
8
- icon: 'Medal',
9
- firstLineText: 'Quality',
10
- secondLineText: 'Products',
11
- },
12
- {
13
- icon: 'CircleWavyCheck',
14
- firstLineText: '3-year',
15
- secondLineText: 'Guarantee',
16
- },
17
- {
18
- icon: 'Storefront',
19
- firstLineText: 'Pickup',
20
- secondLineText: 'Options',
21
- },
22
- {
23
- icon: 'Truck',
24
- firstLineText: 'Free',
25
- secondLineText: 'Shippping',
26
- },
27
- ]