@megafon/ui-core 3.2.0 → 3.3.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,23 @@
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
+ # [3.3.0](https://github.com/MegafonWebLab/megafon-ui/compare/@megafon/ui-core@3.2.0...@megafon/ui-core@3.3.0) (2022-03-14)
7
+
8
+
9
+ ### Bug Fixes
10
+
11
+ * **accordion:** remove outline for safari ([787b572](https://github.com/MegafonWebLab/megafon-ui/commit/787b5725ef962637401a0a3a1a8ae7ba0cece031))
12
+
13
+
14
+ ### Features
15
+
16
+ * **badges:** add new component PriceBadge ([9214baa](https://github.com/MegafonWebLab/megafon-ui/commit/9214baab003f958b916b728cf07e6f9db15173dd))
17
+ * **badges:** add new component PromoBadge ([6e550a0](https://github.com/MegafonWebLab/megafon-ui/commit/6e550a06fd2d0fb7b3dba488702f4a34f4f6d101))
18
+
19
+
20
+
21
+
22
+
6
23
  # [3.2.0](https://github.com/MegafonWebLab/megafon-ui/compare/@megafon/ui-core@3.1.0...@megafon/ui-core@3.2.0) (2022-02-28)
7
24
 
8
25
 
@@ -32,6 +32,7 @@
32
32
  right: 20px;
33
33
  width: 32px;
34
34
  height: 32px;
35
+ outline: none;
35
36
  -webkit-transform: translateY(-50%);
36
37
  transform: translateY(-50%);
37
38
  opacity: 1;
@@ -0,0 +1,70 @@
1
+ .mfui-price-badge {
2
+ font-size: 12px;
3
+ line-height: 16px;
4
+ display: -webkit-box;
5
+ display: -ms-flexbox;
6
+ display: flex;
7
+ -webkit-box-align: center;
8
+ -ms-flex-align: center;
9
+ align-items: center;
10
+ padding: 4px;
11
+ padding-right: 8px;
12
+ width: -webkit-fit-content;
13
+ width: -moz-fit-content;
14
+ width: fit-content;
15
+ height: 24px;
16
+ border-radius: 8px;
17
+ }
18
+ @media screen and (min-width: 1024px) {
19
+ .mfui-price-badge_adaptive {
20
+ font-size: 15px;
21
+ line-height: 24px;
22
+ padding: 4px 8px;
23
+ height: 32px;
24
+ border-radius: 12px;
25
+ }
26
+ }
27
+ .mfui-price-badge_theme_grey {
28
+ background-color: var(--spbSky0);
29
+ }
30
+ .mfui-price-badge_theme_grey .mfui-price-badge__text {
31
+ color: var(--spbSky3);
32
+ }
33
+ .mfui-price-badge_theme_grey .mfui-price-badge__icon {
34
+ fill: var(--spbSky3);
35
+ }
36
+ .mfui-price-badge_theme_orange {
37
+ background-color: var(--137C20);
38
+ }
39
+ .mfui-price-badge_theme_orange .mfui-price-badge__text {
40
+ color: var(--137C);
41
+ }
42
+ .mfui-price-badge_theme_orange .mfui-price-badge__icon {
43
+ fill: var(--137C);
44
+ }
45
+ .mfui-price-badge_theme_green {
46
+ background-color: var(--brandGreen20);
47
+ }
48
+ .mfui-price-badge_theme_green .mfui-price-badge__text {
49
+ color: var(--brandGreen);
50
+ }
51
+ .mfui-price-badge_theme_green .mfui-price-badge__icon {
52
+ fill: var(--brandGreen);
53
+ }
54
+ .mfui-price-badge_theme_red {
55
+ background-color: var(--fury20);
56
+ }
57
+ .mfui-price-badge_theme_red .mfui-price-badge__text {
58
+ color: var(--fury);
59
+ }
60
+ .mfui-price-badge_theme_red .mfui-price-badge__icon {
61
+ fill: var(--fury);
62
+ }
63
+ .mfui-price-badge__text {
64
+ font-family: inherit;
65
+ margin-left: 4px;
66
+ }
67
+ .mfui-price-badge__icon {
68
+ height: 20px;
69
+ width: 20px;
70
+ }
@@ -0,0 +1,33 @@
1
+ import * as React from 'react';
2
+ import './PriceBadge.less';
3
+ export declare const PriceBadgeTheme: {
4
+ readonly RED: "red";
5
+ readonly GREY: "grey";
6
+ readonly GREEN: "green";
7
+ readonly ORANGE: "orange";
8
+ };
9
+ export declare const PriceBadgeIcon: {
10
+ readonly TIMER: "timer";
11
+ readonly PRICE: "price";
12
+ readonly CHECK: "check";
13
+ readonly ATTENTION: "attention";
14
+ };
15
+ declare type PriceBadgeThemeType = typeof PriceBadgeTheme[keyof typeof PriceBadgeTheme];
16
+ declare type PriceBadgeIconType = typeof PriceBadgeIcon[keyof typeof PriceBadgeIcon];
17
+ export interface IPriceBadgeProps {
18
+ /** Адаптивный режим */
19
+ isAdaptive?: boolean;
20
+ /** Тип иконки */
21
+ iconType?: PriceBadgeIconType;
22
+ /** Цветовая тема */
23
+ theme?: PriceBadgeThemeType;
24
+ /** Дополнительный класс корневого элемента */
25
+ className?: string;
26
+ /** Дополнительные data-атрибуты к внутренним элементам */
27
+ dataAttrs?: {
28
+ root?: Record<string, string>;
29
+ };
30
+ children: JSX.Element[] | Element[] | JSX.Element | Element | string;
31
+ }
32
+ declare const PriceBadge: React.FC<IPriceBadgeProps>;
33
+ export default PriceBadge;
@@ -0,0 +1,113 @@
1
+ import "core-js/modules/es.object.values";
2
+ import _extends from "@babel/runtime/helpers/extends";
3
+ import * as React from 'react';
4
+ import { cnCreate, filterDataAttrs } from '@megafon/ui-helpers';
5
+ import * as PropTypes from 'prop-types';
6
+ import "./PriceBadge.css";
7
+
8
+ var AttentionIcon = function AttentionIcon(props) {
9
+ return /*#__PURE__*/React.createElement("svg", _extends({
10
+ viewBox: "0 0 20 20"
11
+ }, props), /*#__PURE__*/React.createElement("path", {
12
+ d: "M10 2c4.4 0 8 3.6 8 8s-3.6 8-8 8-8-3.6-8-8 3.6-8 8-8zm0 13c.3 0 .5-.1.7-.3.2-.2.3-.4.3-.7s-.1-.5-.3-.7c-.2-.2-.5-.3-.7-.3s-.5.1-.7.3c-.2.2-.3.4-.3.7s.1.5.3.7.5.3.7.3zM9 5v6h2V5H9z"
13
+ }));
14
+ };
15
+
16
+ var CheckIcon = function CheckIcon(props) {
17
+ return /*#__PURE__*/React.createElement("svg", _extends({
18
+ viewBox: "0 0 20 20"
19
+ }, props), /*#__PURE__*/React.createElement("path", {
20
+ fillRule: "evenodd",
21
+ clipRule: "evenodd",
22
+ d: "M10 18a8 8 0 100-16 8 8 0 000 16zM7.295 9.467l1.77 1.77 3.66-5.22 1.31.918-4.745 6.79-3.126-3.127 1.131-1.13z"
23
+ }));
24
+ };
25
+
26
+ var PriceIcon = function PriceIcon(props) {
27
+ return /*#__PURE__*/React.createElement("svg", _extends({
28
+ viewBox: "0 0 20 20"
29
+ }, props), /*#__PURE__*/React.createElement("path", {
30
+ fillRule: "evenodd",
31
+ clipRule: "evenodd",
32
+ d: "M10 18a8 8 0 100-16 8 8 0 000 16zM7.75 5.75H11a2.75 2.75 0 010 5.5H9.25V12h3v1.5h-3v1.75h-1.5V13.5h-1V12h1v-.75h-1v-1.5h1v-4zM11 7.25H9.25v2.5H11a1.25 1.25 0 000-2.5z"
33
+ }));
34
+ };
35
+
36
+ var TimerIcon = function TimerIcon(props) {
37
+ return /*#__PURE__*/React.createElement("svg", _extends({
38
+ viewBox: "0 0 20 20"
39
+ }, props), /*#__PURE__*/React.createElement("path", {
40
+ fillRule: "evenodd",
41
+ clipRule: "evenodd",
42
+ d: "M10 18a8 8 0 100-16 8 8 0 000 16zm1-8.414V5H9v5.414l3 3L13.414 12 11 9.586z"
43
+ }));
44
+ };
45
+
46
+ export var PriceBadgeTheme = {
47
+ RED: 'red',
48
+ GREY: 'grey',
49
+ GREEN: 'green',
50
+ ORANGE: 'orange'
51
+ };
52
+ export var PriceBadgeIcon = {
53
+ TIMER: 'timer',
54
+ PRICE: 'price',
55
+ CHECK: 'check',
56
+ ATTENTION: 'attention'
57
+ };
58
+
59
+ var getPriceBadgeIcon = function getPriceBadgeIcon(iconType) {
60
+ switch (iconType) {
61
+ case PriceBadgeIcon.TIMER:
62
+ return TimerIcon;
63
+
64
+ case PriceBadgeIcon.PRICE:
65
+ return PriceIcon;
66
+
67
+ case PriceBadgeIcon.CHECK:
68
+ return CheckIcon;
69
+
70
+ case PriceBadgeIcon.ATTENTION:
71
+ return AttentionIcon;
72
+
73
+ default:
74
+ return TimerIcon;
75
+ }
76
+ };
77
+
78
+ var cn = cnCreate('mfui-price-badge');
79
+
80
+ var PriceBadge = function PriceBadge(_ref) {
81
+ var _ref$iconType = _ref.iconType,
82
+ iconType = _ref$iconType === void 0 ? 'timer' : _ref$iconType,
83
+ _ref$isAdaptive = _ref.isAdaptive,
84
+ isAdaptive = _ref$isAdaptive === void 0 ? false : _ref$isAdaptive,
85
+ _ref$theme = _ref.theme,
86
+ theme = _ref$theme === void 0 ? 'grey' : _ref$theme,
87
+ className = _ref.className,
88
+ dataAttrs = _ref.dataAttrs,
89
+ children = _ref.children;
90
+ var Icon = getPriceBadgeIcon(iconType);
91
+ return /*#__PURE__*/React.createElement("div", _extends({}, filterDataAttrs(dataAttrs === null || dataAttrs === void 0 ? void 0 : dataAttrs.root), {
92
+ className: cn({
93
+ theme: theme,
94
+ adaptive: isAdaptive
95
+ }, className)
96
+ }), /*#__PURE__*/React.createElement(Icon, {
97
+ className: cn('icon')
98
+ }), /*#__PURE__*/React.createElement("span", {
99
+ className: cn('text')
100
+ }, children));
101
+ };
102
+
103
+ PriceBadge.propTypes = {
104
+ isAdaptive: PropTypes.bool,
105
+ iconType: PropTypes.oneOf(Object.values(PriceBadgeIcon)),
106
+ theme: PropTypes.oneOf(Object.values(PriceBadgeTheme)),
107
+ className: PropTypes.string,
108
+ dataAttrs: PropTypes.shape({
109
+ root: PropTypes.objectOf(PropTypes.string.isRequired).isRequired
110
+ }),
111
+ children: PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.element.isRequired), PropTypes.element, PropTypes.string]).isRequired
112
+ };
113
+ export default PriceBadge;
@@ -0,0 +1,32 @@
1
+ .mfui-promo-badge {
2
+ display: -webkit-box;
3
+ display: -ms-flexbox;
4
+ display: flex;
5
+ -webkit-box-align: center;
6
+ -ms-flex-align: center;
7
+ align-items: center;
8
+ padding: 4px 12px;
9
+ width: -webkit-fit-content;
10
+ width: -moz-fit-content;
11
+ width: fit-content;
12
+ border-radius: 8px;
13
+ color: var(--base);
14
+ }
15
+ .mfui-promo-badge_type_hit {
16
+ background-color: var(--warmRedC);
17
+ }
18
+ .mfui-promo-badge_type_new {
19
+ background-color: var(--systemBlue);
20
+ }
21
+ .mfui-promo-badge_type_popular {
22
+ background-color: var(--137C);
23
+ }
24
+ .mfui-promo-badge_type_user-choice {
25
+ background-color: var(--reflexBlue);
26
+ }
27
+ .mfui-promo-badge__text {
28
+ font-family: inherit;
29
+ font-size: 12px;
30
+ line-height: 16px;
31
+ font-weight: 500;
32
+ }
@@ -0,0 +1,22 @@
1
+ import * as React from 'react';
2
+ import './PromoBadge.less';
3
+ export declare const PromoBadgeTypes: {
4
+ readonly HIT: "hit";
5
+ readonly NEW: "new";
6
+ readonly POPULAR: "popular";
7
+ readonly USER_CHOICE: "user-choice";
8
+ };
9
+ declare type PromoBadgeTypesType = typeof PromoBadgeTypes[keyof typeof PromoBadgeTypes];
10
+ export interface IPromoBadgeProps {
11
+ /** Тип промо-бэйджа */
12
+ type?: PromoBadgeTypesType;
13
+ /** Дополнительный класс корневого элемента */
14
+ className?: string;
15
+ /** Дополнительные data-атрибуты к внутренним элементам */
16
+ dataAttrs?: {
17
+ root?: Record<string, string>;
18
+ };
19
+ children: JSX.Element[] | Element[] | JSX.Element | Element | string;
20
+ }
21
+ declare const PromoBadge: React.FC<IPromoBadgeProps>;
22
+ export default PromoBadge;
@@ -0,0 +1,38 @@
1
+ import "core-js/modules/es.object.values";
2
+ import _extends from "@babel/runtime/helpers/extends";
3
+ import * as React from 'react';
4
+ import { cnCreate, filterDataAttrs } from '@megafon/ui-helpers';
5
+ import * as PropTypes from 'prop-types';
6
+ import "./PromoBadge.css";
7
+ export var PromoBadgeTypes = {
8
+ HIT: 'hit',
9
+ NEW: 'new',
10
+ POPULAR: 'popular',
11
+ USER_CHOICE: 'user-choice'
12
+ };
13
+ var cn = cnCreate('mfui-promo-badge');
14
+
15
+ var PromoBadge = function PromoBadge(_ref) {
16
+ var _ref$type = _ref.type,
17
+ type = _ref$type === void 0 ? 'hit' : _ref$type,
18
+ className = _ref.className,
19
+ children = _ref.children,
20
+ dataAttrs = _ref.dataAttrs;
21
+ return /*#__PURE__*/React.createElement("div", _extends({}, filterDataAttrs(dataAttrs === null || dataAttrs === void 0 ? void 0 : dataAttrs.root), {
22
+ className: cn({
23
+ type: type
24
+ }, className)
25
+ }), /*#__PURE__*/React.createElement("span", {
26
+ className: cn('text')
27
+ }, children));
28
+ };
29
+
30
+ PromoBadge.propTypes = {
31
+ type: PropTypes.oneOf(Object.values(PromoBadgeTypes)),
32
+ className: PropTypes.string,
33
+ dataAttrs: PropTypes.shape({
34
+ root: PropTypes.objectOf(PropTypes.string.isRequired)
35
+ }),
36
+ children: PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.element.isRequired), PropTypes.element, PropTypes.string]).isRequired
37
+ };
38
+ export default PromoBadge;
@@ -28,6 +28,8 @@ export { default as PaginationButtons } from './components/Pagination/components
28
28
  export { default as PaginationNavigation } from './components/Pagination/components/PaginationNavigation/PaginationNavigation';
29
29
  export { default as Paragraph } from './components/Paragraph/Paragraph';
30
30
  export { default as Preloader } from './components/Preloader/Preloader';
31
+ export { default as PriceBadge } from './components/Badges/components/PriceBadge/PriceBadge';
32
+ export { default as PromoBadge } from './components/Badges/components/PromoBadge/PromoBadge';
31
33
  export { default as RadioButton } from './components/RadioButton/RadioButton';
32
34
  export { default as Search } from './components/Search/Search';
33
35
  export { default as Select } from './components/Select/Select';
package/dist/es/index.js CHANGED
@@ -28,6 +28,8 @@ export { default as PaginationButtons } from "./components/Pagination/components
28
28
  export { default as PaginationNavigation } from "./components/Pagination/components/PaginationNavigation/PaginationNavigation";
29
29
  export { default as Paragraph } from "./components/Paragraph/Paragraph";
30
30
  export { default as Preloader } from "./components/Preloader/Preloader";
31
+ export { default as PriceBadge } from "./components/Badges/components/PriceBadge/PriceBadge";
32
+ export { default as PromoBadge } from "./components/Badges/components/PromoBadge/PromoBadge";
31
33
  export { default as RadioButton } from "./components/RadioButton/RadioButton";
32
34
  export { default as Search } from "./components/Search/Search";
33
35
  export { default as Select } from "./components/Select/Select";
@@ -32,6 +32,7 @@
32
32
  right: 20px;
33
33
  width: 32px;
34
34
  height: 32px;
35
+ outline: none;
35
36
  -webkit-transform: translateY(-50%);
36
37
  transform: translateY(-50%);
37
38
  opacity: 1;
@@ -0,0 +1,70 @@
1
+ .mfui-price-badge {
2
+ font-size: 12px;
3
+ line-height: 16px;
4
+ display: -webkit-box;
5
+ display: -ms-flexbox;
6
+ display: flex;
7
+ -webkit-box-align: center;
8
+ -ms-flex-align: center;
9
+ align-items: center;
10
+ padding: 4px;
11
+ padding-right: 8px;
12
+ width: -webkit-fit-content;
13
+ width: -moz-fit-content;
14
+ width: fit-content;
15
+ height: 24px;
16
+ border-radius: 8px;
17
+ }
18
+ @media screen and (min-width: 1024px) {
19
+ .mfui-price-badge_adaptive {
20
+ font-size: 15px;
21
+ line-height: 24px;
22
+ padding: 4px 8px;
23
+ height: 32px;
24
+ border-radius: 12px;
25
+ }
26
+ }
27
+ .mfui-price-badge_theme_grey {
28
+ background-color: var(--spbSky0);
29
+ }
30
+ .mfui-price-badge_theme_grey .mfui-price-badge__text {
31
+ color: var(--spbSky3);
32
+ }
33
+ .mfui-price-badge_theme_grey .mfui-price-badge__icon {
34
+ fill: var(--spbSky3);
35
+ }
36
+ .mfui-price-badge_theme_orange {
37
+ background-color: var(--137C20);
38
+ }
39
+ .mfui-price-badge_theme_orange .mfui-price-badge__text {
40
+ color: var(--137C);
41
+ }
42
+ .mfui-price-badge_theme_orange .mfui-price-badge__icon {
43
+ fill: var(--137C);
44
+ }
45
+ .mfui-price-badge_theme_green {
46
+ background-color: var(--brandGreen20);
47
+ }
48
+ .mfui-price-badge_theme_green .mfui-price-badge__text {
49
+ color: var(--brandGreen);
50
+ }
51
+ .mfui-price-badge_theme_green .mfui-price-badge__icon {
52
+ fill: var(--brandGreen);
53
+ }
54
+ .mfui-price-badge_theme_red {
55
+ background-color: var(--fury20);
56
+ }
57
+ .mfui-price-badge_theme_red .mfui-price-badge__text {
58
+ color: var(--fury);
59
+ }
60
+ .mfui-price-badge_theme_red .mfui-price-badge__icon {
61
+ fill: var(--fury);
62
+ }
63
+ .mfui-price-badge__text {
64
+ font-family: inherit;
65
+ margin-left: 4px;
66
+ }
67
+ .mfui-price-badge__icon {
68
+ height: 20px;
69
+ width: 20px;
70
+ }
@@ -0,0 +1,33 @@
1
+ import * as React from 'react';
2
+ import './PriceBadge.less';
3
+ export declare const PriceBadgeTheme: {
4
+ readonly RED: "red";
5
+ readonly GREY: "grey";
6
+ readonly GREEN: "green";
7
+ readonly ORANGE: "orange";
8
+ };
9
+ export declare const PriceBadgeIcon: {
10
+ readonly TIMER: "timer";
11
+ readonly PRICE: "price";
12
+ readonly CHECK: "check";
13
+ readonly ATTENTION: "attention";
14
+ };
15
+ declare type PriceBadgeThemeType = typeof PriceBadgeTheme[keyof typeof PriceBadgeTheme];
16
+ declare type PriceBadgeIconType = typeof PriceBadgeIcon[keyof typeof PriceBadgeIcon];
17
+ export interface IPriceBadgeProps {
18
+ /** Адаптивный режим */
19
+ isAdaptive?: boolean;
20
+ /** Тип иконки */
21
+ iconType?: PriceBadgeIconType;
22
+ /** Цветовая тема */
23
+ theme?: PriceBadgeThemeType;
24
+ /** Дополнительный класс корневого элемента */
25
+ className?: string;
26
+ /** Дополнительные data-атрибуты к внутренним элементам */
27
+ dataAttrs?: {
28
+ root?: Record<string, string>;
29
+ };
30
+ children: JSX.Element[] | Element[] | JSX.Element | Element | string;
31
+ }
32
+ declare const PriceBadge: React.FC<IPriceBadgeProps>;
33
+ export default PriceBadge;
@@ -0,0 +1,134 @@
1
+ "use strict";
2
+
3
+ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
4
+
5
+ Object.defineProperty(exports, "__esModule", {
6
+ value: true
7
+ });
8
+ exports["default"] = exports.PriceBadgeIcon = exports.PriceBadgeTheme = void 0;
9
+
10
+ require("core-js/modules/es.object.values");
11
+
12
+ var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
13
+
14
+ var React = _interopRequireWildcard(require("react"));
15
+
16
+ var _uiHelpers = require("@megafon/ui-helpers");
17
+
18
+ var PropTypes = _interopRequireWildcard(require("prop-types"));
19
+
20
+ function _getRequireWildcardCache() { if (typeof WeakMap !== "function") return null; var cache = new WeakMap(); _getRequireWildcardCache = function _getRequireWildcardCache() { return cache; }; return cache; }
21
+
22
+ function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { "default": obj }; } var cache = _getRequireWildcardCache(); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj["default"] = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
23
+
24
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
25
+
26
+ var AttentionIcon = function AttentionIcon(props) {
27
+ return /*#__PURE__*/React.createElement("svg", (0, _extends2["default"])({
28
+ viewBox: "0 0 20 20"
29
+ }, props), /*#__PURE__*/React.createElement("path", {
30
+ d: "M10 2c4.4 0 8 3.6 8 8s-3.6 8-8 8-8-3.6-8-8 3.6-8 8-8zm0 13c.3 0 .5-.1.7-.3.2-.2.3-.4.3-.7s-.1-.5-.3-.7c-.2-.2-.5-.3-.7-.3s-.5.1-.7.3c-.2.2-.3.4-.3.7s.1.5.3.7.5.3.7.3zM9 5v6h2V5H9z"
31
+ }));
32
+ };
33
+
34
+ var CheckIcon = function CheckIcon(props) {
35
+ return /*#__PURE__*/React.createElement("svg", (0, _extends2["default"])({
36
+ viewBox: "0 0 20 20"
37
+ }, props), /*#__PURE__*/React.createElement("path", {
38
+ fillRule: "evenodd",
39
+ clipRule: "evenodd",
40
+ d: "M10 18a8 8 0 100-16 8 8 0 000 16zM7.295 9.467l1.77 1.77 3.66-5.22 1.31.918-4.745 6.79-3.126-3.127 1.131-1.13z"
41
+ }));
42
+ };
43
+
44
+ var PriceIcon = function PriceIcon(props) {
45
+ return /*#__PURE__*/React.createElement("svg", (0, _extends2["default"])({
46
+ viewBox: "0 0 20 20"
47
+ }, props), /*#__PURE__*/React.createElement("path", {
48
+ fillRule: "evenodd",
49
+ clipRule: "evenodd",
50
+ d: "M10 18a8 8 0 100-16 8 8 0 000 16zM7.75 5.75H11a2.75 2.75 0 010 5.5H9.25V12h3v1.5h-3v1.75h-1.5V13.5h-1V12h1v-.75h-1v-1.5h1v-4zM11 7.25H9.25v2.5H11a1.25 1.25 0 000-2.5z"
51
+ }));
52
+ };
53
+
54
+ var TimerIcon = function TimerIcon(props) {
55
+ return /*#__PURE__*/React.createElement("svg", (0, _extends2["default"])({
56
+ viewBox: "0 0 20 20"
57
+ }, props), /*#__PURE__*/React.createElement("path", {
58
+ fillRule: "evenodd",
59
+ clipRule: "evenodd",
60
+ d: "M10 18a8 8 0 100-16 8 8 0 000 16zm1-8.414V5H9v5.414l3 3L13.414 12 11 9.586z"
61
+ }));
62
+ };
63
+
64
+ var PriceBadgeTheme = {
65
+ RED: 'red',
66
+ GREY: 'grey',
67
+ GREEN: 'green',
68
+ ORANGE: 'orange'
69
+ };
70
+ exports.PriceBadgeTheme = PriceBadgeTheme;
71
+ var PriceBadgeIcon = {
72
+ TIMER: 'timer',
73
+ PRICE: 'price',
74
+ CHECK: 'check',
75
+ ATTENTION: 'attention'
76
+ };
77
+ exports.PriceBadgeIcon = PriceBadgeIcon;
78
+
79
+ var getPriceBadgeIcon = function getPriceBadgeIcon(iconType) {
80
+ switch (iconType) {
81
+ case PriceBadgeIcon.TIMER:
82
+ return TimerIcon;
83
+
84
+ case PriceBadgeIcon.PRICE:
85
+ return PriceIcon;
86
+
87
+ case PriceBadgeIcon.CHECK:
88
+ return CheckIcon;
89
+
90
+ case PriceBadgeIcon.ATTENTION:
91
+ return AttentionIcon;
92
+
93
+ default:
94
+ return TimerIcon;
95
+ }
96
+ };
97
+
98
+ var cn = (0, _uiHelpers.cnCreate)('mfui-price-badge');
99
+
100
+ var PriceBadge = function PriceBadge(_ref) {
101
+ var _ref$iconType = _ref.iconType,
102
+ iconType = _ref$iconType === void 0 ? 'timer' : _ref$iconType,
103
+ _ref$isAdaptive = _ref.isAdaptive,
104
+ isAdaptive = _ref$isAdaptive === void 0 ? false : _ref$isAdaptive,
105
+ _ref$theme = _ref.theme,
106
+ theme = _ref$theme === void 0 ? 'grey' : _ref$theme,
107
+ className = _ref.className,
108
+ dataAttrs = _ref.dataAttrs,
109
+ children = _ref.children;
110
+ var Icon = getPriceBadgeIcon(iconType);
111
+ return /*#__PURE__*/React.createElement("div", (0, _extends2["default"])({}, (0, _uiHelpers.filterDataAttrs)(dataAttrs === null || dataAttrs === void 0 ? void 0 : dataAttrs.root), {
112
+ className: cn({
113
+ theme: theme,
114
+ adaptive: isAdaptive
115
+ }, className)
116
+ }), /*#__PURE__*/React.createElement(Icon, {
117
+ className: cn('icon')
118
+ }), /*#__PURE__*/React.createElement("span", {
119
+ className: cn('text')
120
+ }, children));
121
+ };
122
+
123
+ PriceBadge.propTypes = {
124
+ isAdaptive: PropTypes.bool,
125
+ iconType: PropTypes.oneOf(Object.values(PriceBadgeIcon)),
126
+ theme: PropTypes.oneOf(Object.values(PriceBadgeTheme)),
127
+ className: PropTypes.string,
128
+ dataAttrs: PropTypes.shape({
129
+ root: PropTypes.objectOf(PropTypes.string.isRequired).isRequired
130
+ }),
131
+ children: PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.element.isRequired), PropTypes.element, PropTypes.string]).isRequired
132
+ };
133
+ var _default = PriceBadge;
134
+ exports["default"] = _default;
@@ -0,0 +1,32 @@
1
+ .mfui-promo-badge {
2
+ display: -webkit-box;
3
+ display: -ms-flexbox;
4
+ display: flex;
5
+ -webkit-box-align: center;
6
+ -ms-flex-align: center;
7
+ align-items: center;
8
+ padding: 4px 12px;
9
+ width: -webkit-fit-content;
10
+ width: -moz-fit-content;
11
+ width: fit-content;
12
+ border-radius: 8px;
13
+ color: var(--base);
14
+ }
15
+ .mfui-promo-badge_type_hit {
16
+ background-color: var(--warmRedC);
17
+ }
18
+ .mfui-promo-badge_type_new {
19
+ background-color: var(--systemBlue);
20
+ }
21
+ .mfui-promo-badge_type_popular {
22
+ background-color: var(--137C);
23
+ }
24
+ .mfui-promo-badge_type_user-choice {
25
+ background-color: var(--reflexBlue);
26
+ }
27
+ .mfui-promo-badge__text {
28
+ font-family: inherit;
29
+ font-size: 12px;
30
+ line-height: 16px;
31
+ font-weight: 500;
32
+ }
@@ -0,0 +1,22 @@
1
+ import * as React from 'react';
2
+ import './PromoBadge.less';
3
+ export declare const PromoBadgeTypes: {
4
+ readonly HIT: "hit";
5
+ readonly NEW: "new";
6
+ readonly POPULAR: "popular";
7
+ readonly USER_CHOICE: "user-choice";
8
+ };
9
+ declare type PromoBadgeTypesType = typeof PromoBadgeTypes[keyof typeof PromoBadgeTypes];
10
+ export interface IPromoBadgeProps {
11
+ /** Тип промо-бэйджа */
12
+ type?: PromoBadgeTypesType;
13
+ /** Дополнительный класс корневого элемента */
14
+ className?: string;
15
+ /** Дополнительные data-атрибуты к внутренним элементам */
16
+ dataAttrs?: {
17
+ root?: Record<string, string>;
18
+ };
19
+ children: JSX.Element[] | Element[] | JSX.Element | Element | string;
20
+ }
21
+ declare const PromoBadge: React.FC<IPromoBadgeProps>;
22
+ export default PromoBadge;
@@ -0,0 +1,59 @@
1
+ "use strict";
2
+
3
+ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
4
+
5
+ Object.defineProperty(exports, "__esModule", {
6
+ value: true
7
+ });
8
+ exports["default"] = exports.PromoBadgeTypes = void 0;
9
+
10
+ require("core-js/modules/es.object.values");
11
+
12
+ var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
13
+
14
+ var React = _interopRequireWildcard(require("react"));
15
+
16
+ var _uiHelpers = require("@megafon/ui-helpers");
17
+
18
+ var PropTypes = _interopRequireWildcard(require("prop-types"));
19
+
20
+ function _getRequireWildcardCache() { if (typeof WeakMap !== "function") return null; var cache = new WeakMap(); _getRequireWildcardCache = function _getRequireWildcardCache() { return cache; }; return cache; }
21
+
22
+ function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { "default": obj }; } var cache = _getRequireWildcardCache(); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj["default"] = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
23
+
24
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
25
+
26
+ var PromoBadgeTypes = {
27
+ HIT: 'hit',
28
+ NEW: 'new',
29
+ POPULAR: 'popular',
30
+ USER_CHOICE: 'user-choice'
31
+ };
32
+ exports.PromoBadgeTypes = PromoBadgeTypes;
33
+ var cn = (0, _uiHelpers.cnCreate)('mfui-promo-badge');
34
+
35
+ var PromoBadge = function PromoBadge(_ref) {
36
+ var _ref$type = _ref.type,
37
+ type = _ref$type === void 0 ? 'hit' : _ref$type,
38
+ className = _ref.className,
39
+ children = _ref.children,
40
+ dataAttrs = _ref.dataAttrs;
41
+ return /*#__PURE__*/React.createElement("div", (0, _extends2["default"])({}, (0, _uiHelpers.filterDataAttrs)(dataAttrs === null || dataAttrs === void 0 ? void 0 : dataAttrs.root), {
42
+ className: cn({
43
+ type: type
44
+ }, className)
45
+ }), /*#__PURE__*/React.createElement("span", {
46
+ className: cn('text')
47
+ }, children));
48
+ };
49
+
50
+ PromoBadge.propTypes = {
51
+ type: PropTypes.oneOf(Object.values(PromoBadgeTypes)),
52
+ className: PropTypes.string,
53
+ dataAttrs: PropTypes.shape({
54
+ root: PropTypes.objectOf(PropTypes.string.isRequired)
55
+ }),
56
+ children: PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.element.isRequired), PropTypes.element, PropTypes.string]).isRequired
57
+ };
58
+ var _default = PromoBadge;
59
+ exports["default"] = _default;
@@ -28,6 +28,8 @@ export { default as PaginationButtons } from './components/Pagination/components
28
28
  export { default as PaginationNavigation } from './components/Pagination/components/PaginationNavigation/PaginationNavigation';
29
29
  export { default as Paragraph } from './components/Paragraph/Paragraph';
30
30
  export { default as Preloader } from './components/Preloader/Preloader';
31
+ export { default as PriceBadge } from './components/Badges/components/PriceBadge/PriceBadge';
32
+ export { default as PromoBadge } from './components/Badges/components/PromoBadge/PromoBadge';
31
33
  export { default as RadioButton } from './components/RadioButton/RadioButton';
32
34
  export { default as Search } from './components/Search/Search';
33
35
  export { default as Select } from './components/Select/Select';
package/dist/lib/index.js CHANGED
@@ -183,6 +183,18 @@ Object.defineProperty(exports, "Preloader", {
183
183
  return _Preloader["default"];
184
184
  }
185
185
  });
186
+ Object.defineProperty(exports, "PriceBadge", {
187
+ enumerable: true,
188
+ get: function get() {
189
+ return _PriceBadge["default"];
190
+ }
191
+ });
192
+ Object.defineProperty(exports, "PromoBadge", {
193
+ enumerable: true,
194
+ get: function get() {
195
+ return _PromoBadge["default"];
196
+ }
197
+ });
186
198
  Object.defineProperty(exports, "RadioButton", {
187
199
  enumerable: true,
188
200
  get: function get() {
@@ -316,6 +328,10 @@ var _Paragraph = _interopRequireDefault(require("./components/Paragraph/Paragrap
316
328
 
317
329
  var _Preloader = _interopRequireDefault(require("./components/Preloader/Preloader"));
318
330
 
331
+ var _PriceBadge = _interopRequireDefault(require("./components/Badges/components/PriceBadge/PriceBadge"));
332
+
333
+ var _PromoBadge = _interopRequireDefault(require("./components/Badges/components/PromoBadge/PromoBadge"));
334
+
319
335
  var _RadioButton = _interopRequireDefault(require("./components/RadioButton/RadioButton"));
320
336
 
321
337
  var _Search = _interopRequireDefault(require("./components/Search/Search"));
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@megafon/ui-core",
3
- "version": "3.2.0",
3
+ "version": "3.3.0",
4
4
  "files": [
5
5
  "dist",
6
6
  "styles"
@@ -54,7 +54,7 @@
54
54
  "@babel/preset-env": "^7.8.6",
55
55
  "@babel/preset-react": "^7.8.3",
56
56
  "@babel/preset-typescript": "^7.8.3",
57
- "@megafon/ui-icons": "^1.0.2",
57
+ "@megafon/ui-icons": "^1.1.0",
58
58
  "@svgr/core": "^2.4.1",
59
59
  "@testing-library/react-hooks": "^7.0.1",
60
60
  "@types/enzyme": "^3.10.5",
@@ -86,7 +86,7 @@
86
86
  "dependencies": {
87
87
  "@babel/runtime": "^7.8.4",
88
88
  "@datepicker-react/hooks": "^2.7.0",
89
- "@megafon/ui-helpers": "^2.0.1",
89
+ "@megafon/ui-helpers": "^2.1.0",
90
90
  "@popperjs/core": "^2.5.3",
91
91
  "core-js": "^3.6.4",
92
92
  "date-fns": "^2.16.1",
@@ -97,5 +97,5 @@
97
97
  "react-popper": "^2.2.3",
98
98
  "swiper": "^6.5.6"
99
99
  },
100
- "gitHead": "c0a542f967f26e925dfb99dd6e07a2df2e97be14"
100
+ "gitHead": "e1007fdaa6e0dd724388f6c5ebae4448cf2732c8"
101
101
  }