@lumx/react 3.14.0 → 3.14.1-alpha.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/index.d.ts +1 -1
- package/index.js +13 -14
- package/index.js.map +1 -1
- package/package.json +3 -3
- package/src/components/button/Button.stories.tsx +2 -0
- package/src/components/button/Button.test.tsx +6 -0
- package/src/components/button/ButtonRoot.tsx +4 -2
- package/src/components/thumbnail/useFocusPointStyle.tsx +6 -9
package/package.json
CHANGED
|
@@ -6,8 +6,8 @@
|
|
|
6
6
|
"url": "https://github.com/lumapps/design-system/issues"
|
|
7
7
|
},
|
|
8
8
|
"dependencies": {
|
|
9
|
-
"@lumx/core": "^3.14.0",
|
|
10
|
-
"@lumx/icons": "^3.14.0",
|
|
9
|
+
"@lumx/core": "^3.14.1-alpha.0",
|
|
10
|
+
"@lumx/icons": "^3.14.1-alpha.0",
|
|
11
11
|
"@popperjs/core": "^2.5.4",
|
|
12
12
|
"body-scroll-lock": "^3.1.5",
|
|
13
13
|
"classnames": "^2.3.2",
|
|
@@ -110,5 +110,5 @@
|
|
|
110
110
|
"build:storybook": "storybook build"
|
|
111
111
|
},
|
|
112
112
|
"sideEffects": false,
|
|
113
|
-
"version": "3.14.0"
|
|
113
|
+
"version": "3.14.1-alpha.0"
|
|
114
114
|
}
|
|
@@ -178,6 +178,7 @@ export const StateVariations = {
|
|
|
178
178
|
Active: { isActive: true },
|
|
179
179
|
Focused: { isFocused: true },
|
|
180
180
|
Disabled: { isDisabled: true },
|
|
181
|
+
AriaDisabled: { 'aria-disabled': true },
|
|
181
182
|
},
|
|
182
183
|
// Emphasis/Background
|
|
183
184
|
sections: {
|
|
@@ -212,6 +213,7 @@ export const Theming = {
|
|
|
212
213
|
Active: { isActive: true },
|
|
213
214
|
Focused: { isFocused: true },
|
|
214
215
|
Disabled: { isDisabled: true },
|
|
216
|
+
AriaDisabled: { 'aria-disabled': true },
|
|
215
217
|
},
|
|
216
218
|
rows: {
|
|
217
219
|
Default: {},
|
|
@@ -63,6 +63,12 @@ describe(`<${Button.displayName}>`, () => {
|
|
|
63
63
|
expect(buttonWrapper).toBeInTheDocument();
|
|
64
64
|
expect(button).toBe(within(buttonWrapper as any).queryByRole('button', { name: label }));
|
|
65
65
|
});
|
|
66
|
+
|
|
67
|
+
it('should prevent click when aria-disabled', () => {
|
|
68
|
+
const onClick = jest.fn();
|
|
69
|
+
const { button } = setup({ children: 'Label', 'aria-disabled': true, onClick });
|
|
70
|
+
expect(button.onclick).toBeFalsy();
|
|
71
|
+
});
|
|
66
72
|
});
|
|
67
73
|
|
|
68
74
|
// Common tests suite.
|
|
@@ -20,7 +20,7 @@ export type ButtonSize = Extract<Size, 's' | 'm'>;
|
|
|
20
20
|
|
|
21
21
|
export interface BaseButtonProps
|
|
22
22
|
extends GenericProps,
|
|
23
|
-
Pick<AriaAttributes, 'aria-expanded' | 'aria-haspopup' | 'aria-pressed' | 'aria-label'>,
|
|
23
|
+
Pick<AriaAttributes, 'aria-expanded' | 'aria-haspopup' | 'aria-pressed' | 'aria-label' | 'aria-disabled'>,
|
|
24
24
|
HasTheme {
|
|
25
25
|
/** Color variant. */
|
|
26
26
|
color?: ColorPalette;
|
|
@@ -106,6 +106,7 @@ export const ButtonRoot = forwardRef<ButtonRootProps, HTMLButtonElement | HTMLAn
|
|
|
106
106
|
hasBackground,
|
|
107
107
|
href,
|
|
108
108
|
isDisabled = disabled,
|
|
109
|
+
'aria-disabled': ariaDisabled = isDisabled,
|
|
109
110
|
isSelected,
|
|
110
111
|
isActive,
|
|
111
112
|
isFocused,
|
|
@@ -172,8 +173,9 @@ export const ButtonRoot = forwardRef<ButtonRootProps, HTMLButtonElement | HTMLAn
|
|
|
172
173
|
return (
|
|
173
174
|
<button
|
|
174
175
|
{...forwardedProps}
|
|
176
|
+
{...(ariaDisabled ? { onClick: undefined } : undefined)}
|
|
175
177
|
disabled={isDisabled}
|
|
176
|
-
aria-disabled={
|
|
178
|
+
aria-disabled={ariaDisabled}
|
|
177
179
|
aria-label={ariaLabel}
|
|
178
180
|
ref={ref as RefObject<HTMLButtonElement>}
|
|
179
181
|
className={buttonClassName}
|
|
@@ -62,21 +62,18 @@ export const useFocusPointStyle = (
|
|
|
62
62
|
);
|
|
63
63
|
|
|
64
64
|
// Compute style.
|
|
65
|
-
const
|
|
66
|
-
useEffect(() => {
|
|
65
|
+
const style: CSSProperties = useMemo(() => {
|
|
67
66
|
// Focus point is not applicable => exit early
|
|
68
67
|
if (!image || aspectRatio === AspectRatio.original || (!focusPoint?.x && !focusPoint?.y)) {
|
|
69
|
-
return;
|
|
68
|
+
return {};
|
|
70
69
|
}
|
|
71
70
|
if (!element || !imageSize) {
|
|
72
71
|
// Focus point can be computed but now right now (image size unknown).
|
|
73
|
-
|
|
74
|
-
return;
|
|
72
|
+
return { visibility: 'hidden' };
|
|
75
73
|
}
|
|
76
74
|
if (!containerSize || !imageSize.height || !imageSize.width) {
|
|
77
75
|
// Missing container or image size abort focus point compute.
|
|
78
|
-
|
|
79
|
-
return;
|
|
76
|
+
return {};
|
|
80
77
|
}
|
|
81
78
|
|
|
82
79
|
const heightScale = imageSize.height / containerSize.height;
|
|
@@ -102,8 +99,8 @@ export const useFocusPointStyle = (
|
|
|
102
99
|
});
|
|
103
100
|
|
|
104
101
|
const objectPosition = `${x}% ${y}%`;
|
|
105
|
-
|
|
106
|
-
|
|
102
|
+
|
|
103
|
+
return { objectPosition };
|
|
107
104
|
}, [aspectRatio, containerSize, element, focusPoint?.x, focusPoint?.y, image, imageSize]);
|
|
108
105
|
|
|
109
106
|
return style;
|