@feminab/box-ui 0.1.0 → 0.1.3

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/.storybook/main.ts +40 -2
  2. package/README.md +59 -26
  3. package/dist/@interfaces/Badge.d.d.ts.map +1 -1
  4. package/dist/@interfaces/Button.d.d.ts.map +1 -1
  5. package/dist/@interfaces/Color.d.d.ts.map +1 -1
  6. package/dist/@interfaces/IButtonItem.d.d.ts.map +1 -1
  7. package/dist/@interfaces/ISubNavItem.d.d.ts.map +1 -1
  8. package/dist/@interfaces/MobileNavProps.d.d.ts.map +1 -1
  9. package/dist/@interfaces/NavItem.d.d.ts.map +1 -1
  10. package/dist/@interfaces/Pagination.d.d.ts.map +1 -1
  11. package/dist/@interfaces/Select.d.d.ts.map +1 -1
  12. package/dist/@interfaces/SideNavProps.d.d.ts.map +1 -1
  13. package/dist/@interfaces/TextInput.d.d.ts.map +1 -1
  14. package/dist/@interfaces/index.d.ts.map +1 -1
  15. package/dist/Badge.d.ts.map +1 -1
  16. package/dist/Button.d.ts.map +1 -1
  17. package/dist/ButtonGroup.d.ts.map +1 -1
  18. package/dist/ColorBox.d.ts.map +1 -1
  19. package/dist/Header.d.ts.map +1 -1
  20. package/dist/Nav/MobileNav.d.ts.map +1 -1
  21. package/dist/Nav/NavItem.d.ts.map +1 -1
  22. package/dist/Nav/SideNav.d.ts.map +1 -1
  23. package/dist/Nav/SubNavItem.d.ts.map +1 -1
  24. package/dist/Paginate.d.ts.map +1 -1
  25. package/dist/Select.d.ts.map +1 -1
  26. package/dist/StoryLayout.d.ts.map +1 -1
  27. package/dist/TextInput.d.ts.map +1 -1
  28. package/dist/Typography.d.ts.map +1 -1
  29. package/dist/box-ui.cjs.development.js +17 -11
  30. package/dist/box-ui.cjs.development.js.map +1 -1
  31. package/dist/box-ui.cjs.production.min.js +1 -1
  32. package/dist/box-ui.cjs.production.min.js.map +1 -1
  33. package/dist/box-ui.esm.js +17 -11
  34. package/dist/box-ui.esm.js.map +1 -1
  35. package/dist/data/colors.d.ts.map +1 -1
  36. package/dist/data/countries.d.ts.map +1 -1
  37. package/dist/data/images/index.d.ts.map +1 -1
  38. package/dist/data/index.d.ts.map +1 -1
  39. package/dist/data/navItems.d.ts.map +1 -1
  40. package/dist/data/options.d.ts.map +1 -1
  41. package/dist/data/prices.d.ts.map +1 -1
  42. package/dist/hooks/useIconClassName.d.ts.map +1 -1
  43. package/dist/hooks/useIconProps.d.ts.map +1 -1
  44. package/dist/index.d.ts.map +1 -1
  45. package/dist/jest.config.d.ts +9 -0
  46. package/dist/jest.config.d.ts.map +1 -0
  47. package/dist/reportWebVitals.d.ts.map +1 -1
  48. package/dist/setupTests.d.ts.map +1 -1
  49. package/dist/stories/Badge.stories.d.ts +3 -4
  50. package/dist/stories/Badge.stories.d.ts.map +1 -1
  51. package/dist/stories/Button.stories.d.ts +3 -4
  52. package/dist/stories/Button.stories.d.ts.map +1 -1
  53. package/dist/stories/ButtonGroup.stories.d.ts +4 -4
  54. package/dist/stories/ButtonGroup.stories.d.ts.map +1 -1
  55. package/dist/stories/Colors.stories.d.ts +3 -3
  56. package/dist/stories/Colors.stories.d.ts.map +1 -1
  57. package/dist/stories/MobileNav.stories.d.ts +3 -4
  58. package/dist/stories/MobileNav.stories.d.ts.map +1 -1
  59. package/dist/stories/Paginate.stories.d.ts +3 -4
  60. package/dist/stories/Paginate.stories.d.ts.map +1 -1
  61. package/dist/stories/Select.stories.d.ts +3 -4
  62. package/dist/stories/Select.stories.d.ts.map +1 -1
  63. package/dist/stories/SideNav.stories.d.ts +3 -4
  64. package/dist/stories/SideNav.stories.d.ts.map +1 -1
  65. package/dist/stories/TextInput.stories.d.ts +3 -4
  66. package/dist/stories/TextInput.stories.d.ts.map +1 -1
  67. package/dist/stories/Typography.stories.d.ts +4 -4
  68. package/dist/stories/Typography.stories.d.ts.map +1 -1
  69. package/dist/utils/IconWrapper.d.ts +8 -0
  70. package/dist/utils/IconWrapper.d.ts.map +1 -0
  71. package/jest.config.js +13 -0
  72. package/jest.setup.ts +3 -0
  73. package/netlify.toml +3 -0
  74. package/package.json +25 -26
  75. package/src/Nav/MobileNav.tsx +2 -0
  76. package/src/Nav/SideNav.tsx +1 -0
  77. package/src/Paginate.tsx +2 -0
  78. package/src/Select.tsx +1 -1
  79. package/src/TextInput.tsx +23 -27
  80. package/src/index.js +1 -1
  81. package/src/stories/Badge.stories.tsx +6 -8
  82. package/src/stories/Button.stories.tsx +21 -8
  83. package/src/stories/ButtonGroup.stories.tsx +48 -48
  84. package/src/stories/Colors.stories.tsx +2 -4
  85. package/src/stories/MobileNav.stories.tsx +29 -19
  86. package/src/stories/Paginate.stories.tsx +36 -35
  87. package/src/stories/Select.stories.tsx +46 -43
  88. package/src/stories/SideNav.stories.tsx +18 -19
  89. package/src/stories/TextInput.stories.tsx +81 -71
  90. package/src/stories/Typography.stories.tsx +2 -4
  91. package/src/styles/global.css +1 -181
  92. package/src/tests/Badge.test.tsx +48 -0
  93. package/src/tests/Button.test.tsx +69 -0
  94. package/src/tests/ButtonGroup.test.tsx +51 -0
  95. package/src/tests/MobileNav.test.tsx +66 -0
  96. package/src/tests/Paginate.test.tsx +86 -0
  97. package/src/tests/Select.test.tsx +63 -0
  98. package/src/tests/SideNav.test.tsx +43 -0
  99. package/src/tests/TextInput.test.tsx +42 -0
  100. package/src/tests/Typography.test.tsx +41 -0
  101. package/src/tests/__snapshots__/Badge.test.tsx.snap +13 -0
  102. package/src/tests/__snapshots__/Button.test.tsx.snap +106 -0
  103. package/src/tests/__snapshots__/ButtonGroup.test.tsx.snap +228 -0
  104. package/src/tests/__snapshots__/Paginate.test.tsx.snap +580 -0
  105. package/src/tests/__snapshots__/Select.test.tsx.snap +119 -0
  106. package/src/tests/__snapshots__/TextInput.test.tsx.snap +323 -0
  107. package/src/utils/IconWrapper.tsx +11 -0
  108. package/storybook-static/{125.65b26339.iframe.bundle.js → 125.df7cc93e.iframe.bundle.js} +3 -3
  109. package/storybook-static/125.df7cc93e.iframe.bundle.js.map +1 -0
  110. package/storybook-static/13.d4c3993e.iframe.bundle.js +2 -0
  111. package/storybook-static/161.f5193502.iframe.bundle.js +2 -0
  112. package/storybook-static/167.89fa6ac2.iframe.bundle.js +1 -0
  113. package/storybook-static/294.eccdc80d.iframe.bundle.js +1 -0
  114. package/storybook-static/314.c9f9245e.iframe.bundle.js +2 -0
  115. package/storybook-static/364.1cfcaebe.iframe.bundle.js +1 -0
  116. package/storybook-static/735.c396ee77.iframe.bundle.js +2 -0
  117. package/storybook-static/742.52c662a4.iframe.bundle.js +1 -0
  118. package/storybook-static/{844.aec20bdb.iframe.bundle.js → 844.3bb89aad.iframe.bundle.js} +3 -3
  119. package/storybook-static/844.3bb89aad.iframe.bundle.js.map +1 -0
  120. package/storybook-static/936.c827da74.iframe.bundle.js +1 -0
  121. package/storybook-static/961.c3df469f.iframe.bundle.js +2 -0
  122. package/storybook-static/iframe.html +3 -3
  123. package/storybook-static/main.179173d1.iframe.bundle.js +1 -0
  124. package/storybook-static/project.json +1 -1
  125. package/storybook-static/{runtime~main.295ddda4.iframe.bundle.js → runtime~main.70344601.iframe.bundle.js} +1 -1
  126. package/storybook-static/static/css/main.08036cd2.css.map +1 -1
  127. package/storybook-static/stories-Badge-stories.a924d6d5.iframe.bundle.js +1 -0
  128. package/storybook-static/stories-Button-stories.a3c88a14.iframe.bundle.js +1 -0
  129. package/storybook-static/stories-ButtonGroup-stories.2c74e4c4.iframe.bundle.js +1 -0
  130. package/storybook-static/stories-Colors-stories.424256b4.iframe.bundle.js +2 -0
  131. package/storybook-static/stories-Configure-mdx.46ebbf59.iframe.bundle.js +1 -0
  132. package/storybook-static/stories-Header-stories.df09e844.iframe.bundle.js +2 -0
  133. package/storybook-static/stories-MobileNav-stories.eb9a0ca6.iframe.bundle.js +1 -0
  134. package/storybook-static/stories-Page-stories.ab66c885.iframe.bundle.js +2 -0
  135. package/storybook-static/stories-Paginate-stories.086f736a.iframe.bundle.js +1 -0
  136. package/storybook-static/stories-Select-stories.4c04edb3.iframe.bundle.js +1 -0
  137. package/storybook-static/stories-SideNav-stories.272a4362.iframe.bundle.js +1 -0
  138. package/storybook-static/stories-TextInput-stories.cfa81131.iframe.bundle.js +1 -0
  139. package/storybook-static/stories-Typography-stories.a31da7ce.iframe.bundle.js +2 -0
  140. package/tailwind.config.js +1 -1
  141. package/tsconfig.json +6 -3
  142. package/tsdx.config.js +14 -0
  143. package/dist/Page.d.ts +0 -3
  144. package/dist/Page.d.ts.map +0 -1
  145. package/dist/stories/Header.stories.d.ts +0 -20
  146. package/dist/stories/Header.stories.d.ts.map +0 -1
  147. package/dist/stories/Page.stories.d.ts +0 -14
  148. package/dist/stories/Page.stories.d.ts.map +0 -1
  149. package/src/Page.tsx +0 -72
  150. package/src/stories/Configure.mdx +0 -364
  151. package/src/stories/Header.stories.ts +0 -33
  152. package/src/stories/Page.stories.ts +0 -32
  153. package/storybook-static/125.65b26339.iframe.bundle.js.map +0 -1
  154. package/storybook-static/13.0638081a.iframe.bundle.js +0 -2
  155. package/storybook-static/161.a19908ac.iframe.bundle.js +0 -2
  156. package/storybook-static/167.3fa3a909.iframe.bundle.js +0 -1
  157. package/storybook-static/294.ce38f65c.iframe.bundle.js +0 -1
  158. package/storybook-static/314.568bd9af.iframe.bundle.js +0 -2
  159. package/storybook-static/364.0b18ef67.iframe.bundle.js +0 -1
  160. package/storybook-static/735.1625d9f4.iframe.bundle.js +0 -2
  161. package/storybook-static/742.597501f6.iframe.bundle.js +0 -1
  162. package/storybook-static/844.aec20bdb.iframe.bundle.js.map +0 -1
  163. package/storybook-static/936.fd850a3f.iframe.bundle.js +0 -1
  164. package/storybook-static/961.0e5457c5.iframe.bundle.js +0 -2
  165. package/storybook-static/main.069281cf.iframe.bundle.js +0 -1
  166. package/storybook-static/stories-Badge-stories.484f7206.iframe.bundle.js +0 -1
  167. package/storybook-static/stories-Button-stories.5e29be85.iframe.bundle.js +0 -1
  168. package/storybook-static/stories-ButtonGroup-stories.cc89968c.iframe.bundle.js +0 -1
  169. package/storybook-static/stories-Colors-stories.f892dc75.iframe.bundle.js +0 -2
  170. package/storybook-static/stories-Configure-mdx.81346d97.iframe.bundle.js +0 -1
  171. package/storybook-static/stories-Header-stories.cf691094.iframe.bundle.js +0 -2
  172. package/storybook-static/stories-MobileNav-stories.f04cccdd.iframe.bundle.js +0 -1
  173. package/storybook-static/stories-Page-stories.0c9aa29d.iframe.bundle.js +0 -2
  174. package/storybook-static/stories-Paginate-stories.3b161781.iframe.bundle.js +0 -1
  175. package/storybook-static/stories-Select-stories.7556ae0d.iframe.bundle.js +0 -1
  176. package/storybook-static/stories-SideNav-stories.093fac6a.iframe.bundle.js +0 -1
  177. package/storybook-static/stories-TextInput-stories.6d3e15c6.iframe.bundle.js +0 -1
  178. package/storybook-static/stories-Typography-stories.6640f7ac.iframe.bundle.js +0 -2
  179. /package/storybook-static/{125.65b26339.iframe.bundle.js.LICENSE.txt → 125.df7cc93e.iframe.bundle.js.LICENSE.txt} +0 -0
  180. /package/storybook-static/{13.0638081a.iframe.bundle.js.LICENSE.txt → 13.d4c3993e.iframe.bundle.js.LICENSE.txt} +0 -0
  181. /package/storybook-static/{161.a19908ac.iframe.bundle.js.LICENSE.txt → 161.f5193502.iframe.bundle.js.LICENSE.txt} +0 -0
  182. /package/storybook-static/{314.568bd9af.iframe.bundle.js.LICENSE.txt → 314.c9f9245e.iframe.bundle.js.LICENSE.txt} +0 -0
  183. /package/storybook-static/{735.1625d9f4.iframe.bundle.js.LICENSE.txt → 735.c396ee77.iframe.bundle.js.LICENSE.txt} +0 -0
  184. /package/storybook-static/{844.aec20bdb.iframe.bundle.js.LICENSE.txt → 844.3bb89aad.iframe.bundle.js.LICENSE.txt} +0 -0
  185. /package/storybook-static/{961.0e5457c5.iframe.bundle.js.LICENSE.txt → 961.c3df469f.iframe.bundle.js.LICENSE.txt} +0 -0
  186. /package/storybook-static/{stories-Colors-stories.f892dc75.iframe.bundle.js.LICENSE.txt → stories-Colors-stories.424256b4.iframe.bundle.js.LICENSE.txt} +0 -0
  187. /package/storybook-static/{stories-Header-stories.cf691094.iframe.bundle.js.LICENSE.txt → stories-Header-stories.df09e844.iframe.bundle.js.LICENSE.txt} +0 -0
  188. /package/storybook-static/{stories-Page-stories.0c9aa29d.iframe.bundle.js.LICENSE.txt → stories-Page-stories.ab66c885.iframe.bundle.js.LICENSE.txt} +0 -0
  189. /package/storybook-static/{stories-Typography-stories.6640f7ac.iframe.bundle.js.LICENSE.txt → stories-Typography-stories.a31da7ce.iframe.bundle.js.LICENSE.txt} +0 -0
@@ -1,30 +1,27 @@
1
-
2
1
  import React, { useState } from "react";
3
2
  import { Meta, StoryObj } from "@storybook/react";
4
- import { MobileNavProps} from "../@interfaces";
3
+ import { MobileNavProps } from "../@interfaces";
5
4
  import { SideNav } from "../Nav/SideNav";
6
5
  import { StoryLayout } from "../StoryLayout";
7
6
  import { navItemsTop, navItemsBottom } from "../data/navItems";
8
7
  import { MobileNavbar } from "../Nav/MobileNav";
9
- import { FiX } from "react-icons/fi";
8
+ import { FiX } from "react-icons/fi"; // Directly import FiX
9
+ import type { IconBaseProps } from "react-icons";
10
10
 
11
- const meta: Meta<typeof SideNav> = {
11
+ const CloseIcon = FiX as React.FC<IconBaseProps>;
12
+ // Wrapper to fix TS JSX issues
13
+
14
+ export default {
12
15
  title: "Example/MobileNav",
13
16
  component: MobileNavbar,
14
- };
15
-
16
- export default meta;
17
+ } as Meta;
17
18
 
18
19
  interface Props extends MobileNavProps {
19
20
  darkMode: boolean;
20
21
  }
21
22
 
22
- export const Default: StoryObj<Props> = {
23
- args: {
24
- darkMode: false,
25
- },
26
- render: (args) => {
27
- const [open, setOpen] = useState<boolean>(false);
23
+ const MobileNavWithState = (args: Props) => {
24
+ const [open, setOpen] = useState<boolean>(false);
28
25
 
29
26
  const handleToggle = () => {
30
27
  setOpen(!open);
@@ -34,16 +31,23 @@ export const Default: StoryObj<Props> = {
34
31
  <StoryLayout {...args}>
35
32
  <MobileNavbar open={open} toggleOpen={handleToggle} />
36
33
 
37
- {open ? (
34
+ {open && (
38
35
  <div
36
+ data-testid="backdrop"
39
37
  className="fixed top-0 left-0 z-40 w-screen h-screen bg-gray-500 cursor-pointer bg-opacity-80"
40
38
  onClick={() => setOpen(false)}
41
39
  >
42
- <FiX size={40} className="fixed text-white top-5 right-9" />
40
+ <CloseIcon
41
+ data-testid="close-icon"
42
+ size={40}
43
+ className="fixed text-white top-5 right-9"
44
+ role="button"
45
+ aria-label="Close sidebar"
46
+ />
43
47
  </div>
44
- ) : null}
48
+ )}
45
49
 
46
- {open ? (
50
+ {open && (
47
51
  <SideNav
48
52
  className="relative z-50 h-screen -mt-20"
49
53
  navItemsTop={navItemsTop}
@@ -53,8 +57,14 @@ export const Default: StoryObj<Props> = {
53
57
  username="Veronica Woods"
54
58
  email="veronica@example.com"
55
59
  />
56
- ) : null}
60
+ )}
57
61
  </StoryLayout>
58
- );
62
+ );
63
+ };
64
+
65
+ export const Default: StoryObj<Props> = {
66
+ args: {
67
+ darkMode: false,
59
68
  },
69
+ render: (args) => <MobileNavWithState {...args} />,
60
70
  };
@@ -4,41 +4,56 @@ import { Meta, StoryObj } from "@storybook/react";
4
4
  import { PaginationProps } from "../@interfaces";
5
5
  import {Paginate} from "../Paginate";
6
6
 
7
- const meta: Meta<typeof Paginate> = {
7
+ export default {
8
8
  title: "Example/Pagination",
9
9
  component: Paginate,
10
10
  parameters: {
11
11
  layout: "centered",
12
12
  },
13
13
  tags: ["autodocs"],
14
- };
15
-
16
- export default meta;
17
-
14
+ } as Meta;
18
15
  interface Props extends PaginationProps {
19
16
  darkMode: boolean;
20
17
  }
21
18
 
19
+ const DesktopPaginationComponent = (args: Props) => {
20
+ const [currentPage, setCurrentPage] = useState<number>(0);
21
+
22
+ return (
23
+ <StoryLayout {...args}>
24
+ <Paginate
25
+ className=""
26
+ isMobile={false}
27
+ totalPages={args.totalPages}
28
+ page={currentPage}
29
+ setPage={setCurrentPage}
30
+ />
31
+ </StoryLayout>
32
+ );
33
+ };
34
+
22
35
  export const DesktopPagination: StoryObj<Props> = {
23
36
  args: {
24
37
  darkMode: false,
25
38
  totalPages: 10,
26
39
  },
27
- render: (args) => {
28
- const [currentPage, setCurrentPage] = useState<number>(0);
40
+ render: (args) => <DesktopPaginationComponent {...args} />,
41
+ };
29
42
 
30
- return (
31
- <StoryLayout {...args}>
32
- <Paginate
33
- className=""
34
- isMobile={false}
35
- totalPages={args.totalPages}
36
- page={currentPage}
37
- setPage={setCurrentPage}
38
- />
39
- </StoryLayout>
40
- );
41
- },
43
+ const MobilePaginationComponent = (args: Props) => {
44
+ const [currentPage, setCurrentPage] = useState<number>(0);
45
+
46
+ return (
47
+ <StoryLayout {...args}>
48
+ <Paginate
49
+ className=""
50
+ isMobile={true}
51
+ totalPages={args.totalPages}
52
+ page={currentPage}
53
+ setPage={setCurrentPage}
54
+ />
55
+ </StoryLayout>
56
+ );
42
57
  };
43
58
 
44
59
  export const MobilePagination: StoryObj<Props> = {
@@ -46,19 +61,5 @@ export const MobilePagination: StoryObj<Props> = {
46
61
  darkMode: false,
47
62
  totalPages: 10,
48
63
  },
49
- render: (args) => {
50
- const [currentPage, setCurrentPage] = useState<number>(0);
51
-
52
- return (
53
- <StoryLayout {...args}>
54
- <Paginate
55
- className=""
56
- isMobile={true}
57
- totalPages={args.totalPages}
58
- page={currentPage}
59
- setPage={setCurrentPage}
60
- />
61
- </StoryLayout>
62
- );
63
- },
64
- };
64
+ render: (args) => <MobilePaginationComponent {...args} />,
65
+ };
@@ -1,24 +1,21 @@
1
-
2
- import React, {useState} from "react";
1
+ import React, { useState } from "react";
3
2
  import { Meta, StoryObj } from "@storybook/react";
4
3
  import { Select } from "../Select";
5
4
  import { IOption, SelectProps } from "../@interfaces";
6
5
  import { StoryLayout } from "../StoryLayout";
7
6
  import { countries } from "../data/countries";
8
7
  import { prices } from "../data/prices";
9
- import {FiDollarSign} from 'react-icons/fi';
8
+ import { FiDollarSign } from 'react-icons/fi';
9
+ import { IconWrapper } from "../utils/IconWrapper";
10
10
 
11
- const meta: Meta<typeof Select> = {
11
+ export default {
12
12
  title: "Example/Select",
13
13
  component: Select,
14
14
  parameters: {
15
15
  layout: "centered",
16
16
  },
17
17
  tags: ["autodocs"],
18
- }
19
-
20
- export default meta;
21
-
18
+ } as Meta;
22
19
  interface Props extends SelectProps {
23
20
  darkMode: false;
24
21
  }
@@ -28,24 +25,27 @@ export const Default: StoryObj<Props> = {
28
25
  darkMode: false
29
26
  },
30
27
  render: (args) => {
31
- const [selectedCountry, setSelectedCountry] = useState<IOption>(countries[0]);
28
+ const SelectStory = () => {
29
+ const [selectedCountry, setSelectedCountry] = useState<IOption>(countries[0]);
30
+
31
+ const handleSelectedCountry = (country: string) => {
32
+ const option = countries.find((obj) => obj.value === country) as IOption;
33
+ setSelectedCountry(option);
34
+ }
32
35
 
33
- const handleSelectedCountry = (country:string) => {
34
- const option = countries.find((obj) => obj.value === country) as IOption;
35
- setSelectedCountry(option);
36
- }
37
-
38
- return(
39
- <StoryLayout {...args} className="flex">
40
- <Select
41
- options={countries}
42
- selectedOption={selectedCountry}
43
- setSelectedOption={handleSelectedCountry}
44
- placeholder="Select country"
45
- width="w-50"
46
- />
47
- </StoryLayout>
48
- )
36
+ return (
37
+ <StoryLayout {...args} className="flex">
38
+ <Select
39
+ options={countries}
40
+ selectedOption={selectedCountry}
41
+ setSelectedOption={handleSelectedCountry}
42
+ placeholder="Select country"
43
+ width="w-50"
44
+ />
45
+ </StoryLayout>
46
+ );
47
+ };
48
+ return <SelectStory />;
49
49
  }
50
50
  }
51
51
 
@@ -54,24 +54,27 @@ export const SelectWithIcon: StoryObj<Props> = {
54
54
  darkMode: false
55
55
  },
56
56
  render: (args) => {
57
- const [selectedPrice, setSelectedPrice] = useState<IOption>(prices[0]);
57
+ const SelectWithIconStory = () => {
58
+ const [selectedPrice, setSelectedPrice] = useState<IOption>(prices[0]);
59
+
60
+ const handleSelectedPrice = (price: string) => {
61
+ const option = prices.find((obj) => obj.value === price) as IOption;
62
+ setSelectedPrice(option);
63
+ }
58
64
 
59
- const handleSelectedPrice = (price:string) => {
60
- const option = prices.find((obj) => obj.value === price) as IOption;
61
- setSelectedPrice(option);
62
- }
63
-
64
- return(
65
- <StoryLayout {...args} className="flex">
66
- <Select
67
- options={prices}
68
- selectedOption={selectedPrice}
69
- setSelectedOption={handleSelectedPrice}
70
- placeholder="Select a price"
71
- LeadingIcon={<FiDollarSign />}
72
- width="w-50"
73
- />
74
- </StoryLayout>
75
- )
65
+ return (
66
+ <StoryLayout {...args} className="flex">
67
+ <Select
68
+ options={prices}
69
+ selectedOption={selectedPrice}
70
+ setSelectedOption={handleSelectedPrice}
71
+ placeholder="Select a price"
72
+ LeadingIcon={<IconWrapper Icon={FiDollarSign} />}
73
+ width="w-50"
74
+ />
75
+ </StoryLayout>
76
+ );
77
+ };
78
+ return <SelectWithIconStory />;
76
79
  }
77
80
  }
@@ -5,34 +5,33 @@ import { SideNav } from "../Nav/SideNav";
5
5
  import { StoryLayout } from "../StoryLayout";
6
6
  import { navItemsTop, navItemsBottom } from "../data/navItems";
7
7
 
8
- const meta: Meta<typeof SideNav> = {
8
+ export default {
9
9
  title: "Example/SideNav",
10
10
  component: SideNav,
11
- };
12
-
13
- export default meta;
11
+ } as Meta;
14
12
 
15
13
  interface Props extends SideNavProps {
16
14
  darkMode: boolean;
17
15
  }
18
16
 
17
+ const SideNavWithState = (args: Props) => {
18
+ const [open, setOpen] = useState<boolean>(true);
19
+ return (
20
+ <StoryLayout {...args} className="flex flex-col h-screen">
21
+ <SideNav
22
+ {...args}
23
+ navItemsTop={navItemsTop}
24
+ navItemsBottom={navItemsBottom}
25
+ open={open}
26
+ setOpen={setOpen}
27
+ username="Veronica Woods"
28
+ email="veronica@example.com"/>
29
+ </StoryLayout>
30
+ );
31
+ }
19
32
  export const Default: StoryObj<Props> = {
20
33
  args: {
21
34
  darkMode: false,
22
35
  },
23
- render: (args) => {
24
- const [open, setOpen] = useState<boolean>(true);
25
- return (
26
- <StoryLayout {...args} className="flex flex-col h-screen">
27
- <SideNav
28
- {...args}
29
- navItemsTop={navItemsTop}
30
- navItemsBottom={navItemsBottom}
31
- open={open}
32
- setOpen={setOpen}
33
- username="Veronica Woods"
34
- email="veronica@example.com"/>
35
- </StoryLayout>
36
- );
37
- },
36
+ render: (args) => <SideNavWithState {...args} />,
38
37
  };
@@ -4,13 +4,12 @@ import { Meta, StoryObj } from "@storybook/react";
4
4
  import { TextInput } from "../TextInput";
5
5
  import { StoryLayout } from "../StoryLayout";
6
6
  import { FiMail, FiHelpCircle, FiAlertCircle } from "react-icons/fi";
7
+ import { IconWrapper } from "../utils/IconWrapper";
7
8
 
8
- const meta: Meta<typeof TextInput> = {
9
+ export default {
9
10
  title: "Example/TextInput",
10
11
  component: TextInput,
11
- };
12
-
13
- export default meta;
12
+ } as Meta;
14
13
 
15
14
  interface Props extends TextInputProps {
16
15
  darkMode: boolean;
@@ -19,82 +18,93 @@ interface Props extends TextInputProps {
19
18
  export const Default: StoryObj<Props> = {
20
19
  args: {
21
20
  darkMode: false,
21
+ value: ''
22
22
  },
23
- render: (args) => {
24
- const [text1, setText1] = useState<string>(args.value);
23
+ render: (args) => <DefaultTextInputStory {...args} />,
24
+ };
25
25
 
26
- const handleChange = (e: ChangeEvent<HTMLInputElement>) => {
27
- setText1(e.target.value);
28
- };
26
+ const DefaultTextInputStory = (args: Props) => {
27
+ const [text1, setText1] = useState<string>(args.value || "");
29
28
 
30
- return (
31
- <StoryLayout {...args}>
32
- <TextInput
33
- type="email"
34
- value={text1}
35
- handleChange={handleChange}
36
- label="Email"
37
- placeholder="veronica@example.com"
38
- helperText="This is a hint text to help the user."
39
- LeadingIcon={<FiMail />}
40
- TrailingIcon={<FiHelpCircle />}
41
- disabled={args.disabled}
42
- />
43
- <div className="mb-4" />
44
- <TextInput
45
- type="email"
46
- value={text1}
47
- handleChange={handleChange}
48
- label="Email"
49
- placeholder="veronica@example.com"
50
- helperText="This is a hint text to help the user."
51
- error="This is an error message."
52
- LeadingIcon={<FiMail />}
53
- TrailingIcon={<FiHelpCircle />}
54
- disabled={args.disabled}
55
- />
56
- </StoryLayout>
57
- );
58
- },
29
+ const handleChange = (e: ChangeEvent<HTMLInputElement>) => {
30
+ setText1(e.target.value);
31
+ };
32
+
33
+ return (
34
+ <StoryLayout {...args}>
35
+ <TextInput
36
+ {...args}
37
+ type="email"
38
+ value={text1}
39
+ handleChange={handleChange}
40
+ label="Email"
41
+ placeholder="veronica@example.com"
42
+ helperText="This is a hint text to help the user."
43
+ LeadingIcon={<IconWrapper Icon={FiMail} />}
44
+ TrailingIcon={<IconWrapper Icon={FiHelpCircle} />}
45
+ disabled={args.disabled}
46
+ />
47
+ <div className="mb-4" />
48
+ <TextInput
49
+ {...args}
50
+ type="email"
51
+ value={text1}
52
+ handleChange={handleChange}
53
+ label="Email"
54
+ placeholder="veronica@example.com"
55
+ helperText="This is a hint text to help the user."
56
+ error="This is an error message."
57
+ LeadingIcon={<IconWrapper Icon={FiMail} />}
58
+ TrailingIcon={<IconWrapper Icon={FiHelpCircle} />}
59
+ disabled={args.disabled}
60
+ />
61
+ </StoryLayout>
62
+ );
59
63
  };
60
64
 
61
65
  export const LeadingTextInput: StoryObj<Props> = {
62
66
  args: {
63
67
  darkMode: false,
68
+ value: ''
64
69
  },
65
- render: (args) => {
66
- const [text1, setText1] = useState<string>(args.value);
70
+ render: (args) => <LeadingTextInputStory {...args} />,
71
+ };
67
72
 
68
- const handleChange = (e: ChangeEvent<HTMLInputElement>) => {
69
- setText1(e.target.value);
70
- };
73
+ const LeadingTextInputStory = (args: Props) => {
74
+ const [text1, setText1] = useState<string>(args.value || "");
71
75
 
72
- return (
73
- <StoryLayout {...args}>
74
- <TextInput
75
- type="text"
76
- value={text1}
77
- handleChange={handleChange}
78
- label="Website"
79
- placeholder="example.com"
80
- leadingText="https://"
81
- helperText="This is a hint text to help the user."
82
- TrailingIcon={<FiHelpCircle />}
83
- disabled={args.disabled}
84
- />
85
- <div className="mb-4" />
86
- <TextInput
87
- type="text"
88
- value={text1}
89
- handleChange={handleChange}
90
- label="Website"
91
- placeholder="example.com"
92
- leadingText="https://"
93
- error="This is an error message."
94
- TrailingIcon={<FiAlertCircle />}
95
- disabled={args.disabled}
96
- />
97
- </StoryLayout>
98
- );
99
- },
76
+ const handleChange = (e: ChangeEvent<HTMLInputElement>) => {
77
+ setText1(e.target.value);
78
+ };
79
+
80
+ return (
81
+ <StoryLayout {...args}>
82
+ <TextInput
83
+ {...args}
84
+ type="text"
85
+ value={text1}
86
+ handleChange={handleChange}
87
+ label="Website"
88
+ placeholder="example.com"
89
+ leadingText="https://"
90
+ helperText="This is a hint text to help the user."
91
+ TrailingIcon={<IconWrapper Icon={FiHelpCircle} />}
92
+ disabled={args.disabled}
93
+ />
94
+ <div className="mb-4" />
95
+ <TextInput
96
+ {...args}
97
+ type="text"
98
+ value={text1}
99
+ handleChange={handleChange}
100
+ label="Website"
101
+ placeholder="example.com"
102
+ leadingText="https://"
103
+ error="This is an error message."
104
+ TrailingIcon={<IconWrapper Icon={FiAlertCircle} />}
105
+ disabled={args.disabled}
106
+ />
107
+ </StoryLayout>
108
+ );
100
109
  };
110
+
@@ -3,15 +3,13 @@ import { Meta, StoryObj } from "@storybook/react";
3
3
  import { Typography, TypographyProps } from "../Typography";
4
4
  import { StoryLayout } from "../StoryLayout";
5
5
 
6
- const meta: Meta<typeof Typography> = {
6
+ export default {
7
7
  title: "Example/Typography",
8
8
  component: Typography,
9
9
  parameters: {
10
10
  layout: 'centered',
11
11
  },
12
- };
13
-
14
- export default meta;
12
+ } as Meta;
15
13
 
16
14
  interface Props extends TypographyProps {
17
15
  darkMode: boolean;