@snack-uikit/counter 0.5.0 → 0.6.1-preview-993a9cfb.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,17 @@
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
+
6
17
  # 0.5.0 (2023-12-14)
7
18
 
8
19
 
package/README.md CHANGED
@@ -36,6 +36,7 @@ import { Counter } from "@snack-uikit/counter";
36
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 './types';
2
+ import { Appearance, Color, Size, Variant } from './types';
3
3
  export type CounterProps = WithSupportProps<{
4
4
  /** Значение */
5
5
  value: number;
@@ -13,6 +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;
20
+ export declare function Counter({ value, appearance, variant, size, plusLimit, color, className, ...rest }: CounterProps): import("react/jsx-runtime").JSX.Element;
@@ -12,12 +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 { APPEARANCE, DEFAULT_PLUS_LIMIT, SIZE, VARIANT } from './constants';
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 = APPEARANCE.Primary, variant = VARIANT.Count, size = SIZE.S, plusLimit = DEFAULT_PLUS_LIMIT, className } = _a, rest = __rest(_a, ["value", "appearance", "variant", "size", "plusLimit", "className"]);
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 }, { children: formattedValue })));
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
  }
@@ -12,6 +12,10 @@ export declare const SIZE: {
12
12
  readonly S: "s";
13
13
  readonly M: "m";
14
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";
@@ -12,6 +12,10 @@ export const SIZE = {
12
12
  S: 's',
13
13
  M: 'm',
14
14
  };
15
+ export const COLOR = {
16
+ Accent: 'accent',
17
+ Decor: 'decor',
18
+ };
15
19
  export const DEFAULT_PLUS_LIMIT = 10;
16
20
  export const DEFAULT_KEY_LIMIT = 1000;
17
21
  export const DEFAULT_KEY_POSTFIX = 'K';
@@ -7,20 +7,35 @@
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
- border-color:var(--sys-neutral-background1-level, #f9f9f9);
13
+ border-color:var(--sys-neutral-background1-level, #fafafc);
14
14
  }
15
- .counter[data-appearance=neutral]{
16
- color:var(--sys-neutral-on-accent, #fdfdfd);
17
- background-color:var(--sys-neutral-accent-default, #757575);
18
- border-color:var(--sys-neutral-background1-level, #f9f9f9);
15
+ .counter[data-color=accent][data-appearance=neutral]{
16
+ color:var(--sys-neutral-on-accent, #ffffff);
17
+ background-color:var(--sys-neutral-accent-default, #6f717c);
18
+ border-color:var(--sys-neutral-background1-level, #fafafc);
19
19
  }
20
- .counter[data-appearance=red]{
21
- color:var(--sys-red-on-accent, #fffbfa);
22
- background-color:var(--sys-red-accent-default, #d93f2f);
23
- border-color:var(--sys-neutral-background1-level, #f9f9f9);
20
+ .counter[data-color=accent][data-appearance=red]{
21
+ color:var(--sys-red-on-accent, #fffbf9);
22
+ background-color:var(--sys-red-accent-default, #cd3c3c);
23
+ border-color:var(--sys-neutral-background1-level, #fafafc);
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, #fafafc);
29
+ }
30
+ .counter[data-color=decor][data-appearance=neutral]{
31
+ color:var(--sys-neutral-text-main, #33333b);
32
+ background-color:var(--sys-neutral-decor-default, #dfe2ec);
33
+ border-color:var(--sys-neutral-background1-level, #fafafc);
34
+ }
35
+ .counter[data-color=decor][data-appearance=red]{
36
+ color:var(--sys-red-text-main, #621c1b);
37
+ background-color:var(--sys-red-decor-default, #fdd6cd);
38
+ border-color:var(--sys-neutral-background1-level, #fafafc);
24
39
  }
25
40
  .counter[data-size=s]{
26
41
  font-family:var(--sans-label-s-font-family, SB Sans Interface);
@@ -30,7 +45,7 @@
30
45
  letter-spacing:var(--sans-label-s-letter-spacing, -0.1px);
31
46
  paragraph-spacing:var(--sans-label-s-paragraph-spacing, 6.05px);
32
47
  border-radius:var(--radius-counter-s, 8px);
33
- height:var(--dimension-theme-general-16px, 16px);
48
+ height:var(--size-counter-s-height, 16px);
34
49
  min-width:var(--size-counter-s-minimal-width, 16px);
35
50
  padding-right:var(--space-counter-s, 2.5px);
36
51
  padding-left:var(--space-counter-s, 2.5px);
@@ -60,7 +75,7 @@
60
75
  letter-spacing:var(--sans-label-l-letter-spacing, -0.1px);
61
76
  paragraph-spacing:var(--sans-label-l-paragraph-spacing, 7.7px);
62
77
  border-radius:var(--radius-counter-m, 16px);
63
- height:var(--dimension-theme-general-24px, 24px);
78
+ height:var(--size-counter-m-height, 24px);
64
79
  min-width:var(--size-counter-m-minimal-width, 24px);
65
80
  padding-right:var(--space-counter-m, 4.5px);
66
81
  padding-left:var(--space-counter-m, 4.5px);
@@ -1,5 +1,6 @@
1
1
  import { ValueOf } from '@snack-uikit/utils';
2
- import { APPEARANCE, SIZE, VARIANT } from './constants';
2
+ import { APPEARANCE, COLOR, SIZE, VARIANT } from './constants';
3
3
  export type Appearance = ValueOf<typeof APPEARANCE>;
4
4
  export type Size = ValueOf<typeof SIZE>;
5
5
  export type Variant = ValueOf<typeof VARIANT>;
6
+ export type Color = ValueOf<typeof COLOR>;
@@ -6,9 +6,9 @@ export function formatValue({ value, variant, plusLimit, }) {
6
6
  return value;
7
7
  }
8
8
  if (variant === VARIANT.CountPlus) {
9
- return value < plusLimit ? (value) : (_jsxs(_Fragment, { children: [plusLimit - 1, _jsx("span", Object.assign({ className: styles.plus }, { children: "+" }))] }));
9
+ return value < plusLimit ? (value) : (_jsxs(_Fragment, { children: [plusLimit - 1, _jsx("span", { className: styles.plus, children: "+" })] }));
10
10
  }
11
11
  if (variant === VARIANT.CountK) {
12
- 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 }))] }));
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.5.0",
7
+ "version": "0.6.1-preview-993a9cfb.0",
8
8
  "sideEffects": [
9
9
  "*.css",
10
10
  "*.woff",
@@ -35,5 +35,5 @@
35
35
  "@snack-uikit/utils": "3.2.0",
36
36
  "classnames": "2.3.2"
37
37
  },
38
- "gitHead": "bd39c5e674f3b91b0e2487782a04b15034cf3d8b"
38
+ "gitHead": "a421965dc78af63a8c292e595b3f0a8ff1be86f9"
39
39
  }
@@ -2,9 +2,9 @@ import cn from 'classnames';
2
2
 
3
3
  import { extractSupportProps, WithSupportProps } from '@snack-uikit/utils';
4
4
 
5
- import { APPEARANCE, DEFAULT_PLUS_LIMIT, SIZE, VARIANT } from './constants';
5
+ import { APPEARANCE, COLOR, DEFAULT_PLUS_LIMIT, SIZE, VARIANT } from './constants';
6
6
  import classNames from './styles.module.scss';
7
- import { Appearance, Size, Variant } from './types';
7
+ import { Appearance, Color, Size, Variant } from './types';
8
8
  import { formatValue } from './utils';
9
9
 
10
10
  export type CounterProps = WithSupportProps<{
@@ -20,6 +20,8 @@ export type CounterProps = WithSupportProps<{
20
20
  plusLimit?: number;
21
21
  /** CSS-класс */
22
22
  className?: string;
23
+ /** Семантический цвет */
24
+ color?: Color;
23
25
  }>;
24
26
 
25
27
  /** Компонент счетчик */
@@ -29,6 +31,7 @@ export function Counter({
29
31
  variant = VARIANT.Count,
30
32
  size = SIZE.S,
31
33
  plusLimit = DEFAULT_PLUS_LIMIT,
34
+ color = COLOR.Accent,
32
35
  className,
33
36
  ...rest
34
37
  }: CounterProps) {
@@ -41,6 +44,7 @@ export function Counter({
41
44
  data-size={size}
42
45
  data-variant={variant}
43
46
  data-appearance={appearance}
47
+ data-color={color}
44
48
  >
45
49
  {formattedValue}
46
50
  </div>
@@ -15,6 +15,11 @@ export const SIZE = {
15
15
  M: 'm',
16
16
  } as const;
17
17
 
18
+ export const COLOR = {
19
+ Accent: 'accent',
20
+ Decor: 'decor',
21
+ } as const;
22
+
18
23
  export const DEFAULT_PLUS_LIMIT = 10;
19
24
  export const DEFAULT_KEY_LIMIT = 1000;
20
25
  export const DEFAULT_KEY_POSTFIX = 'K';
@@ -1,8 +1,9 @@
1
1
  @import '@snack-uikit/figma-tokens/build/scss/components/styles-tokens-counter';
2
2
 
3
- $appearances: 'primary', 'neutral', 'red';
4
3
  $sizes: 's', 'm';
4
+ $appearances: 'primary', 'neutral', 'red';
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 $appearance in $appearances {
31
- &[data-appearance='#{$appearance}'] {
32
- color: simple-var($theme-variables, 'sys', $appearance, 'on-accent');
33
- background-color: simple-var($theme-variables, 'sys', $appearance, 'accent-default');
34
- border-color: $sys-neutral-background1-level;
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
 
@@ -1,7 +1,8 @@
1
1
  import { ValueOf } from '@snack-uikit/utils';
2
2
 
3
- import { APPEARANCE, SIZE, VARIANT } from './constants';
3
+ import { APPEARANCE, COLOR, SIZE, VARIANT } from './constants';
4
4
 
5
5
  export type Appearance = ValueOf<typeof APPEARANCE>;
6
6
  export type Size = ValueOf<typeof SIZE>;
7
7
  export type Variant = ValueOf<typeof VARIANT>;
8
+ export type Color = ValueOf<typeof COLOR>;