@snack-uikit/card 0.10.7 → 0.11.1

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,33 @@
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.11.1 (2024-02-28)
7
+
8
+ ### Only dependencies have been changed
9
+ * [@snack-uikit/button@0.17.0](https://github.com/cloud-ru-tech/snack-uikit/blob/master/packages/button/CHANGELOG.md)
10
+ * [@snack-uikit/icon-predefined@0.5.0](https://github.com/cloud-ru-tech/snack-uikit/blob/master/packages/icon-predefined/CHANGELOG.md)
11
+ * [@snack-uikit/list@0.6.1](https://github.com/cloud-ru-tech/snack-uikit/blob/master/packages/list/CHANGELOG.md)
12
+
13
+
14
+
15
+
16
+
17
+ # 0.11.0 (2024-02-28)
18
+
19
+
20
+ ### Bug Fixes
21
+
22
+ * **FF-0000:** fix badge overlaps title ([b0594c2](https://github.com/cloud-ru-tech/snack-uikit/commit/b0594c26f49cb741ec95b0e018c82214aa4aff51))
23
+
24
+
25
+ ### Features
26
+
27
+ * **FF-011:** add into prop type promoBadge {text,appearance?} ([dcb3b7b](https://github.com/cloud-ru-tech/snack-uikit/commit/dcb3b7b31d7c3904f3401094b63838c08308506f))
28
+
29
+
30
+
31
+
32
+
6
33
  ## 0.10.7 (2024-02-27)
7
34
 
8
35
  ### Only dependencies have been changed
package/README.md CHANGED
@@ -34,7 +34,7 @@ import { Card, SearchPrivate } from "@snack-uikit/card";
34
34
  | multipleSelection | `boolean` | - | Отображение галочки для режима массового выделения карточек |
35
35
  | onClick | `(e: MouseEvent<HTMLDivElement \| HTMLAnchorElement, MouseEvent>) => void` | - | Колбек на клик по карточке |
36
36
  | size | enum Size: `"s"`, `"m"`, `"l"` | - | Размер |
37
- | promoBadge | `string` | - | Текст для PromoBadge |
37
+ | promoBadge | `string \| Pick<PromoTagProps, "text" \| "appearance">` | - | PromoBadge |
38
38
  | children | `ReactNode` | - | Вложенный контент |
39
39
  | header | `ReactElement<HeaderProps, string \| JSXElementConstructor<any>>` | - | Вложенный Header |
40
40
  | footer | `ReactNode` | - | Вложенный Footer |
@@ -1,4 +1,5 @@
1
1
  import { MouseEvent, ReactElement, ReactNode } from 'react';
2
+ import { PromoTagProps } from '@snack-uikit/promo-tag';
2
3
  import { WithSupportProps } from '@snack-uikit/utils';
3
4
  import { Size } from '../../types';
4
5
  import { HeaderProps } from '../Header';
@@ -15,8 +16,8 @@ export type CardProps = WithSupportProps<{
15
16
  onClick?(e: MouseEvent<HTMLDivElement | HTMLAnchorElement>): void;
16
17
  /** Размер */
17
18
  size?: Size;
18
- /** Текст для PromoBadge */
19
- promoBadge?: string;
19
+ /** PromoBadge */
20
+ promoBadge?: Pick<PromoTagProps, 'text' | 'appearance'> | string;
20
21
  /** Вложенный контент */
21
22
  children?: ReactNode;
22
23
  /** Вложенный Header */
@@ -34,5 +34,5 @@ export function Card(_a) {
34
34
  const supportProps = extractSupportProps(rest);
35
35
  return (_jsx(CardContext.Provider, { value: { size, disabled }, children: _jsxs("div", Object.assign({ ref: localDivRef, className: cn(styles.card, className) }, supportProps, { onClick: onClick, "data-disabled": disabled || undefined, "data-checked": checked || undefined, "data-outline": outline || undefined, "data-pointer": onClick ? true : undefined,
36
36
  // eslint-disable-next-line jsx-a11y/no-noninteractive-tabindex
37
- tabIndex: 0, onKeyDown: onKeyDown, children: [image, promoBadge && _jsx(PromoBadge, { text: promoBadge }), _jsxs("div", { className: styles.composition, tabIndex: -1, children: [href && (_jsx("a", { ref: localAnchorRef, "data-test-id": TEST_IDS.anchor, tabIndex: -1, href: href, className: styles.anchor, "aria-label": supportProps['aria-label'] })), !disabled && functionBadge && (_jsx(FunctionBadgeWrapper, { className: styles.functionBadgeWrapper, children: functionBadge })), _jsx("div", { className: styles.contentWrapper, children: _jsxs("div", { className: styles.content, "data-size": size, children: [header || null, children && (_jsx(Typography, { family: 'sans', size: size, purpose: 'body', className: styles.body, tag: 'div', children: children })), footer && _jsx("div", { className: styles.footer, children: footer })] }) })] }), checked && multipleSelection && _jsx(Check, { className: styles.check })] })) }));
37
+ tabIndex: 0, onKeyDown: onKeyDown, children: [image, _jsxs("div", { className: styles.composition, tabIndex: -1, children: [href && (_jsx("a", { ref: localAnchorRef, "data-test-id": TEST_IDS.anchor, tabIndex: -1, href: href, className: styles.anchor, "aria-label": supportProps['aria-label'] })), !disabled && functionBadge && (_jsx(FunctionBadgeWrapper, { className: styles.functionBadgeWrapper, children: functionBadge })), _jsx("div", { className: styles.contentWrapper, children: _jsxs("div", { className: styles.content, "data-size": size, children: [header || null, children && (_jsx(Typography, { family: 'sans', size: size, purpose: 'body', className: styles.body, tag: 'div', children: children })), footer && _jsx("div", { className: styles.footer, children: footer })] }) }), promoBadge && _jsx(PromoBadge, Object.assign({}, (typeof promoBadge === 'string' ? { text: promoBadge } : promoBadge)))] }), checked && multipleSelection && _jsx(Check, { className: styles.check })] })) }));
38
38
  }
@@ -1,6 +1,6 @@
1
1
  .functionBadge{
2
- padding-top:var(--space-card-gap-m, 8px);
3
- padding-right:var(--space-card-gap-m, 8px);
2
+ padding-top:var(--space-card-padding-function-badge, 8px);
3
+ padding-right:var(--space-card-padding-function-badge, 8px);
4
4
  position:absolute;
5
5
  z-index:1;
6
6
  top:0;
@@ -1,4 +1,3 @@
1
- export type PromoBadgeProps = {
2
- text: string;
3
- };
4
- export declare function PromoBadge({ text }: PromoBadgeProps): import("react/jsx-runtime").JSX.Element;
1
+ import { PromoTagProps } from '@snack-uikit/promo-tag';
2
+ export type PromoBadgeProps = Pick<PromoTagProps, 'text' | 'appearance'>;
3
+ export declare function PromoBadge({ text, appearance }: PromoBadgeProps): import("react/jsx-runtime").JSX.Element;
@@ -2,6 +2,6 @@ import { jsx as _jsx } from "react/jsx-runtime";
2
2
  import { PromoTag } from '@snack-uikit/promo-tag';
3
3
  import { TEST_IDS } from '../../constants';
4
4
  import styles from './styles.module.css';
5
- export function PromoBadge({ text }) {
6
- return (_jsx("div", { className: styles.promoBadge, children: _jsx(PromoTag, { appearance: 'primary', text: text, "data-test-id": TEST_IDS.promoBadge }) }));
5
+ export function PromoBadge({ text, appearance = 'primary' }) {
6
+ return (_jsx("div", { className: styles.promoBadge, children: _jsx(PromoTag, { appearance: appearance, text: text, "data-test-id": TEST_IDS.promoBadge }) }));
7
7
  }
@@ -1,6 +1,6 @@
1
1
  .promoBadge{
2
- padding-top:var(--space-card-gap-m, 8px);
3
- padding-right:var(--space-card-gap-m, 8px);
2
+ padding-top:var(--space-card-padding-promo-badge, 8px);
3
+ padding-right:var(--space-card-padding-promo-badge, 8px);
4
4
  position:absolute;
5
5
  top:0;
6
6
  right:0;
package/package.json CHANGED
@@ -4,7 +4,7 @@
4
4
  "access": "public"
5
5
  },
6
6
  "title": "Card",
7
- "version": "0.10.7",
7
+ "version": "0.11.1",
8
8
  "sideEffects": [
9
9
  "*.css",
10
10
  "*.woff",
@@ -32,10 +32,10 @@
32
32
  "license": "Apache-2.0",
33
33
  "scripts": {},
34
34
  "dependencies": {
35
- "@snack-uikit/button": "0.16.1",
36
- "@snack-uikit/icon-predefined": "0.4.2",
35
+ "@snack-uikit/button": "0.17.0",
36
+ "@snack-uikit/icon-predefined": "0.5.0",
37
37
  "@snack-uikit/icons": "0.20.1",
38
- "@snack-uikit/list": "0.6.0",
38
+ "@snack-uikit/list": "0.6.1",
39
39
  "@snack-uikit/promo-tag": "0.4.1",
40
40
  "@snack-uikit/tag": "0.8.1",
41
41
  "@snack-uikit/truncate-string": "0.4.9",
@@ -43,5 +43,5 @@
43
43
  "@snack-uikit/utils": "3.2.0",
44
44
  "classnames": "2.3.2"
45
45
  },
46
- "gitHead": "559f1542bf57e8a3be174390e4bd1f2b8f799946"
46
+ "gitHead": "0054db0a5550fb69d388335d844017bca31fffe7"
47
47
  }
@@ -1,6 +1,7 @@
1
1
  import cn from 'classnames';
2
2
  import { KeyboardEvent, MouseEvent, ReactElement, ReactNode, useCallback, useRef } from 'react';
3
3
 
4
+ import { PromoTagProps } from '@snack-uikit/promo-tag';
4
5
  import { Typography } from '@snack-uikit/typography';
5
6
  import { extractSupportProps, WithSupportProps } from '@snack-uikit/utils';
6
7
 
@@ -25,8 +26,8 @@ export type CardProps = WithSupportProps<{
25
26
  onClick?(e: MouseEvent<HTMLDivElement | HTMLAnchorElement>): void;
26
27
  /** Размер */
27
28
  size?: Size;
28
- /** Текст для PromoBadge */
29
- promoBadge?: string;
29
+ /** PromoBadge */
30
+ promoBadge?: Pick<PromoTagProps, 'text' | 'appearance'> | string;
30
31
  /** Вложенный контент */
31
32
  children?: ReactNode;
32
33
  /** Вложенный Header */
@@ -94,8 +95,6 @@ export function Card({
94
95
  >
95
96
  {image}
96
97
 
97
- {promoBadge && <PromoBadge text={promoBadge} />}
98
-
99
98
  <div className={styles.composition} tabIndex={-1}>
100
99
  {href && (
101
100
  <a
@@ -125,6 +124,8 @@ export function Card({
125
124
  {footer && <div className={styles.footer}>{footer}</div>}
126
125
  </div>
127
126
  </div>
127
+
128
+ {promoBadge && <PromoBadge {...(typeof promoBadge === 'string' ? { text: promoBadge } : promoBadge)} />}
128
129
  </div>
129
130
 
130
131
  {checked && multipleSelection && <Check className={styles.check} />}
@@ -1,16 +1,14 @@
1
- import { PromoTag } from '@snack-uikit/promo-tag';
1
+ import { PromoTag, PromoTagProps } from '@snack-uikit/promo-tag';
2
2
 
3
3
  import { TEST_IDS } from '../../constants';
4
4
  import styles from './styles.module.scss';
5
5
 
6
- export type PromoBadgeProps = {
7
- text: string;
8
- };
6
+ export type PromoBadgeProps = Pick<PromoTagProps, 'text' | 'appearance'>;
9
7
 
10
- export function PromoBadge({ text }: PromoBadgeProps) {
8
+ export function PromoBadge({ text, appearance = 'primary' }: PromoBadgeProps) {
11
9
  return (
12
10
  <div className={styles.promoBadge}>
13
- <PromoTag appearance='primary' text={text} data-test-id={TEST_IDS.promoBadge} />
11
+ <PromoTag appearance={appearance} text={text} data-test-id={TEST_IDS.promoBadge} />
14
12
  </div>
15
13
  );
16
14
  }