@lumx/react 3.7.6-alpha.13 → 3.7.6-alpha.14
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.js +20 -7
- package/index.js.map +1 -1
- package/package.json +3 -3
- package/src/components/heading/Heading.test.tsx +3 -1
- package/src/components/heading/Heading.tsx +3 -2
- package/src/components/image-lightbox/internal/ImageSlide.tsx +1 -1
- package/src/components/thumbnail/Thumbnail.stories.tsx +4 -1
- package/src/components/thumbnail/Thumbnail.tsx +4 -4
- package/src/utils/object/isEqual.test.js +25 -0
- package/src/utils/object/isEqual.ts +11 -0
package/package.json
CHANGED
|
@@ -7,8 +7,8 @@
|
|
|
7
7
|
},
|
|
8
8
|
"dependencies": {
|
|
9
9
|
"@juggle/resize-observer": "^3.2.0",
|
|
10
|
-
"@lumx/core": "^3.7.6-alpha.
|
|
11
|
-
"@lumx/icons": "^3.7.6-alpha.
|
|
10
|
+
"@lumx/core": "^3.7.6-alpha.14",
|
|
11
|
+
"@lumx/icons": "^3.7.6-alpha.14",
|
|
12
12
|
"@popperjs/core": "^2.5.4",
|
|
13
13
|
"body-scroll-lock": "^3.1.5",
|
|
14
14
|
"classnames": "^2.3.2",
|
|
@@ -112,5 +112,5 @@
|
|
|
112
112
|
"build:storybook": "storybook build"
|
|
113
113
|
},
|
|
114
114
|
"sideEffects": false,
|
|
115
|
-
"version": "3.7.6-alpha.
|
|
115
|
+
"version": "3.7.6-alpha.14"
|
|
116
116
|
}
|
|
@@ -21,13 +21,15 @@ describe(`<${Heading.displayName}>`, () => {
|
|
|
21
21
|
const heading = screen.getByRole('heading', { level: 1, name: 'Some text' });
|
|
22
22
|
expect(heading).toBeInTheDocument();
|
|
23
23
|
expect(heading).toHaveClass(CLASSNAME);
|
|
24
|
+
expect(heading).toHaveClass('lumx-typography-display1');
|
|
24
25
|
});
|
|
25
26
|
|
|
26
|
-
it('should render with as', () => {
|
|
27
|
+
it('should render with as with the correct default typography', () => {
|
|
27
28
|
setup({ children: 'Some text', as: 'h2' });
|
|
28
29
|
const heading = screen.getByRole('heading', { level: 2, name: 'Some text' });
|
|
29
30
|
expect(heading).toBeInTheDocument();
|
|
30
31
|
expect(heading).toHaveClass(CLASSNAME);
|
|
32
|
+
expect(heading).toHaveClass('lumx-typography-headline');
|
|
31
33
|
});
|
|
32
34
|
|
|
33
35
|
it('should correctly render levels nested in HeadingLevel', () => {
|
|
@@ -40,6 +40,7 @@ export const Heading: Comp<HeadingProps> = forwardRef((props, ref) => {
|
|
|
40
40
|
const { children, as, className, ...forwardedProps } = props;
|
|
41
41
|
const { headingElement } = useHeadingLevel();
|
|
42
42
|
|
|
43
|
+
const computedHeadingElement = as || headingElement;
|
|
43
44
|
return (
|
|
44
45
|
<Text
|
|
45
46
|
ref={ref}
|
|
@@ -49,8 +50,8 @@ export const Heading: Comp<HeadingProps> = forwardRef((props, ref) => {
|
|
|
49
50
|
prefix: CLASSNAME,
|
|
50
51
|
}),
|
|
51
52
|
)}
|
|
52
|
-
as={
|
|
53
|
-
typography={DEFAULT_TYPOGRAPHY_BY_LEVEL[
|
|
53
|
+
as={computedHeadingElement}
|
|
54
|
+
typography={DEFAULT_TYPOGRAPHY_BY_LEVEL[computedHeadingElement]}
|
|
54
55
|
{...forwardedProps}
|
|
55
56
|
>
|
|
56
57
|
{children}
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
|
|
3
|
-
import isEqual from 'lodash/isEqual';
|
|
4
3
|
import { SlideshowItem, Thumbnail } from '@lumx/react';
|
|
5
4
|
import { mergeRefs } from '@lumx/react/utils/mergeRefs';
|
|
6
5
|
import { useElementSizeDependentOfWindowSize } from '@lumx/react/hooks/useElementSizeDependentOfWindowSize';
|
|
7
6
|
import { useImageSize } from '@lumx/react/hooks/useImageSize';
|
|
8
7
|
import { getPrefersReducedMotion } from '@lumx/react/utils/getPrefersReducedMotion';
|
|
8
|
+
import { isEqual } from '@lumx/react/utils/object/isEqual';
|
|
9
9
|
|
|
10
10
|
import { CLASSNAME } from '../constants';
|
|
11
11
|
import { usePointerZoom } from './usePointerZoom';
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
|
|
3
|
+
import uniqueId from 'lodash/uniqueId';
|
|
4
|
+
|
|
3
5
|
import { mdiAbTesting } from '@lumx/icons';
|
|
4
6
|
import {
|
|
5
7
|
Alignment,
|
|
@@ -22,6 +24,7 @@ import { withNestedProps } from '@lumx/react/stories/decorators/withNestedProps'
|
|
|
22
24
|
import { withCombinations } from '@lumx/react/stories/decorators/withCombinations';
|
|
23
25
|
import { withUndefined } from '@lumx/react/stories/controls/withUndefined';
|
|
24
26
|
|
|
27
|
+
|
|
25
28
|
const aligns = [Alignment.center, Alignment.left, Alignment.right];
|
|
26
29
|
const variants = [ThumbnailVariant.squared, ThumbnailVariant.rounded];
|
|
27
30
|
|
|
@@ -428,7 +431,7 @@ export const LoadingPlaceholderImage = () => {
|
|
|
428
431
|
<Thumbnail alt="Small image" imgRef={imgRef} image="https://picsum.photos/id/15/128/85" />
|
|
429
432
|
{isShown && (
|
|
430
433
|
<Thumbnail
|
|
431
|
-
image=
|
|
434
|
+
image={`https://picsum.photos/id/15/2500/1667?cacheBust${uniqueId()}`}
|
|
432
435
|
alt="Large image"
|
|
433
436
|
// Loading placeholder image
|
|
434
437
|
loadingPlaceholderImageRef={imgRef}
|
|
@@ -17,7 +17,7 @@ import { Comp, Falsy, GenericProps, HasTheme } from '@lumx/react/utils/type';
|
|
|
17
17
|
import { getRootClassName, handleBasicClasses } from '@lumx/react/utils/className';
|
|
18
18
|
|
|
19
19
|
import { mdiImageBroken } from '@lumx/icons';
|
|
20
|
-
import { mergeRefs } from '@lumx/react/utils/mergeRefs';
|
|
20
|
+
import { mergeRefs, useMergeRefs } from '@lumx/react/utils/mergeRefs';
|
|
21
21
|
import { useImageLoad } from '@lumx/react/components/thumbnail/useImageLoad';
|
|
22
22
|
import { useFocusPointStyle } from '@lumx/react/components/thumbnail/useFocusPointStyle';
|
|
23
23
|
import { FocusPoint, ThumbnailSize, ThumbnailVariant } from './types';
|
|
@@ -199,9 +199,9 @@ export const Thumbnail: Comp<ThumbnailProps> = forwardRef((props, ref) => {
|
|
|
199
199
|
>
|
|
200
200
|
<span className={`${CLASSNAME}__background`}>
|
|
201
201
|
<img
|
|
202
|
+
width={loadingPlaceholderImage?.naturalWidth}
|
|
203
|
+
height={loadingPlaceholderImage?.naturalHeight}
|
|
202
204
|
{...imgProps}
|
|
203
|
-
width={imgProps?.width || loadingPlaceholderImage?.naturalWidth}
|
|
204
|
-
height={imgProps?.height || loadingPlaceholderImage?.naturalHeight}
|
|
205
205
|
style={{
|
|
206
206
|
...imgProps?.style,
|
|
207
207
|
...imageErrorStyle,
|
|
@@ -213,7 +213,7 @@ export const Thumbnail: Comp<ThumbnailProps> = forwardRef((props, ref) => {
|
|
|
213
213
|
handleBasicClasses({
|
|
214
214
|
prefix: `${CLASSNAME}__image`,
|
|
215
215
|
isLoading,
|
|
216
|
-
hasDefinedSize: Boolean(imgProps?.height && imgProps.width),
|
|
216
|
+
hasDefinedSize: !isLoading && Boolean(imgProps?.height && imgProps.width),
|
|
217
217
|
}),
|
|
218
218
|
imgProps?.className,
|
|
219
219
|
)}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { isEqual } from './isEqual';
|
|
2
|
+
|
|
3
|
+
test(isEqual, () => {
|
|
4
|
+
expect(isEqual('', '')).toBe(true);
|
|
5
|
+
expect(isEqual(0, 0)).toBe(true);
|
|
6
|
+
expect(isEqual(Number.POSITIVE_INFINITY, Number.POSITIVE_INFINITY)).toBe(true);
|
|
7
|
+
|
|
8
|
+
expect(isEqual('', 0)).toBe(false);
|
|
9
|
+
|
|
10
|
+
expect(isEqual({}, {})).toBe(true);
|
|
11
|
+
expect(isEqual({ a: 1 }, { a: 1 })).toBe(true);
|
|
12
|
+
expect(isEqual({ a: { a: 1 } }, { a: { a: 1 } })).toBe(true);
|
|
13
|
+
|
|
14
|
+
expect(isEqual([], [])).toBe(true);
|
|
15
|
+
|
|
16
|
+
expect(isEqual([1], [2])).toBe(false);
|
|
17
|
+
expect(isEqual([1], [1, 2])).toBe(false);
|
|
18
|
+
expect(isEqual([1, 2], [2, 1])).toBe(false);
|
|
19
|
+
|
|
20
|
+
expect(isEqual({ a: 1 }, { a: 2 })).toBe(false);
|
|
21
|
+
expect(isEqual({ a: 1 }, {})).toBe(false);
|
|
22
|
+
expect(isEqual({}, { a: 1 })).toBe(false);
|
|
23
|
+
expect(isEqual({ a: { a: 1 } }, { a: { a: 2 } })).toBe(false);
|
|
24
|
+
expect(isEqual({ a: 1 }, { a: 1, b: 1 })).toBe(false);
|
|
25
|
+
});
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/** Minimal recursive deep equal of JS values */
|
|
2
|
+
export function isEqual(obj1: any, obj2: any): boolean {
|
|
3
|
+
if (obj1 === obj2) return true;
|
|
4
|
+
if (typeof obj1 === 'object' && typeof obj2 === 'object') {
|
|
5
|
+
const keys1 = Object.keys(obj1);
|
|
6
|
+
const keys2 = Object.keys(obj2);
|
|
7
|
+
if (keys1.length !== keys2.length) return false;
|
|
8
|
+
return keys1.every((key1) => isEqual(obj1[key1], obj2[key1]));
|
|
9
|
+
}
|
|
10
|
+
return false;
|
|
11
|
+
}
|