@fpkit/acss 0.5.4 → 0.5.6

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 (158) hide show
  1. package/libs/chunk-PWVRDQ3R.js +8 -0
  2. package/libs/chunk-PWVRDQ3R.js.map +1 -0
  3. package/libs/chunk-SVS4MX3U.cjs +31 -0
  4. package/libs/chunk-SVS4MX3U.cjs.map +1 -0
  5. package/libs/{icons-2f29127c.d.ts → icons-31ace3de.d.ts} +87 -81
  6. package/libs/icons.cjs +2 -2
  7. package/libs/icons.d.cts +1 -1
  8. package/libs/icons.d.ts +1 -1
  9. package/libs/icons.js +1 -1
  10. package/libs/index.cjs +42 -42
  11. package/libs/index.cjs.map +1 -1
  12. package/libs/index.d.cts +59 -29
  13. package/libs/index.d.ts +59 -29
  14. package/libs/index.js +7 -7
  15. package/libs/index.js.map +1 -1
  16. package/package.json +4 -3
  17. package/src/components/README.mdx +84 -0
  18. package/src/components/alert/README.mdx +86 -0
  19. package/src/components/alert/alert.mdx +74 -0
  20. package/src/components/alert/alert.scss +80 -0
  21. package/src/components/alert/alert.stories.tsx +132 -0
  22. package/src/components/alert/alert.tsx +154 -0
  23. package/src/components/alert/elements/README.mdx +77 -0
  24. package/src/components/alert/elements/dismiss-button.stories.tsx +31 -0
  25. package/src/components/alert/elements/dismiss-button.tsx +28 -0
  26. package/src/components/badge/badge.mdx +124 -0
  27. package/src/components/badge/badge.scss +4 -4
  28. package/src/components/badge/badge.stories.tsx +21 -23
  29. package/src/components/breadcrumbs/breadcrumb.scss +2 -2
  30. package/src/components/breadcrumbs/breadcrumb.stories.tsx +42 -47
  31. package/src/components/buttons/button.scss +41 -15
  32. package/src/components/buttons/button.stories.tsx +8 -1
  33. package/src/components/buttons/button.test.tsx +72 -72
  34. package/src/components/cards/card.stories.tsx +15 -15
  35. package/src/components/details/details.scss +26 -6
  36. package/src/components/details/details.stories.tsx +33 -30
  37. package/src/components/details/details.tsx +17 -17
  38. package/src/components/dialog/README.mdx +187 -0
  39. package/src/components/dialog/dialog-modal.stories.tsx +113 -0
  40. package/src/components/dialog/dialog-modal.tsx +111 -0
  41. package/src/components/dialog/dialog.scss +76 -0
  42. package/src/components/dialog/dialog.stories.tsx +116 -0
  43. package/src/components/dialog/dialog.tsx +128 -0
  44. package/src/components/dialog/hooks/useClickOutside.ts +33 -0
  45. package/src/components/dialog/views/README.mdx +182 -0
  46. package/src/components/dialog/views/dialog-footer.tsx +45 -0
  47. package/src/components/dialog/views/dialog-header.stories.tsx +42 -0
  48. package/src/components/dialog/views/dialog-header.tsx +61 -0
  49. package/src/components/form/form.stories.tsx +16 -16
  50. package/src/components/form/input.stories.tsx +62 -62
  51. package/src/components/form/select.stories.tsx +22 -15
  52. package/src/components/heading/heading.stories.tsx +32 -33
  53. package/src/components/heading/heading.tsx +1 -1
  54. package/src/components/icons/components/add.tsx +14 -14
  55. package/src/components/icons/components/alert-solid.tsx +36 -0
  56. package/src/components/icons/components/alert-square-solid.tsx +36 -0
  57. package/src/components/icons/components/info-solid.tsx +40 -0
  58. package/src/components/icons/components/info.tsx +36 -0
  59. package/src/components/icons/components/question-solid.tsx +36 -0
  60. package/src/components/icons/components/success-solid.tsx +36 -0
  61. package/src/components/icons/components/svg.tsx +0 -1
  62. package/src/components/icons/components/warn-solid.tsx +36 -0
  63. package/src/components/icons/icon.scss +1 -3
  64. package/src/components/icons/icon.stories.tsx +87 -78
  65. package/src/components/icons/icon.tsx +57 -52
  66. package/src/components/icons/index.ts +36 -29
  67. package/src/components/icons/types.ts +1 -1
  68. package/src/components/images/figure.stories.tsx +13 -13
  69. package/src/components/images/img.stories.tsx +12 -12
  70. package/src/components/link/link.stories.tsx +32 -35
  71. package/src/components/link/link.tsx +27 -14
  72. package/src/components/list/list.stories.tsx +16 -16
  73. package/src/components/modal/dialog.tsx +13 -12
  74. package/src/components/modal/modal.tsx +28 -30
  75. package/src/components/nav/nav.stories.tsx +25 -24
  76. package/src/components/popover/popover.stories.tsx +17 -18
  77. package/src/components/progress/progress.stories.tsx +14 -20
  78. package/src/components/tag/tag.stories.tsx +17 -18
  79. package/src/components/text/text.stories.tsx +28 -29
  80. package/src/components/text-to-speech/TextToSpeech.stories.tsx +100 -101
  81. package/src/components/ui.tsx +28 -25
  82. package/src/decorators/instructions.tsx +44 -0
  83. package/src/hooks/useDialogClickHandler.ts +26 -0
  84. package/src/index.scss +23 -22
  85. package/src/index.ts +31 -30
  86. package/src/patterns/page/page-header.stories.tsx +17 -21
  87. package/src/sass/_globals.scss +14 -32
  88. package/src/sass/_styles.scss +2 -1
  89. package/src/sass/styles/_colors.scss +13 -0
  90. package/src/styles/alert/alert.css +68 -0
  91. package/src/styles/alert/alert.css.map +1 -0
  92. package/src/styles/badge/badge.css +3 -3
  93. package/src/styles/breadcrumbs/breadcrumb.css +1 -1
  94. package/src/styles/buttons/button.css +25 -2
  95. package/src/styles/buttons/button.css.map +1 -1
  96. package/src/styles/details/details.css +19 -4
  97. package/src/styles/details/details.css.map +1 -1
  98. package/src/styles/dialog/dialog.css +76 -0
  99. package/src/styles/dialog/dialog.css.map +1 -0
  100. package/src/styles/icons/icon.css +1 -3
  101. package/src/styles/icons/icon.css.map +1 -1
  102. package/src/styles/index.css +213 -60
  103. package/src/styles/index.css.map +1 -1
  104. package/libs/chunk-TBM2QIVT.js +0 -8
  105. package/libs/chunk-TBM2QIVT.js.map +0 -1
  106. package/libs/chunk-VAH6X2DZ.cjs +0 -31
  107. package/libs/chunk-VAH6X2DZ.cjs.map +0 -1
  108. package/libs/components/badge/badge.css +0 -1
  109. package/libs/components/badge/badge.css.map +0 -1
  110. package/libs/components/badge/badge.min.css +0 -3
  111. package/libs/components/breadcrumbs/breadcrumb.css +0 -1
  112. package/libs/components/breadcrumbs/breadcrumb.css.map +0 -1
  113. package/libs/components/breadcrumbs/breadcrumb.min.css +0 -3
  114. package/libs/components/buttons/button.css +0 -1
  115. package/libs/components/buttons/button.css.map +0 -1
  116. package/libs/components/buttons/button.min.css +0 -3
  117. package/libs/components/cards/card-style.css +0 -1
  118. package/libs/components/cards/card-style.css.map +0 -1
  119. package/libs/components/cards/card-style.min.css +0 -3
  120. package/libs/components/cards/card.css +0 -1
  121. package/libs/components/cards/card.css.map +0 -1
  122. package/libs/components/cards/card.min.css +0 -3
  123. package/libs/components/details/details.css +0 -1
  124. package/libs/components/details/details.css.map +0 -1
  125. package/libs/components/details/details.min.css +0 -3
  126. package/libs/components/form/form.css +0 -1
  127. package/libs/components/form/form.css.map +0 -1
  128. package/libs/components/form/form.min.css +0 -3
  129. package/libs/components/icons/icon.css +0 -1
  130. package/libs/components/icons/icon.css.map +0 -1
  131. package/libs/components/icons/icon.min.css +0 -3
  132. package/libs/components/images/img.css +0 -1
  133. package/libs/components/images/img.css.map +0 -1
  134. package/libs/components/images/img.min.css +0 -3
  135. package/libs/components/layout/landmarks.css +0 -1
  136. package/libs/components/layout/landmarks.css.map +0 -1
  137. package/libs/components/layout/landmarks.min.css +0 -3
  138. package/libs/components/link/link.css +0 -1
  139. package/libs/components/link/link.css.map +0 -1
  140. package/libs/components/link/link.min.css +0 -3
  141. package/libs/components/nav/nav.css +0 -1
  142. package/libs/components/nav/nav.css.map +0 -1
  143. package/libs/components/nav/nav.min.css +0 -3
  144. package/libs/components/progress/progress.css +0 -1
  145. package/libs/components/progress/progress.css.map +0 -1
  146. package/libs/components/progress/progress.min.css +0 -3
  147. package/libs/components/styles/index.css +0 -1
  148. package/libs/components/styles/index.css.map +0 -1
  149. package/libs/components/styles/index.min.css +0 -3
  150. package/libs/components/tag/tag.css +0 -1
  151. package/libs/components/tag/tag.css.map +0 -1
  152. package/libs/components/tag/tag.min.css +0 -3
  153. package/libs/components/text-to-speech/text-to-speech.css +0 -1
  154. package/libs/components/text-to-speech/text-to-speech.css.map +0 -1
  155. package/libs/components/text-to-speech/text-to-speech.min.css +0 -3
  156. package/libs/index.css +0 -1
  157. package/libs/index.css.map +0 -1
  158. package/src/components/readme.stories.mdx +0 -7
@@ -1,10 +1,10 @@
1
1
  sup:has(> span) {
2
2
  --badge-bg: lightgray;
3
3
  --badge-color: currentColor;
4
- --badge-radius: 0.15rem;
5
- --badge-padding: 0.15rem;
4
+ --badge-radius: 0.5rem;
5
+ --badge-padding: 0.3rem;
6
6
  --badge-v-align: 0.5rem;
7
- --badge-fs: clamp(0.4rem, 0.5rem + 0.5vw, 7rem);
7
+ --badge-fs: var(--fs-1);
8
8
  background-color: var(--badge-bg);
9
9
  color: var(--badge-color);
10
10
  padding: var(--badge-padding);
@@ -14,7 +14,7 @@ sup:has(> span) {
14
14
  span {
15
15
  color: inherit;
16
16
  }
17
- &[data-badge~='rounded'] {
17
+ &[data-badge~="rounded"] {
18
18
  --badge-radius: 100%;
19
19
  --badge-padding: 0.2rem;
20
20
  }
@@ -1,54 +1,52 @@
1
- import { StoryObj, Meta } from '@storybook/react'
2
- import { within, expect } from '@storybook/test'
1
+ import { StoryObj, Meta } from "@storybook/react";
2
+ import { within, expect } from "@storybook/test";
3
3
 
4
-
5
- import Badge from './badge'
6
- // import './badge.scss'
4
+ import Badge from "./badge";
7
5
 
8
6
  const meta: Meta<typeof Badge> = {
9
- title: 'FP.REACT Components/Badge',
7
+ title: "FP.REACT Components/Badge",
10
8
  component: Badge,
9
+ tags: ["beta"],
11
10
  args: {
12
- // @ts-ignore
13
- children: 'Link',
11
+ children: "Link",
14
12
  },
15
- } as Story
13
+ } as Story;
16
14
 
17
- export default meta
18
- type Story = StoryObj<typeof Badge>
15
+ export default meta;
16
+ type Story = StoryObj<typeof Badge>;
19
17
 
20
18
  export const BadgeComponent: Story = {
21
19
  args: {},
22
20
  play: async ({ canvasElement }) => {
23
- const canvas = within(canvasElement)
24
- expect(canvas.getByText(/link/i)).toBeInTheDocument()
21
+ const canvas = within(canvasElement);
22
+ expect(canvas.getByText(/link/i)).toBeInTheDocument();
25
23
  },
26
- }
24
+ };
27
25
 
28
26
  export const CustomBadge: Story = {
29
27
  args: {
30
- children: 'Custom',
28
+ children: "Custom",
31
29
  },
32
- render: ({ ...args }) => {
30
+ render: () => {
33
31
  return (
34
32
  <p>
35
33
  Custom
36
34
  <Badge aria-label="badge">21</Badge>
37
35
  </p>
38
- )
36
+ );
39
37
  },
40
38
  play: async ({ canvasElement }) => {
41
- const canvas = within(canvasElement)
42
- expect(canvas.getByText(/custom/i)).toBeInTheDocument()
39
+ const canvas = within(canvasElement);
40
+ expect(canvas.getByText(/custom/i)).toBeInTheDocument();
43
41
  },
44
- } as Story
42
+ } as Story;
45
43
 
46
44
  export const RoundedBadge: Story = {
47
- render: ({ ...args }) => {
45
+ render: () => {
48
46
  return (
49
47
  <p>
50
48
  Custom<Badge data-badge="rounded">21</Badge>
51
49
  </p>
52
- )
50
+ );
53
51
  },
54
- } as Story
52
+ } as Story;
@@ -5,7 +5,7 @@ nav[data-breadcrumb] {
5
5
  --breadcrumb-gap: 0.5rem;
6
6
  --breadcrumb-color: currentColor;
7
7
  --breadcrumb-current-color: rgb(46, 46, 46);
8
- --breadcrumb-fs: var(--fs-0);
8
+ --breadcrumb-fs: var(--fs-3);
9
9
  margin-inline: unset;
10
10
  padding-inline: unset;
11
11
  ol {
@@ -20,7 +20,7 @@ nav[data-breadcrumb] {
20
20
  color: var(--breadcrumb-color);
21
21
  gap: 0.5rem;
22
22
  font-size: var(--breadcrumb-fs);
23
- span[aria-hidden='true'] {
23
+ span[aria-hidden="true"] {
24
24
  opacity: 0.6;
25
25
  }
26
26
  a[href] {
@@ -1,108 +1,103 @@
1
- import type { StoryObj, Meta } from '@storybook/react'
2
- import { within, userEvent, fn, expect } from '@storybook/test'
1
+ import type { StoryObj, Meta } from "@storybook/react";
2
+ import { within, fn, expect } from "@storybook/test";
3
3
 
4
+ import Breadcrumb from "./breadcrumb";
4
5
 
5
- import Breadcrumb from './breadcrumb'
6
-
7
- const linkClicked = fn()
6
+ const linkClicked = fn();
8
7
 
9
8
  const meta: Meta<typeof Breadcrumb> = {
10
- title: 'FP.REACT Components/Breadcrumb',
9
+ title: "FP.REACT Components/Breadcrumb",
11
10
  component: Breadcrumb,
11
+ tags: ["beta"],
12
12
  parameters: {
13
- actions: { argTypesRegex: '^on.*' },
13
+ actions: { argTypesRegex: "^on.*" },
14
14
  docs: {
15
15
  description: {
16
- component: 'Breadcrumb description here...',
16
+ component: "Breadcrumb description here...",
17
17
  },
18
18
  },
19
19
  },
20
20
  args: {
21
- children: 'Link',
21
+ children: "Link",
22
22
  },
23
- } as Meta
23
+ } as Meta;
24
24
 
25
- export default meta
26
- type Story = StoryObj<typeof Breadcrumb>
25
+ export default meta;
26
+ type Story = StoryObj<typeof Breadcrumb>;
27
27
 
28
28
  export const BreadcrumbComponent: Story = {
29
29
  args: {},
30
- }
30
+ };
31
31
 
32
32
  export const CustomURL: Story = {
33
33
  args: {
34
34
  routes: [
35
35
  {
36
- name: 'Products',
37
- url: '/products',
38
- path: 'product',
36
+ name: "Products",
37
+ url: "/products",
38
+ path: "product",
39
39
  },
40
40
  {
41
- name: 'Shirts',
42
- url: '/products/shirts',
43
- path: 'shirts',
41
+ name: "Shirts",
42
+ url: "/products/shirts",
43
+ path: "shirts",
44
44
  },
45
45
  {
46
- name: 'Pants',
47
- url: '/products/pants',
48
- path: 'pants',
46
+ name: "Pants",
47
+ url: "/products/pants",
48
+ path: "pants",
49
49
  },
50
50
  ],
51
- currentRoute: '/product/men/shirts/size-22',
51
+ currentRoute: "/product/men/shirts/size-22",
52
52
  },
53
- } as Story
53
+ } as Story;
54
54
 
55
55
  export const AstroBreadcrumbs: Story = {
56
56
  args: {
57
57
  ...CustomURL.args,
58
- currentRoute: '/about',
58
+ currentRoute: "/about",
59
59
  },
60
- } as Story
60
+ } as Story;
61
61
 
62
62
  export const EncodedBreadcrumbs: Story = {
63
63
  args: {
64
64
  routes: [
65
65
  {
66
- name: 'Home',
67
- path: '/',
66
+ name: "Home",
67
+ path: "#",
68
68
  },
69
69
  {
70
- name: 'Products',
71
- path: '/products',
70
+ name: "Products",
71
+ path: "/products",
72
72
  },
73
73
  {
74
- name: 'Shirts',
75
- path: '/products/shirts',
74
+ name: "Shirts",
75
+ path: "/products/shirts",
76
76
  },
77
77
  ],
78
- currentRoute: '/products/learning%20in%20public',
79
-
78
+ currentRoute: "/products/learning%20in%20public",
80
79
  },
81
-
82
- } as Story
80
+ } as Story;
83
81
 
84
82
  export const TruncateName: Story = {
85
83
  args: {
86
84
  ...CustomURL.args,
87
- currentRoute: '/products/AveryLongNameTruncate',
85
+ currentRoute: "/products/AveryLongNameTruncate",
88
86
  },
89
- } as Story
87
+ } as Story;
90
88
 
91
- export const ClickHomeLink: Story = {
89
+ export const BreadCrumbInteractions: Story = {
92
90
  args: {
93
91
  ...CustomURL.args,
94
- currentRoute: '/products/shirts',
92
+ currentRoute: "/products/shirts",
95
93
  startRouteUrl: "#",
96
94
  linkProps: {
97
95
  onClick: linkClicked,
98
96
  },
99
97
  },
100
-
101
98
  play: async ({ canvasElement }) => {
102
- const canvas = within(canvasElement)
103
- const homeLink = canvas.getByRole('link', { name: 'Home' })
104
- expect(homeLink).toHaveAttribute('href', '#')
105
- // await userEvent.click(homeLink)
106
- // expect(linkClicked).toHaveBeenCalled()
99
+ const canvas = within(canvasElement);
100
+ const homeLink = canvas.getByRole("link", { name: "Home" });
101
+ expect(homeLink).toHaveAttribute("href", "#");
107
102
  },
108
- } as Story
103
+ } as Story;
@@ -1,6 +1,7 @@
1
1
  button {
2
- --btn-sm: calc(12rem / 16);
3
- --btn-md: calc(16rem / 16);
2
+ --btn-xs: 0.6rem;
3
+ --btn-sm: 0.7rem;
4
+ --btn-md: 0.85rem;
4
5
  --btn-lg: calc(21rem / 16);
5
6
  --btn-pill: 100rem;
6
7
  --btn-height: 2.5rem;
@@ -28,20 +29,23 @@ button {
28
29
  background-color: var(--btn-bg, var(--btn));
29
30
  outline: none;
30
31
  width: var(--btn-width);
32
+ display: inline-flex;
33
+ align-items: center;
34
+ line-height: 0cap;
31
35
 
32
36
  &[type] {
33
37
  background-color: var(--btn-bg, var(--neutral-300));
34
38
  --btn-bdr: solid var(--btn-sg);
35
39
  }
36
40
 
37
- &[type='submit'],
38
- &[style*='submit'] {
41
+ &[type="submit"],
42
+ &[style*="submit"] {
39
43
  --btn-bg: var(--primary-500, royal-blue);
40
44
  --btn-color: white;
41
45
  }
42
46
 
43
47
  &[disabled],
44
- &[aria-disabled='true'] {
48
+ &[aria-disabled="true"] {
45
49
  cursor: var(--btn-cursor, not-allowed);
46
50
  // opacity: var(--btn-opacity, 0.5);
47
51
 
@@ -60,44 +64,66 @@ button {
60
64
  transform: scale(0.95) var(--line-style, solid);
61
65
  outline-offset: var(--line-offset, 1px);
62
66
 
63
- &[aria-disabled='true'] {
67
+ &[aria-disabled="true"] {
64
68
  transform: none;
65
69
  opacity: var(--btn-opacity, 0.5);
66
70
  }
67
71
  }
68
72
 
69
- &[type='reset'] {
73
+ &[type="reset"] {
70
74
  --btn-bg: transparent;
71
75
  --btn-color: gray;
72
76
  --btn-bdr: gray thin solid;
73
77
  }
74
78
 
75
- &[type='submit'] {
79
+ &[type="submit"] {
76
80
  --btn-bg: var(--primary-700, blue);
77
81
  --btn-cl: #fff;
78
82
  --btn-color: rgb(231, 231, 231);
79
83
  --btn-border: none;
80
84
  }
81
85
 
82
- &[data-fp-btn~='pill'],
83
- &[data-btn~='pill'],
84
- &[data-style~='pill'] {
86
+ &[data-fp-btn~="pill"],
87
+ &[data-btn~="pill"],
88
+ &[data-style~="pill"] {
85
89
  border-radius: var(--btn-pill, 100rem);
86
90
  }
87
91
 
88
- &[data-btn~='sm'] {
92
+ &[data-btn~="xs"] {
93
+ padding-inline: var(--btn-xs);
94
+ --btn-fs: var(--btn-xs);
95
+ --btn-height: 1.5rem;
96
+ text-transform: uppercase;
97
+ }
98
+
99
+ &[data-btn~="sm"] {
89
100
  --btn-fs: var(--btn-sm);
101
+ --btn-height: 1.75rem;
90
102
  }
91
103
 
92
- &[data-btn~='md'] {
104
+ &[data-btn~="md"] {
93
105
  --btn-fs: var(--btn-md);
106
+ --btn-height: 2rem;
94
107
  }
95
108
 
96
- &[data-btn~='lg'] {
109
+ &[data-btn~="lg"] {
97
110
  --btn-fs: var(--btn-lg);
111
+ --btn-height: 2.5rem;
112
+ }
113
+
114
+ &[data-btn~="icon"] {
115
+ padding: unset;
116
+ height: unset;
117
+ --btn-bg: transparent;
118
+ min-width: 1.5rem;
119
+ min-height: 1.5rem;
120
+ text-align: center;
121
+ display: inline-flex;
122
+ align-items: center;
123
+ justify-content: center;
98
124
  }
99
125
 
100
- &[data-btn~='text'] {
126
+ &[data-btn~="text"] {
101
127
  --btn-bg: transparent;
102
128
  --btn-cl: currentColor;
103
129
  --btn-bdr: none;
@@ -9,12 +9,13 @@ const buttonClicked = fn();
9
9
  const meta = {
10
10
  title: "FP.React Components/Buttons",
11
11
  component: Button,
12
+ tags: ["rc"],
12
13
  args: {
13
14
  children: "Click me",
14
15
  onClick: buttonClicked,
15
16
  },
16
17
  parameters: {
17
- actions: { argTypesRegex: '^on.*' },
18
+ actions: { argTypesRegex: "^on.*" },
18
19
  },
19
20
  } as Meta;
20
21
 
@@ -52,6 +53,12 @@ export const ButtonComponent: Story = {
52
53
  },
53
54
  } as Story;
54
55
 
56
+ export const Xsmall: Story = {
57
+ args: {
58
+ "data-btn": "xs",
59
+ },
60
+ } as Story;
61
+
55
62
  export const Small: Story = {
56
63
  args: {
57
64
  "data-btn": "sm",
@@ -1,86 +1,86 @@
1
- import React from 'react'
2
- import { render, screen } from '@testing-library/react'
3
- import { Button } from './button'
4
- import user from '@testing-library/user-event'
5
- import jest from 'jest-mock'
6
- import { userEvent } from '@storybook/test'
1
+ import React from "react";
2
+ import { render, screen } from "@testing-library/react";
3
+ import { Button } from "./button";
4
+ // import user from '@testing-library/user-event'
5
+ import jest from "jest-mock";
6
+ import { userEvent } from "@storybook/test";
7
7
 
8
- describe('Button', () => {
9
- it('renders a button element with the correct label', () => {
10
- render(<Button type="button">Click me</Button>)
11
- const button = screen.getByText('Click me')
12
- expect(button.tagName).toBe('BUTTON')
13
- screen.logTestingPlaygroundURL()
14
- })
8
+ describe("Button", () => {
9
+ it("renders a button element with the correct label", () => {
10
+ render(<Button type="button">Click me</Button>);
11
+ const button = screen.getByText("Click me");
12
+ expect(button.tagName).toBe("BUTTON");
13
+ screen.logTestingPlaygroundURL();
14
+ });
15
15
 
16
16
  it('has the type attribute set to "button" by default', () => {
17
- render(<Button type="button">Click me</Button>)
18
- const button = screen.getByText('Click me')
19
- expect(button).toHaveAttribute('type', 'button')
20
- })
17
+ render(<Button type="button">Click me</Button>);
18
+ const button = screen.getByText("Click me");
19
+ expect(button).toHaveAttribute("type", "button");
20
+ });
21
21
 
22
- it('calls the onClick handler when clicked', async () => {
23
- const handleClick = jest.fn()
24
- const handlePointerEvents = jest.fn()
22
+ it("calls the onClick handler when clicked", async () => {
23
+ const handleClick = jest.fn();
24
+ const handlePointerEvents = jest.fn();
25
25
  render(
26
26
  <Button type="button" onClick={handleClick}>
27
27
  Click me
28
- </Button>,
29
- )
30
- const button = screen.getByText('Click me')
31
- await userEvent.click(button)
32
- expect(handleClick).toHaveBeenCalledTimes(1)
33
- expect(handlePointerEvents).toHaveBeenCalledTimes(0)
34
- })
28
+ </Button>
29
+ );
30
+ const button = screen.getByText("Click me");
31
+ await userEvent.click(button);
32
+ expect(handleClick).toHaveBeenCalledTimes(1);
33
+ expect(handlePointerEvents).toHaveBeenCalledTimes(0);
34
+ });
35
35
 
36
- it('applies custom styles when provided', () => {
36
+ it("applies custom styles when provided", () => {
37
37
  render(
38
- <Button type="button" styles={{ backgroundColor: 'red' }}>
38
+ <Button type="button" styles={{ backgroundColor: "red" }}>
39
39
  Click me
40
- </Button>,
41
- )
42
- const button = screen.getByRole('button')
43
- expect(button).toHaveAttribute('style')
44
- })
40
+ </Button>
41
+ );
42
+ const button = screen.getByRole("button");
43
+ expect(button).toHaveAttribute("style");
44
+ });
45
45
 
46
- it('calls the onPointerDown handler when pointer is down', async () => {
47
- const handlePointerDown = jest.fn()
46
+ it("calls the onPointerDown handler when pointer is down", async () => {
47
+ const handlePointerDown = jest.fn();
48
48
  render(
49
49
  <Button type="button" onPointerDown={handlePointerDown}>
50
50
  Click me
51
- </Button>,
52
- )
53
- const button = screen.getByText('Click me')
54
- await userEvent.click(button)
55
- expect(handlePointerDown).toHaveBeenCalledTimes(1)
56
- })
51
+ </Button>
52
+ );
53
+ const button = screen.getByText("Click me");
54
+ await userEvent.click(button);
55
+ expect(handlePointerDown).toHaveBeenCalledTimes(1);
56
+ });
57
57
 
58
- it('calls the onPointerOver handler when pointer is over', async () => {
59
- const handlePointerOver = jest.fn()
58
+ it("calls the onPointerOver handler when pointer is over", async () => {
59
+ const handlePointerOver = jest.fn();
60
60
  render(
61
61
  <Button type="button" onPointerOver={handlePointerOver}>
62
62
  Click me
63
- </Button>,
64
- )
65
- const button = screen.getByText('Click me')
66
- await userEvent.hover(button)
67
- expect(handlePointerOver).toHaveBeenCalledTimes(1)
68
- })
63
+ </Button>
64
+ );
65
+ const button = screen.getByText("Click me");
66
+ await userEvent.hover(button);
67
+ expect(handlePointerOver).toHaveBeenCalledTimes(1);
68
+ });
69
69
 
70
- it('calls the onPointerLeave handler when pointer leaves', async () => {
71
- const handlePointerEvents = jest.fn()
70
+ it("calls the onPointerLeave handler when pointer leaves", async () => {
71
+ const handlePointerEvents = jest.fn();
72
72
  render(
73
73
  <Button type="button" onPointerLeave={handlePointerEvents}>
74
74
  Click me
75
- </Button>,
76
- )
77
- const button = screen.getByText('Click me')
78
- await userEvent.unhover(button)
79
- expect(handlePointerEvents).toHaveBeenCalledTimes(1)
80
- })
75
+ </Button>
76
+ );
77
+ const button = screen.getByText("Click me");
78
+ await userEvent.unhover(button);
79
+ expect(handlePointerEvents).toHaveBeenCalledTimes(1);
80
+ });
81
81
 
82
- it('it is disabled when disabled is true', () => {
83
- const handleClick = jest.fn()
82
+ it("it is disabled when disabled is true", () => {
83
+ const handleClick = jest.fn();
84
84
  render(
85
85
  <Button
86
86
  type="button"
@@ -90,15 +90,15 @@ describe('Button', () => {
90
90
  onPointerLeave={handleClick}
91
91
  >
92
92
  Click me
93
- </Button>,
94
- )
95
- const button = screen.getByText('Click me')
96
- expect(button).not.toBeDisabled()
97
- userEvent.click(button)
98
- expect(handleClick).toHaveBeenCalledTimes(0)
99
- userEvent.hover(button)
100
- expect(handleClick).toHaveBeenCalledTimes(0)
101
- userEvent.unhover(button)
102
- expect(handleClick).toHaveBeenCalledTimes(0)
103
- })
104
- })
93
+ </Button>
94
+ );
95
+ const button = screen.getByText("Click me");
96
+ expect(button).not.toBeDisabled();
97
+ userEvent.click(button);
98
+ expect(handleClick).toHaveBeenCalledTimes(0);
99
+ userEvent.hover(button);
100
+ expect(handleClick).toHaveBeenCalledTimes(0);
101
+ userEvent.unhover(button);
102
+ expect(handleClick).toHaveBeenCalledTimes(0);
103
+ });
104
+ });
@@ -1,36 +1,36 @@
1
- import { StoryObj, Meta } from '@storybook/react'
2
- import { within, userEvent, screen } from '@storybook/test'
1
+ import { StoryObj, Meta } from "@storybook/react";
2
+ // import { within, userEvent, screen } from "@storybook/test";
3
3
 
4
-
5
- import Card from './card'
4
+ import Card from "./card";
6
5
  // import './card.scss'
7
6
 
8
7
  const content =
9
- 'Enim aliquip excepteur veniam esse culpa. Et exercitation incididunt occaecat incididunt proident consectetur. Voluptate elit reprehenderit nulla reprehenderit excepteur tempor adipisicing officia eiusmod est id aute. Nisi do et nulla fugiat enim id pariatur ex. Culpa aliquip excepteur velit fugiat qui magna deserunt adipisicing dolore quis. Esse proident qui consectetur Lorem id fugiat elit amet proident enim deserunt dolore sit.'
8
+ "Enim aliquip excepteur veniam esse culpa. Et exercitation incididunt occaecat incididunt proident consectetur. Voluptate elit reprehenderit nulla reprehenderit excepteur tempor adipisicing officia eiusmod est id aute. Nisi do et nulla fugiat enim id pariatur ex. Culpa aliquip excepteur velit fugiat qui magna deserunt adipisicing dolore quis. Esse proident qui consectetur Lorem id fugiat elit amet proident enim deserunt dolore sit.";
10
9
 
11
10
  const meta: Meta<typeof Card> = {
12
- title: 'FP.REACT Components/Card',
11
+ title: "FP.REACT Components/Card",
12
+ tags: ["rc"],
13
13
  component: Card,
14
14
  args: {
15
15
  children: <p>{content}</p>,
16
16
  },
17
- } as Story
17
+ } as Story;
18
18
 
19
- export default meta
20
- type Story = StoryObj<typeof Card>
19
+ export default meta;
20
+ type Story = StoryObj<typeof Card>;
21
21
 
22
22
  export const CardComponent: Story = {
23
23
  args: {},
24
- }
24
+ };
25
25
 
26
26
  export const Multiple: Story = {
27
27
  args: {
28
28
  styles: {
29
- '--theme': 'warm',
29
+ "--theme": "warm",
30
30
  },
31
31
  },
32
32
  render: (args) => (
33
- <div style={{ display: 'flex', gap: '1rem', flexDirection: 'column' }}>
33
+ <div style={{ display: "flex", gap: "1rem", flexDirection: "column" }}>
34
34
  <Card {...args}>
35
35
  <p>
36
36
  Proident et amet aliqua excepteur sunt qui deserunt commodo tempor
@@ -57,7 +57,7 @@ export const Multiple: Story = {
57
57
  </Card>
58
58
  </div>
59
59
  ),
60
- } as Story
60
+ } as Story;
61
61
 
62
62
  export const CardWithTitle: Story = {
63
63
  args: {},
@@ -73,7 +73,7 @@ export const CardWithTitle: Story = {
73
73
  </Card.Content>
74
74
  </Card>
75
75
  ),
76
- } as Story
76
+ } as Story;
77
77
 
78
78
  export const FlexibleContent: Story = {
79
79
  args: {
@@ -144,4 +144,4 @@ export const FlexibleContent: Story = {
144
144
  </Card>
145
145
  </div>
146
146
  ),
147
- } as Story
147
+ } as Story;