@hyphen/hyphen-components 2.19.0 → 2.19.2

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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hyphen/hyphen-components",
3
- "version": "2.19.0",
3
+ "version": "2.19.2",
4
4
  "license": "MIT",
5
5
  "author": {
6
6
  "name": "@hyphen"
@@ -1,11 +1,12 @@
1
1
  import { Drawer, DrawerPlacementType } from './Drawer';
2
- import type { Meta } from '@storybook/react';
2
+ import type { Meta, StoryObj } from '@storybook/react';
3
3
  import React, { MutableRefObject, useEffect, useRef, useState } from 'react';
4
4
  import { useOpenClose } from '../../hooks';
5
5
  import { Button } from '../Button/Button';
6
6
  import { Box } from '../Box/Box';
7
7
  import { RadioGroup } from '../RadioGroup/RadioGroup';
8
8
  import { WidthSize } from '../../types';
9
+ import { userEvent, within, expect } from '@storybook/test';
9
10
 
10
11
  const meta: Meta<typeof Drawer> = {
11
12
  title: 'Components/Drawer',
@@ -13,6 +14,7 @@ const meta: Meta<typeof Drawer> = {
13
14
  };
14
15
 
15
16
  export default meta;
17
+ type Story = StoryObj<typeof Drawer>;
16
18
 
17
19
  export const BasicUsage = () => {
18
20
  const {
@@ -20,8 +22,11 @@ export const BasicUsage = () => {
20
22
  handleOpen: openDrawer,
21
23
  handleClose: closeDrawer,
22
24
  } = useOpenClose();
25
+
26
+ const ref = useRef(null);
27
+
23
28
  return (
24
- <>
29
+ <div id="drawerContainer" ref={ref} style={{ height: '240px' }}>
25
30
  <Button variant="primary" onClick={openDrawer}>
26
31
  Open Drawer
27
32
  </Button>
@@ -30,17 +35,31 @@ export const BasicUsage = () => {
30
35
  title="Drawer Title"
31
36
  onDismiss={closeDrawer}
32
37
  ariaLabel="drawer component example"
38
+ containerRef={ref}
33
39
  >
34
- <Box padding="2xl" display="block" childGap="md">
35
- <Box>Drawer content&hellip;</Box>
36
- <Box>Drawer content&hellip;</Box>
37
- <Box>Drawer content&hellip;</Box>
40
+ <Box
41
+ padding={{ base: '0 2xl 2xl 2xl', tablet: '0 4xl 4xl 4xl' }}
42
+ display="block"
43
+ childGap="md"
44
+ >
45
+ <Box>Drawer content</Box>
38
46
  </Box>
39
47
  </Drawer>
40
- </>
48
+ </div>
41
49
  );
42
50
  };
43
51
 
52
+ export const OpenDrawer: Story = {
53
+ play: async ({ canvasElement, mount }) => {
54
+ await mount(<BasicUsage />);
55
+ const canvas = within(canvasElement);
56
+
57
+ await userEvent.click(canvas.getByText('Open Drawer'));
58
+
59
+ await expect(canvas.getByText('Drawer content')).toBeInTheDocument();
60
+ },
61
+ };
62
+
44
63
  export const Placement = () => {
45
64
  const {
46
65
  isOpen: isDrawerOpen,
@@ -90,7 +109,11 @@ export const Placement = () => {
90
109
  placement={placement as DrawerPlacementType}
91
110
  ariaLabel="drawer component example"
92
111
  >
93
- <Box padding="2xl" display="block" childGap="md">
112
+ <Box
113
+ padding={{ base: '0 2xl 2xl 2xl', tablet: '0 4xl 4xl 4xl' }}
114
+ display="block"
115
+ childGap="md"
116
+ >
94
117
  <Box as="p">drawer content</Box>
95
118
  <Box as="p">drawer content</Box>
96
119
  <Box as="p">drawer content</Box>
@@ -127,7 +150,11 @@ export const DrawerHeader = () => {
127
150
  onDismiss={closeDrawer}
128
151
  title="Drawer Title"
129
152
  >
130
- <Box padding="2xl" display="block" childGap="md">
153
+ <Box
154
+ padding={{ base: '0 2xl 2xl 2xl', tablet: '0 4xl 4xl 4xl' }}
155
+ display="block"
156
+ childGap="md"
157
+ >
131
158
  {drawerContent}
132
159
  </Box>
133
160
  </Drawer>
@@ -156,7 +183,11 @@ export const TitleAndCloseButton = () => {
156
183
  onDismiss={closeDrawer}
157
184
  title="Drawer Title"
158
185
  >
159
- <Box padding="2xl" display="block" childGap="md">
186
+ <Box
187
+ padding={{ base: '0 2xl 2xl 2xl', tablet: '0 4xl 4xl 4xl' }}
188
+ display="block"
189
+ childGap="md"
190
+ >
160
191
  {drawerContent}
161
192
  </Box>
162
193
  </Drawer>
@@ -185,7 +216,11 @@ export const CloseButtonOnly = () => {
185
216
  onDismiss={closeDrawer}
186
217
  closeButton
187
218
  >
188
- <Box padding="2xl" display="block" childGap="md">
219
+ <Box
220
+ padding={{ base: '0 2xl 2xl 2xl', tablet: '0 4xl 4xl 4xl' }}
221
+ display="block"
222
+ childGap="md"
223
+ >
189
224
  {drawerContent}
190
225
  </Box>
191
226
  </Drawer>
@@ -226,7 +261,11 @@ export const Width = () => {
226
261
  closeButton
227
262
  ariaLabel="drawer component example"
228
263
  >
229
- <Box padding="2xl" display="block" childGap="md">
264
+ <Box
265
+ padding={{ base: '0 2xl 2xl 2xl', tablet: '0 4xl 4xl 4xl' }}
266
+ display="block"
267
+ childGap="md"
268
+ >
230
269
  <Box>drawer content</Box>
231
270
  </Box>
232
271
  </Drawer>
@@ -252,8 +291,8 @@ export const Height = () => {
252
291
  closeButton
253
292
  ariaLabel="drawer component example"
254
293
  >
255
- <Box padding="lg" height="3xl" display="block" childGap="md">
256
- <Box>3xl Height</Box>
294
+ <Box padding="lg" height="4xl" display="block" childGap="md">
295
+ <Box>4xl Height</Box>
257
296
  </Box>
258
297
  </Drawer>
259
298
  </>
@@ -295,7 +334,11 @@ export const HiddenOverlay = () => {
295
334
  ariaLabel="drawer component example"
296
335
  hideOverlay
297
336
  >
298
- <Box padding="2xl" display="block" childGap="md">
337
+ <Box
338
+ padding={{ base: '2xl', tablet: '4xl' }}
339
+ display="block"
340
+ childGap="md"
341
+ >
299
342
  <Button
300
343
  ref={closeBtnRef as MutableRefObject<HTMLButtonElement>}
301
344
  onClick={closeDrawer}
@@ -329,7 +372,11 @@ export const InitialFocusRef = () => {
329
372
  title="initialFocusRef"
330
373
  ariaLabel="drawer component example"
331
374
  >
332
- <Box padding="2xl" display="block" childGap="md">
375
+ <Box
376
+ padding={{ base: '0 2xl 2xl 2xl', tablet: '0 4xl 4xl 4xl' }}
377
+ display="block"
378
+ childGap="md"
379
+ >
333
380
  <Box>drawer content</Box>
334
381
  <Button variant="primary" ref={ref} onClick={closeDrawer}>
335
382
  I receive focus
@@ -370,7 +417,10 @@ export const ContainedDrawer = () => {
370
417
  title="containerRef"
371
418
  ariaLabel="drawer component example"
372
419
  >
373
- <Box padding="lg" as="p">
420
+ <Box
421
+ padding={{ base: '0 2xl 2xl 2xl', tablet: '0 4xl 4xl 4xl' }}
422
+ as="p"
423
+ >
374
424
  This drawer is rendered inside it&apos;s containing div, rather than
375
425
  the document.body
376
426
  </Box>
@@ -176,7 +176,7 @@ export const Drawer: React.FC<DrawerProps> = forwardRef<
176
176
  direction="row"
177
177
  justifyContent="space-between"
178
178
  alignItems="center"
179
- padding="2xl"
179
+ padding={{ base: '2xl', tablet: '4xl' }}
180
180
  >
181
181
  <Box className={styles.title} fontWeight="bold">
182
182
  {title}
@@ -20,7 +20,7 @@
20
20
  margin-top: 1px;
21
21
  cursor: default;
22
22
  width: 100%;
23
- border-collapse: separate;
23
+ border-collapse: collapse;
24
24
  border-spacing: 0;
25
25
  white-space: normal;
26
26
 
@@ -56,7 +56,6 @@ export interface TableBodyProps {
56
56
 
57
57
  export const TableBody: FC<TableBodyProps> = ({
58
58
  columns,
59
- rowKey,
60
59
  rows,
61
60
  align = 'left',
62
61
  className = '',
@@ -84,7 +83,7 @@ export const TableBody: FC<TableBodyProps> = ({
84
83
  row={row}
85
84
  rowIndex={rowIndex}
86
85
  align={align}
87
- key={row[rowKey as any]}
86
+ key={rowIndex}
88
87
  emptyCellPlaceholder={emptyCellPlaceholder}
89
88
  truncateOverflow={truncateOverflow}
90
89
  isBorderless={isBorderless}
@@ -1,9 +1,6 @@
1
1
  .table-cell {
2
- border-color: var(--color-border-default);
3
- border-bottom-style: solid;
4
- border-width: 0 0 var(--size-border-width-sm) 0;
5
2
  color: var(--color-font-base);
6
- padding: var(--size-spacing-md) var(--size-spacing-lg);
3
+ padding: var(--size-spacing-md) var(--size-spacing-2xl);
7
4
 
8
5
  &.borderless {
9
6
  border-width: 0;
@@ -3,15 +3,11 @@
3
3
  text-transform: uppercase;
4
4
  letter-spacing: 0.05em;
5
5
  white-space: nowrap;
6
- border-color: var(--color-border-default);
7
- border-bottom-style: solid;
8
- border-width: 0 0 var(--size-border-width-sm) 0;
9
6
  background-color: var(--color-background-primary);
10
7
  color: var(--color-font-secondary);
11
8
  font-size: var(--size-font-size-sm);
12
9
  font-weight: var(--size-font-weight-bold);
13
- padding: var(--size-spacing-md)
14
- var(--size-spacing-lg);
10
+ padding: var(--size-spacing-md) var(--size-spacing-2xl);
15
11
 
16
12
  &.sortable {
17
13
  cursor: pointer;
@@ -1,5 +1,17 @@
1
1
  .table-row {
2
+ border-color: var(--color-border-subtle);
3
+ border-bottom-style: solid;
4
+ border-bottom-width: var(--size-border-width-sm);
5
+
6
+ &:last-of-type {
7
+ border-bottom-width: 0;
8
+ }
9
+
2
10
  &.hoverable {
3
11
  background-color: var(--table-row-hover-background);
4
12
  }
5
13
  }
14
+
15
+ thead > .table-row {
16
+ border-bottom-width: var(--size-border-width-sm) !important;
17
+ }