@lumx/react 3.7.6-alpha.7 → 3.7.6-alpha.8
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
|
@@ -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.8",
|
|
11
|
+
"@lumx/icons": "^3.7.6-alpha.8",
|
|
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.8"
|
|
116
116
|
}
|
|
@@ -3,12 +3,12 @@ import React, { forwardRef, ReactNode } from 'react';
|
|
|
3
3
|
import classNames from 'classnames';
|
|
4
4
|
|
|
5
5
|
import { Alignment, HorizontalAlignment, Size, Theme, Thumbnail } from '@lumx/react';
|
|
6
|
+
|
|
6
7
|
import { Comp, GenericProps, HasTheme, ValueOf } from '@lumx/react/utils/type';
|
|
7
|
-
import { handleBasicClasses } from '@lumx/react/utils/className';
|
|
8
|
+
import { getRootClassName, handleBasicClasses } from '@lumx/react/utils/className';
|
|
8
9
|
|
|
9
10
|
import { ThumbnailProps } from '../thumbnail/Thumbnail';
|
|
10
11
|
import { ImageCaption, ImageCaptionMetadata } from './ImageCaption';
|
|
11
|
-
import { CLASSNAME, COMPONENT_NAME } from './constants';
|
|
12
12
|
|
|
13
13
|
/**
|
|
14
14
|
* Image block variants.
|
|
@@ -46,6 +46,16 @@ export interface ImageBlockProps extends GenericProps, HasTheme, ImageCaptionMet
|
|
|
46
46
|
thumbnailProps?: Omit<ThumbnailProps, 'image' | 'size' | 'theme' | 'align' | 'fillHeight'>;
|
|
47
47
|
}
|
|
48
48
|
|
|
49
|
+
/**
|
|
50
|
+
* Component display name.
|
|
51
|
+
*/
|
|
52
|
+
const COMPONENT_NAME = 'ImageBlock';
|
|
53
|
+
|
|
54
|
+
/**
|
|
55
|
+
* Component default class name and class prefix.
|
|
56
|
+
*/
|
|
57
|
+
const CLASSNAME = getRootClassName(COMPONENT_NAME);
|
|
58
|
+
|
|
49
59
|
/**
|
|
50
60
|
* Component default props.
|
|
51
61
|
*/
|
|
@@ -107,11 +117,14 @@ export const ImageBlock: Comp<ImageBlockProps, HTMLDivElement> = forwardRef((pro
|
|
|
107
117
|
alt={(alt || title) as string}
|
|
108
118
|
/>
|
|
109
119
|
<ImageCaption
|
|
120
|
+
className={`${CLASSNAME}__wrapper`}
|
|
121
|
+
theme={theme}
|
|
110
122
|
title={title}
|
|
111
123
|
description={description}
|
|
112
124
|
tags={tags}
|
|
113
125
|
captionStyle={captionStyle}
|
|
114
126
|
align={align}
|
|
127
|
+
truncate={captionPosition === 'over'}
|
|
115
128
|
/>
|
|
116
129
|
{actions && <div className={`${CLASSNAME}__actions`}>{actions}</div>}
|
|
117
130
|
</figure>
|
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
import React, { CSSProperties, ReactNode } from 'react';
|
|
2
2
|
|
|
3
3
|
import { FlexBox, HorizontalAlignment, Text } from '@lumx/react';
|
|
4
|
-
import { HasPolymorphicAs, HasTheme } from '@lumx/react/utils/type';
|
|
5
|
-
import { CLASSNAME } from './constants';
|
|
4
|
+
import { HasClassName, HasPolymorphicAs, HasTheme } from '@lumx/react/utils/type';
|
|
6
5
|
|
|
7
6
|
type As = 'div' | 'figcaption';
|
|
8
7
|
|
|
@@ -18,19 +17,22 @@ export type ImageCaptionMetadata = {
|
|
|
18
17
|
};
|
|
19
18
|
|
|
20
19
|
export type ImageCaptionProps<AS extends As = 'figcaption'> = HasTheme &
|
|
20
|
+
HasClassName &
|
|
21
21
|
HasPolymorphicAs<AS> &
|
|
22
22
|
ImageCaptionMetadata & {
|
|
23
23
|
/** Alignment. */
|
|
24
24
|
align?: HorizontalAlignment;
|
|
25
|
+
/** Truncate title & description */
|
|
26
|
+
truncate?: boolean;
|
|
25
27
|
};
|
|
26
28
|
|
|
27
29
|
/** Internal component used to render image captions */
|
|
28
30
|
export const ImageCaption = <AS extends As>(props: ImageCaptionProps<AS>) => {
|
|
29
|
-
const { theme, as = 'figcaption', title, description, tags, captionStyle, align } = props;
|
|
31
|
+
const { className, theme, as = 'figcaption', title, description, tags, captionStyle, align, truncate } = props;
|
|
30
32
|
if (!title && !description && !tags) return null;
|
|
31
33
|
|
|
32
|
-
const titleColor = theme === 'dark' ?
|
|
33
|
-
const descriptionColor = theme === 'dark' ?
|
|
34
|
+
const titleColor = { color: theme === 'dark' ? 'light' : 'dark' } as const;
|
|
35
|
+
const descriptionColor = { color: theme === 'dark' ? 'light' : 'dark', colorVariant: 'L2' } as const;
|
|
34
36
|
|
|
35
37
|
// Display description as string or HTML
|
|
36
38
|
const descriptionContent =
|
|
@@ -39,32 +41,25 @@ export const ImageCaption = <AS extends As>(props: ImageCaptionProps<AS>) => {
|
|
|
39
41
|
return (
|
|
40
42
|
<FlexBox
|
|
41
43
|
as={as}
|
|
42
|
-
className={
|
|
44
|
+
className={className}
|
|
43
45
|
style={captionStyle}
|
|
44
46
|
orientation="horizontal"
|
|
45
47
|
vAlign={align}
|
|
48
|
+
hAlign={align === 'center' ? align : undefined}
|
|
49
|
+
gap="regular"
|
|
46
50
|
>
|
|
47
51
|
{(title || description) && (
|
|
48
|
-
<
|
|
52
|
+
<Text as="p" truncate={truncate}>
|
|
49
53
|
{title && (
|
|
50
|
-
<Text as="span"
|
|
54
|
+
<Text as="span" typography="subtitle1" {...titleColor}>
|
|
51
55
|
{title}
|
|
52
56
|
</Text>
|
|
53
|
-
)}
|
|
54
|
-
{
|
|
55
|
-
|
|
56
|
-
{description && (
|
|
57
|
-
<Text
|
|
58
|
-
as="span"
|
|
59
|
-
className={`${CLASSNAME}__description`}
|
|
60
|
-
{...descriptionColor}
|
|
61
|
-
{...descriptionContent}
|
|
62
|
-
/>
|
|
63
|
-
)}
|
|
64
|
-
</div>
|
|
57
|
+
)}{' '}
|
|
58
|
+
{description && <Text as="span" typography="body1" {...descriptionColor} {...descriptionContent} />}
|
|
59
|
+
</Text>
|
|
65
60
|
)}
|
|
66
61
|
{tags && (
|
|
67
|
-
<FlexBox orientation="horizontal" vAlign={align}
|
|
62
|
+
<FlexBox orientation="horizontal" vAlign={align}>
|
|
68
63
|
{tags}
|
|
69
64
|
</FlexBox>
|
|
70
65
|
)}
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import { getRootClassName } from '@lumx/react/utils/className';
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* Component display name.
|
|
5
|
-
*/
|
|
6
|
-
export const COMPONENT_NAME = 'ImageBlock';
|
|
7
|
-
|
|
8
|
-
/**
|
|
9
|
-
* Component default class name and class prefix.
|
|
10
|
-
*/
|
|
11
|
-
export const CLASSNAME = getRootClassName(COMPONENT_NAME);
|