@snack-uikit/info-block 0.3.6-preview-0df2fefa.0 → 0.4.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/CHANGELOG.md +20 -0
- package/dist/components/Footer/Footer.js +3 -1
- package/dist/components/InfoBlock/InfoBlock.js +2 -1
- package/dist/contexts.d.ts +8 -0
- package/dist/contexts.js +8 -0
- package/package.json +3 -3
- package/src/components/Footer/Footer.tsx +4 -2
- package/src/components/InfoBlock/InfoBlock.tsx +48 -40
- package/src/contexts.ts +16 -0
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,26 @@
|
|
|
3
3
|
All notable changes to this project will be documented in this file.
|
|
4
4
|
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
|
5
5
|
|
|
6
|
+
# 0.4.0 (2024-06-06)
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
### Features
|
|
10
|
+
|
|
11
|
+
* **PDS-42:** add size context to InfoBlock.Footer ([39c681a](https://github.com/cloud-ru-tech/snack-uikit/commit/39c681a045594645fb6c87cade4acd4d81e65a23))
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
## 0.3.6 (2024-05-30)
|
|
18
|
+
|
|
19
|
+
### Only dependencies have been changed
|
|
20
|
+
* [@snack-uikit/tooltip@0.13.4](https://github.com/cloud-ru-tech/snack-uikit/blob/master/packages/tooltip/CHANGELOG.md)
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
|
|
6
26
|
## 0.3.5 (2024-05-08)
|
|
7
27
|
|
|
8
28
|
### Only dependencies have been changed
|
|
@@ -2,10 +2,12 @@ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
|
2
2
|
import cn from 'classnames';
|
|
3
3
|
import { ButtonFilled, ButtonTonal } from '@snack-uikit/button';
|
|
4
4
|
import { TEST_IDS } from '../../constants';
|
|
5
|
+
import { useInfoBlockContext } from '../../contexts';
|
|
5
6
|
import { useButtonWithTooltip } from './hooks';
|
|
6
7
|
import styles from './styles.module.css';
|
|
7
8
|
export function Footer({ primaryButton, secondaryButton, className }) {
|
|
8
9
|
const PrimaryButton = useButtonWithTooltip({ Button: ButtonFilled, tooltip: primaryButton.tooltip });
|
|
9
10
|
const SecondaryButton = useButtonWithTooltip({ Button: ButtonTonal, tooltip: secondaryButton === null || secondaryButton === void 0 ? void 0 : secondaryButton.tooltip });
|
|
10
|
-
|
|
11
|
+
const { size } = useInfoBlockContext();
|
|
12
|
+
return (_jsxs("div", { className: cn(styles.infoBlockFooter, className), children: [secondaryButton && (_jsx(SecondaryButton, Object.assign({}, secondaryButton, { size: size, "data-test-id": secondaryButton['data-test-id'] || TEST_IDS.secondaryButton }))), _jsx(PrimaryButton, Object.assign({}, primaryButton, { size: size, "data-test-id": primaryButton['data-test-id'] || TEST_IDS.primaryButton }))] }));
|
|
11
13
|
}
|
|
@@ -15,9 +15,10 @@ import { IconPredefined } from '@snack-uikit/icon-predefined';
|
|
|
15
15
|
import { Typography } from '@snack-uikit/typography';
|
|
16
16
|
import { extractSupportProps } from '@snack-uikit/utils';
|
|
17
17
|
import { ALIGN, SIZE, TEST_IDS } from '../../constants';
|
|
18
|
+
import { InfoBlockContext } from '../../contexts';
|
|
18
19
|
import styles from './styles.module.css';
|
|
19
20
|
export function InfoBlock(_a) {
|
|
20
21
|
var _b, _c;
|
|
21
22
|
var { title, description, icon, size = SIZE.S, footer, align = ALIGN.Vertical, className } = _a, rest = __rest(_a, ["title", "description", "icon", "size", "footer", "align", "className"]);
|
|
22
|
-
return (_jsxs("div", Object.assign({ className: cn(styles.infoBlock, className), "data-size": size, "data-align": align }, extractSupportProps(rest), { children: [icon && (_jsx(IconPredefined, { icon: icon.icon, appearance: (_b = icon.appearance) !== null && _b !== void 0 ? _b : 'primary', decor: (_c = icon.decor) !== null && _c !== void 0 ? _c : true, size: size, "data-test-id": TEST_IDS.icon })), _jsxs("div", { className: styles.contentLayout, children: [_jsxs("div", { className: styles.textWrap, children: [title && (_jsx(Typography, { family: 'sans', purpose: 'title', size: size, className: styles.title, "data-test-id": TEST_IDS.title, children: title })), description && (_jsx(Typography, { family: 'sans', purpose: 'body', size: size, className: styles.description, "data-test-id": TEST_IDS.description, children: description }))] }), footer && (_jsx("div", { className: styles.footer, "data-test-id": TEST_IDS.footer, children: footer }))] })] })));
|
|
23
|
+
return (_jsx(InfoBlockContext.Provider, { value: { size }, children: _jsxs("div", Object.assign({ className: cn(styles.infoBlock, className), "data-size": size, "data-align": align }, extractSupportProps(rest), { children: [icon && (_jsx(IconPredefined, { icon: icon.icon, appearance: (_b = icon.appearance) !== null && _b !== void 0 ? _b : 'primary', decor: (_c = icon.decor) !== null && _c !== void 0 ? _c : true, size: size, "data-test-id": TEST_IDS.icon })), _jsxs("div", { className: styles.contentLayout, children: [_jsxs("div", { className: styles.textWrap, children: [title && (_jsx(Typography, { family: 'sans', purpose: 'title', size: size, className: styles.title, "data-test-id": TEST_IDS.title, children: title })), description && (_jsx(Typography, { family: 'sans', purpose: 'body', size: size, className: styles.description, "data-test-id": TEST_IDS.description, children: description }))] }), footer && (_jsx("div", { className: styles.footer, "data-test-id": TEST_IDS.footer, children: footer }))] })] })) }));
|
|
23
24
|
}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
import { Size } from './types';
|
|
3
|
+
type InfoBlockContextValue = {
|
|
4
|
+
size: Size;
|
|
5
|
+
};
|
|
6
|
+
export declare const InfoBlockContext: import("react").Context<InfoBlockContextValue>;
|
|
7
|
+
export declare function useInfoBlockContext(): InfoBlockContextValue;
|
|
8
|
+
export {};
|
package/dist/contexts.js
ADDED
package/package.json
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
"access": "public"
|
|
5
5
|
},
|
|
6
6
|
"title": "Info Block",
|
|
7
|
-
"version": "0.
|
|
7
|
+
"version": "0.4.0",
|
|
8
8
|
"sideEffects": [
|
|
9
9
|
"*.css",
|
|
10
10
|
"*.woff",
|
|
@@ -34,10 +34,10 @@
|
|
|
34
34
|
"dependencies": {
|
|
35
35
|
"@snack-uikit/button": "0.17.1",
|
|
36
36
|
"@snack-uikit/icon-predefined": "0.5.1",
|
|
37
|
-
"@snack-uikit/tooltip": "0.13.4
|
|
37
|
+
"@snack-uikit/tooltip": "0.13.4",
|
|
38
38
|
"@snack-uikit/typography": "0.6.2",
|
|
39
39
|
"@snack-uikit/utils": "3.3.0",
|
|
40
40
|
"classnames": "2.3.2"
|
|
41
41
|
},
|
|
42
|
-
"gitHead": "
|
|
42
|
+
"gitHead": "0fc5480c934d08f8578e1e7d862321bc89113ca5"
|
|
43
43
|
}
|
|
@@ -4,6 +4,7 @@ import { ButtonFilled, ButtonFilledProps, ButtonTonal, ButtonTonalProps } from '
|
|
|
4
4
|
import { TooltipProps } from '@snack-uikit/tooltip';
|
|
5
5
|
|
|
6
6
|
import { TEST_IDS } from '../../constants';
|
|
7
|
+
import { useInfoBlockContext } from '../../contexts';
|
|
7
8
|
import { useButtonWithTooltip } from './hooks';
|
|
8
9
|
import styles from './styles.module.scss';
|
|
9
10
|
|
|
@@ -18,20 +19,21 @@ export type FooterProps = {
|
|
|
18
19
|
export function Footer({ primaryButton, secondaryButton, className }: FooterProps) {
|
|
19
20
|
const PrimaryButton = useButtonWithTooltip({ Button: ButtonFilled, tooltip: primaryButton.tooltip });
|
|
20
21
|
const SecondaryButton = useButtonWithTooltip({ Button: ButtonTonal, tooltip: secondaryButton?.tooltip });
|
|
22
|
+
const { size } = useInfoBlockContext();
|
|
21
23
|
|
|
22
24
|
return (
|
|
23
25
|
<div className={cn(styles.infoBlockFooter, className)}>
|
|
24
26
|
{secondaryButton && (
|
|
25
27
|
<SecondaryButton
|
|
26
28
|
{...secondaryButton}
|
|
27
|
-
size=
|
|
29
|
+
size={size}
|
|
28
30
|
data-test-id={secondaryButton['data-test-id'] || TEST_IDS.secondaryButton}
|
|
29
31
|
/>
|
|
30
32
|
)}
|
|
31
33
|
|
|
32
34
|
<PrimaryButton
|
|
33
35
|
{...primaryButton}
|
|
34
|
-
size=
|
|
36
|
+
size={size}
|
|
35
37
|
data-test-id={primaryButton['data-test-id'] || TEST_IDS.primaryButton}
|
|
36
38
|
/>
|
|
37
39
|
</div>
|
|
@@ -6,6 +6,7 @@ import { Typography } from '@snack-uikit/typography';
|
|
|
6
6
|
import { extractSupportProps, WithSupportProps } from '@snack-uikit/utils';
|
|
7
7
|
|
|
8
8
|
import { ALIGN, SIZE, TEST_IDS } from '../../constants';
|
|
9
|
+
import { InfoBlockContext } from '../../contexts';
|
|
9
10
|
import { Align, Size } from '../../types';
|
|
10
11
|
import { Footer, FooterProps } from '../Footer';
|
|
11
12
|
import styles from './styles.module.scss';
|
|
@@ -37,50 +38,57 @@ export function InfoBlock({
|
|
|
37
38
|
...rest
|
|
38
39
|
}: InfoBlockProps) {
|
|
39
40
|
return (
|
|
40
|
-
<
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
41
|
+
<InfoBlockContext.Provider value={{ size }}>
|
|
42
|
+
<div
|
|
43
|
+
className={cn(styles.infoBlock, className)}
|
|
44
|
+
data-size={size}
|
|
45
|
+
data-align={align}
|
|
46
|
+
{...extractSupportProps(rest)}
|
|
47
|
+
>
|
|
48
|
+
{icon && (
|
|
49
|
+
<IconPredefined
|
|
50
|
+
icon={icon.icon}
|
|
51
|
+
appearance={icon.appearance ?? 'primary'}
|
|
52
|
+
decor={icon.decor ?? true}
|
|
53
|
+
size={size}
|
|
54
|
+
data-test-id={TEST_IDS.icon}
|
|
55
|
+
/>
|
|
56
|
+
)}
|
|
50
57
|
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
58
|
+
<div className={styles.contentLayout}>
|
|
59
|
+
<div className={styles.textWrap}>
|
|
60
|
+
{title && (
|
|
61
|
+
<Typography
|
|
62
|
+
family='sans'
|
|
63
|
+
purpose='title'
|
|
64
|
+
size={size}
|
|
65
|
+
className={styles.title}
|
|
66
|
+
data-test-id={TEST_IDS.title}
|
|
67
|
+
>
|
|
68
|
+
{title}
|
|
69
|
+
</Typography>
|
|
70
|
+
)}
|
|
71
|
+
|
|
72
|
+
{description && (
|
|
73
|
+
<Typography
|
|
74
|
+
family='sans'
|
|
75
|
+
purpose='body'
|
|
76
|
+
size={size}
|
|
77
|
+
className={styles.description}
|
|
78
|
+
data-test-id={TEST_IDS.description}
|
|
79
|
+
>
|
|
80
|
+
{description}
|
|
81
|
+
</Typography>
|
|
82
|
+
)}
|
|
83
|
+
</div>
|
|
64
84
|
|
|
65
|
-
{
|
|
66
|
-
<
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
size={size}
|
|
70
|
-
className={styles.description}
|
|
71
|
-
data-test-id={TEST_IDS.description}
|
|
72
|
-
>
|
|
73
|
-
{description}
|
|
74
|
-
</Typography>
|
|
85
|
+
{footer && (
|
|
86
|
+
<div className={styles.footer} data-test-id={TEST_IDS.footer}>
|
|
87
|
+
{footer}
|
|
88
|
+
</div>
|
|
75
89
|
)}
|
|
76
90
|
</div>
|
|
77
|
-
|
|
78
|
-
{footer && (
|
|
79
|
-
<div className={styles.footer} data-test-id={TEST_IDS.footer}>
|
|
80
|
-
{footer}
|
|
81
|
-
</div>
|
|
82
|
-
)}
|
|
83
91
|
</div>
|
|
84
|
-
</
|
|
92
|
+
</InfoBlockContext.Provider>
|
|
85
93
|
);
|
|
86
94
|
}
|
package/src/contexts.ts
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { createContext, useContext } from 'react';
|
|
2
|
+
|
|
3
|
+
import { SIZE } from './constants';
|
|
4
|
+
import { Size } from './types';
|
|
5
|
+
|
|
6
|
+
type InfoBlockContextValue = {
|
|
7
|
+
size: Size;
|
|
8
|
+
};
|
|
9
|
+
|
|
10
|
+
export const InfoBlockContext = createContext<InfoBlockContextValue>({
|
|
11
|
+
size: SIZE.S,
|
|
12
|
+
});
|
|
13
|
+
|
|
14
|
+
export function useInfoBlockContext() {
|
|
15
|
+
return useContext(InfoBlockContext);
|
|
16
|
+
}
|