uikit-react-public 0.26.1 → 0.26.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.
@@ -14,6 +14,7 @@ import MenuAccordionChevron from './MenuAccordionChevron';
14
14
  import MenuAccordionItem, { MenuAccordionItemProps } from './MenuAccordionItem';
15
15
 
16
16
  export const NAME = 'ucl-uikit-menu__accordion';
17
+ const FOCUS_RING_GUTTER_PX = 6;
17
18
 
18
19
  export interface MenuAccordionProps extends Omit<
19
20
  MenuBaseItemProps,
@@ -68,9 +69,9 @@ const MenuAccordion = ({
68
69
  opacity: 0;
69
70
  pointer-events: none;
70
71
  transition:
71
- grid-template-rows 300ms ease-in,
72
- margin-top 300ms ease-in,
73
- opacity 300ms ease-in;
72
+ grid-template-rows 200ms ease-in-out,
73
+ margin-top 200ms ease-in-out,
74
+ opacity 200ms ease-in-out;
74
75
  `;
75
76
 
76
77
  const bodyExpandedStyle = css`
@@ -79,13 +80,15 @@ const MenuAccordion = ({
79
80
  opacity: 1;
80
81
  pointer-events: auto;
81
82
  transition:
82
- grid-template-rows 300ms ease-out,
83
- margin-top 300ms ease-out,
84
- opacity 300ms ease-out;
83
+ grid-template-rows 200ms ease-in-out,
84
+ margin-top 200ms ease-in-out,
85
+ opacity 200ms ease-in-out;
85
86
  `;
86
87
 
87
88
  const bodyInnerStyle = css`
88
89
  min-height: 0;
90
+ padding-top: ${FOCUS_RING_GUTTER_PX}px;
91
+ padding-bottom: ${FOCUS_RING_GUTTER_PX}px;
89
92
  overflow: hidden;
90
93
  `;
91
94
 
@@ -5,6 +5,7 @@ import MenuItemText from '../MenuItemText';
5
5
  import { useTheme } from '../../../theme';
6
6
 
7
7
  export const NAME = 'ucl-uikit-menu__accordion-item';
8
+ const FOCUS_RING_GUTTER_PX = 6;
8
9
 
9
10
  export interface MenuAccordionItemProps extends HTMLAttributes<HTMLDivElement> {
10
11
  asChild?: boolean;
@@ -21,11 +22,12 @@ const MenuAccordionItem = ({
21
22
  const [theme] = useTheme();
22
23
 
23
24
  const baseStyle = css`
24
- margin: 0;
25
- padding-left: ${theme.padding.p40};
25
+ width: calc(100% - ${FOCUS_RING_GUTTER_PX * 2}px);
26
+ margin: 0 ${FOCUS_RING_GUTTER_PX}px;
27
+ padding-left: calc(${theme.padding.p40} - ${FOCUS_RING_GUTTER_PX}px);
26
28
 
27
29
  @media screen and (min-width: ${theme.breakpoints.tablet}px) {
28
- padding: 0 ${theme.padding.p56};
30
+ padding: 0 calc(${theme.padding.p56} - ${FOCUS_RING_GUTTER_PX}px);
29
31
  }
30
32
  `;
31
33
 
@@ -113,6 +113,36 @@ describe('Menu', () => {
113
113
  expect(screen.getByText('Library')).toBeInTheDocument();
114
114
  });
115
115
 
116
+ test('accordion items allow space for focus borders', () => {
117
+ wrap(
118
+ <Menu>
119
+ <Menu.Accordion
120
+ label='Services'
121
+ defaultExpanded
122
+ >
123
+ <Menu.Accordion.Item>Library</Menu.Accordion.Item>
124
+ </Menu.Accordion>
125
+ </Menu>
126
+ );
127
+
128
+ const accordionItem = screen
129
+ .getByText('Library')
130
+ .closest('.ucl-uikit-menu__accordion-item');
131
+ const accordionContentInner = accordionItem?.parentElement;
132
+
133
+ expect(accordionItem).toHaveStyle({
134
+ marginTop: '0px',
135
+ marginLeft: '6px',
136
+ marginRight: '6px',
137
+ marginBottom: '0px',
138
+ width: 'calc(100% - 12px)',
139
+ });
140
+ expect(accordionContentInner).toHaveStyle({
141
+ paddingTop: '6px',
142
+ paddingBottom: '6px',
143
+ });
144
+ });
145
+
116
146
  test('accordion item supports asChild link content', () => {
117
147
  wrap(
118
148
  <Menu>
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "name": "uikit-react-public",
3
3
  "private": false,
4
4
  "license": "UNLICENSED",
5
- "version": "0.26.1",
5
+ "version": "0.26.3",
6
6
  "type": "module",
7
7
  "main": "dist/index.js",
8
8
  "types": "dist/index.d.ts",