@sima-land/moleculas 16.0.0-alpha.38 → 16.0.0-alpha.39
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/common/components/modifier/default-border.svg +3 -0
- package/common/components/modifier/hover-border.svg +3 -0
- package/common/components/modifier/modifier.d.ts +1 -1
- package/common/components/modifier/modifier.js +4 -5
- package/common/components/modifier/modifier.js.map +1 -1
- package/common/components/modifier/modifier.m.scss +63 -29
- package/common/components/modifier/types.d.ts +3 -1
- package/desktop/components/promotion-card/estimate.js +2 -2
- package/desktop/components/promotion-card/promotion-card.d.ts +4 -5
- package/desktop/components/promotion-card/promotion-card.js +9 -4
- package/desktop/components/promotion-card/promotion-card.js.map +1 -1
- package/desktop/components/promotion-card/promotion-card.m.scss +15 -26
- package/package.json +1 -1
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
<svg width="33" height="33" viewBox="0 0 33 33" fill="none" xmlns="http://www.w3.org/2000/svg">
|
|
2
|
+
<rect x="0.5" y="0.5" width="32" height="32" rx="3.5" stroke="rgba(194, 194, 194, 1)" stroke-linecap="round" stroke-linejoin="round" stroke-dasharray="5 5" stroke-dashoffset="3.8"/>
|
|
3
|
+
</svg>
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
<svg width="33" height="33" viewBox="0 0 33 33" fill="none" xmlns="http://www.w3.org/2000/svg">
|
|
2
|
+
<rect x="0.5" y="0.5" width="32" height="32" rx="3.5" stroke="rgba(158, 158, 158, 1)" stroke-linecap="round" stroke-linejoin="round" stroke-dasharray="5 5" stroke-dashoffset="3.8"/>
|
|
3
|
+
</svg>
|
|
@@ -4,7 +4,7 @@ import { ModifierProps, MoreButtonProps } from './types';
|
|
|
4
4
|
* @param props Свойства.
|
|
5
5
|
* @return Элемент.
|
|
6
6
|
*/
|
|
7
|
-
export declare function Modifier({ size, active, crossedOut, disabled, content, count, className, markdown, 'data-testid': testId, ...props }: ModifierProps): import("react/jsx-runtime").JSX.Element;
|
|
7
|
+
export declare function Modifier({ size, active, crossedOut, disabled, nonExistent, content, count, className, markdown, 'data-testid': testId, ...props }: ModifierProps): import("react/jsx-runtime").JSX.Element;
|
|
8
8
|
/**
|
|
9
9
|
* Кнопка "+N" для показа полного списка модификаторов.
|
|
10
10
|
* @param props Свойства.
|
|
@@ -10,7 +10,6 @@ const react_1 = require("react");
|
|
|
10
10
|
const hint_1 = require("@sima-land/ui-nucleons/hint");
|
|
11
11
|
const hooks_1 = require("../../hooks");
|
|
12
12
|
const ImageBroken_1 = __importDefault(require("@sima-land/ui-quarks/icons/40x40/Stroked/ImageBroken"));
|
|
13
|
-
const Cross_1 = __importDefault(require("@sima-land/ui-quarks/icons/24x24/Stroked/Cross"));
|
|
14
13
|
const bind_1 = __importDefault(require("classnames/bind"));
|
|
15
14
|
const modifier_m_scss_1 = __importDefault(require("./modifier.m.scss"));
|
|
16
15
|
const cx = bind_1.default.bind(modifier_m_scss_1.default);
|
|
@@ -19,7 +18,7 @@ const cx = bind_1.default.bind(modifier_m_scss_1.default);
|
|
|
19
18
|
* @param props Свойства.
|
|
20
19
|
* @return Элемент.
|
|
21
20
|
*/
|
|
22
|
-
function Modifier({ size = 'm', active, crossedOut, disabled, content, count, className, markdown, 'data-testid': testId = 'modifier', ...props }) {
|
|
21
|
+
function Modifier({ size = 'm', active, crossedOut, disabled, nonExistent, content, count, className, markdown, 'data-testid': testId = 'modifier', ...props }) {
|
|
23
22
|
// текст хинта
|
|
24
23
|
const [hint, setHint] = (0, react_1.useState)('');
|
|
25
24
|
// состояние хинта
|
|
@@ -41,9 +40,9 @@ function Modifier({ size = 'm', active, crossedOut, disabled, content, count, cl
|
|
|
41
40
|
observer.observe(textElement);
|
|
42
41
|
return () => observer.disconnect();
|
|
43
42
|
}, [content.text]);
|
|
44
|
-
// ВАЖНО: по дизайн-гайдам disabled не может быть перечеркнут
|
|
45
|
-
const
|
|
46
|
-
return ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsxs)("a", { ...props, className: cx('root', `size-${size}`, { active, disabled }, className), "data-testid": testId, children: [content.type === 'color' && ((0, jsx_runtime_1.jsx)("span", { className: cx('color'), role: 'banner', style: { background: content.color }
|
|
43
|
+
// ВАЖНО: по дизайн-гайдам disabled и nonExistent не может быть перечеркнут и не может иметь значок уценки.
|
|
44
|
+
const canStrikeOrMarkdown = !disabled && !nonExistent;
|
|
45
|
+
return ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsxs)("a", { ...props, className: cx('root', `size-${size}`, { active, disabled }, nonExistent && 'non-existent', className), "data-testid": testId, children: [content.type === 'color' && ((0, jsx_runtime_1.jsx)("span", { className: cx('color'), role: 'banner', style: { background: content.color } })), content.type === 'image' && (0, jsx_runtime_1.jsx)(Image, { src: content.src }), content.type === 'text' && ((0, jsx_runtime_1.jsx)("span", { ref: refs.setReference, className: cx('text'), ...getReferenceProps(), children: content.text })), typeof count === 'number' && ((0, jsx_runtime_1.jsx)("span", { className: cx('counter'), children: count > 99 ? '99+' : count })), canStrikeOrMarkdown && crossedOut && ((0, jsx_runtime_1.jsx)("svg", { width: '100%', height: '100%', className: cx('diagonal'), children: (0, jsx_runtime_1.jsx)("line", { x1: '0', y1: '100%', x2: '100%', y2: '0', stroke: 'var(--modifier-border-color)', strokeWidth: 2 }) })), canStrikeOrMarkdown && markdown && (0, jsx_runtime_1.jsx)("span", { className: modifier_m_scss_1.default.corner, children: "\u0423" })] }), hint && ((0, jsx_runtime_1.jsx)(hint_1.Hint, { open: open, hintRef: refs.setFloating, arrowRef: refs.setArrow, ...getFloatingProps(), children: hint }))] }));
|
|
47
46
|
}
|
|
48
47
|
/**
|
|
49
48
|
* Картинка с заглушкой в случае ошибки загрузки.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"modifier.js","sourceRoot":"","sources":["../../../../src/common/components/modifier/modifier.tsx"],"names":[],"mappings":";;;;;
|
|
1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L,uBAAC,QAAQ,IACP,IAAI,EAAC,QAAQ,gBACF,gHAAsB,KAC7B,IAAI,EACR,SAAS,EAAE,EAAE,CAAC,MAAM,EAAE,SAAS,CAAC,EAChC,OAAO,EAAE,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,IAAI,KAAK,EAAE,EAAE,iBAC/B,MAAM,GACnB,CACH,CAAC;AACJ,CAAC;AAED;;;;GAIG;AACH,SAAS,WAAW,CAAC,EAAoD;IACvE,OAAO,EAAE,CAAC,WAAW,GAAG,EAAE,CAAC,WAAW,CAAC;AACzC,CAAC"}
|
|
@@ -16,6 +16,7 @@
|
|
|
16
16
|
--modifier-border-color: #{colors.$basic-gray12};
|
|
17
17
|
--modifier-corner-bg: #{colors.$basic-gray12};
|
|
18
18
|
--modifier-corner-color: #{colors.$basic-gray87};
|
|
19
|
+
--content-offset: 3px;
|
|
19
20
|
&.active {
|
|
20
21
|
--modifier-border-color: #{colors.$basic-blue};
|
|
21
22
|
--modifier-corner-color: #fff;
|
|
@@ -24,29 +25,49 @@
|
|
|
24
25
|
&:hover:not(.disabled) {
|
|
25
26
|
cursor: pointer;
|
|
26
27
|
}
|
|
27
|
-
&:hover:not(.disabled):not(.active) {
|
|
28
|
-
--modifier-border-width:
|
|
28
|
+
&:hover:not(.disabled):not(.active):not(.non-existent) {
|
|
29
|
+
--modifier-border-width: 1px;
|
|
30
|
+
--modifier-border-color: #{colors.$basic-gray24};
|
|
31
|
+
--modifier-corner-bg: #{colors.$basic-gray24};
|
|
29
32
|
}
|
|
30
33
|
&.disabled {
|
|
31
34
|
--modifier-media-opacity: 0.24;
|
|
32
35
|
--modifier-overlay-color: rgba(0, 0, 0, 0.04);
|
|
33
|
-
--modifier-border-width:
|
|
36
|
+
--modifier-border-width: 1px;
|
|
34
37
|
--modifier-text-color: #{colors.$basic-gray38};
|
|
35
38
|
--modifier-corner-bg: transparent;
|
|
36
39
|
--modifier-corner-color: #{colors.$basic-gray38};
|
|
40
|
+
.text {
|
|
41
|
+
background-color: colors.$basic-gray8;
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
&.non-existent {
|
|
45
|
+
--border-image-source: url(./default-border.svg);
|
|
46
|
+
--border-image-slice: 6;
|
|
47
|
+
--border-image-width: 6;
|
|
48
|
+
&:hover {
|
|
49
|
+
// ВАЖНО! Невидимость, чтобы не мелькала сплошлая граница во время загрузки изображения.
|
|
50
|
+
--modifier-border-color: rgba(255, 255, 255, 0);
|
|
51
|
+
--border-image-source: url(./hover-border.svg);
|
|
52
|
+
}
|
|
53
|
+
&::before {
|
|
54
|
+
border-image-source: var(--border-image-source);
|
|
55
|
+
border-image-slice: var(--border-image-slice);
|
|
56
|
+
border-image-repeat: round;
|
|
57
|
+
border-image-width: var(--border-image-width);
|
|
58
|
+
}
|
|
37
59
|
}
|
|
38
|
-
&::
|
|
60
|
+
&::before {
|
|
39
61
|
content: '';
|
|
40
62
|
display: block;
|
|
41
63
|
pointer-events: none;
|
|
42
64
|
position: absolute;
|
|
43
65
|
top: 0;
|
|
44
66
|
left: 0;
|
|
45
|
-
width: 100
|
|
46
|
-
height: 100
|
|
67
|
+
width: calc(100% - var(--modifier-border-width) * 2);
|
|
68
|
+
height: calc(100% - var(--modifier-border-width) * 2);
|
|
47
69
|
border-radius: inherit;
|
|
48
|
-
|
|
49
|
-
background: var(--modifier-overlay-color);
|
|
70
|
+
border: var(--modifier-border-width) solid var(--modifier-border-color);
|
|
50
71
|
}
|
|
51
72
|
&.more {
|
|
52
73
|
width: var(--modifier-size);
|
|
@@ -60,14 +81,28 @@
|
|
|
60
81
|
}
|
|
61
82
|
}
|
|
62
83
|
|
|
84
|
+
.size-xs {
|
|
85
|
+
--modifier-size: 32px;
|
|
86
|
+
--modifier-padding: 6px 8px;
|
|
87
|
+
--corner-size: 16px;
|
|
88
|
+
--corner-font-size: 8px;
|
|
89
|
+
--corner-line-height: 10px;
|
|
90
|
+
}
|
|
91
|
+
|
|
63
92
|
.size-s {
|
|
64
93
|
--modifier-size: 40px;
|
|
65
94
|
--modifier-padding: 10px;
|
|
95
|
+
--corner-size: 20px;
|
|
96
|
+
--corner-font-size: 11px;
|
|
97
|
+
--corner-line-height: 13px;
|
|
66
98
|
}
|
|
67
99
|
|
|
68
100
|
.size-m {
|
|
69
101
|
--modifier-size: 48px;
|
|
70
|
-
--modifier-padding: 14px
|
|
102
|
+
--modifier-padding: 14px 16px;
|
|
103
|
+
--corner-size: 24px;
|
|
104
|
+
--corner-font-size: 12px;
|
|
105
|
+
--corner-line-height: 14px;
|
|
71
106
|
}
|
|
72
107
|
|
|
73
108
|
.diagonal {
|
|
@@ -81,6 +116,16 @@
|
|
|
81
116
|
}
|
|
82
117
|
|
|
83
118
|
.color,
|
|
119
|
+
.image-wrapper {
|
|
120
|
+
border-radius: inherit;
|
|
121
|
+
display: block;
|
|
122
|
+
position: absolute;
|
|
123
|
+
top: var(--content-offset);
|
|
124
|
+
left: var(--content-offset);
|
|
125
|
+
width: calc(100% - var(--content-offset) * 2);
|
|
126
|
+
height: calc(100% - var(--content-offset) * 2);
|
|
127
|
+
}
|
|
128
|
+
|
|
84
129
|
.image {
|
|
85
130
|
border-radius: inherit;
|
|
86
131
|
display: block;
|
|
@@ -89,31 +134,22 @@
|
|
|
89
134
|
left: 0;
|
|
90
135
|
width: 100%;
|
|
91
136
|
height: 100%;
|
|
92
|
-
opacity: var(--modifier-media-opacity);
|
|
93
|
-
}
|
|
94
|
-
|
|
95
|
-
.image {
|
|
96
137
|
background-position: center;
|
|
97
138
|
background-size: cover;
|
|
139
|
+
opacity: var(--modifier-media-opacity);
|
|
98
140
|
}
|
|
99
141
|
|
|
100
142
|
.image-wrapper {
|
|
101
|
-
border-radius: inherit;
|
|
102
143
|
display: flex;
|
|
103
144
|
align-items: center;
|
|
104
145
|
justify-content: center;
|
|
105
|
-
position: absolute;
|
|
106
|
-
top: 0;
|
|
107
|
-
left: 0;
|
|
108
|
-
width: 100%;
|
|
109
|
-
height: 100%;
|
|
110
|
-
background: colors.$basic-gray4;
|
|
111
146
|
&.fail {
|
|
112
147
|
--modifier-media-opacity: 0;
|
|
148
|
+
background-color: colors.$basic-gray4;
|
|
113
149
|
}
|
|
114
150
|
> svg {
|
|
115
|
-
width: calc(
|
|
116
|
-
height: calc(
|
|
151
|
+
width: calc(50%);
|
|
152
|
+
height: calc(50%);
|
|
117
153
|
fill: colors.$basic-gray24;
|
|
118
154
|
}
|
|
119
155
|
}
|
|
@@ -122,12 +158,10 @@
|
|
|
122
158
|
display: flex;
|
|
123
159
|
align-items: center;
|
|
124
160
|
justify-content: center;
|
|
125
|
-
.cross {
|
|
126
|
-
fill: colors.$basic-gray24;
|
|
127
|
-
}
|
|
128
161
|
}
|
|
129
162
|
|
|
130
163
|
.text {
|
|
164
|
+
border-radius: inherit;
|
|
131
165
|
padding: var(--modifier-padding);
|
|
132
166
|
display: block;
|
|
133
167
|
max-width: 100%;
|
|
@@ -162,11 +196,11 @@
|
|
|
162
196
|
position: absolute;
|
|
163
197
|
bottom: 0;
|
|
164
198
|
right: 0;
|
|
165
|
-
width:
|
|
166
|
-
height:
|
|
199
|
+
width: var(--corner-size);
|
|
200
|
+
height: var(--corner-size);
|
|
167
201
|
border-bottom-right-radius: inherit;
|
|
168
|
-
font-size:
|
|
169
|
-
line-height:
|
|
202
|
+
font-size: var(--corner-font-size);
|
|
203
|
+
line-height: var(--corner-line-height);
|
|
170
204
|
padding-right: 2px;
|
|
171
205
|
display: flex;
|
|
172
206
|
justify-content: flex-end;
|
|
@@ -19,10 +19,12 @@ export interface ModifierProps extends Omit<AnchorHTMLAttributes<HTMLAnchorEleme
|
|
|
19
19
|
disabled?: boolean;
|
|
20
20
|
/** Вывести зачеркнутым. */
|
|
21
21
|
crossedOut?: boolean;
|
|
22
|
+
/** Вывести несуществующим. */
|
|
23
|
+
nonExistent?: boolean;
|
|
22
24
|
/** Содержимое. */
|
|
23
25
|
content: ModifierContent;
|
|
24
26
|
/** Высота по дизайн-гайдам. */
|
|
25
|
-
size?: 's' | 'm';
|
|
27
|
+
size?: 'xs' | 's' | 'm';
|
|
26
28
|
/** Кол-во. */
|
|
27
29
|
count?: number;
|
|
28
30
|
/** Выводить ли ярлык уценки. */
|
|
@@ -35,10 +35,10 @@ const Estimate = ({ dueDate }) => {
|
|
|
35
35
|
const text = [date_fns_1.getDate, (d) => (0, date_fns_1.getMonth)(d) + 1, date_fns_1.getYear]
|
|
36
36
|
.map(fn => toTimePart(fn(dueDate)))
|
|
37
37
|
.join('.');
|
|
38
|
-
content =
|
|
38
|
+
content = `до ${text}`;
|
|
39
39
|
}
|
|
40
40
|
else {
|
|
41
|
-
content =
|
|
41
|
+
content = `до ${(0, date_fns_1.getDate)(dueDate)} ${MONTH_SHORT_NAME[(0, date_fns_1.getMonth)(dueDate)]}`;
|
|
42
42
|
}
|
|
43
43
|
return (0, jsx_runtime_1.jsx)(jsx_runtime_1.Fragment, { children: content });
|
|
44
44
|
};
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { HTMLAttributes } from 'react';
|
|
2
|
-
import { PromotionType } from './types';
|
|
3
2
|
export interface PromotionCardProps extends HTMLAttributes<HTMLDivElement> {
|
|
4
3
|
/** Ссылка, переход по которой будет произведён при нажатии на карточку. */
|
|
5
4
|
href?: string;
|
|
@@ -7,14 +6,14 @@ export interface PromotionCardProps extends HTMLAttributes<HTMLDivElement> {
|
|
|
7
6
|
title: string;
|
|
8
7
|
/** Подзаголовок. */
|
|
9
8
|
subtitle?: string;
|
|
10
|
-
/**
|
|
11
|
-
|
|
9
|
+
/** Название акции. */
|
|
10
|
+
name?: string;
|
|
12
11
|
/** Путь к изображению для баннера. */
|
|
13
12
|
imageSrc: string;
|
|
14
13
|
/** Дата окончания акции. */
|
|
15
14
|
dueDate: Date;
|
|
16
15
|
/** Тип акции. */
|
|
17
|
-
|
|
16
|
+
type?: string;
|
|
18
17
|
/** Скидка за объем, указывается при соответствующем типе акции. */
|
|
19
18
|
volumeDiscount?: number;
|
|
20
19
|
/** Идентификатор для систем автоматизированного тестирования. */
|
|
@@ -26,7 +25,7 @@ export interface PromotionCardProps extends HTMLAttributes<HTMLDivElement> {
|
|
|
26
25
|
* @return Элемент.
|
|
27
26
|
*/
|
|
28
27
|
export declare const PromotionCard: {
|
|
29
|
-
({
|
|
28
|
+
({ type, href, imageSrc, title, subtitle, dueDate, volumeDiscount, name, className, "data-testid": testId, ...restProps }: PromotionCardProps): import("react/jsx-runtime").JSX.Element;
|
|
30
29
|
/** @deprecated Лучше использовать прямой импорт PromotionCardPlaceholder. */
|
|
31
30
|
Placeholder: (props: import("./placeholder").PromotionCardPlaceholderProps) => import("react/jsx-runtime").JSX.Element;
|
|
32
31
|
};
|
|
@@ -8,22 +8,27 @@ const jsx_runtime_1 = require("react/jsx-runtime");
|
|
|
8
8
|
const react_1 = require("react");
|
|
9
9
|
const banner_title_1 = require("./banner-title");
|
|
10
10
|
const estimate_1 = require("./estimate");
|
|
11
|
-
const Watch_1 = __importDefault(require("@sima-land/ui-quarks/icons/16x16/Stroked/Watch"));
|
|
12
11
|
const classnames_1 = __importDefault(require("classnames"));
|
|
13
12
|
const promotion_card_m_scss_1 = __importDefault(require("./promotion-card.m.scss"));
|
|
14
13
|
const placeholder_1 = require("./placeholder");
|
|
15
|
-
const
|
|
14
|
+
const KNOWN_NAME = {
|
|
16
15
|
gift: 'Подарок',
|
|
17
16
|
special: 'Спецпредложение',
|
|
18
17
|
'3-by-2': '3 по цене 2',
|
|
19
18
|
'volume-discount': 'Скидка за объём',
|
|
20
19
|
};
|
|
20
|
+
/**
|
|
21
|
+
* Проверяет тип акции.
|
|
22
|
+
* @param type Тип.
|
|
23
|
+
* @return Признак.
|
|
24
|
+
*/
|
|
25
|
+
const isKnownType = (type) => Boolean(type && Object.keys(KNOWN_NAME).includes(type));
|
|
21
26
|
/**
|
|
22
27
|
* Карточка акции.
|
|
23
28
|
* @param props Свойства.
|
|
24
29
|
* @return Элемент.
|
|
25
30
|
*/
|
|
26
|
-
const PromotionCard = ({
|
|
31
|
+
const PromotionCard = ({ type, href, imageSrc, title, subtitle, dueDate, volumeDiscount, name = isKnownType(type) ? KNOWN_NAME[type] : undefined,
|
|
27
32
|
// div props
|
|
28
33
|
className, 'data-testid': testId = 'promotion-card', ...restProps }) => {
|
|
29
34
|
// время нужно выводить только на клиенте - вводим состояние
|
|
@@ -31,7 +36,7 @@ className, 'data-testid': testId = 'promotion-card', ...restProps }) => {
|
|
|
31
36
|
(0, react_1.useEffect)(() => {
|
|
32
37
|
setMounted(true);
|
|
33
38
|
}, []);
|
|
34
|
-
return ((0, jsx_runtime_1.jsx)("div", { className: (0, classnames_1.default)(className, promotion_card_m_scss_1.default.root), ...restProps, "data-testid": testId, children: (0, jsx_runtime_1.jsxs)("a", { href: href, className: promotion_card_m_scss_1.default.link, children: [(0, jsx_runtime_1.jsxs)("div", { className: promotion_card_m_scss_1.default.banner, children: [(0, jsx_runtime_1.jsx)("img", { src: imageSrc, alt: title, className: promotion_card_m_scss_1.default.image }),
|
|
39
|
+
return ((0, jsx_runtime_1.jsx)("div", { className: (0, classnames_1.default)(className, promotion_card_m_scss_1.default.root), ...restProps, "data-testid": testId, children: (0, jsx_runtime_1.jsxs)("a", { href: href, className: promotion_card_m_scss_1.default.link, children: [(0, jsx_runtime_1.jsxs)("div", { className: promotion_card_m_scss_1.default.banner, children: [(0, jsx_runtime_1.jsx)("img", { src: imageSrc, alt: title, className: promotion_card_m_scss_1.default.image }), isKnownType(type) && type !== 'gift' && (mounted || type !== 'special') && ((0, jsx_runtime_1.jsx)("div", { className: promotion_card_m_scss_1.default['banner-content'], children: (0, jsx_runtime_1.jsx)(banner_title_1.BannerTitle, { promotionType: type, volumeDiscount: volumeDiscount, dueDate: dueDate }) }))] }), (0, jsx_runtime_1.jsxs)("div", { className: promotion_card_m_scss_1.default.info, children: [(0, jsx_runtime_1.jsxs)("div", { className: promotion_card_m_scss_1.default.header, children: [(0, jsx_runtime_1.jsx)("h4", { className: promotion_card_m_scss_1.default.title, children: title }), subtitle && (0, jsx_runtime_1.jsx)("p", { className: promotion_card_m_scss_1.default.subtitle, children: subtitle })] }), (0, jsx_runtime_1.jsxs)("div", { className: promotion_card_m_scss_1.default.footer, children: [name && ((0, jsx_runtime_1.jsx)("div", { "data-testid": 'promotion-card:name', className: promotion_card_m_scss_1.default.name, children: name })), mounted && ((0, jsx_runtime_1.jsx)("time", { "data-testid": 'promotion-card:due-date', children: (0, jsx_runtime_1.jsx)(estimate_1.Estimate, { dueDate: dueDate }) }))] })] })] }) }));
|
|
35
40
|
};
|
|
36
41
|
exports.PromotionCard = PromotionCard;
|
|
37
42
|
/** @deprecated Лучше использовать прямой импорт PromotionCardPlaceholder. */
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"promotion-card.js","sourceRoot":"","sources":["../../../../src/desktop/components/promotion-card/promotion-card.tsx"],"names":[],"mappings":";;;;;;;AAAA,iCAA4D;AAE5D,iDAA6C;AAC7C,yCAAsC;AACtC,
|
|
1
|
+
{"version":3,"file":"promotion-card.js","sourceRoot":"","sources":["../../../../src/desktop/components/promotion-card/promotion-card.tsx"],"names":[],"mappings":";;;;;;;AAAA,iCAA4D;AAE5D,iDAA6C;AAC7C,yCAAsC;AACtC,4DAAoC;AACpC,oFAA6C;AAC7C,+CAAyD;AA+BzD,MAAM,UAAU,GAA4C;IAC1D,IAAI,EAAE,SAAS;IACf,OAAO,EAAE,iBAAiB;IAC1B,QAAQ,EAAE,aAAa;IACvB,iBAAiB,EAAE,iBAAiB;CACrC,CAAC;AAEF;;;;GAIG;AACH,MAAM,WAAW,GAAG,CAAC,IAAa,EAAyB,EAAE,CAC3D,OAAO,CAAC,IAAI,IAAI,MAAM,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC,CAAC;AAE1D;;;;GAIG;AACI,MAAM,aAAa,GAAG,CAAC,EAC5B,IAAI,EACJ,IAAI,EACJ,QAAQ,EACR,KAAK,EACL,QAAQ,EACR,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E,+BAAM,CAAC,QAAQ,YAAG,QAAQ,GAAK,IACtD,EAEN,iCAAK,SAAS,EAAE,+BAAM,CAAC,MAAM,aAC1B,IAAI,IAAI,CACP,+CAAiB,qBAAqB,EAAC,SAAS,EAAE,+BAAM,CAAC,IAAI,YAC1D,IAAI,GACD,CACP,EAEA,OAAO,IAAI,CACV,gDAAkB,yBAAyB,YACzC,uBAAC,mBAAQ,IAAC,OAAO,EAAE,OAAO,GAAI,GACzB,CACR,IACG,IACF,IACJ,GACA,CACP,CAAC;AACJ,CAAC,CAAC;AA3DW,QAAA,aAAa,iBA2DxB;AAEF,6EAA6E;AAC7E,qBAAa,CAAC,WAAW,GAAG,sCAAwB,CAAC"}
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
@use 'pkg:@sima-land/ui-nucleons/colors.scss';
|
|
2
|
-
@use 'pkg:@sima-land/ui-nucleons/breakpoints.scss';
|
|
3
2
|
@use 'pkg:@sima-land/ui-nucleons/shadows.scss';
|
|
4
3
|
@use './_variables';
|
|
5
4
|
|
|
@@ -20,7 +19,9 @@
|
|
|
20
19
|
}
|
|
21
20
|
|
|
22
21
|
.link {
|
|
23
|
-
display:
|
|
22
|
+
display: flex;
|
|
23
|
+
flex-direction: column;
|
|
24
|
+
height: 100%;
|
|
24
25
|
text-decoration: none;
|
|
25
26
|
}
|
|
26
27
|
|
|
@@ -55,19 +56,19 @@
|
|
|
55
56
|
font-size: 48px;
|
|
56
57
|
line-height: 60px;
|
|
57
58
|
color: colors.$basic-gray76;
|
|
58
|
-
padding:
|
|
59
|
-
@include breakpoints.down('xs') {
|
|
60
|
-
padding: 16px;
|
|
61
|
-
}
|
|
59
|
+
padding: 8px 16px;
|
|
62
60
|
}
|
|
63
61
|
|
|
64
62
|
.info {
|
|
63
|
+
display: flex;
|
|
64
|
+
flex-direction: column;
|
|
65
|
+
flex-grow: 1;
|
|
65
66
|
padding: 16px;
|
|
66
67
|
color: colors.$basic-gray87;
|
|
67
68
|
}
|
|
68
69
|
|
|
69
70
|
.header {
|
|
70
|
-
|
|
71
|
+
flex-grow: 1;
|
|
71
72
|
}
|
|
72
73
|
|
|
73
74
|
.title {
|
|
@@ -85,7 +86,7 @@
|
|
|
85
86
|
font-size: 14px;
|
|
86
87
|
line-height: 20px;
|
|
87
88
|
color: colors.$basic-gray38;
|
|
88
|
-
margin
|
|
89
|
+
margin: 4px 0 0;
|
|
89
90
|
display: -webkit-box;
|
|
90
91
|
-webkit-line-clamp: 2;
|
|
91
92
|
-webkit-box-orient: vertical;
|
|
@@ -94,28 +95,16 @@
|
|
|
94
95
|
|
|
95
96
|
.footer {
|
|
96
97
|
display: flex;
|
|
97
|
-
|
|
98
|
+
white-space: nowrap;
|
|
98
99
|
margin-top: 16px;
|
|
99
100
|
font-weight: 600;
|
|
100
101
|
font-size: 14px;
|
|
101
102
|
line-height: 20px;
|
|
102
103
|
}
|
|
103
104
|
|
|
104
|
-
.
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
.timer-svg {
|
|
111
|
-
fill: currentColor;
|
|
112
|
-
margin-right: 8px;
|
|
113
|
-
@include breakpoints.down('xs') {
|
|
114
|
-
display: none;
|
|
115
|
-
}
|
|
116
|
-
}
|
|
117
|
-
|
|
118
|
-
.postfix {
|
|
119
|
-
margin-left: auto;
|
|
120
|
-
padding-left: 16px;
|
|
105
|
+
.name {
|
|
106
|
+
margin-right: auto;
|
|
107
|
+
padding-right: 8px;
|
|
108
|
+
text-overflow: ellipsis;
|
|
109
|
+
overflow: hidden;
|
|
121
110
|
}
|
package/package.json
CHANGED