@bosonprotocol/react-kit 0.34.0-alpha.15 → 0.34.0-alpha.17

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 (43) hide show
  1. package/dist/cjs/components/currencyDisplay/CurrencyDisplay.d.ts +4 -1
  2. package/dist/cjs/components/currencyDisplay/CurrencyDisplay.d.ts.map +1 -1
  3. package/dist/cjs/components/currencyDisplay/CurrencyDisplay.js +6 -7
  4. package/dist/cjs/components/currencyDisplay/CurrencyDisplay.js.map +1 -1
  5. package/dist/cjs/components/image/Image.styles.d.ts.map +1 -1
  6. package/dist/cjs/components/image/Image.styles.js +0 -2
  7. package/dist/cjs/components/image/Image.styles.js.map +1 -1
  8. package/dist/cjs/components/productCard/ProductCard.d.ts +4 -1
  9. package/dist/cjs/components/productCard/ProductCard.d.ts.map +1 -1
  10. package/dist/cjs/components/productCard/ProductCard.js +42 -34
  11. package/dist/cjs/components/productCard/ProductCard.js.map +1 -1
  12. package/dist/cjs/components/productCard/ProductCard.styles.d.ts +111 -4
  13. package/dist/cjs/components/productCard/ProductCard.styles.d.ts.map +1 -1
  14. package/dist/cjs/components/productCard/ProductCard.styles.js +49 -25
  15. package/dist/cjs/components/productCard/ProductCard.styles.js.map +1 -1
  16. package/dist/cjs/components/skeleton/ProductCardSkeleton.d.ts.map +1 -1
  17. package/dist/cjs/components/skeleton/ProductCardSkeleton.js +1 -1
  18. package/dist/cjs/components/skeleton/ProductCardSkeleton.js.map +1 -1
  19. package/dist/esm/components/currencyDisplay/CurrencyDisplay.d.ts +4 -1
  20. package/dist/esm/components/currencyDisplay/CurrencyDisplay.d.ts.map +1 -1
  21. package/dist/esm/components/currencyDisplay/CurrencyDisplay.js +6 -7
  22. package/dist/esm/components/currencyDisplay/CurrencyDisplay.js.map +1 -1
  23. package/dist/esm/components/image/Image.styles.d.ts.map +1 -1
  24. package/dist/esm/components/image/Image.styles.js +0 -2
  25. package/dist/esm/components/image/Image.styles.js.map +1 -1
  26. package/dist/esm/components/productCard/ProductCard.d.ts +4 -1
  27. package/dist/esm/components/productCard/ProductCard.d.ts.map +1 -1
  28. package/dist/esm/components/productCard/ProductCard.js +20 -32
  29. package/dist/esm/components/productCard/ProductCard.js.map +1 -1
  30. package/dist/esm/components/productCard/ProductCard.styles.d.ts +111 -4
  31. package/dist/esm/components/productCard/ProductCard.styles.d.ts.map +1 -1
  32. package/dist/esm/components/productCard/ProductCard.styles.js +48 -23
  33. package/dist/esm/components/productCard/ProductCard.styles.js.map +1 -1
  34. package/dist/esm/components/skeleton/ProductCardSkeleton.d.ts.map +1 -1
  35. package/dist/esm/components/skeleton/ProductCardSkeleton.js +2 -2
  36. package/dist/esm/components/skeleton/ProductCardSkeleton.js.map +1 -1
  37. package/package.json +5 -5
  38. package/src/components/currencyDisplay/CurrencyDisplay.tsx +20 -17
  39. package/src/components/image/Image.styles.ts +0 -2
  40. package/src/components/productCard/ProductCard.styles.ts +55 -25
  41. package/src/components/productCard/ProductCard.tsx +53 -55
  42. package/src/components/skeleton/ProductCardSkeleton.tsx +2 -3
  43. package/src/stories/ProductCard.stories.tsx +1 -7
@@ -1,5 +1,5 @@
1
1
  import React from "react";
2
- import styled, { css } from "styled-components";
2
+ import styled, { css, CSSProperties } from "styled-components";
3
3
 
4
4
  import {
5
5
  Bitcoin,
@@ -24,10 +24,14 @@ export enum Currencies {
24
24
  USDC = "USDC",
25
25
  WETH = "WETH"
26
26
  }
27
+
27
28
  interface CurrencyDisplayProps {
28
29
  value?: number | string;
29
30
  currency: Currencies;
30
31
  height?: number;
32
+ fontSize?: number | string;
33
+ iconSize?: number;
34
+ gap?: number | string;
31
35
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
32
36
  [x: string]: any;
33
37
  }
@@ -36,6 +40,9 @@ export const CurrencyDisplay = ({
36
40
  value,
37
41
  currency,
38
42
  height = 25,
43
+ fontSize,
44
+ iconSize,
45
+ gap,
39
46
  ...rest
40
47
  }: CurrencyDisplayProps) => {
41
48
  return (
@@ -43,9 +50,11 @@ export const CurrencyDisplay = ({
43
50
  style={{ height: `${height}px`, width: "100%" }}
44
51
  {...rest}
45
52
  >
46
- <CurrencyLogo currency={currency} size={height} />
53
+ <CurrencyLogo currency={currency} size={iconSize || height} />
47
54
  {value && (
48
- <CurrencyDisplayValue $height={height}>{value}</CurrencyDisplayValue>
55
+ <CurrencyDisplayValue $height={height} $fontSize={fontSize} $gap={gap}>
56
+ {value}
57
+ </CurrencyDisplayValue>
49
58
  )}
50
59
  </CurrencyDisplayValueWrapper>
51
60
  );
@@ -57,17 +66,20 @@ const CurrencyDisplayValueWrapper = styled.div`
57
66
  align-items: center;
58
67
  `;
59
68
 
60
- const CurrencyDisplayValue = styled.span<{ $height: number }>`
61
- ${({ $height }) => css`
69
+ const CurrencyDisplayValue = styled.span<{
70
+ $height: CSSProperties["height"];
71
+ $fontSize?: CSSProperties["fontSize"];
72
+ $gap?: CSSProperties["gap"];
73
+ }>`
74
+ ${({ $height, $fontSize, $gap }) => css`
62
75
  line-height: ${$height}px;
63
- font-size: ${($height - 5) / 16}rem;
76
+ font-size: ${$fontSize ? $fontSize : `${(Number($height) - 5) / 16}rem`};
77
+ padding-left: ${$gap !== undefined ? $gap : "1rem"};
64
78
  `}
65
-
66
79
  color: #09182c;
67
80
  display: flex;
68
81
  text-align: right;
69
82
  align-items: center;
70
- padding-left: 1rem;
71
83
  `;
72
84
 
73
85
  export const CurrencyLogo = ({
@@ -80,31 +92,22 @@ export const CurrencyLogo = ({
80
92
  switch (currency) {
81
93
  case Currencies.ETH:
82
94
  return <Ether size={size} />;
83
-
84
95
  case Currencies.BTC:
85
96
  return <Bitcoin size={size} />;
86
-
87
97
  case Currencies.POLYGON:
88
98
  return <Polygon size={size} />;
89
-
90
99
  case Currencies.SOLANA:
91
100
  return <Solana size={size} />;
92
-
93
101
  case Currencies.TETHER:
94
102
  return <Tether size={size} />;
95
-
96
103
  case Currencies.DAI:
97
104
  return <Dai size={size} />;
98
-
99
105
  case Currencies.WETH:
100
106
  return <Weth size={size} />;
101
-
102
107
  case Currencies.BOSON:
103
108
  return <Boson size={size} />;
104
-
105
109
  case Currencies.USDC:
106
110
  return <Usdc size={size} />;
107
-
108
111
  default:
109
112
  return <div>{currency}</div>;
110
113
  }
@@ -15,8 +15,6 @@ export const ImageContainer = styled.img`
15
15
  width: 100%;
16
16
  height: 100%;
17
17
  object-fit: contain;
18
- object-position: top;
19
- padding: 1rem;
20
18
  `;
21
19
 
22
20
  const buttonText = css`
@@ -1,13 +1,14 @@
1
1
  import styled, { css } from "styled-components";
2
2
  import { theme } from "../../theme";
3
3
  import { cardWrapperStyles } from "./commonStyles";
4
+ import { Typography } from "../ui/Typography";
5
+ import { zIndex } from "../ui/zIndex";
4
6
 
5
7
  export const ProductCardLabelWrapper = styled.div`
6
8
  position: absolute;
7
9
  top: 0.5rem;
8
10
  left: 0.5rem;
9
11
  background: white;
10
- padding: 0.25rem 0.5rem 0.25rem 0.5rem;
11
12
  font-weight: 600;
12
13
  color: ${({ theme }) => theme?.colors?.light.darkGrey};
13
14
  z-index: 1;
@@ -73,20 +74,24 @@ export const ProductCardCreatorAvatar = styled.div`
73
74
 
74
75
  export const ProductCardCreatorName = styled.div`
75
76
  font-weight: 600;
76
- font-size: 0.75rem;
77
+ font-size: 0.625rem;
77
78
  line-height: 150%;
78
- min-height: 3em;
79
- color: ${({ theme }) => theme?.colors?.light.accent};
79
+ color: ${({ theme }) => theme?.colors?.light.darkGrey};
80
80
  flex: none;
81
81
  order: 1;
82
82
  flex-grow: 0;
83
- justify-self: flex-end;
84
- margin-bottom: 0.25rem;
83
+ justify-self: flex-start;
84
+ margin-right: auto;
85
+ > span {
86
+ font-weight: 600;
87
+ font-size: 0.625rem;
88
+ color: ${({ theme }) => theme?.colors?.light.darkGrey};
89
+ }
85
90
  `;
86
91
 
87
- export const ProductCardTitle = styled.div.attrs({ className: "title" })`
88
- font-weight: 600;
89
- font-size: 1.25rem;
92
+ export const ProductCardTitle = styled(Typography).attrs({
93
+ className: "title"
94
+ })`
90
95
  color: ${({ theme }) => theme?.colors?.light.black};
91
96
  word-break: break-word;
92
97
  overflow: hidden;
@@ -117,37 +122,34 @@ export const ProductCardPrice = styled.div`
117
122
  color: ${({ theme }) => theme?.colors?.light.darkGrey};
118
123
  `;
119
124
 
120
- export const ProductCardData = styled.div`
121
- display: flex;
122
- flex-direction: column;
123
- `;
124
-
125
125
  export const ProductCardBottom = styled.div.attrs({ className: "bottom" })`
126
126
  width: 100%;
127
- background: ${theme?.colors?.light.white};
128
127
  height: 12rem;
129
128
  display: flex;
130
129
  flex-direction: column;
131
- justify-content: space-between;
130
+ justify-content: flex-end;
131
+ z-index: ${zIndex.ChatSeparator};
132
+ flex: 0;
132
133
  `;
133
134
  export const ProductCardBottomContent = styled.div`
134
135
  display: flex;
135
136
  justify-content: space-between;
137
+ flex-direction: column;
136
138
  width: 100%;
137
- padding: 1rem 1.5rem 0.5rem 1.5rem;
138
139
  box-sizing: border-box;
139
140
  align-items: flex-start;
140
141
  column-gap: 0.25rem;
141
- border-top: 2px solid ${theme.colors.light.border};
142
142
  `;
143
143
 
144
144
  export const ProductCardTitleWrapper = styled.div`
145
145
  width: 100%;
146
- padding: 0 1.5rem 0.5rem 1.5rem;
147
146
  box-sizing: border-box;
148
147
  `;
149
148
 
150
- export const ProductCardWrapper = styled.div<{ $isHoverDisabled: boolean }>`
149
+ export const ProductCardWrapper = styled.div<{
150
+ $isHoverDisabled: boolean;
151
+ $isImageFitCover?: boolean;
152
+ }>`
151
153
  ${cardWrapperStyles}
152
154
  overflow: hidden;
153
155
  position: relative;
@@ -156,6 +158,9 @@ export const ProductCardWrapper = styled.div<{ $isHoverDisabled: boolean }>`
156
158
  justify-content: space-between;
157
159
  flex-direction: column;
158
160
  cursor: pointer;
161
+ min-height: 286px;
162
+ height: 286px;
163
+ padding: 0 1rem 1rem 1rem;
159
164
  [data-image-wrapper] {
160
165
  position: static;
161
166
  padding-top: 0;
@@ -163,6 +168,15 @@ export const ProductCardWrapper = styled.div<{ $isHoverDisabled: boolean }>`
163
168
  display: flex;
164
169
  justify-content: center;
165
170
  align-items: center;
171
+ ${({ $isImageFitCover }) =>
172
+ $isImageFitCover
173
+ ? css`
174
+ width: 100%;
175
+ img {
176
+ object-fit: cover;
177
+ }
178
+ `
179
+ : ""}
166
180
  }
167
181
  ${({ $isHoverDisabled }) =>
168
182
  !$isHoverDisabled
@@ -176,8 +190,10 @@ export const ProductCardWrapper = styled.div<{ $isHoverDisabled: boolean }>`
176
190
  16px 16px 16px rgba(0, 0, 0, 0.05);
177
191
 
178
192
  [data-image-wrapper] {
193
+ width: 110%;
179
194
  img {
180
- transform: scale(1.05);
195
+ transform: scale(1.5);
196
+ object-position: center;
181
197
  transition: all 300ms ease-in-out;
182
198
  }
183
199
  }
@@ -192,7 +208,7 @@ export const ProductCardTop = styled.div<{ $isNotImageLoaded: boolean }>`
192
208
  overflow: hidden;
193
209
  width: 100%;
194
210
  align-self: stretch;
195
- z-index: 0;
211
+ z-index: ${zIndex.Default};
196
212
  `;
197
213
 
198
214
  export const BottomText = styled.p`
@@ -200,14 +216,28 @@ export const BottomText = styled.p`
200
216
  font-weight: 600;
201
217
  line-height: 0.975rem;
202
218
  margin: 0;
203
- padding: 0 1.5rem 1rem 1.5rem;
204
219
  letter-spacing: 0.5px;
205
220
  color: ${theme.colors.light.darkGrey};
206
221
  `;
207
222
 
208
223
  export const ProductCardImageWrapper = styled.div`
209
224
  width: 100%;
210
- min-height: 0;
211
- height: auto;
225
+ height: 13.125rem;
226
+ display: flex;
227
+ justify-content: center;
228
+ align-items: center;
229
+ padding-top: 0.9375rem;
230
+ padding-bottom: 0.9375rem;
212
231
  flex: 1;
213
232
  `;
233
+
234
+ export const ProductCardImageAndCTAContainer = styled.div`
235
+ position: relative;
236
+ `;
237
+
238
+ export const CTAOnHoverContainer = styled.div<{ $isHovered: boolean }>`
239
+ position: absolute;
240
+ z-index: ${zIndex.OfferCard};
241
+ bottom: ${({ $isHovered }) => ($isHovered ? "95px" : "1.875rem")};
242
+ transition: all 300ms ease-in-out;
243
+ `;
@@ -1,4 +1,4 @@
1
- import React from "react";
1
+ import React, { ReactNode, useState } from "react";
2
2
  import {
3
3
  Currencies,
4
4
  CurrencyDisplay
@@ -6,23 +6,20 @@ import {
6
6
  import { IBaseImage, Image } from "../image/Image";
7
7
  import { Tooltip, TooltipProps } from "../tooltip/Tooltip";
8
8
  import {
9
- BottomText,
10
9
  ProductCardBottom,
11
10
  ProductCardBottomContent,
12
- ProductCardCreator,
13
- ProductCardCreatorAvatar,
14
11
  TopLeftRibbon,
15
12
  ProductCardCreatorName,
16
- ProductCardData,
17
13
  ProductCardImageWrapper,
18
- ProductCardPrice,
19
- ProductCardPriceWrapper,
20
14
  ProductCardTitle,
21
15
  ProductCardTitleWrapper,
22
- ProductCardWrapper
16
+ ProductCardWrapper,
17
+ CTAOnHoverContainer
23
18
  } from "./ProductCard.styles";
24
19
 
25
20
  import { ProductType } from "./const";
21
+ import { Grid } from "../ui/Grid";
22
+
26
23
  interface IProductCard {
27
24
  asterisk?: boolean;
28
25
  avatar: string;
@@ -42,6 +39,9 @@ interface IProductCard {
42
39
  title: string;
43
40
  tooltip?: string;
44
41
  tooltipProps?: Omit<TooltipProps, "content">;
42
+ CTAOnHover?: ReactNode;
43
+ hideCreatorName?: boolean;
44
+ isImageFitCover?: boolean;
45
45
  }
46
46
 
47
47
  const Wrapper = ({
@@ -62,85 +62,83 @@ const Wrapper = ({
62
62
  }
63
63
  return <>{children}</>;
64
64
  };
65
+
65
66
  export const PhygitalLabel = ({ ...rest }) => {
66
67
  return <TopLeftRibbon {...rest} data-text="Phygital" />;
67
68
  };
69
+
68
70
  export const ProductCard = (props: IProductCard) => {
69
71
  const {
70
- asterisk = false,
71
- avatar,
72
- onAvatarError,
73
72
  avatarName,
74
- bottomText,
75
73
  currency,
76
74
  dataCard = "product-card",
77
75
  dataTestId = "offer",
78
76
  imageProps,
79
77
  isHoverDisabled = false,
80
- onAvatarNameClick,
81
78
  onCardClick,
82
79
  price,
83
80
  productId,
84
81
  title,
85
82
  tooltip = "",
86
83
  tooltipProps = {},
87
- productType
84
+ CTAOnHover,
85
+ hideCreatorName = false,
86
+ isImageFitCover = false
88
87
  } = props;
89
- const isPhygital = productType === ProductType.phygital;
88
+
89
+ const [isHovered, setIsHovered] = useState(false);
90
+
90
91
  return (
91
92
  <ProductCardWrapper
92
93
  data-card={dataCard}
93
94
  $isHoverDisabled={isHoverDisabled}
94
95
  data-testid={dataTestId}
96
+ $isImageFitCover={isImageFitCover}
95
97
  onClick={(e) => {
96
98
  e.preventDefault();
97
99
  onCardClick?.(productId);
98
100
  }}
101
+ onMouseEnter={() => setIsHovered(true)}
102
+ onMouseLeave={() => setIsHovered(false)}
99
103
  >
100
104
  <ProductCardImageWrapper>
101
- {isPhygital && <PhygitalLabel />}
102
105
  <Image {...imageProps} />
103
106
  </ProductCardImageWrapper>
107
+ {CTAOnHover && (
108
+ <CTAOnHoverContainer $isHovered={isHovered}>
109
+ {CTAOnHover}
110
+ </CTAOnHoverContainer>
111
+ )}
104
112
  <ProductCardBottom>
105
- <div>
106
- <ProductCardBottomContent>
107
- <ProductCardData>
108
- <ProductCardCreator
109
- onClick={(e) => {
110
- e.stopPropagation();
111
- onAvatarNameClick?.();
112
- }}
113
- >
114
- <ProductCardCreatorAvatar>
115
- <img src={avatar} alt="avatar" onError={onAvatarError} />
116
- </ProductCardCreatorAvatar>
117
- <ProductCardCreatorName data-avatarname="product-card">
118
- {avatarName}
119
- </ProductCardCreatorName>
120
- </ProductCardCreator>
121
- </ProductCardData>
122
- <ProductCardPriceWrapper>
123
- <Wrapper tooltip={tooltip} tooltipProps={tooltipProps}>
124
- <>
125
- <ProductCardPrice>Price {asterisk && "*"}</ProductCardPrice>
126
- <CurrencyDisplay
127
- value={price}
128
- currency={currency}
129
- style={{
130
- wordBreak: "break-all",
131
- alignItems: "flex-start",
132
- justifyContent: "flex-end"
133
- }}
134
- />
135
- </>
136
- </Wrapper>
137
- </ProductCardPriceWrapper>
138
- </ProductCardBottomContent>
139
- <ProductCardTitleWrapper>
140
- <ProductCardTitle>{title}</ProductCardTitle>
141
- </ProductCardTitleWrapper>
142
- </div>
143
- {bottomText && <BottomText>{bottomText}</BottomText>}
113
+ <ProductCardBottomContent>
114
+ <Grid flexDirection="column">
115
+ <ProductCardTitleWrapper>
116
+ <ProductCardTitle fontSize={"0.75rem"} fontWeight={"600"}>
117
+ {title}
118
+ </ProductCardTitle>
119
+ </ProductCardTitleWrapper>
120
+ {!hideCreatorName && (
121
+ <ProductCardCreatorName data-avatarname="product-card">
122
+ {avatarName}
123
+ </ProductCardCreatorName>
124
+ )}
125
+ </Grid>
126
+ <Wrapper tooltip={tooltip} tooltipProps={tooltipProps}>
127
+ <CurrencyDisplay
128
+ value={price}
129
+ currency={currency}
130
+ fontSize={"0.875rem"}
131
+ iconSize={16}
132
+ gap={"0.3125rem"}
133
+ style={{
134
+ wordBreak: "break-all",
135
+ alignItems: "center",
136
+ justifyContent: "center",
137
+ paddingTop: "0.25rem"
138
+ }}
139
+ />
140
+ </Wrapper>
141
+ </ProductCardBottomContent>
144
142
  </ProductCardBottom>
145
143
  </ProductCardWrapper>
146
144
  );
@@ -6,7 +6,6 @@ import {
6
6
  ProductCardCreator,
7
7
  ProductCardCreatorAvatar,
8
8
  ProductCardCreatorName,
9
- ProductCardData,
10
9
  ProductCardImageWrapper,
11
10
  ProductCardPrice,
12
11
  ProductCardPriceWrapper,
@@ -37,7 +36,7 @@ export const ProductCardSkeleton = (props: SkeletonCardProps) => {
37
36
  <ProductCardBottom>
38
37
  <div>
39
38
  <ProductCardBottomContent>
40
- <ProductCardData>
39
+ <Grid flexDirection="column">
41
40
  <ProductCardCreator>
42
41
  <ProductCardCreatorAvatar>
43
42
  <LoadingBubble $width="16px" $height="16px" />
@@ -46,7 +45,7 @@ export const ProductCardSkeleton = (props: SkeletonCardProps) => {
46
45
  <LoadingBubble $width="50px" $height="12.5px" />
47
46
  </ProductCardCreatorName>
48
47
  </ProductCardCreator>
49
- </ProductCardData>
48
+ </Grid>
50
49
  <ProductCardPriceWrapper>
51
50
  <ProductCardPrice>
52
51
  <Grid justifyContent="flex-end">
@@ -39,13 +39,7 @@ ProductCardPrimary.args = {
39
39
  "https://images.unsplash.com/flagged/photo-1570612861542-284f4c12e75f?ixlib=rb-1.2.1&ixid=MnwxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8&auto=format&fit=crop&w=1740&q=80",
40
40
  avatarName: (
41
41
  <>
42
- <span
43
- style={{
44
- color: "green"
45
- }}
46
- >
47
- JSON Doe
48
- </span>
42
+ <span>JSON Doe</span>
49
43
  </>
50
44
  ),
51
45
  asterisk: true,