@snack-uikit/info-block 0.3.6 → 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 CHANGED
@@ -3,6 +3,17 @@
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
+
6
17
  ## 0.3.6 (2024-05-30)
7
18
 
8
19
  ### 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
- return (_jsxs("div", { className: cn(styles.infoBlockFooter, className), children: [secondaryButton && (_jsx(SecondaryButton, Object.assign({}, secondaryButton, { size: 'm', "data-test-id": secondaryButton['data-test-id'] || TEST_IDS.secondaryButton }))), _jsx(PrimaryButton, Object.assign({}, primaryButton, { size: 'm', "data-test-id": primaryButton['data-test-id'] || TEST_IDS.primaryButton }))] }));
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 {};
@@ -0,0 +1,8 @@
1
+ import { createContext, useContext } from 'react';
2
+ import { SIZE } from './constants';
3
+ export const InfoBlockContext = createContext({
4
+ size: SIZE.S,
5
+ });
6
+ export function useInfoBlockContext() {
7
+ return useContext(InfoBlockContext);
8
+ }
package/package.json CHANGED
@@ -4,7 +4,7 @@
4
4
  "access": "public"
5
5
  },
6
6
  "title": "Info Block",
7
- "version": "0.3.6",
7
+ "version": "0.4.0",
8
8
  "sideEffects": [
9
9
  "*.css",
10
10
  "*.woff",
@@ -39,5 +39,5 @@
39
39
  "@snack-uikit/utils": "3.3.0",
40
40
  "classnames": "2.3.2"
41
41
  },
42
- "gitHead": "6a5d30f58b1ca79c29b9f4b3078edbd8c02e15a4"
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='m'
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='m'
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
- <div className={cn(styles.infoBlock, className)} data-size={size} data-align={align} {...extractSupportProps(rest)}>
41
- {icon && (
42
- <IconPredefined
43
- icon={icon.icon}
44
- appearance={icon.appearance ?? 'primary'}
45
- decor={icon.decor ?? true}
46
- size={size}
47
- data-test-id={TEST_IDS.icon}
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
- <div className={styles.contentLayout}>
52
- <div className={styles.textWrap}>
53
- {title && (
54
- <Typography
55
- family='sans'
56
- purpose='title'
57
- size={size}
58
- className={styles.title}
59
- data-test-id={TEST_IDS.title}
60
- >
61
- {title}
62
- </Typography>
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
- {description && (
66
- <Typography
67
- family='sans'
68
- purpose='body'
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
- </div>
92
+ </InfoBlockContext.Provider>
85
93
  );
86
94
  }
@@ -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
+ }