@snack-uikit/link 0.9.3 → 0.10.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.
@@ -1,5 +1,5 @@
1
1
  import { ValueOf } from '@snack-uikit/utils';
2
- import { ON_COLOR, ON_SURFACE, SIZE } from './constants';
3
- export type OnColor = ValueOf<typeof ON_COLOR>;
2
+ import { APPEARANCE, SIZE, TEXT_MODE } from './constants';
3
+ export type Appearance = ValueOf<typeof APPEARANCE>;
4
4
  export type Size = ValueOf<typeof SIZE>;
5
- export type OnSurface = ValueOf<typeof ON_SURFACE>;
5
+ export type TextMode = ValueOf<typeof TEXT_MODE>;
package/package.json CHANGED
@@ -4,7 +4,7 @@
4
4
  "access": "public"
5
5
  },
6
6
  "title": "Link",
7
- "version": "0.9.3",
7
+ "version": "0.10.0",
8
8
  "sideEffects": [
9
9
  "*.css",
10
10
  "*.woff",
@@ -33,9 +33,9 @@
33
33
  "scripts": {},
34
34
  "dependencies": {
35
35
  "@snack-uikit/icons": "0.19.2",
36
- "@snack-uikit/truncate-string": "0.4.3",
36
+ "@snack-uikit/truncate-string": "0.4.4",
37
37
  "@snack-uikit/utils": "3.2.0",
38
38
  "classnames": "2.3.2"
39
39
  },
40
- "gitHead": "420ccb07e016ae79a8b783e88c24f2045fadc026"
40
+ "gitHead": "57c597a3eebaf6528c0c61b6b27dd244753de1cf"
41
41
  }
@@ -5,9 +5,9 @@ import { ArrowLinksSVG } from '@snack-uikit/icons';
5
5
  import { TruncateString } from '@snack-uikit/truncate-string';
6
6
  import { extractSupportProps, WithSupportProps } from '@snack-uikit/utils';
7
7
 
8
- import { ON_COLOR, ON_SURFACE, SIZE } from './constants';
8
+ import { APPEARANCE, SIZE, TEXT_MODE } from './constants';
9
9
  import styles from './styles.module.scss';
10
- import { OnColor, OnSurface, Size } from './types';
10
+ import { Appearance, Size, TextMode } from './types';
11
11
 
12
12
  export type LinkProps = WithSupportProps<{
13
13
  /** Текст ссылки */
@@ -22,14 +22,20 @@ export type LinkProps = WithSupportProps<{
22
22
  download?: string;
23
23
  /** Колбек обработки клика */
24
24
  onClick?: MouseEventHandler<HTMLAnchorElement>;
25
- /** Размер */
25
+ /** Размер
26
+ * @default 's'
27
+ */
26
28
  size?: Size;
27
29
  /** Ведет ли ссылка на внешний ресурс (добавляет иконку если true) */
28
30
  external?: boolean;
29
- /** Стилизует ссылку для размещения на цветном фоне */
30
- onColor?: OnColor;
31
- /** Тип поверхности, на которой размещена ссылка */
32
- onSurface?: OnSurface;
31
+ /** Стилизует ссылку для размещения на цветном фоне
32
+ * @default 'primary'
33
+ */
34
+ appearance?: Appearance;
35
+ /** Тип поверхности, на которой размещена ссылка
36
+ * @default 'default'
37
+ */
38
+ textMode?: TextMode;
33
39
  }>;
34
40
 
35
41
  /** Компонент ссылка */
@@ -40,10 +46,10 @@ export function Link({
40
46
  target = '_blank',
41
47
  download,
42
48
  onClick,
43
- onSurface = ON_SURFACE.Background,
49
+ textMode = TEXT_MODE.Default,
44
50
  size = SIZE.S,
45
51
  external,
46
- onColor = ON_COLOR.Primary,
52
+ appearance = APPEARANCE.Primary,
47
53
  ...rest
48
54
  }: LinkProps) {
49
55
  return (
@@ -55,8 +61,8 @@ export function Link({
55
61
  onClick={onClick}
56
62
  {...extractSupportProps(rest)}
57
63
  data-size={size}
58
- data-on-surface={onSurface}
59
- data-color={onColor}
64
+ data-text-mode={textMode}
65
+ data-appearance={appearance}
60
66
  rel={target === '_blank' ? 'noopener noreferrer' : undefined}
61
67
  >
62
68
  <TruncateString text={text} maxLines={1} />
@@ -1,4 +1,4 @@
1
- export const ON_COLOR = {
1
+ export const APPEARANCE = {
2
2
  InvertNeutral: 'invert-neutral',
3
3
  Neutral: 'neutral',
4
4
  Primary: 'primary',
@@ -24,8 +24,8 @@ export const TARGET = {
24
24
  Top: '_top',
25
25
  } as const;
26
26
 
27
- export const ON_SURFACE = {
28
- Background: 'background',
29
- Decor: 'decor',
27
+ export const TEXT_MODE = {
28
+ Default: 'default',
30
29
  Accent: 'accent',
30
+ OnAccent: 'on-accent',
31
31
  } as const;
@@ -1,2 +1 @@
1
1
  export * from './Link';
2
- export { ON_COLOR } from './constants';
@@ -2,8 +2,8 @@
2
2
  @import '@snack-uikit/figma-tokens/build/scss/components/styles-tokens-element';
3
3
 
4
4
  $sizes: 's', 'm', 'l';
5
- $colors: 'invert-neutral','neutral', 'primary', 'red', 'orange', 'blue', 'violet', 'pink', 'yellow', 'green';
6
- $on-surfaces: 'background', 'decor', 'accent';
5
+ $appearances: 'invert-neutral','neutral', 'primary', 'red', 'orange', 'blue', 'violet', 'pink', 'yellow', 'green';
6
+ $text-modes: 'default', 'accent', 'on-accent';
7
7
  $icon-sizes: (
8
8
  's': $icon-xs,
9
9
  'm': $icon-s,
@@ -22,66 +22,84 @@ $icon-sizes: (
22
22
  text-decoration: none;
23
23
  text-decoration-skip-ink: none;
24
24
 
25
- @each $on-surface in $on-surfaces {
26
- &[data-on-surface='#{$on-surface}'] {
27
- @each $color in $colors {
28
- &[data-color='#{$color}'] {
29
- @if $on-surface == 'accent' {
30
- color: simple-var($theme-variables, 'sys', $color, 'on-accent');
31
-
32
- &:hover {
33
- color: simple-var($theme-variables, 'sys', $color, 'on-accent');
34
- opacity: $opacity-a080;
35
- }
36
- &:focus-visible {
37
- @include outline-var($container-focused-s);
38
-
39
- opacity: $opacity-a080;
40
- outline-color: $sys-available-on-complementary;
41
- }
25
+ @each $appearance in $appearances {
26
+ &[data-appearance='#{$appearance}'] {
27
+ &[data-text-mode='default'] {
28
+ color: simple-var($theme-variables, 'sys', $appearance, 'text-support');
29
+
30
+ &:hover {
31
+ color: simple-var($theme-variables, 'sys', $appearance, 'text-main');
32
+ }
33
+
34
+ &:focus-visible {
35
+ @include outline-var($container-focused-s);
36
+
37
+ color: simple-var($theme-variables, 'sys', $appearance, 'text-main');
38
+ outline-color: $sys-available-complementary;
39
+ }
40
+ }
41
+
42
+ &[data-text-mode='accent'] {
43
+ color: simple-var($theme-variables, 'sys', $appearance, 'accent-default');
44
+
45
+ &:hover {
46
+ color: simple-var($theme-variables, 'sys', $appearance, 'text-main');
47
+ }
48
+
49
+ &:focus-visible {
50
+ @include outline-var($container-focused-s);
51
+
52
+ color: simple-var($theme-variables, 'sys', $appearance, 'text-main');
53
+
54
+ @if $appearance == 'invert-neutral' {
55
+ outline-color: $sys-available-on-complementary;
42
56
  }
43
57
 
44
- @else {
45
- color: simple-var($theme-variables, 'sys', $color, 'accent-default');
46
-
47
- &:hover {
48
- color: simple-var($theme-variables, 'sys', $color, 'text-main');
49
- }
50
- &:focus-visible {
51
- @include outline-var($container-focused-s);
52
-
53
- color: simple-var($theme-variables, 'sys', $color, 'text-main');
54
-
55
- @if $color == 'invert-neutral' {
56
- outline-color: $sys-available-on-complementary;
57
- }
58
-
59
- @else {
60
- outline-color: $sys-available-complementary;
61
- }
62
- }
58
+ @else {
59
+ outline-color: $sys-available-complementary;
63
60
  }
61
+ }
62
+ }
63
+
64
+ &[data-text-mode='on-accent'] {
65
+ color: simple-var($theme-variables, 'sys', $appearance, 'on-accent');
66
+
67
+ &:hover {
68
+ color: simple-var($theme-variables, 'sys', $appearance, 'on-accent');
69
+ opacity: $opacity-a080;
70
+ }
64
71
 
65
- @each $size in $sizes {
66
- &[data-size='#{$size}'] {
67
- @if $on-surface == 'decor' {
68
- @include composite-var($theme-variables, 'sans', 'body', $size);
69
- }
72
+ &:focus-visible {
73
+ @include outline-var($container-focused-s);
70
74
 
71
- @else {
72
- @include composite-var($theme-variables, 'link', 'body', $size);
73
- }
75
+ color: simple-var($theme-variables, 'sys', $appearance, 'on-accent');
76
+ opacity: $opacity-a080;
77
+ outline-color: $sys-available-on-complementary;
78
+ }
79
+ }
80
+ }
81
+ }
74
82
 
75
- @include composite-var($link, 'container', $size);
83
+ @each $size in $sizes {
84
+ &[data-size='#{$size}'] {
85
+ @each $text-mode in $text-modes {
86
+ &[data-text-mode='#{$text-mode}'] {
87
+ @if $text-mode == 'default' {
88
+ @include composite-var($theme-variables, 'sans', 'body', $size);
89
+ }
76
90
 
77
- svg {
78
- width: simple-var($icon-sizes, $size) !important; /* stylelint-disable-line declaration-no-important */
79
- height: simple-var($icon-sizes, $size) !important; /* stylelint-disable-line declaration-no-important */
80
- }
81
- }
91
+ @else {
92
+ @include composite-var($theme-variables, 'link', 'body', $size);
82
93
  }
83
94
  }
84
95
  }
96
+
97
+ @include composite-var($link, 'container', $size);
98
+
99
+ svg {
100
+ width: simple-var($icon-sizes, $size) !important; /* stylelint-disable-line declaration-no-important */
101
+ height: simple-var($icon-sizes, $size) !important; /* stylelint-disable-line declaration-no-important */
102
+ }
85
103
  }
86
104
  }
87
105
  }
@@ -1,9 +1,9 @@
1
1
  import { ValueOf } from '@snack-uikit/utils';
2
2
 
3
- import { ON_COLOR, ON_SURFACE, SIZE } from './constants';
3
+ import { APPEARANCE, SIZE, TEXT_MODE } from './constants';
4
4
 
5
- export type OnColor = ValueOf<typeof ON_COLOR>;
5
+ export type Appearance = ValueOf<typeof APPEARANCE>;
6
6
 
7
7
  export type Size = ValueOf<typeof SIZE>;
8
8
 
9
- export type OnSurface = ValueOf<typeof ON_SURFACE>;
9
+ export type TextMode = ValueOf<typeof TEXT_MODE>;