@lumx/react 2.2.22 → 2.2.23
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/esm/_internal/FlexBox.js.map +1 -1
- package/esm/_internal/GenericBlock.js +32 -52
- package/esm/_internal/GenericBlock.js.map +1 -1
- package/esm/_internal/Link2.js.map +1 -1
- package/esm/_internal/Thumbnail2.js +26 -12
- package/esm/_internal/Thumbnail2.js.map +1 -1
- package/esm/_internal/components.js +7 -7
- package/esm/_internal/components.js.map +1 -1
- package/esm/index.js +1 -1
- package/package.json +4 -4
- package/src/components/flex-box/FlexBox.stories.tsx +1 -1
- package/src/components/flex-box/FlexBox.tsx +1 -1
- package/src/components/generic-block/GenericBlock.stories.jsx +106 -0
- package/src/components/generic-block/GenericBlock.test.tsx +36 -19
- package/src/components/generic-block/GenericBlock.tsx +52 -53
- package/src/components/index.ts +7 -7
- package/src/components/link/Link.stories.tsx +70 -40
- package/src/components/link/Link.tsx +2 -2
- package/src/components/thumbnail/useFocusPointStyle.test.ts +92 -0
- package/src/components/thumbnail/useFocusPointStyle.tsx +26 -4
- package/types.d.ts +18 -15
- package/src/components/generic-block/GenericBlock.stories.tsx +0 -90
|
@@ -3,11 +3,24 @@ import { AspectRatio } from '@lumx/react/components';
|
|
|
3
3
|
import { ThumbnailProps } from '@lumx/react/components/thumbnail/Thumbnail';
|
|
4
4
|
|
|
5
5
|
// Calculate shift to center the focus point in the container.
|
|
6
|
-
function shiftPosition(
|
|
6
|
+
export function shiftPosition({
|
|
7
|
+
scale,
|
|
8
|
+
focusPoint,
|
|
9
|
+
imageSize,
|
|
10
|
+
containerSize,
|
|
11
|
+
}: {
|
|
12
|
+
scale: number;
|
|
13
|
+
focusPoint: number;
|
|
14
|
+
imageSize: number;
|
|
15
|
+
containerSize: number;
|
|
16
|
+
}) {
|
|
17
|
+
if (imageSize === containerSize) return 0;
|
|
7
18
|
const scaledSize = imageSize / scale;
|
|
19
|
+
|
|
8
20
|
const scaledFocusHeight = focusPoint * scaledSize;
|
|
9
21
|
const startFocus = scaledFocusHeight - containerSize / 2;
|
|
10
22
|
const shift = startFocus / (scaledSize - containerSize);
|
|
23
|
+
|
|
11
24
|
return Math.floor(Math.max(Math.min(shift, 1), 0) * 100);
|
|
12
25
|
}
|
|
13
26
|
|
|
@@ -73,14 +86,23 @@ export const useFocusPointStyle = (
|
|
|
73
86
|
|
|
74
87
|
// Focus Y relative to the top (instead of the center)
|
|
75
88
|
const focusPointFromTop = Math.abs((focusPoint?.y || 0) - 1) / 2;
|
|
76
|
-
const y = shiftPosition(
|
|
89
|
+
const y = shiftPosition({
|
|
90
|
+
scale,
|
|
91
|
+
focusPoint: focusPointFromTop,
|
|
92
|
+
imageSize: imageSize.height,
|
|
93
|
+
containerSize: containerSize.height,
|
|
94
|
+
});
|
|
77
95
|
|
|
78
96
|
// Focus X relative to the left (instead of the center)
|
|
79
97
|
const focusPointFromLeft = Math.abs((focusPoint?.x || 0) + 1) / 2;
|
|
80
|
-
const x = shiftPosition(
|
|
98
|
+
const x = shiftPosition({
|
|
99
|
+
scale,
|
|
100
|
+
focusPoint: focusPointFromLeft,
|
|
101
|
+
imageSize: imageSize.width,
|
|
102
|
+
containerSize: containerSize.width,
|
|
103
|
+
});
|
|
81
104
|
|
|
82
105
|
const objectPosition = `${x}% ${y}%`;
|
|
83
|
-
|
|
84
106
|
// Update only if needed.
|
|
85
107
|
setStyle((oldStyle) => (oldStyle.objectPosition === objectPosition ? oldStyle : { objectPosition }));
|
|
86
108
|
}, [aspectRatio, containerSize, element, focusPoint?.x, focusPoint?.y, image, imageSize]);
|
package/types.d.ts
CHANGED
|
@@ -162,13 +162,16 @@ export declare const TypographyTitleCustom: {
|
|
|
162
162
|
readonly title6: "custom-title6";
|
|
163
163
|
};
|
|
164
164
|
export declare type TypographyTitleCustom = ValueOf<typeof TypographyTitleCustom>;
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
readonly
|
|
170
|
-
readonly "
|
|
171
|
-
readonly
|
|
165
|
+
/**
|
|
166
|
+
* List of typographies that can be customized (via CSS variables).
|
|
167
|
+
*/
|
|
168
|
+
export declare const TypographyCustom: {
|
|
169
|
+
readonly intro: "custom-intro";
|
|
170
|
+
readonly "body-large": "custom-body-large";
|
|
171
|
+
readonly body: "custom-body";
|
|
172
|
+
readonly quote: "custom-quote";
|
|
173
|
+
readonly "publish-info": "custom-publish-info";
|
|
174
|
+
readonly button: "custom-button";
|
|
172
175
|
readonly title1: "custom-title1";
|
|
173
176
|
readonly title2: "custom-title2";
|
|
174
177
|
readonly title3: "custom-title3";
|
|
@@ -182,12 +185,12 @@ export declare type TypographyCustom = ValueOf<typeof TypographyCustom>;
|
|
|
182
185
|
*/
|
|
183
186
|
export declare const Typography: {
|
|
184
187
|
readonly custom: {
|
|
185
|
-
readonly intro: "intro";
|
|
186
|
-
readonly "body-large": "body-large";
|
|
187
|
-
readonly body: "body";
|
|
188
|
-
readonly quote: "quote";
|
|
189
|
-
readonly "publish-info": "publish-info";
|
|
190
|
-
readonly button: "button";
|
|
188
|
+
readonly intro: "custom-intro";
|
|
189
|
+
readonly "body-large": "custom-body-large";
|
|
190
|
+
readonly body: "custom-body";
|
|
191
|
+
readonly quote: "custom-quote";
|
|
192
|
+
readonly "publish-info": "custom-publish-info";
|
|
193
|
+
readonly button: "custom-button";
|
|
191
194
|
readonly title1: "custom-title1";
|
|
192
195
|
readonly title2: "custom-title2";
|
|
193
196
|
readonly title3: "custom-title3";
|
|
@@ -1096,7 +1099,7 @@ export interface FlagProps extends GenericProps, HasTheme {
|
|
|
1096
1099
|
*/
|
|
1097
1100
|
export declare const Flag: Comp<FlagProps, HTMLDivElement>;
|
|
1098
1101
|
export declare type MarginAutoAlignment = Extract<Alignment, "top" | "bottom" | "right" | "left">;
|
|
1099
|
-
export declare type GapSize = Extract<Size, "regular" | "medium" | "big" | "huge">;
|
|
1102
|
+
export declare type GapSize = Extract<Size, "tiny" | "regular" | "medium" | "big" | "huge">;
|
|
1100
1103
|
/**
|
|
1101
1104
|
* Defines the props of the component.
|
|
1102
1105
|
*/
|
|
@@ -1471,7 +1474,7 @@ export interface LinkProps extends GenericProps {
|
|
|
1471
1474
|
/** Link target. */
|
|
1472
1475
|
target?: HTMLAnchorProps["target"];
|
|
1473
1476
|
/** Typography variant. */
|
|
1474
|
-
typography?:
|
|
1477
|
+
typography?: Typography;
|
|
1475
1478
|
}
|
|
1476
1479
|
/**
|
|
1477
1480
|
* Link component.
|
|
@@ -1,90 +0,0 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import { mdiPencil } from '@lumx/icons';
|
|
3
|
-
import { GenericBlock, Button, Icon, Size, Orientation, Alignment } from '@lumx/react';
|
|
4
|
-
import { HasTheme } from '@lumx/react/utils';
|
|
5
|
-
|
|
6
|
-
export default { title: 'LumX components/generic-block/GenericBlock' };
|
|
7
|
-
|
|
8
|
-
const redBorderStyle = { border: '1px solid red' };
|
|
9
|
-
|
|
10
|
-
/**
|
|
11
|
-
* Fill sections using props
|
|
12
|
-
*/
|
|
13
|
-
export const SectionsInProps = ({ theme }: HasTheme) => (
|
|
14
|
-
<GenericBlock
|
|
15
|
-
figure={<Icon icon={mdiPencil} size={Size.m} />}
|
|
16
|
-
actionsProps={{ style: redBorderStyle }}
|
|
17
|
-
figureProps={{ style: redBorderStyle }}
|
|
18
|
-
contentProps={{ style: redBorderStyle }}
|
|
19
|
-
actions={<Button theme={theme}>Button</Button>}
|
|
20
|
-
>
|
|
21
|
-
Content
|
|
22
|
-
</GenericBlock>
|
|
23
|
-
);
|
|
24
|
-
|
|
25
|
-
/**
|
|
26
|
-
* Fill sections using child section components.
|
|
27
|
-
*/
|
|
28
|
-
export const SectionsInChildren = ({ theme }: HasTheme) => (
|
|
29
|
-
<GenericBlock>
|
|
30
|
-
<GenericBlock.Figure style={redBorderStyle}>
|
|
31
|
-
<Icon icon={mdiPencil} size={Size.m} />
|
|
32
|
-
</GenericBlock.Figure>
|
|
33
|
-
<GenericBlock.Content style={redBorderStyle}>Content</GenericBlock.Content>
|
|
34
|
-
<GenericBlock.Actions style={redBorderStyle}>
|
|
35
|
-
<Button theme={theme}>Button</Button>
|
|
36
|
-
</GenericBlock.Actions>
|
|
37
|
-
</GenericBlock>
|
|
38
|
-
);
|
|
39
|
-
|
|
40
|
-
export const Vertical = ({ theme }: HasTheme) => (
|
|
41
|
-
<GenericBlock orientation={Orientation.vertical}>
|
|
42
|
-
<GenericBlock.Figure style={redBorderStyle}>
|
|
43
|
-
<Icon icon={mdiPencil} size={Size.m} />
|
|
44
|
-
</GenericBlock.Figure>
|
|
45
|
-
<GenericBlock.Content style={redBorderStyle}>Content</GenericBlock.Content>
|
|
46
|
-
<GenericBlock.Actions fillSpace style={redBorderStyle}>
|
|
47
|
-
<Button theme={theme}>Button</Button>
|
|
48
|
-
</GenericBlock.Actions>
|
|
49
|
-
</GenericBlock>
|
|
50
|
-
);
|
|
51
|
-
|
|
52
|
-
export const Horizontal = ({ theme }: HasTheme) => (
|
|
53
|
-
<GenericBlock orientation={Orientation.horizontal}>
|
|
54
|
-
<GenericBlock.Figure style={redBorderStyle}>
|
|
55
|
-
<Icon icon={mdiPencil} size={Size.m} />
|
|
56
|
-
</GenericBlock.Figure>
|
|
57
|
-
<GenericBlock.Content style={redBorderStyle}>Content</GenericBlock.Content>
|
|
58
|
-
<GenericBlock.Actions style={redBorderStyle}>
|
|
59
|
-
<Button theme={theme}>Button</Button>
|
|
60
|
-
</GenericBlock.Actions>
|
|
61
|
-
</GenericBlock>
|
|
62
|
-
);
|
|
63
|
-
|
|
64
|
-
export const HorizontalTop = ({ theme }: HasTheme) => (
|
|
65
|
-
<GenericBlock orientation={Orientation.horizontal} hAlign={Alignment.top}>
|
|
66
|
-
<GenericBlock.Figure style={redBorderStyle}>
|
|
67
|
-
<Icon icon={mdiPencil} size={Size.m} />
|
|
68
|
-
</GenericBlock.Figure>
|
|
69
|
-
<GenericBlock.Content style={redBorderStyle}>Content</GenericBlock.Content>
|
|
70
|
-
<GenericBlock.Actions style={redBorderStyle}>
|
|
71
|
-
<Button theme={theme}>Button</Button>
|
|
72
|
-
</GenericBlock.Actions>
|
|
73
|
-
</GenericBlock>
|
|
74
|
-
);
|
|
75
|
-
|
|
76
|
-
export const GapSizes = ({ theme }: HasTheme) =>
|
|
77
|
-
[Size.regular, Size.big, Size.huge].map((gap) => (
|
|
78
|
-
<GenericBlock key={gap} orientation={Orientation.vertical} gap={gap} style={{ marginBottom: 40 }}>
|
|
79
|
-
<GenericBlock.Figure style={redBorderStyle}>
|
|
80
|
-
<Icon icon={mdiPencil} size={Size.m} />
|
|
81
|
-
</GenericBlock.Figure>
|
|
82
|
-
<GenericBlock.Content style={redBorderStyle}>
|
|
83
|
-
<h2>{gap} gap size</h2>
|
|
84
|
-
<p>block description</p>
|
|
85
|
-
</GenericBlock.Content>
|
|
86
|
-
<GenericBlock.Actions style={redBorderStyle}>
|
|
87
|
-
<Button theme={theme}>Button</Button>
|
|
88
|
-
</GenericBlock.Actions>
|
|
89
|
-
</GenericBlock>
|
|
90
|
-
));
|