@hyphen/hyphen-components 2.25.2 → 3.0.0

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.25.2",
3
+ "version": "3.0.0",
4
4
  "license": "MIT",
5
5
  "author": {
6
6
  "name": "@hyphen"
@@ -9,12 +9,14 @@ import * as Stories from './Drawer.stories';
9
9
 
10
10
  A Drawer is a panel that slides in from one edge of the viewport and overlays content on top of the page. It contains information or actions without leaving the context of the original page.
11
11
 
12
- <Canvas withSource="open" of={Stories.BasicUsage} />
12
+ <Canvas withSource="open" of={Stories.UncontrolledWithProvider} />
13
13
 
14
14
  ## Usage Guidelines
15
15
 
16
16
  - Use the drawer as way to achieve progressive disclosure, to reveal relevant information at the appropriate time.
17
- - The Drawer visibility is controlled via the `isOpen` prop, and is hidden by default. To handle closing the Drawer, provide an `onDismiss` callback that will be called when the user clicks the Overlay or Esc keyboard key.
17
+ - The Drawer can be both uncontrolled and controlled. The uncontrolled Drawer is managed by the component itself, while the controlled Drawer is managed by the consuming component.
18
+ - For an uncontrolled Drawer, use the `DrawerProvider` to manage the Drawer's visibility. You can set a default `defaultIsOpen` value to determine if the Drawer is open by default.
19
+ - For a controlled Drawer, omit the `DrawerProvider` as visibility is controlled via the `isOpen` prop. To handle closing the Drawer, provide an `onDismiss` callback that will be called when the user clicks the Overlay or Esc keyboard key.
18
20
  - When a Drawer is open, the main body is scroll-locked by default.
19
21
  - Avoid nesting Drawers to prevent usability issues.
20
22
  - The button that triggers the drawer opening should be in close proximity to the Drawer itself.
@@ -36,10 +38,11 @@ Drawers are good for short pieces of content that are related to the main screen
36
38
 
37
39
  ## Accessibility
38
40
 
39
- - Use the `ariaLabel` or `ariaLabelledBy` props to properly label a drawer to provide context for users with assistive technology such as screen readers. If a drawer is announced to the user without a label, it can be confusing and difficult to navigate.
40
- - When the Drawer is opened, focus is trapped inside the Drawer.
41
+ - Ensure the `ariaLabel` or `ariaLabelledBy` props are provided for accessibility.
42
+ - The drawer traps focus within its content when open, ensuring keyboard navigation is contained.
41
43
  - The 'Esc' key will close the Drawer.
42
44
  - After the drawer closes, focus is returned to the element that triggered it.
45
+ - The `DrawerCloseButton` component provides a close button with appropriate aria attributes.
43
46
 
44
47
  ## Props
45
48
 
@@ -51,20 +54,6 @@ The Drawer can appear from the right (default), left, top, or bottom of the scre
51
54
 
52
55
  <Canvas withSource="open" of={Stories.Placement} />
53
56
 
54
- ## Drawer Header
55
-
56
- A header will be added to the drawer content if `title` is defined, or `closeButton` is `true`. If the content of the drawer is taller than the drawer height, then the content will scroll while the header remains fixed to the top.
57
-
58
- <Canvas withSource="open" of={Stories.DrawerHeader} />
59
-
60
- ## Title and Close Button
61
-
62
- <Canvas withSource="open" of={Stories.TitleAndCloseButton} />
63
-
64
- ## Close Button Only
65
-
66
- <Canvas withSource="open" of={Stories.CloseButtonOnly} />
67
-
68
57
  ## Width
69
58
 
70
59
  Set the width of a Drawer to specific value for a `left` or `right` placement via `width`. The Drawer height will be 100% of the viewport, or if `containerRef` is used, 100% of the container.
@@ -73,11 +62,6 @@ When `placement` is set to `top` or `bottom`, the `width` prop is ignored and th
73
62
 
74
63
  <Canvas withSource="open" of={Stories.Width} />
75
64
 
76
- ## Height
77
-
78
- The height of Drawers with a `top` or `bottom` placement is determined by Drawer's contents. The width will be set to 100%.
79
-
80
- <Canvas withSource="open" of={Stories.Height} />
81
65
 
82
66
  ## Hidden Overlay
83
67
 
@@ -92,6 +76,7 @@ In cases where content in the drawer is supplemental to content on the main area
92
76
 
93
77
  <Canvas withSource="open" of={Stories.HiddenOverlay} />
94
78
 
79
+
95
80
  ## Initial Focus Ref
96
81
 
97
82
  By default the first focusable element will receive focus when the drawer opens, but you can provide a ref to focus instead.
@@ -114,4 +99,4 @@ Render the Drawer within a containing div using `containerRef`.
114
99
  variant="info"
115
100
  />
116
101
 
117
- <Canvas withSource="open" of={Stories.ContainedDrawer} />
102
+ <Canvas withSource="open" of={Stories.ContainedDrawer} />
@@ -45,10 +45,11 @@
45
45
  position: absolute;
46
46
  box-shadow: var(--drawer-box-shadow, var(--size-box-shadow-xl));
47
47
  z-index: var(--size-z-index-drawer);
48
+ overflow: auto;
48
49
 
49
50
  &.left {
50
51
  left: 0;
51
- width: var(--w, 80vw);
52
+ width: var(--drawer-width, 80vw);
52
53
  height: 100%;
53
54
 
54
55
  :global {
@@ -58,7 +59,7 @@
58
59
 
59
60
  &.right {
60
61
  right: 0;
61
- width: var(--w, 80vw);
62
+ width: var(--drawer-width, 80vw);
62
63
  height: 100%;
63
64
 
64
65
  :global {
@@ -89,7 +90,7 @@
89
90
  @media (min-width: $size-breakpoint-tablet) {
90
91
  &.right,
91
92
  &.left {
92
- width: var(--w, var(--size-dimension-8xl));
93
+ width: var(--drawer-width, var(--size-dimension-8xl));
93
94
  }
94
95
  }
95
96
  }