@snack-uikit/link 0.9.3 → 0.10.1
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 +21 -0
- package/README.md +2 -2
- package/dist/components/Link.d.ts +13 -7
- package/dist/components/Link.js +3 -3
- package/dist/components/constants.d.ts +4 -4
- package/dist/components/constants.js +4 -4
- package/dist/components/index.d.ts +0 -1
- package/dist/components/index.js +0 -1
- package/dist/components/styles.module.css +311 -1573
- package/dist/components/types.d.ts +3 -3
- package/package.json +4 -4
- package/src/components/Link.tsx +17 -11
- package/src/components/constants.ts +4 -4
- package/src/components/index.ts +0 -1
- package/src/components/styles.module.scss +70 -52
- package/src/components/types.ts +3 -3
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { ValueOf } from '@snack-uikit/utils';
|
|
2
|
-
import {
|
|
3
|
-
export type
|
|
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
|
|
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.
|
|
7
|
+
"version": "0.10.1",
|
|
8
8
|
"sideEffects": [
|
|
9
9
|
"*.css",
|
|
10
10
|
"*.woff",
|
|
@@ -32,10 +32,10 @@
|
|
|
32
32
|
"license": "Apache-2.0",
|
|
33
33
|
"scripts": {},
|
|
34
34
|
"dependencies": {
|
|
35
|
-
"@snack-uikit/icons": "0.
|
|
36
|
-
"@snack-uikit/truncate-string": "0.4.
|
|
35
|
+
"@snack-uikit/icons": "0.20.0",
|
|
36
|
+
"@snack-uikit/truncate-string": "0.4.5",
|
|
37
37
|
"@snack-uikit/utils": "3.2.0",
|
|
38
38
|
"classnames": "2.3.2"
|
|
39
39
|
},
|
|
40
|
-
"gitHead": "
|
|
40
|
+
"gitHead": "c292f4c45173928f57cc5c9f3cb02efb26887b64"
|
|
41
41
|
}
|
package/src/components/Link.tsx
CHANGED
|
@@ -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 {
|
|
8
|
+
import { APPEARANCE, SIZE, TEXT_MODE } from './constants';
|
|
9
9
|
import styles from './styles.module.scss';
|
|
10
|
-
import {
|
|
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
|
-
|
|
31
|
-
|
|
32
|
-
|
|
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
|
-
|
|
49
|
+
textMode = TEXT_MODE.Default,
|
|
44
50
|
size = SIZE.S,
|
|
45
51
|
external,
|
|
46
|
-
|
|
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-
|
|
59
|
-
data-
|
|
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
|
|
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
|
|
28
|
-
|
|
29
|
-
Decor: 'decor',
|
|
27
|
+
export const TEXT_MODE = {
|
|
28
|
+
Default: 'default',
|
|
30
29
|
Accent: 'accent',
|
|
30
|
+
OnAccent: 'on-accent',
|
|
31
31
|
} as const;
|
package/src/components/index.ts
CHANGED
|
@@ -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
|
-
$
|
|
6
|
-
$
|
|
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 $
|
|
26
|
-
&[data-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
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
|
-
|
|
45
|
-
color:
|
|
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
|
-
|
|
66
|
-
|
|
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
|
-
|
|
72
|
-
|
|
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
|
-
|
|
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
|
-
|
|
78
|
-
|
|
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
|
}
|
package/src/components/types.ts
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { ValueOf } from '@snack-uikit/utils';
|
|
2
2
|
|
|
3
|
-
import {
|
|
3
|
+
import { APPEARANCE, SIZE, TEXT_MODE } from './constants';
|
|
4
4
|
|
|
5
|
-
export type
|
|
5
|
+
export type Appearance = ValueOf<typeof APPEARANCE>;
|
|
6
6
|
|
|
7
7
|
export type Size = ValueOf<typeof SIZE>;
|
|
8
8
|
|
|
9
|
-
export type
|
|
9
|
+
export type TextMode = ValueOf<typeof TEXT_MODE>;
|