@envive-ai/react-toolkit 0.2.0 → 0.2.1

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 (189) hide show
  1. package/package.json +10 -13
  2. package/src/components/Accordion/Accordion.tsx +3 -3
  3. package/src/components/AppliedFiltersScrollbar/AppliedFiltersScrollbar.tsx +2 -2
  4. package/src/components/ButtonBase/ButtonBase.tsx +2 -2
  5. package/src/components/DynamicFiltersScrollbar/DynamicFiltersScrollbar.tsx +2 -2
  6. package/src/components/FilterScrollbar/AppliedFiltersScrollbar.tsx +2 -2
  7. package/src/components/FilterScrollbar/DynamicFiltersScrollbar.tsx +2 -2
  8. package/src/components/ProductCard/ProductCard.tsx +10 -9
  9. package/src/components/RadioButton/RadioButton.tsx +2 -2
  10. package/src/components/SearchFilter/SearchFilterHeader.tsx +3 -3
  11. package/src/components/SearchFilter/SearchFilterItem.tsx +2 -2
  12. package/src/components/SearchInput/searchInputVariants.ts +2 -2
  13. package/src/components/SearchResultsStates/NoSearchResultsFound.tsx +3 -3
  14. package/src/components/SearchResultsStates/SearchResultsLoadingGrid.tsx +2 -2
  15. package/src/components/TextInput/TextInput.tsx +4 -3
  16. package/src/components/ToggleButton/ToggleButton.tsx +5 -5
  17. package/src/components/Typography/Typography.spec.tsx +22 -0
  18. package/src/components/Typography/Typography.tsx +73 -0
  19. package/src/components/Typography/index.ts +2 -0
  20. package/src/components/{Text/textVariantClasses.ts → Typography/typographyVariantClasses.ts} +36 -38
  21. package/src/components/Typography/util.ts +19 -0
  22. package/dist/Accordion/index.cjs +0 -6
  23. package/dist/Accordion/index.d.cts +0 -13
  24. package/dist/Accordion/index.d.ts +0 -13
  25. package/dist/Accordion/index.js +0 -6
  26. package/dist/Accordion-D9gO9_y3.cjs +0 -88
  27. package/dist/Accordion-ZEdp99Ph.js +0 -77
  28. package/dist/AnimatedChevron/index.cjs +0 -3
  29. package/dist/AnimatedChevron/index.d.cts +0 -11
  30. package/dist/AnimatedChevron/index.d.ts +0 -11
  31. package/dist/AnimatedChevron/index.js +0 -3
  32. package/dist/AnimatedChevron-CwuXgR2r.js +0 -29
  33. package/dist/AnimatedChevron-e_UzWBl0.cjs +0 -37
  34. package/dist/AppliedFiltersScrollbar/index.cjs +0 -48
  35. package/dist/AppliedFiltersScrollbar/index.d.cts +0 -22
  36. package/dist/AppliedFiltersScrollbar/index.d.ts +0 -22
  37. package/dist/AppliedFiltersScrollbar/index.js +0 -44
  38. package/dist/ButtonBase/index.cjs +0 -7
  39. package/dist/ButtonBase/index.d.cts +0 -42
  40. package/dist/ButtonBase/index.d.ts +0 -42
  41. package/dist/ButtonBase/index.js +0 -6
  42. package/dist/ButtonBase-BJ0qXMWD.js +0 -60
  43. package/dist/ButtonBase-BktteD9c.js +0 -1
  44. package/dist/ButtonBase-Cb6Iec6f.cjs +0 -0
  45. package/dist/ButtonBase-VIv-tn7H.cjs +0 -75
  46. package/dist/DynamicFiltersScrollbar/index.cjs +0 -36
  47. package/dist/DynamicFiltersScrollbar/index.d.cts +0 -28
  48. package/dist/DynamicFiltersScrollbar/index.d.ts +0 -28
  49. package/dist/DynamicFiltersScrollbar/index.js +0 -32
  50. package/dist/DynamicFiltersScrollbar-HCYZjI14.cjs +0 -81
  51. package/dist/DynamicFiltersScrollbar-O0ai3cIG.js +0 -66
  52. package/dist/FilterScrollbar/index.cjs +0 -6
  53. package/dist/FilterScrollbar/index.d.cts +0 -47
  54. package/dist/FilterScrollbar/index.d.ts +0 -47
  55. package/dist/FilterScrollbar/index.js +0 -5
  56. package/dist/Headline/index.cjs +0 -4
  57. package/dist/Headline/index.d.cts +0 -21
  58. package/dist/Headline/index.d.ts +0 -21
  59. package/dist/Headline/index.js +0 -4
  60. package/dist/Headline-CKJmd2w4.cjs +0 -72
  61. package/dist/Headline-DtjTB4xS.js +0 -64
  62. package/dist/ImageWithFallback/index.cjs +0 -3
  63. package/dist/ImageWithFallback/index.d.cts +0 -26
  64. package/dist/ImageWithFallback/index.d.ts +0 -26
  65. package/dist/ImageWithFallback/index.js +0 -3
  66. package/dist/ImageWithFallback-CbYsD1_a.js +0 -42
  67. package/dist/ImageWithFallback-Km9h16Vz.cjs +0 -51
  68. package/dist/ModalSheet/index.cjs +0 -4
  69. package/dist/ModalSheet/index.d.cts +0 -38
  70. package/dist/ModalSheet/index.d.ts +0 -38
  71. package/dist/ModalSheet/index.js +0 -4
  72. package/dist/ModalSheet-DwnbbFh7.cjs +0 -313
  73. package/dist/ModalSheet-sMg44OLz.js +0 -302
  74. package/dist/ProductCard/index.cjs +0 -17
  75. package/dist/ProductCard/index.d.cts +0 -2
  76. package/dist/ProductCard/index.d.ts +0 -2
  77. package/dist/ProductCard/index.js +0 -8
  78. package/dist/ProductCard-BDz80MCQ.cjs +0 -319
  79. package/dist/ProductCard-CqhNJShq.js +0 -255
  80. package/dist/ProductGrid/index.cjs +0 -10
  81. package/dist/ProductGrid/index.d.cts +0 -33
  82. package/dist/ProductGrid/index.d.ts +0 -33
  83. package/dist/ProductGrid/index.js +0 -9
  84. package/dist/ProductGrid-8n4XgcMr.js +0 -60
  85. package/dist/ProductGrid-RRcdkY5J.cjs +0 -74
  86. package/dist/RadioButton/index.cjs +0 -6
  87. package/dist/RadioButton/index.d.cts +0 -32
  88. package/dist/RadioButton/index.d.ts +0 -32
  89. package/dist/RadioButton/index.js +0 -6
  90. package/dist/RadioButton-BWnaUI8o.cjs +0 -84
  91. package/dist/RadioButton-CG8_M0hY.js +0 -75
  92. package/dist/RadioButtonGroup/index.cjs +0 -8
  93. package/dist/RadioButtonGroup/index.d.cts +0 -36
  94. package/dist/RadioButtonGroup/index.d.ts +0 -36
  95. package/dist/RadioButtonGroup/index.js +0 -7
  96. package/dist/RadioButtonGroup-B7EuiEP1.js +0 -38
  97. package/dist/RadioButtonGroup-ReQqakpS.cjs +0 -52
  98. package/dist/SearchAutocomplete/index.cjs +0 -3
  99. package/dist/SearchAutocomplete/index.d.cts +0 -13
  100. package/dist/SearchAutocomplete/index.d.ts +0 -13
  101. package/dist/SearchAutocomplete/index.js +0 -3
  102. package/dist/SearchAutocomplete-BMNYZiJL.js +0 -51
  103. package/dist/SearchAutocomplete-BmHdijOv.cjs +0 -62
  104. package/dist/SearchFilter/index.cjs +0 -19
  105. package/dist/SearchFilter/index.d.cts +0 -91
  106. package/dist/SearchFilter/index.d.ts +0 -91
  107. package/dist/SearchFilter/index.js +0 -14
  108. package/dist/SearchFilter-C8mgj84o.js +0 -268
  109. package/dist/SearchFilter-FrdHPM5O.cjs +0 -307
  110. package/dist/SearchInput/index.cjs +0 -7
  111. package/dist/SearchInput/index.d.cts +0 -34
  112. package/dist/SearchInput/index.d.ts +0 -34
  113. package/dist/SearchInput/index.js +0 -6
  114. package/dist/SearchInput--x9NTMTb.cjs +0 -106
  115. package/dist/SearchInput-IBq83nqF.js +0 -89
  116. package/dist/SearchInputForm/index.cjs +0 -39
  117. package/dist/SearchInputForm/index.d.cts +0 -34
  118. package/dist/SearchInputForm/index.d.ts +0 -34
  119. package/dist/SearchInputForm/index.js +0 -37
  120. package/dist/SearchResultsContent/index.cjs +0 -47
  121. package/dist/SearchResultsContent/index.d.cts +0 -48
  122. package/dist/SearchResultsContent/index.d.ts +0 -48
  123. package/dist/SearchResultsContent/index.js +0 -44
  124. package/dist/SearchResultsFilterSidebar/index.cjs +0 -62
  125. package/dist/SearchResultsFilterSidebar/index.d.cts +0 -2
  126. package/dist/SearchResultsFilterSidebar/index.d.ts +0 -2
  127. package/dist/SearchResultsFilterSidebar/index.js +0 -57
  128. package/dist/SearchResultsStates/index.cjs +0 -17
  129. package/dist/SearchResultsStates/index.d.cts +0 -69
  130. package/dist/SearchResultsStates/index.d.ts +0 -69
  131. package/dist/SearchResultsStates/index.js +0 -15
  132. package/dist/SearchResultsStates-D7dM35qq.js +0 -110
  133. package/dist/SearchResultsStates-nlaPbkj3.cjs +0 -132
  134. package/dist/SparkleAnimation/index.cjs +0 -4
  135. package/dist/SparkleAnimation/index.d.cts +0 -23
  136. package/dist/SparkleAnimation/index.d.ts +0 -23
  137. package/dist/SparkleAnimation/index.js +0 -3
  138. package/dist/SparkleAnimation-D1aZE-7A.cjs +0 -101
  139. package/dist/SparkleAnimation-DtWkXmkN.js +0 -84
  140. package/dist/Spinner/index.cjs +0 -3
  141. package/dist/Spinner/index.d.cts +0 -11
  142. package/dist/Spinner/index.d.ts +0 -11
  143. package/dist/Spinner/index.js +0 -3
  144. package/dist/Spinner-bg6jb_ks.js +0 -38
  145. package/dist/Spinner-rcWX566W.cjs +0 -46
  146. package/dist/SuggestionButton/index.cjs +0 -188
  147. package/dist/SuggestionButton/index.d.cts +0 -35
  148. package/dist/SuggestionButton/index.d.ts +0 -35
  149. package/dist/SuggestionButton/index.js +0 -180
  150. package/dist/Text/index.cjs +0 -10
  151. package/dist/Text/index.d.cts +0 -42
  152. package/dist/Text/index.d.ts +0 -42
  153. package/dist/Text/index.js +0 -5
  154. package/dist/Text-BLzNhX4H.js +0 -42
  155. package/dist/Text-BMsncrpY.js +0 -10
  156. package/dist/Text-C8t_iEj6.cjs +0 -16
  157. package/dist/Text-DllCE9_D.cjs +0 -50
  158. package/dist/TextInput/index.cjs +0 -4
  159. package/dist/TextInput/index.d.cts +0 -12
  160. package/dist/TextInput/index.d.ts +0 -12
  161. package/dist/TextInput/index.js +0 -4
  162. package/dist/TextInput-BeHPlVHT.js +0 -31
  163. package/dist/TextInput-CGs4BY1q.cjs +0 -40
  164. package/dist/ToggleButton/index.cjs +0 -6
  165. package/dist/ToggleButton/index.d.cts +0 -30
  166. package/dist/ToggleButton/index.d.ts +0 -30
  167. package/dist/ToggleButton/index.js +0 -6
  168. package/dist/ToggleButton-CRiPqTCb.js +0 -60
  169. package/dist/ToggleButton-DfJZ8POQ.cjs +0 -68
  170. package/dist/chunk-CUT6urMc.cjs +0 -30
  171. package/dist/colorsConfig-Ck2jeqWe.js +0 -26
  172. package/dist/colorsConfig-CqCKftuM.cjs +0 -38
  173. package/dist/index-B9WeFNlO.d.cts +0 -325
  174. package/dist/index-CLGe_Pam.d.cts +0 -46
  175. package/dist/index-CeECGrFM.d.ts +0 -325
  176. package/dist/index-PSzeHU2s.d.ts +0 -46
  177. package/dist/searchFilterSidebarVariants-B05f5SD5.js +0 -34
  178. package/dist/searchFilterSidebarVariants-NQhqq-NT.cjs +0 -39
  179. package/dist/textVariantClasses-B0gNjzl4.d.cts +0 -174
  180. package/dist/textVariantClasses-Bl8SAGwZ.d.ts +0 -174
  181. package/dist/textVariantClasses-CBre7vXv.cjs +0 -123
  182. package/dist/textVariantClasses-CRrTb43V.js +0 -99
  183. package/dist/types-BhGjnuWx.d.cts +0 -4
  184. package/dist/types-CTOdb0G0.d.ts +0 -4
  185. package/src/components/Headline/Headline.tsx +0 -81
  186. package/src/components/Headline/index.ts +0 -1
  187. package/src/components/Text/Text.tsx +0 -58
  188. package/src/components/Text/index.ts +0 -3
  189. package/src/components/Text/types.ts +0 -23
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@envive-ai/react-toolkit",
3
- "version": "0.2.0",
3
+ "version": "0.2.1",
4
4
  "description": "React component library for Envive services.",
5
5
  "keywords": [
6
6
  "react",
@@ -21,13 +21,13 @@
21
21
  "tailwind-preset.js"
22
22
  ],
23
23
  "scripts": {
24
- "build": "npm run typecheck && tsdown",
24
+ "build": "tsdown",
25
25
  "build:watch": "tsdown --watch",
26
26
  "prepublish": "npm run build",
27
- "typecheck": "tsc"
27
+ "typecheck": "tsc",
28
+ "test": "vitest"
28
29
  },
29
30
  "dependencies": {
30
- "@envive-ai/react-icons": "0.1.1",
31
31
  "@envive-ai/react-hooks": "^0.1.8",
32
32
  "@tailwindcss/typography": "^0.5.15",
33
33
  "classnames": "^2.5.1",
@@ -45,7 +45,8 @@
45
45
  "postcss": "^8.5.6",
46
46
  "tailwindcss": "^3.4.17",
47
47
  "tsdown": "^0.14.2",
48
- "typescript": "^5.4.3"
48
+ "typescript": "^5.4.3",
49
+ "vitest": "^3.2.4"
49
50
  },
50
51
  "exports": {
51
52
  "./Accordion": {
@@ -72,10 +73,6 @@
72
73
  "import": "./dist/FilterScrollbar/index.js",
73
74
  "require": "./dist/FilterScrollbar/index.cjs"
74
75
  },
75
- "./Headline": {
76
- "import": "./dist/Headline/index.js",
77
- "require": "./dist/Headline/index.cjs"
78
- },
79
76
  "./ImageWithFallback": {
80
77
  "import": "./dist/ImageWithFallback/index.js",
81
78
  "require": "./dist/ImageWithFallback/index.cjs"
@@ -140,10 +137,6 @@
140
137
  "import": "./dist/SuggestionButton/index.js",
141
138
  "require": "./dist/SuggestionButton/index.cjs"
142
139
  },
143
- "./Text": {
144
- "import": "./dist/Text/index.js",
145
- "require": "./dist/Text/index.cjs"
146
- },
147
140
  "./TextInput": {
148
141
  "import": "./dist/TextInput/index.js",
149
142
  "require": "./dist/TextInput/index.cjs"
@@ -152,6 +145,10 @@
152
145
  "import": "./dist/ToggleButton/index.js",
153
146
  "require": "./dist/ToggleButton/index.cjs"
154
147
  },
148
+ "./Typography": {
149
+ "import": "./dist/Typography/index.js",
150
+ "require": "./dist/Typography/index.cjs"
151
+ },
155
152
  "./package.json": "./package.json"
156
153
  }
157
154
  }
@@ -1,7 +1,7 @@
1
1
  import { motion } from 'framer-motion';
2
2
  import { useRef, useState } from 'react';
3
3
  import classNames from 'classnames';
4
- import { Text } from 'src/components/Text';
4
+ import { Typography } from 'src/components/Typography';
5
5
  import ChevronDown from '@envive-ai/react-icons/ChevronDown';
6
6
 
7
7
  interface AccordionProps {
@@ -46,9 +46,9 @@ export const Accordion = ({ title, content }: AccordionProps) => {
46
46
  className={titleWrapperClasses}
47
47
  onClick={() => setIsOpen(!isOpen)}
48
48
  >
49
- <Text variant="body4" className={titleClasses}>
49
+ <Typography variant="body4" className={titleClasses}>
50
50
  {title}
51
- </Text>
51
+ </Typography>
52
52
  <motion.div
53
53
  variants={{
54
54
  open: {
@@ -1,6 +1,6 @@
1
1
  import classNames from 'classnames';
2
2
  import ScrollContainer from 'react-indiana-drag-scroll';
3
- import { Text } from 'src/components/Text';
3
+ import { Typography } from 'src/components/Typography';
4
4
  import { SelectedFilterOption } from '@envive-ai/react-hooks/atoms/search';
5
5
 
6
6
  interface AppliedFiltersScrollbarProps {
@@ -47,7 +47,7 @@ export const AppliedFiltersScrollbar = ({
47
47
  aria-label={`Remove filter: ${filter.displayName}`}
48
48
  >
49
49
  <div className="spiffy-tw-flex spiffy-tw-items-center spiffy-tw-gap-[8px]">
50
- <Text variant="body3">{filter.displayName}</Text>
50
+ <Typography variant="body3">{filter.displayName}</Typography>
51
51
  <svg
52
52
  xmlns="http://www.w3.org/2000/svg"
53
53
  width="10"
@@ -1,7 +1,7 @@
1
1
  import classNames from 'classnames';
2
2
  import { createElement, useEffect, useRef } from 'react';
3
3
  import { ButtonBaseOverrides, ButtonBaseProps } from './types';
4
- import { Text } from '../Text/Text';
4
+ import { Typography } from '../Typography';
5
5
 
6
6
  export const ButtonBase = ({
7
7
  isDisabled = false,
@@ -63,7 +63,7 @@ export const ButtonBase = ({
63
63
  createElement(icon, {
64
64
  className: iconClassName,
65
65
  })}
66
- <Text className={textClassName}>{text}</Text>
66
+ <Typography className={textClassName}>{text}</Typography>
67
67
  </button>
68
68
  );
69
69
  };
@@ -1,6 +1,6 @@
1
1
  import classNames from 'classnames';
2
2
  import ScrollContainer from 'react-indiana-drag-scroll';
3
- import { Text } from 'src/components/Text';
3
+ import { Typography } from 'src/components/Typography';
4
4
 
5
5
  interface DynamicFiltersScrollbarProps {
6
6
  availableDynamicFilters: { name: string; displayName: string }[];
@@ -42,7 +42,7 @@ export const DynamicFiltersScrollbar = ({
42
42
  });
43
43
  }}
44
44
  >
45
- <Text variant="body3">{displayName}</Text>
45
+ <Typography variant="body3">{displayName}</Typography>
46
46
  </button>
47
47
  );
48
48
  })}
@@ -1,7 +1,7 @@
1
1
  import { SelectedFilterOption } from '@envive-ai/react-hooks/atoms/search';
2
2
  import classNames from 'classnames';
3
3
  import ScrollContainer from 'react-indiana-drag-scroll';
4
- import { Text } from 'src/components/Text/Text';
4
+ import { Typography } from 'src/components/Typography';
5
5
 
6
6
  interface AppliedFiltersScrollbarProps {
7
7
  selectedFilterOptions: SelectedFilterOption[];
@@ -47,7 +47,7 @@ export const AppliedFiltersScrollbar = ({
47
47
  aria-label={`Remove filter: ${filter.displayName}`}
48
48
  >
49
49
  <div className="spiffy-tw-flex spiffy-tw-items-center spiffy-tw-gap-[8px]">
50
- <Text variant="body3">{filter.displayName}</Text>
50
+ <Typography variant="body3">{filter.displayName}</Typography>
51
51
  <svg
52
52
  xmlns="http://www.w3.org/2000/svg"
53
53
  width="10"
@@ -1,6 +1,6 @@
1
1
  import classNames from 'classnames';
2
2
  import ScrollContainer from 'react-indiana-drag-scroll';
3
- import { Text } from 'src/components/Text/Text';
3
+ import { Typography } from 'src/components/Typography';
4
4
 
5
5
  interface DynamicFiltersScrollbarProps {
6
6
  availableDynamicFilters: { name: string; displayName: string }[];
@@ -42,7 +42,7 @@ export const DynamicFiltersScrollbar = ({
42
42
  });
43
43
  }}
44
44
  >
45
- <Text variant="body3">{displayName}</Text>
45
+ <Typography variant="body3">{displayName}</Typography>
46
46
  </button>
47
47
  );
48
48
  })}
@@ -1,7 +1,7 @@
1
1
  import classNames from 'classnames';
2
2
  import { MdStar } from 'react-icons/md';
3
3
  import Logger from 'src/logging/logger';
4
- import { Text } from 'src/components/Text/Text';
4
+ import { Typography } from 'src/components/Typography';
5
5
  import { formatPrice } from 'src/util/formatPrice';
6
6
  import { TestProps } from '@envive-ai/react-hooks/types';
7
7
  import { useImageResolver } from '@envive-ai/react-hooks/hooks/ImageResolver';
@@ -11,7 +11,6 @@ import {
11
11
  productCardLayoutVariantClasses,
12
12
  variantTitleColorMap,
13
13
  } from './productCardVariants';
14
- import { Headline } from '../Headline';
15
14
  import { ImageWithFallback } from '../ImageWithFallback';
16
15
  import { Spinner } from '../Spinner';
17
16
  import {
@@ -55,8 +54,8 @@ export const RatingSummary = ({ stars, reviewCount, className }: RatingSummaryPr
55
54
  <div className={className}>
56
55
  <div className={group}>
57
56
  <MdStar className={starClassnames} />
58
- <Text variant="body3">{formatReviews(stars)}</Text>
59
- <Text variant="body3">({reviewCount})</Text>
57
+ <Typography variant="body3">{formatReviews(stars)}</Typography>
58
+ <Typography variant="body3">({reviewCount})</Typography>
60
59
  </div>
61
60
  </div>
62
61
  );
@@ -88,9 +87,11 @@ export const PriceSection = ({ originalPrice, salePrice, pricePrefix }: PriceSec
88
87
 
89
88
  return (
90
89
  <div className={priceClassName}>
91
- {pricePrefix && <Text>{pricePrefix}</Text>}
92
- {showSalePrice && <Text>{salePrice}</Text>}
93
- <Text className={showSalePrice ? 'spiffy-tw-line-through' : ''}>{originalPrice}</Text>
90
+ {pricePrefix && <Typography>{pricePrefix}</Typography>}
91
+ {showSalePrice && <Typography>{salePrice}</Typography>}
92
+ <Typography className={showSalePrice ? 'spiffy-tw-line-through' : ''}>
93
+ {originalPrice}
94
+ </Typography>
94
95
  </div>
95
96
  );
96
97
  };
@@ -275,9 +276,9 @@ export const ProductCard = ({
275
276
  </div>
276
277
  </div>
277
278
  <div className={contentClassnames}>
278
- <Headline variant="h4" className={productTitleClassnames}>
279
+ <Typography variant="h4" className={productTitleClassnames}>
279
280
  {title}
280
- </Headline>
281
+ </Typography>
281
282
  <div className={priceAndRatingContainerClassnames}>
282
283
  {(originalPrice || salePrice) && (
283
284
  <PriceSection
@@ -1,5 +1,5 @@
1
1
  import classNames from 'classnames';
2
- import { Text } from 'src/components/Text';
2
+ import { Typography } from 'src/components/Typography';
3
3
  import { useState } from 'react';
4
4
  import { TestProps } from '@envive-ai/react-hooks/types';
5
5
 
@@ -91,7 +91,7 @@ export const RadioButton = ({
91
91
  {checked && <circle cx="12" cy="12" r="9" fill={getFillColor()} />}
92
92
  </svg>
93
93
  </div>
94
- <Text variant="body3">{label}</Text>
94
+ <Typography variant="body3">{label}</Typography>
95
95
  </>
96
96
  );
97
97
  };
@@ -1,5 +1,5 @@
1
1
  import classNames from 'classnames';
2
- import { Text } from 'src/components/Text/Text';
2
+ import { Typography } from 'src/components/Typography';
3
3
  import type { SearchFilterHeaderProps } from './types';
4
4
 
5
5
  export const SearchFilterHeader = ({
@@ -20,9 +20,9 @@ export const SearchFilterHeader = ({
20
20
  headerClassName,
21
21
  )}
22
22
  >
23
- <Text variant="body2" className="spiffy-tw-font-medium">
23
+ <Typography variant="body2" className="spiffy-tw-font-medium">
24
24
  Filters ({productCount})
25
- </Text>
25
+ </Typography>
26
26
  <button
27
27
  onClick={closeModal}
28
28
  className="spiffy-tw-p-2"
@@ -1,5 +1,5 @@
1
1
  import classNames from 'classnames';
2
- import { Text } from 'src/components/Text/Text';
2
+ import { Typography } from 'src/components/Typography';
3
3
  import type { SearchFilterItemProps } from './types';
4
4
 
5
5
  export const SearchFilterItem = ({
@@ -40,7 +40,7 @@ export const SearchFilterItem = ({
40
40
  }
41
41
  }}
42
42
  >
43
- <Text variant="body3">{displayName}</Text>
43
+ <Typography variant="body3">{displayName}</Typography>
44
44
  <div className={radioClasses}>
45
45
  {isSelected && (
46
46
  <div
@@ -1,6 +1,6 @@
1
1
  import { colorVar, ColorNames } from 'src/models/colorsConfig';
2
2
  import { SearchInputVariant } from '../../atoms/search/types';
3
- import { TextStyleVariantMap } from '../Text/textVariantClasses';
3
+ import { TypographyVariantMap } from '../Typography/typographyVariantClasses';
4
4
 
5
5
  type SearchInputVariantClasses = {
6
6
  searchInputIconColor: string;
@@ -9,7 +9,7 @@ type SearchInputVariantClasses = {
9
9
  searchInputActiveStarClasses: string;
10
10
  autocompleteIconColor: string;
11
11
  searchInputClasses: string;
12
- placeholderVariant: keyof typeof TextStyleVariantMap;
12
+ placeholderVariant: keyof typeof TypographyVariantMap;
13
13
  };
14
14
 
15
15
  export const searchInputVariantClasses: Record<SearchInputVariant, SearchInputVariantClasses> = {
@@ -1,6 +1,6 @@
1
1
  import classNames from 'classnames';
2
2
  import Sparkles from '@envive-ai/react-icons/Sparkles';
3
- import { Text } from 'src/components/Text';
3
+ import { Typography } from 'src/components/Typography';
4
4
 
5
5
  interface NoSearchResultsFoundProps {
6
6
  containerPaddingClasses: string;
@@ -23,7 +23,7 @@ export const NoSearchResultsFound = ({
23
23
 
24
24
  const textPrompt =
25
25
  noResultsFoundText ||
26
- 'I’m sorry, I wasnt able to find an exact match. Try changing your filters or adjusting your search query.';
26
+ "I'm sorry, I wasn't able to find an exact match. Try changing your filters or adjusting your search query.";
27
27
 
28
28
  return (
29
29
  <div className={containerClasses}>
@@ -34,7 +34,7 @@ export const NoSearchResultsFound = ({
34
34
  style={{ color: sparkleIconColor }}
35
35
  />
36
36
  </div>
37
- <Text variant="body2">{textPrompt}</Text>
37
+ <Typography variant="body2">{textPrompt}</Typography>
38
38
  </div>
39
39
  </div>
40
40
  );
@@ -1,5 +1,5 @@
1
1
  import { motion } from 'framer-motion';
2
- import { Text } from 'src/components/Text';
2
+ import { Typography } from 'src/components/Typography';
3
3
  import { ProductGridVariant, ProductCardSkeleton } from '../ProductCard';
4
4
  import { productGridVariantClasses } from '../ProductGrid';
5
5
  import { SparkleAnimation } from '../SparkleAnimation';
@@ -30,7 +30,7 @@ export const SearchResultsLoadingGrid = ({
30
30
  <div className="spiffy-tw-width-[24px]">
31
31
  <SparkleAnimation color={sparkleIconColor} animate />
32
32
  </div>
33
- <Text variant="body2">Finding the best options for you...</Text>
33
+ <Typography variant="body2">Finding the best options for you...</Typography>
34
34
  </div>
35
35
  </div>
36
36
  <div className={productGridClasses}>
@@ -4,17 +4,18 @@
4
4
  // Keeping it enabled requires listing every possible prop.
5
5
  import React from 'react';
6
6
  import classNames from 'classnames';
7
- import { getVariantPlaceholderClassNames, TextStyleVariantMap } from '../Text/textVariantClasses';
7
+
8
+ import { getVariantPlaceholderClassNames, TypographyVariantMap } from '../Typography';
8
9
 
9
10
  export interface TextInputProps extends React.InputHTMLAttributes<HTMLInputElement> {
10
11
  borderRadius: 'sm' | 'md' | 'lg' | 'xl';
11
12
  borderColorClass?: string;
12
- placeholderVariant?: keyof typeof TextStyleVariantMap;
13
+ placeholderVariant?: keyof typeof TypographyVariantMap;
13
14
  }
14
15
 
15
16
  export const TextInput = React.forwardRef<HTMLInputElement, TextInputProps>(
16
17
  ({ className, borderRadius, borderColorClass, placeholderVariant, ...rest }, ref) => {
17
- const variantClassNames = placeholderVariant ? TextStyleVariantMap[placeholderVariant] : {};
18
+ const variantClassNames = placeholderVariant ? TypographyVariantMap[placeholderVariant] : {};
18
19
  const placeholderVariantClassNames = getVariantPlaceholderClassNames(variantClassNames);
19
20
  const inputClasses = classNames([
20
21
  {
@@ -1,5 +1,5 @@
1
1
  import classNames from 'classnames';
2
- import { Text } from 'src/components/Text';
2
+ import { Typography } from 'src/components/Typography';
3
3
 
4
4
  export type ToggleButtonProps = {
5
5
  isSelected: boolean;
@@ -85,13 +85,13 @@ export const ToggleButton = ({
85
85
  return (
86
86
  <button className={buttonClassNames} onClick={onClick} type="button">
87
87
  {icon && <div className={iconClassName}>{icon}</div>}
88
- <Text variant="body3" className={labelClassNames}>
88
+ <Typography variant="body3" className={labelClassNames}>
89
89
  {label}
90
- </Text>
90
+ </Typography>
91
91
  {secondaryLabel && (
92
- <Text variant="body4" className={secondaryLabelClassNames}>
92
+ <Typography variant="body4" className={secondaryLabelClassNames}>
93
93
  {secondaryLabel}
94
- </Text>
94
+ </Typography>
95
95
  )}
96
96
  </button>
97
97
  );
@@ -0,0 +1,22 @@
1
+ import { describe, it, expect } from 'vitest';
2
+ import { getElementTypeFromVariant } from './util';
3
+
4
+ describe('getElementTypeFromVariant', () => {
5
+ it('should return the mapped header element when isHeadline is true and variant exists in TypographyDomVariantMap', () => {
6
+ expect(getElementTypeFromVariant('h1', true)).toBe('h1');
7
+ expect(getElementTypeFromVariant('h2', true)).toBe('h2');
8
+ expect(getElementTypeFromVariant('h3', true)).toBe('h3');
9
+ expect(getElementTypeFromVariant('h4', true)).toBe('h4');
10
+ });
11
+
12
+ it('should return "h3" when isHeadline is true and variant does not exist in TypographyDomVariantMap', () => {
13
+ expect(getElementTypeFromVariant('t1', true)).toBe('h3');
14
+ expect(getElementTypeFromVariant('body1', true)).toBe('h3');
15
+ });
16
+
17
+ it('should return "span" when isHeadline is false', () => {
18
+ expect(getElementTypeFromVariant('h1', false)).toBe('span');
19
+ expect(getElementTypeFromVariant('t1', false)).toBe('span');
20
+ expect(getElementTypeFromVariant('body1', false)).toBe('span');
21
+ });
22
+ });
@@ -0,0 +1,73 @@
1
+ import React, { useCallback, useMemo } from 'react';
2
+ import classNames from 'classnames';
3
+ import {
4
+ ElementTypes,
5
+ TypographyVariantMap,
6
+ } from 'src/components/Typography/typographyVariantClasses';
7
+ import { getElementTypeFromVariant } from './util';
8
+
9
+ export type TypographyProps = {
10
+ children: React.ReactNode;
11
+ noOfLines?: number;
12
+ className?: string;
13
+ style?: React.CSSProperties;
14
+ variant?: keyof typeof TypographyVariantMap;
15
+ elementType?: ElementTypes;
16
+ testId?: string;
17
+ id?: string;
18
+ };
19
+
20
+ export const Typography = ({
21
+ children,
22
+ className,
23
+ style,
24
+ noOfLines,
25
+ testId,
26
+ elementType,
27
+ variant = 'body3',
28
+ id,
29
+ }: TypographyProps) => {
30
+ const variantClassNames = variant ? TypographyVariantMap[variant] : {};
31
+ const isHeadline = useCallback(
32
+ () => ['t1', 't2', 't3', 'h1', 'h2', 'h3', 'h4'].includes(variant),
33
+ [variant],
34
+ );
35
+
36
+ const renderedElementType = useMemo(() => {
37
+ if (elementType) {
38
+ return elementType;
39
+ }
40
+ if (!elementType) {
41
+ if (isHeadline()) {
42
+ return getElementTypeFromVariant(variant, isHeadline());
43
+ }
44
+ }
45
+ return 'span'; // default to span for body variants.
46
+ }, [isHeadline, variant, elementType]);
47
+
48
+ const textClassNames = classNames(className, variantClassNames, {
49
+ 'spiffy-tw-font-[Poppins,sans-serif]': isHeadline(),
50
+ 'spiffy-tw-font-["Inter Variable,sans-serif"]': !isHeadline(),
51
+ 'spiffy-tw-line-clamp-1': noOfLines === 1,
52
+ 'spiffy-tw-line-clamp-2': noOfLines === 2,
53
+ 'spiffy-tw-line-clamp-3': noOfLines === 3,
54
+ 'spiffy-tw-line-clamp-4': noOfLines === 4,
55
+ 'spiffy-tw-line-clamp-5': noOfLines === 5,
56
+ 'spiffy-tw-line-clamp-6': noOfLines === 6,
57
+ 'spiffy-tw-line-clamp-7': noOfLines === 7,
58
+ });
59
+
60
+ const renderElement = (elementTypeToRender: ElementTypes) =>
61
+ React.createElement(
62
+ elementTypeToRender,
63
+ {
64
+ 'data-testid': testId,
65
+ className: textClassNames,
66
+ style,
67
+ id,
68
+ },
69
+ children,
70
+ );
71
+
72
+ return renderElement(renderedElementType);
73
+ };
@@ -0,0 +1,2 @@
1
+ export * from './Typography';
2
+ export * from './typographyVariantClasses';
@@ -1,33 +1,16 @@
1
- // TODO: add the rest of the variants as needed
2
- export const HeadlineVariantMap = {
3
- t1: {
4
- 'spiffy-headline': true,
5
- 'spiffy-headline-1': true,
6
- 'spiffy-tw-text-[32px]': true,
7
- 'spiffy-tw-font-medium': true,
8
- 'spiffy-tw-leading-[124%]': true,
9
- },
10
- t2: {
11
- 'spiffy-headline': true,
12
- 'spiffy-headline-1': true,
13
- 'spiffy-tw-text-[16px]': true,
14
- 'spiffy-tw-font-medium': true,
15
- 'spiffy-tw-leading-[124%]': true,
16
- },
17
- t3: {
18
- 'spiffy-headline': true,
19
- 'spiffy-headline-1': true,
20
- 'spiffy-tw-text-[24px]': true,
21
- 'spiffy-tw-leading-[120%]': true,
22
- },
23
- h1: {
1
+ // Variants that map to a particular dom element.
2
+
3
+ export type ElementTypes = 'h1' | 'h2' | 'h3' | 'h4' | 'p' | 'span' | 'sub';
4
+
5
+ export const TypographyDomVariantMap = {
6
+ ['h1' as const]: {
24
7
  'spiffy-headline': true,
25
8
  'spiffy-headline-1': true,
26
9
  'spiffy-tw-text-[20px]': true,
27
10
  'spiffy-tw-font-normal': true,
28
11
  'spiffy-tw-leading-[120%]': true,
29
12
  },
30
- h2: {
13
+ ['h2' as const]: {
31
14
  'spiffy-headline': true,
32
15
  'spiffy-headline-2': true,
33
16
  'spiffy-tw-text-[16px]': true,
@@ -35,14 +18,14 @@ export const HeadlineVariantMap = {
35
18
  'spiffy-tw-leading-[124%]': true,
36
19
  },
37
20
 
38
- h3: {
21
+ ['h3' as const]: {
39
22
  'spiffy-headline': true,
40
23
  'spiffy-headline-3': true,
41
24
  'spiffy-tw-text-[15px]': true,
42
25
  'spiffy-tw-font-medium': true,
43
26
  'spiffy-tw-leading-[124%]': true,
44
27
  },
45
- h4: {
28
+ ['h4' as const]: {
46
29
  'spiffy-headline': true,
47
30
  'spiffy-headline-4': true,
48
31
  'spiffy-tw-text-[14px]': true,
@@ -51,37 +34,57 @@ export const HeadlineVariantMap = {
51
34
  },
52
35
  };
53
36
 
54
- // TODO: add the rest of the variants as needed
55
- export const TextVariantMap = {
56
- body1: {
37
+ export const TypographyVariantMap = {
38
+ ...TypographyDomVariantMap,
39
+ ['t1' as const]: {
40
+ 'spiffy-headline': true,
41
+ 'spiffy-headline-1': true,
42
+ 'spiffy-tw-text-[32px]': true,
43
+ 'spiffy-tw-font-medium': true,
44
+ 'spiffy-tw-leading-[124%]': true,
45
+ },
46
+ ['t2' as const]: {
47
+ 'spiffy-headline': true,
48
+ 'spiffy-headline-1': true,
49
+ 'spiffy-tw-text-[16px]': true,
50
+ 'spiffy-tw-font-medium': true,
51
+ 'spiffy-tw-leading-[124%]': true,
52
+ },
53
+ ['t3' as const]: {
54
+ 'spiffy-headline': true,
55
+ 'spiffy-headline-1': true,
56
+ 'spiffy-tw-text-[24px]': true,
57
+ 'spiffy-tw-leading-[120%]': true,
58
+ },
59
+ ['body1' as const]: {
57
60
  'spiffy-body-text': true,
58
61
  'spiffy-body-1': true,
59
62
  'spiffy-tw-text-[20px]': true,
60
63
  'spiffy-tw-font-normal': true,
61
64
  'spiffy-tw-line-height-[120%]': true,
62
65
  },
63
- body2: {
66
+ ['body2' as const]: {
64
67
  'spiffy-body-text': true,
65
68
  'spiffy-body-2': true,
66
69
  'spiffy-tw-text-[16px]': true,
67
70
  'spiffy-tw-font-normal': true,
68
71
  'spiffy-tw-line-height-[148%]': true,
69
72
  },
70
- body3: {
73
+ ['body3' as const]: {
71
74
  'spiffy-body-text': true,
72
75
  'spiffy-body-3': true,
73
76
  'spiffy-tw-text-sm': true,
74
77
  'spiffy-tw-font-normal': true,
75
78
  'spiffy-tw-leading-[140%]': true,
76
79
  },
77
- body4: {
80
+ ['body4' as const]: {
78
81
  'spiffy-body-text': true,
79
82
  'spiffy-body-4': true,
80
83
  'spiffy-tw-text-xs': true,
81
84
  'spiffy-tw-font-medium': true,
82
85
  'spiffy-tw-leading-[130%]': true,
83
86
  },
84
- body5: {
87
+ ['body5' as const]: {
85
88
  'spiffy-body-text': true,
86
89
  'spiffy-body-5': true,
87
90
  'spiffy-tw-text-[10px]': true,
@@ -89,11 +92,6 @@ export const TextVariantMap = {
89
92
  },
90
93
  };
91
94
 
92
- export const TextStyleVariantMap = {
93
- ...TextVariantMap,
94
- ...HeadlineVariantMap,
95
- };
96
-
97
95
  export const getVariantPlaceholderClassNames = (classes: Record<string, boolean>) =>
98
96
  Object.keys(classes).reduce(
99
97
  (acc, key) => {
@@ -0,0 +1,19 @@
1
+ import {
2
+ TypographyVariantMap,
3
+ TypographyDomVariantMap,
4
+ ElementTypes,
5
+ } from './typographyVariantClasses';
6
+
7
+ export const getElementTypeFromVariant = (
8
+ variant: keyof typeof TypographyVariantMap,
9
+ isHeadline: boolean,
10
+ ): ElementTypes => {
11
+ if (isHeadline) {
12
+ // if the variant corresponds to a real dom element, then use it as the element type.
13
+ const mappedHeaderElement = TypographyDomVariantMap[variant]
14
+ ? (variant as keyof typeof TypographyDomVariantMap)
15
+ : null;
16
+ return mappedHeaderElement || 'h3'; // defaults to h3
17
+ }
18
+ return 'span'; // default to span for body variants.
19
+ };
@@ -1,6 +0,0 @@
1
- require('../textVariantClasses-CBre7vXv.cjs');
2
- require('../Text-DllCE9_D.cjs');
3
- require('../Text-C8t_iEj6.cjs');
4
- const require_Accordion = require('../Accordion-D9gO9_y3.cjs');
5
-
6
- exports.Accordion = require_Accordion.Accordion;