@snack-uikit/counter 0.4.1 → 0.6.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 +24 -1
- package/README.md +8 -7
- package/dist/components/Counter.d.ts +4 -7
- package/dist/components/Counter.js +3 -6
- package/dist/components/constants.d.ts +18 -14
- package/dist/components/constants.js +18 -17
- package/dist/components/styles.module.css +18 -3
- package/dist/components/types.d.ts +6 -0
- package/dist/components/types.js +1 -0
- package/dist/components/utils.d.ts +1 -1
- package/dist/components/utils.js +6 -6
- package/package.json +3 -3
- package/src/components/Counter.tsx +9 -8
- package/src/components/constants.ts +19 -14
- package/src/components/styles.module.scss +21 -5
- package/src/components/types.ts +8 -0
- package/src/components/utils.tsx +5 -4
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,28 @@
|
|
|
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.6.0 (2023-12-28)
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
### Features
|
|
10
|
+
|
|
11
|
+
* **FF-3960:** add new prop color ([3adaa4c](https://github.com/cloud-ru-tech/snack-uikit/commit/3adaa4c7cc3018607a50446caec2fb62dd680fd3))
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
# 0.5.0 (2023-12-14)
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
### BREAKING CHANGES
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
* **FF-3729:** replace enum with unions ([910db4a](https://github.com/cloud-ru-tech/snack-uikit/commit/910db4aa8231ccbc58e538e5c5c1f461b1dec275))
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
|
|
6
28
|
## 0.4.1 (2023-12-06)
|
|
7
29
|
|
|
8
30
|
### Only dependencies have been changed
|
|
@@ -122,7 +144,8 @@ See [Conventional Commits](https://conventionalcommits.org) for commit guideline
|
|
|
122
144
|
|
|
123
145
|
## 0.2.6 (2023-06-23)
|
|
124
146
|
|
|
125
|
-
|
|
147
|
+
### Only dependencies have been changed
|
|
148
|
+
* [@snack-uikit/utils@3.2.0](https://git.sbercloud.tech/sbercloud-ui/tokens-design-system/snack-uikit/-/blob/master/packages/utils/CHANGELOG.md)
|
|
126
149
|
|
|
127
150
|
|
|
128
151
|
|
package/README.md
CHANGED
|
@@ -8,17 +8,17 @@
|
|
|
8
8
|
## Example
|
|
9
9
|
|
|
10
10
|
```typescript jsx
|
|
11
|
-
import {Counter} from "@snack-uikit/counter";
|
|
11
|
+
import { Counter } from "@snack-uikit/counter";
|
|
12
12
|
|
|
13
13
|
<Counter
|
|
14
14
|
value={42}
|
|
15
|
-
size=
|
|
15
|
+
size='m'
|
|
16
16
|
/>
|
|
17
17
|
|
|
18
18
|
<Counter
|
|
19
19
|
value={101}
|
|
20
|
-
appearance=
|
|
21
|
-
variant=
|
|
20
|
+
appearance='critical'
|
|
21
|
+
variant='count-plus'
|
|
22
22
|
plusLimit={100}
|
|
23
23
|
/>
|
|
24
24
|
```
|
|
@@ -31,11 +31,12 @@ import {Counter} from "@snack-uikit/counter";
|
|
|
31
31
|
| name | type | default value | description |
|
|
32
32
|
|------|------|---------------|-------------|
|
|
33
33
|
| value* | `number` | - | Значение |
|
|
34
|
-
| appearance | enum Appearance: `"primary"`, `"neutral"`, `"red"` |
|
|
35
|
-
| variant | enum Variant: `"count"`, `"count-plus"`, `"count-k"` |
|
|
36
|
-
| size | enum Size: `"s"`, `"m"` |
|
|
34
|
+
| appearance | enum Appearance: `"primary"`, `"neutral"`, `"red"` | primary | Внешний вид |
|
|
35
|
+
| variant | enum Variant: `"count"`, `"count-plus"`, `"count-k"` | count | Вариант |
|
|
36
|
+
| size | enum Size: `"s"`, `"m"` | s | Размер |
|
|
37
37
|
| plusLimit | `number` | 10 | Порог сокращения значения в формат v+. Например `1500` -> `999+` для 1000 |
|
|
38
38
|
| className | `string` | - | CSS-класс |
|
|
39
|
+
| color | enum Color: `"accent"`, `"decor"` | accent | Семантический цвет |
|
|
39
40
|
|
|
40
41
|
|
|
41
42
|
[//]: DOCUMENTATION_SECTION_END
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { WithSupportProps } from '@snack-uikit/utils';
|
|
2
|
-
import { Appearance, Size, Variant } from './
|
|
2
|
+
import { Appearance, Color, Size, Variant } from './types';
|
|
3
3
|
export type CounterProps = WithSupportProps<{
|
|
4
4
|
/** Значение */
|
|
5
5
|
value: number;
|
|
@@ -13,11 +13,8 @@ export type CounterProps = WithSupportProps<{
|
|
|
13
13
|
plusLimit?: number;
|
|
14
14
|
/** CSS-класс */
|
|
15
15
|
className?: string;
|
|
16
|
+
/** Семантический цвет */
|
|
17
|
+
color?: Color;
|
|
16
18
|
}>;
|
|
17
19
|
/** Компонент счетчик */
|
|
18
|
-
export declare function Counter({ value, appearance, variant, size, plusLimit, className, ...rest }: CounterProps): import("react/jsx-runtime").JSX.Element;
|
|
19
|
-
export declare namespace Counter {
|
|
20
|
-
var appearances: typeof Appearance;
|
|
21
|
-
var variants: typeof Variant;
|
|
22
|
-
var sizes: typeof Size;
|
|
23
|
-
}
|
|
20
|
+
export declare function Counter({ value, appearance, variant, size, plusLimit, color, className, ...rest }: CounterProps): import("react/jsx-runtime").JSX.Element;
|
|
@@ -12,15 +12,12 @@ var __rest = (this && this.__rest) || function (s, e) {
|
|
|
12
12
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
13
13
|
import cn from 'classnames';
|
|
14
14
|
import { extractSupportProps } from '@snack-uikit/utils';
|
|
15
|
-
import {
|
|
15
|
+
import { APPEARANCE, COLOR, DEFAULT_PLUS_LIMIT, SIZE, VARIANT } from './constants';
|
|
16
16
|
import classNames from './styles.module.css';
|
|
17
17
|
import { formatValue } from './utils';
|
|
18
18
|
/** Компонент счетчик */
|
|
19
19
|
export function Counter(_a) {
|
|
20
|
-
var { value, appearance =
|
|
20
|
+
var { value, appearance = APPEARANCE.Primary, variant = VARIANT.Count, size = SIZE.S, plusLimit = DEFAULT_PLUS_LIMIT, color = COLOR.Accent, className } = _a, rest = __rest(_a, ["value", "appearance", "variant", "size", "plusLimit", "color", "className"]);
|
|
21
21
|
const formattedValue = formatValue({ value, variant, plusLimit });
|
|
22
|
-
return (_jsx("div", Object.assign({ className: cn(classNames.counter, className) }, extractSupportProps(rest), { "data-size": size, "data-variant": variant, "data-appearance": appearance
|
|
22
|
+
return (_jsx("div", Object.assign({ className: cn(classNames.counter, className) }, extractSupportProps(rest), { "data-size": size, "data-variant": variant, "data-appearance": appearance, "data-color": color, children: formattedValue })));
|
|
23
23
|
}
|
|
24
|
-
Counter.appearances = Appearance;
|
|
25
|
-
Counter.variants = Variant;
|
|
26
|
-
Counter.sizes = Size;
|
|
@@ -1,17 +1,21 @@
|
|
|
1
|
-
export declare
|
|
2
|
-
Primary
|
|
3
|
-
Neutral
|
|
4
|
-
Red
|
|
5
|
-
}
|
|
6
|
-
export declare
|
|
7
|
-
Count
|
|
8
|
-
CountPlus
|
|
9
|
-
CountK
|
|
10
|
-
}
|
|
11
|
-
export declare
|
|
12
|
-
S
|
|
13
|
-
M
|
|
14
|
-
}
|
|
1
|
+
export declare const APPEARANCE: {
|
|
2
|
+
readonly Primary: "primary";
|
|
3
|
+
readonly Neutral: "neutral";
|
|
4
|
+
readonly Red: "red";
|
|
5
|
+
};
|
|
6
|
+
export declare const VARIANT: {
|
|
7
|
+
readonly Count: "count";
|
|
8
|
+
readonly CountPlus: "count-plus";
|
|
9
|
+
readonly CountK: "count-k";
|
|
10
|
+
};
|
|
11
|
+
export declare const SIZE: {
|
|
12
|
+
readonly S: "s";
|
|
13
|
+
readonly M: "m";
|
|
14
|
+
};
|
|
15
|
+
export declare const COLOR: {
|
|
16
|
+
readonly Accent: "accent";
|
|
17
|
+
readonly Decor: "decor";
|
|
18
|
+
};
|
|
15
19
|
export declare const DEFAULT_PLUS_LIMIT = 10;
|
|
16
20
|
export declare const DEFAULT_KEY_LIMIT = 1000;
|
|
17
21
|
export declare const DEFAULT_KEY_POSTFIX = "K";
|
|
@@ -1,20 +1,21 @@
|
|
|
1
|
-
export
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
1
|
+
export const APPEARANCE = {
|
|
2
|
+
Primary: 'primary',
|
|
3
|
+
Neutral: 'neutral',
|
|
4
|
+
Red: 'red',
|
|
5
|
+
};
|
|
6
|
+
export const VARIANT = {
|
|
7
|
+
Count: 'count',
|
|
8
|
+
CountPlus: 'count-plus',
|
|
9
|
+
CountK: 'count-k',
|
|
10
|
+
};
|
|
11
|
+
export const SIZE = {
|
|
12
|
+
S: 's',
|
|
13
|
+
M: 'm',
|
|
14
|
+
};
|
|
15
|
+
export const COLOR = {
|
|
16
|
+
Accent: 'accent',
|
|
17
|
+
Decor: 'decor',
|
|
18
|
+
};
|
|
18
19
|
export const DEFAULT_PLUS_LIMIT = 10;
|
|
19
20
|
export const DEFAULT_KEY_LIMIT = 1000;
|
|
20
21
|
export const DEFAULT_KEY_POSTFIX = 'K';
|
|
@@ -7,21 +7,36 @@
|
|
|
7
7
|
width:max-content;
|
|
8
8
|
border:0 solid transparent;
|
|
9
9
|
}
|
|
10
|
-
.counter[data-appearance=primary]{
|
|
10
|
+
.counter[data-color=accent][data-appearance=primary]{
|
|
11
11
|
color:var(--sys-primary-on-accent, #fdfbff);
|
|
12
12
|
background-color:var(--sys-primary-accent-default, #794ed3);
|
|
13
13
|
border-color:var(--sys-neutral-background1-level, #f9f9f9);
|
|
14
14
|
}
|
|
15
|
-
.counter[data-appearance=neutral]{
|
|
15
|
+
.counter[data-color=accent][data-appearance=neutral]{
|
|
16
16
|
color:var(--sys-neutral-on-accent, #fdfdfd);
|
|
17
17
|
background-color:var(--sys-neutral-accent-default, #757575);
|
|
18
18
|
border-color:var(--sys-neutral-background1-level, #f9f9f9);
|
|
19
19
|
}
|
|
20
|
-
.counter[data-appearance=red]{
|
|
20
|
+
.counter[data-color=accent][data-appearance=red]{
|
|
21
21
|
color:var(--sys-red-on-accent, #fffbfa);
|
|
22
22
|
background-color:var(--sys-red-accent-default, #d93f2f);
|
|
23
23
|
border-color:var(--sys-neutral-background1-level, #f9f9f9);
|
|
24
24
|
}
|
|
25
|
+
.counter[data-color=decor][data-appearance=primary]{
|
|
26
|
+
color:var(--sys-primary-text-main, #382a62);
|
|
27
|
+
background-color:var(--sys-primary-decor-default, #ebdefd);
|
|
28
|
+
border-color:var(--sys-neutral-background1-level, #f9f9f9);
|
|
29
|
+
}
|
|
30
|
+
.counter[data-color=decor][data-appearance=neutral]{
|
|
31
|
+
color:var(--sys-neutral-text-main, #333333);
|
|
32
|
+
background-color:var(--sys-neutral-decor-default, #dedede);
|
|
33
|
+
border-color:var(--sys-neutral-background1-level, #f9f9f9);
|
|
34
|
+
}
|
|
35
|
+
.counter[data-color=decor][data-appearance=red]{
|
|
36
|
+
color:var(--sys-red-text-main, #621c1e);
|
|
37
|
+
background-color:var(--sys-red-decor-default, #ffd8d0);
|
|
38
|
+
border-color:var(--sys-neutral-background1-level, #f9f9f9);
|
|
39
|
+
}
|
|
25
40
|
.counter[data-size=s]{
|
|
26
41
|
font-family:var(--sans-label-s-font-family, SB Sans Interface);
|
|
27
42
|
font-weight:var(--sans-label-s-font-weight, Semibold);
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { ValueOf } from '@snack-uikit/utils';
|
|
2
|
+
import { APPEARANCE, COLOR, SIZE, VARIANT } from './constants';
|
|
3
|
+
export type Appearance = ValueOf<typeof APPEARANCE>;
|
|
4
|
+
export type Size = ValueOf<typeof SIZE>;
|
|
5
|
+
export type Variant = ValueOf<typeof VARIANT>;
|
|
6
|
+
export type Color = ValueOf<typeof COLOR>;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
package/dist/components/utils.js
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
-
import { DEFAULT_KEY_LIMIT, DEFAULT_KEY_POSTFIX,
|
|
2
|
+
import { DEFAULT_KEY_LIMIT, DEFAULT_KEY_POSTFIX, VARIANT } from './constants';
|
|
3
3
|
import styles from './styles.module.css';
|
|
4
4
|
export function formatValue({ value, variant, plusLimit, }) {
|
|
5
|
-
if (variant ===
|
|
5
|
+
if (variant === VARIANT.Count) {
|
|
6
6
|
return value;
|
|
7
7
|
}
|
|
8
|
-
if (variant ===
|
|
9
|
-
return value < plusLimit ? (value) : (_jsxs(_Fragment, { children: [plusLimit - 1, _jsx("span",
|
|
8
|
+
if (variant === VARIANT.CountPlus) {
|
|
9
|
+
return value < plusLimit ? (value) : (_jsxs(_Fragment, { children: [plusLimit - 1, _jsx("span", { className: styles.plus, children: "+" })] }));
|
|
10
10
|
}
|
|
11
|
-
if (variant ===
|
|
12
|
-
return value < DEFAULT_KEY_LIMIT ? (value) : (_jsxs(_Fragment, { children: [Math.round(value / DEFAULT_KEY_LIMIT), _jsx("span",
|
|
11
|
+
if (variant === VARIANT.CountK) {
|
|
12
|
+
return value < DEFAULT_KEY_LIMIT ? (value) : (_jsxs(_Fragment, { children: [Math.round(value / DEFAULT_KEY_LIMIT), _jsx("span", { className: styles.key, children: DEFAULT_KEY_POSTFIX })] }));
|
|
13
13
|
}
|
|
14
14
|
}
|
package/package.json
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
"access": "public"
|
|
5
5
|
},
|
|
6
6
|
"title": "Counter",
|
|
7
|
-
"version": "0.
|
|
7
|
+
"version": "0.6.0",
|
|
8
8
|
"sideEffects": [
|
|
9
9
|
"*.css",
|
|
10
10
|
"*.woff",
|
|
@@ -32,8 +32,8 @@
|
|
|
32
32
|
"license": "Apache-2.0",
|
|
33
33
|
"scripts": {},
|
|
34
34
|
"dependencies": {
|
|
35
|
-
"@snack-uikit/utils": "3.
|
|
35
|
+
"@snack-uikit/utils": "3.2.0",
|
|
36
36
|
"classnames": "2.3.2"
|
|
37
37
|
},
|
|
38
|
-
"gitHead": "
|
|
38
|
+
"gitHead": "57c597a3eebaf6528c0c61b6b27dd244753de1cf"
|
|
39
39
|
}
|
|
@@ -2,8 +2,9 @@ import cn from 'classnames';
|
|
|
2
2
|
|
|
3
3
|
import { extractSupportProps, WithSupportProps } from '@snack-uikit/utils';
|
|
4
4
|
|
|
5
|
-
import {
|
|
5
|
+
import { APPEARANCE, COLOR, DEFAULT_PLUS_LIMIT, SIZE, VARIANT } from './constants';
|
|
6
6
|
import classNames from './styles.module.scss';
|
|
7
|
+
import { Appearance, Color, Size, Variant } from './types';
|
|
7
8
|
import { formatValue } from './utils';
|
|
8
9
|
|
|
9
10
|
export type CounterProps = WithSupportProps<{
|
|
@@ -19,15 +20,18 @@ export type CounterProps = WithSupportProps<{
|
|
|
19
20
|
plusLimit?: number;
|
|
20
21
|
/** CSS-класс */
|
|
21
22
|
className?: string;
|
|
23
|
+
/** Семантический цвет */
|
|
24
|
+
color?: Color;
|
|
22
25
|
}>;
|
|
23
26
|
|
|
24
27
|
/** Компонент счетчик */
|
|
25
28
|
export function Counter({
|
|
26
29
|
value,
|
|
27
|
-
appearance =
|
|
28
|
-
variant =
|
|
29
|
-
size =
|
|
30
|
+
appearance = APPEARANCE.Primary,
|
|
31
|
+
variant = VARIANT.Count,
|
|
32
|
+
size = SIZE.S,
|
|
30
33
|
plusLimit = DEFAULT_PLUS_LIMIT,
|
|
34
|
+
color = COLOR.Accent,
|
|
31
35
|
className,
|
|
32
36
|
...rest
|
|
33
37
|
}: CounterProps) {
|
|
@@ -40,12 +44,9 @@ export function Counter({
|
|
|
40
44
|
data-size={size}
|
|
41
45
|
data-variant={variant}
|
|
42
46
|
data-appearance={appearance}
|
|
47
|
+
data-color={color}
|
|
43
48
|
>
|
|
44
49
|
{formattedValue}
|
|
45
50
|
</div>
|
|
46
51
|
);
|
|
47
52
|
}
|
|
48
|
-
|
|
49
|
-
Counter.appearances = Appearance;
|
|
50
|
-
Counter.variants = Variant;
|
|
51
|
-
Counter.sizes = Size;
|
|
@@ -1,19 +1,24 @@
|
|
|
1
|
-
export
|
|
2
|
-
Primary
|
|
3
|
-
Neutral
|
|
4
|
-
Red
|
|
5
|
-
}
|
|
1
|
+
export const APPEARANCE = {
|
|
2
|
+
Primary: 'primary',
|
|
3
|
+
Neutral: 'neutral',
|
|
4
|
+
Red: 'red',
|
|
5
|
+
} as const;
|
|
6
6
|
|
|
7
|
-
export
|
|
8
|
-
Count
|
|
9
|
-
CountPlus
|
|
10
|
-
CountK
|
|
11
|
-
}
|
|
7
|
+
export const VARIANT = {
|
|
8
|
+
Count: 'count',
|
|
9
|
+
CountPlus: 'count-plus',
|
|
10
|
+
CountK: 'count-k',
|
|
11
|
+
} as const;
|
|
12
12
|
|
|
13
|
-
export
|
|
14
|
-
S
|
|
15
|
-
M
|
|
16
|
-
}
|
|
13
|
+
export const SIZE = {
|
|
14
|
+
S: 's',
|
|
15
|
+
M: 'm',
|
|
16
|
+
} as const;
|
|
17
|
+
|
|
18
|
+
export const COLOR = {
|
|
19
|
+
Accent: 'accent',
|
|
20
|
+
Decor: 'decor',
|
|
21
|
+
} as const;
|
|
17
22
|
|
|
18
23
|
export const DEFAULT_PLUS_LIMIT = 10;
|
|
19
24
|
export const DEFAULT_KEY_LIMIT = 1000;
|
|
@@ -3,6 +3,7 @@
|
|
|
3
3
|
$appearances: 'primary', 'neutral', 'red';
|
|
4
4
|
$sizes: 's', 'm';
|
|
5
5
|
$variants: 'count', 'count-plus', 'count-k';
|
|
6
|
+
$colors: 'accent', 'decor';
|
|
6
7
|
|
|
7
8
|
$value-typography: (
|
|
8
9
|
s: $sans-label-s,
|
|
@@ -16,6 +17,14 @@ $key-typography: (
|
|
|
16
17
|
s: $sans-label-s,
|
|
17
18
|
m: $sans-label-l
|
|
18
19
|
);
|
|
20
|
+
$text-color: (
|
|
21
|
+
accent: 'on-accent',
|
|
22
|
+
decor: 'text-main'
|
|
23
|
+
);
|
|
24
|
+
$bg-color: (
|
|
25
|
+
accent: 'accent-default',
|
|
26
|
+
decor: 'decor-default'
|
|
27
|
+
);
|
|
19
28
|
|
|
20
29
|
.counter {
|
|
21
30
|
display: inline-flex;
|
|
@@ -27,11 +36,18 @@ $key-typography: (
|
|
|
27
36
|
|
|
28
37
|
border: 0 solid transparent;
|
|
29
38
|
|
|
30
|
-
@each $
|
|
31
|
-
|
|
32
|
-
color
|
|
33
|
-
|
|
34
|
-
|
|
39
|
+
@each $color in $colors {
|
|
40
|
+
@each $appearance in $appearances {
|
|
41
|
+
&[data-color='#{$color}'] {
|
|
42
|
+
&[data-appearance='#{$appearance}'] {
|
|
43
|
+
$text: simple-var($text-color, $color);
|
|
44
|
+
$background: simple-var($bg-color, $color);
|
|
45
|
+
|
|
46
|
+
color: simple-var($theme-variables, 'sys', $appearance, $text);
|
|
47
|
+
background-color: simple-var($theme-variables, 'sys', $appearance, $background);
|
|
48
|
+
border-color: $sys-neutral-background1-level;
|
|
49
|
+
}
|
|
50
|
+
}
|
|
35
51
|
}
|
|
36
52
|
}
|
|
37
53
|
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { ValueOf } from '@snack-uikit/utils';
|
|
2
|
+
|
|
3
|
+
import { APPEARANCE, COLOR, SIZE, VARIANT } from './constants';
|
|
4
|
+
|
|
5
|
+
export type Appearance = ValueOf<typeof APPEARANCE>;
|
|
6
|
+
export type Size = ValueOf<typeof SIZE>;
|
|
7
|
+
export type Variant = ValueOf<typeof VARIANT>;
|
|
8
|
+
export type Color = ValueOf<typeof COLOR>;
|
package/src/components/utils.tsx
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import { ReactNode } from 'react';
|
|
2
2
|
|
|
3
|
-
import { DEFAULT_KEY_LIMIT, DEFAULT_KEY_POSTFIX,
|
|
3
|
+
import { DEFAULT_KEY_LIMIT, DEFAULT_KEY_POSTFIX, VARIANT } from './constants';
|
|
4
4
|
import styles from './styles.module.scss';
|
|
5
|
+
import { Variant } from './types';
|
|
5
6
|
|
|
6
7
|
export function formatValue({
|
|
7
8
|
value,
|
|
@@ -12,11 +13,11 @@ export function formatValue({
|
|
|
12
13
|
variant: Variant;
|
|
13
14
|
plusLimit: number;
|
|
14
15
|
}): ReactNode {
|
|
15
|
-
if (variant ===
|
|
16
|
+
if (variant === VARIANT.Count) {
|
|
16
17
|
return value;
|
|
17
18
|
}
|
|
18
19
|
|
|
19
|
-
if (variant ===
|
|
20
|
+
if (variant === VARIANT.CountPlus) {
|
|
20
21
|
return value < plusLimit ? (
|
|
21
22
|
value
|
|
22
23
|
) : (
|
|
@@ -27,7 +28,7 @@ export function formatValue({
|
|
|
27
28
|
);
|
|
28
29
|
}
|
|
29
30
|
|
|
30
|
-
if (variant ===
|
|
31
|
+
if (variant === VARIANT.CountK) {
|
|
31
32
|
return value < DEFAULT_KEY_LIMIT ? (
|
|
32
33
|
value
|
|
33
34
|
) : (
|