@snack-uikit/counter
Advanced tools
Comparing version 0.5.0 to 0.6.0
@@ -6,2 +6,13 @@ # Change Log | ||
# 0.6.0 (2023-12-28) | ||
### Features | ||
* **FF-3960:** add new prop color ([3adaa4c](https://github.com/cloud-ru-tech/snack-uikit/commit/3adaa4c7cc3018607a50446caec2fb62dd680fd3)) | ||
# 0.5.0 (2023-12-14) | ||
@@ -8,0 +19,0 @@ |
@@ -15,4 +15,8 @@ export declare const APPEARANCE: { | ||
}; | ||
export declare const COLOR: { | ||
readonly Accent: "accent"; | ||
readonly Decor: "decor"; | ||
}; | ||
export declare const DEFAULT_PLUS_LIMIT = 10; | ||
export declare const DEFAULT_KEY_LIMIT = 1000; | ||
export declare const DEFAULT_KEY_POSTFIX = "K"; |
@@ -15,4 +15,8 @@ export const APPEARANCE = { | ||
}; | ||
export const COLOR = { | ||
Accent: 'accent', | ||
Decor: 'decor', | ||
}; | ||
export const DEFAULT_PLUS_LIMIT = 10; | ||
export const DEFAULT_KEY_LIMIT = 1000; | ||
export const DEFAULT_KEY_POSTFIX = 'K'; |
import { WithSupportProps } from '@snack-uikit/utils'; | ||
import { Appearance, Size, Variant } from './types'; | ||
import { Appearance, Color, Size, Variant } from './types'; | ||
export type CounterProps = WithSupportProps<{ | ||
@@ -16,4 +16,6 @@ /** Значение */ | ||
className?: string; | ||
/** Семантический цвет */ | ||
color?: Color; | ||
}>; | ||
/** Компонент счетчик */ | ||
export declare function Counter({ value, appearance, variant, size, plusLimit, className, ...rest }: CounterProps): import("react/jsx-runtime").JSX.Element; | ||
export declare function Counter({ value, appearance, variant, size, plusLimit, color, className, ...rest }: CounterProps): import("react/jsx-runtime").JSX.Element; |
@@ -15,3 +15,3 @@ var __rest = (this && this.__rest) || function (s, e) { | ||
import { extractSupportProps } from '@snack-uikit/utils'; | ||
import { APPEARANCE, DEFAULT_PLUS_LIMIT, SIZE, VARIANT } from './constants'; | ||
import { APPEARANCE, COLOR, DEFAULT_PLUS_LIMIT, SIZE, VARIANT } from './constants'; | ||
import classNames from './styles.module.css'; | ||
@@ -21,5 +21,5 @@ import { formatValue } from './utils'; | ||
export function Counter(_a) { | ||
var { value, appearance = APPEARANCE.Primary, variant = VARIANT.Count, size = SIZE.S, plusLimit = DEFAULT_PLUS_LIMIT, className } = _a, rest = __rest(_a, ["value", "appearance", "variant", "size", "plusLimit", "className"]); | ||
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"]); | ||
const formattedValue = formatValue({ value, variant, plusLimit }); | ||
return (_jsx("div", Object.assign({ className: cn(classNames.counter, className) }, extractSupportProps(rest), { "data-size": size, "data-variant": variant, "data-appearance": appearance }, { children: formattedValue }))); | ||
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 }))); | ||
} |
import { ValueOf } from '@snack-uikit/utils'; | ||
import { APPEARANCE, SIZE, VARIANT } from './constants'; | ||
import { APPEARANCE, COLOR, SIZE, VARIANT } from './constants'; | ||
export type Appearance = ValueOf<typeof APPEARANCE>; | ||
export type Size = ValueOf<typeof SIZE>; | ||
export type Variant = ValueOf<typeof VARIANT>; | ||
export type Color = ValueOf<typeof COLOR>; |
@@ -9,7 +9,7 @@ import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime"; | ||
if (variant === VARIANT.CountPlus) { | ||
return value < plusLimit ? (value) : (_jsxs(_Fragment, { children: [plusLimit - 1, _jsx("span", Object.assign({ className: styles.plus }, { children: "+" }))] })); | ||
return value < plusLimit ? (value) : (_jsxs(_Fragment, { children: [plusLimit - 1, _jsx("span", { className: styles.plus, children: "+" })] })); | ||
} | ||
if (variant === VARIANT.CountK) { | ||
return value < DEFAULT_KEY_LIMIT ? (value) : (_jsxs(_Fragment, { children: [Math.round(value / DEFAULT_KEY_LIMIT), _jsx("span", Object.assign({ className: styles.key }, { children: DEFAULT_KEY_POSTFIX }))] })); | ||
return value < DEFAULT_KEY_LIMIT ? (value) : (_jsxs(_Fragment, { children: [Math.round(value / DEFAULT_KEY_LIMIT), _jsx("span", { className: styles.key, children: DEFAULT_KEY_POSTFIX })] })); | ||
} | ||
} |
@@ -7,3 +7,3 @@ { | ||
"title": "Counter", | ||
"version": "0.5.0", | ||
"version": "0.6.0", | ||
"sideEffects": [ | ||
@@ -39,3 +39,3 @@ "*.css", | ||
}, | ||
"gitHead": "bd39c5e674f3b91b0e2487782a04b15034cf3d8b" | ||
"gitHead": "57c597a3eebaf6528c0c61b6b27dd244753de1cf" | ||
} |
@@ -39,4 +39,5 @@ # Counter | ||
| className | `string` | - | CSS-класс | | ||
| color | enum Color: `"accent"`, `"decor"` | accent | Семантический цвет | | ||
[//]: DOCUMENTATION_SECTION_END |
@@ -18,4 +18,9 @@ export const APPEARANCE = { | ||
export const COLOR = { | ||
Accent: 'accent', | ||
Decor: 'decor', | ||
} as const; | ||
export const DEFAULT_PLUS_LIMIT = 10; | ||
export const DEFAULT_KEY_LIMIT = 1000; | ||
export const DEFAULT_KEY_POSTFIX = 'K'; |
import { ValueOf } from '@snack-uikit/utils'; | ||
import { APPEARANCE, SIZE, VARIANT } from './constants'; | ||
import { APPEARANCE, COLOR, SIZE, VARIANT } from './constants'; | ||
@@ -8,1 +8,2 @@ export type Appearance = ValueOf<typeof APPEARANCE>; | ||
export type Variant = ValueOf<typeof VARIANT>; | ||
export type Color = ValueOf<typeof COLOR>; |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
32683
329
43