@snack-uikit/link 0.8.1 → 0.9.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 +11 -0
- package/README.md +6 -6
- package/dist/components/Link.d.ts +1 -7
- package/dist/components/Link.js +3 -7
- package/dist/components/constants.d.ts +28 -28
- package/dist/components/constants.js +28 -32
- package/dist/components/index.d.ts +1 -1
- package/dist/components/index.js +1 -1
- package/dist/components/types.d.ts +5 -0
- package/dist/components/types.js +1 -0
- package/package.json +4 -4
- package/src/components/Link.tsx +7 -11
- package/src/components/constants.ts +28 -28
- package/src/components/index.ts +1 -1
- package/src/components/types.ts +9 -0
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.9.0 (2023-12-14)
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
### BREAKING CHANGES
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
* **FF-3729:** replace enum with unions ([910db4a](https://github.com/cloud-ru-tech/snack-uikit/commit/910db4aa8231ccbc58e538e5c5c1f461b1dec275))
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
|
|
6
17
|
## 0.8.1 (2023-12-06)
|
|
7
18
|
|
|
8
19
|
### Only dependencies have been changed
|
package/README.md
CHANGED
|
@@ -14,11 +14,11 @@
|
|
|
14
14
|
import { Link } from '@snack-uikit/link';
|
|
15
15
|
|
|
16
16
|
<Link
|
|
17
|
-
onSurface=
|
|
17
|
+
onSurface='accent'
|
|
18
18
|
href='https://cloud.ru/'
|
|
19
19
|
text='Link text'
|
|
20
20
|
external={true}
|
|
21
|
-
onColor=
|
|
21
|
+
onColor='primary'
|
|
22
22
|
/>;
|
|
23
23
|
```
|
|
24
24
|
|
|
@@ -32,13 +32,13 @@ import { Link } from '@snack-uikit/link';
|
|
|
32
32
|
| text | `string` | - | Текст ссылки |
|
|
33
33
|
| className | `string` | - | CSS-класс |
|
|
34
34
|
| href | `string` | # | Ссылка |
|
|
35
|
-
| target | `HTMLAttributeAnchorTarget` |
|
|
35
|
+
| target | `HTMLAttributeAnchorTarget` | _blank | HTML-атрибут target |
|
|
36
36
|
| download | `string` | - | HTML-атрибут download |
|
|
37
37
|
| onClick | `MouseEventHandler<HTMLAnchorElement>` | - | Колбек обработки клика |
|
|
38
|
-
| size | enum Size: `"s"`, `"m"`, `"l"` |
|
|
38
|
+
| size | enum Size: `"s"`, `"m"`, `"l"` | s | Размер |
|
|
39
39
|
| external | `boolean` | - | Ведет ли ссылка на внешний ресурс (добавляет иконку если true) |
|
|
40
|
-
| onColor | enum OnColor: `"invert-neutral"`, `"neutral"`, `"primary"`, `"red"`, `"orange"`, `"yellow"`, `"green"`, `"blue"`, `"violet"`, `"pink"` |
|
|
41
|
-
| onSurface | enum OnSurface: `"background"`, `"decor"`, `"accent"` |
|
|
40
|
+
| onColor | enum OnColor: `"invert-neutral"`, `"neutral"`, `"primary"`, `"red"`, `"orange"`, `"yellow"`, `"green"`, `"blue"`, `"violet"`, `"pink"` | primary | Стилизует ссылку для размещения на цветном фоне |
|
|
41
|
+
| onSurface | enum OnSurface: `"background"`, `"decor"`, `"accent"` | background | Тип поверхности, на которой размещена ссылка |
|
|
42
42
|
|
|
43
43
|
|
|
44
44
|
[//]: DOCUMENTATION_SECTION_END
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { AnchorHTMLAttributes, MouseEventHandler } from 'react';
|
|
2
2
|
import { WithSupportProps } from '@snack-uikit/utils';
|
|
3
|
-
import { OnColor, OnSurface, Size
|
|
3
|
+
import { OnColor, OnSurface, Size } from './types';
|
|
4
4
|
export type LinkProps = WithSupportProps<{
|
|
5
5
|
/** Текст ссылки */
|
|
6
6
|
text?: string;
|
|
@@ -25,9 +25,3 @@ export type LinkProps = WithSupportProps<{
|
|
|
25
25
|
}>;
|
|
26
26
|
/** Компонент ссылка */
|
|
27
27
|
export declare function Link({ text, className, href, target, download, onClick, onSurface, size, external, onColor, ...rest }: LinkProps): import("react/jsx-runtime").JSX.Element;
|
|
28
|
-
export declare namespace Link {
|
|
29
|
-
var sizes: typeof Size;
|
|
30
|
-
var targets: typeof Target;
|
|
31
|
-
var onColors: typeof OnColor;
|
|
32
|
-
var onSurfaces: typeof OnSurface;
|
|
33
|
-
}
|
package/dist/components/Link.js
CHANGED
|
@@ -14,14 +14,10 @@ import cn from 'classnames';
|
|
|
14
14
|
import { ArrowLinksSVG } from '@snack-uikit/icons';
|
|
15
15
|
import { TruncateString } from '@snack-uikit/truncate-string';
|
|
16
16
|
import { extractSupportProps } from '@snack-uikit/utils';
|
|
17
|
-
import {
|
|
17
|
+
import { ON_COLOR, ON_SURFACE, SIZE } from './constants';
|
|
18
18
|
import styles from './styles.module.css';
|
|
19
19
|
/** Компонент ссылка */
|
|
20
20
|
export function Link(_a) {
|
|
21
|
-
var { text = '', className, href = '#', target =
|
|
22
|
-
return (_jsxs("a", Object.assign({ className: cn(styles.link, className), href: href, target: target, download: download, onClick: onClick }, extractSupportProps(rest), { "data-size": size, "data-on-surface": onSurface, "data-color": onColor, rel: target ===
|
|
21
|
+
var { text = '', className, href = '#', target = '_blank', download, onClick, onSurface = ON_SURFACE.Background, size = SIZE.S, external, onColor = ON_COLOR.Primary } = _a, rest = __rest(_a, ["text", "className", "href", "target", "download", "onClick", "onSurface", "size", "external", "onColor"]);
|
|
22
|
+
return (_jsxs("a", Object.assign({ className: cn(styles.link, className), href: href, target: target, download: download, onClick: onClick }, extractSupportProps(rest), { "data-size": size, "data-on-surface": onSurface, "data-color": onColor, rel: target === '_blank' ? 'noopener noreferrer' : undefined }, { children: [_jsx(TruncateString, { text: text, maxLines: 1 }), external && _jsx(ArrowLinksSVG, { "data-test-id": 'link__external-icon', className: styles.icon })] })));
|
|
23
23
|
}
|
|
24
|
-
Link.sizes = Size;
|
|
25
|
-
Link.targets = Target;
|
|
26
|
-
Link.onColors = OnColor;
|
|
27
|
-
Link.onSurfaces = OnSurface;
|
|
@@ -1,28 +1,28 @@
|
|
|
1
|
-
export declare
|
|
2
|
-
InvertNeutral
|
|
3
|
-
Neutral
|
|
4
|
-
Primary
|
|
5
|
-
Red
|
|
6
|
-
Orange
|
|
7
|
-
Yellow
|
|
8
|
-
Green
|
|
9
|
-
Blue
|
|
10
|
-
Violet
|
|
11
|
-
Pink
|
|
12
|
-
}
|
|
13
|
-
export declare
|
|
14
|
-
S
|
|
15
|
-
M
|
|
16
|
-
L
|
|
17
|
-
}
|
|
18
|
-
export declare
|
|
19
|
-
Self
|
|
20
|
-
Blank
|
|
21
|
-
Parent
|
|
22
|
-
Top
|
|
23
|
-
}
|
|
24
|
-
export declare
|
|
25
|
-
Background
|
|
26
|
-
Decor
|
|
27
|
-
Accent
|
|
28
|
-
}
|
|
1
|
+
export declare const ON_COLOR: {
|
|
2
|
+
readonly InvertNeutral: "invert-neutral";
|
|
3
|
+
readonly Neutral: "neutral";
|
|
4
|
+
readonly Primary: "primary";
|
|
5
|
+
readonly Red: "red";
|
|
6
|
+
readonly Orange: "orange";
|
|
7
|
+
readonly Yellow: "yellow";
|
|
8
|
+
readonly Green: "green";
|
|
9
|
+
readonly Blue: "blue";
|
|
10
|
+
readonly Violet: "violet";
|
|
11
|
+
readonly Pink: "pink";
|
|
12
|
+
};
|
|
13
|
+
export declare const SIZE: {
|
|
14
|
+
readonly S: "s";
|
|
15
|
+
readonly M: "m";
|
|
16
|
+
readonly L: "l";
|
|
17
|
+
};
|
|
18
|
+
export declare const TARGET: {
|
|
19
|
+
readonly Self: "_self";
|
|
20
|
+
readonly Blank: "_blank";
|
|
21
|
+
readonly Parent: "_parent";
|
|
22
|
+
readonly Top: "_top";
|
|
23
|
+
};
|
|
24
|
+
export declare const ON_SURFACE: {
|
|
25
|
+
readonly Background: "background";
|
|
26
|
+
readonly Decor: "decor";
|
|
27
|
+
readonly Accent: "accent";
|
|
28
|
+
};
|
|
@@ -1,32 +1,28 @@
|
|
|
1
|
-
export
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
OnSurface["Background"] = "background";
|
|
30
|
-
OnSurface["Decor"] = "decor";
|
|
31
|
-
OnSurface["Accent"] = "accent";
|
|
32
|
-
})(OnSurface || (OnSurface = {}));
|
|
1
|
+
export const ON_COLOR = {
|
|
2
|
+
InvertNeutral: 'invert-neutral',
|
|
3
|
+
Neutral: 'neutral',
|
|
4
|
+
Primary: 'primary',
|
|
5
|
+
Red: 'red',
|
|
6
|
+
Orange: 'orange',
|
|
7
|
+
Yellow: 'yellow',
|
|
8
|
+
Green: 'green',
|
|
9
|
+
Blue: 'blue',
|
|
10
|
+
Violet: 'violet',
|
|
11
|
+
Pink: 'pink',
|
|
12
|
+
};
|
|
13
|
+
export const SIZE = {
|
|
14
|
+
S: 's',
|
|
15
|
+
M: 'm',
|
|
16
|
+
L: 'l',
|
|
17
|
+
};
|
|
18
|
+
export const TARGET = {
|
|
19
|
+
Self: '_self',
|
|
20
|
+
Blank: '_blank',
|
|
21
|
+
Parent: '_parent',
|
|
22
|
+
Top: '_top',
|
|
23
|
+
};
|
|
24
|
+
export const ON_SURFACE = {
|
|
25
|
+
Background: 'background',
|
|
26
|
+
Decor: 'decor',
|
|
27
|
+
Accent: 'accent',
|
|
28
|
+
};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
export * from './Link';
|
|
2
|
-
export {
|
|
2
|
+
export { ON_COLOR } from './constants';
|
package/dist/components/index.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
export * from './Link';
|
|
2
|
-
export {
|
|
2
|
+
export { ON_COLOR } from './constants';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
package/package.json
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
"access": "public"
|
|
5
5
|
},
|
|
6
6
|
"title": "Link",
|
|
7
|
-
"version": "0.
|
|
7
|
+
"version": "0.9.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.0",
|
|
36
|
-
"@snack-uikit/truncate-string": "0.
|
|
37
|
-
"@snack-uikit/utils": "3.
|
|
36
|
+
"@snack-uikit/truncate-string": "0.4.0",
|
|
37
|
+
"@snack-uikit/utils": "3.2.0",
|
|
38
38
|
"classnames": "2.3.2"
|
|
39
39
|
},
|
|
40
|
-
"gitHead": "
|
|
40
|
+
"gitHead": "bd39c5e674f3b91b0e2487782a04b15034cf3d8b"
|
|
41
41
|
}
|
package/src/components/Link.tsx
CHANGED
|
@@ -5,8 +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 { ON_COLOR, ON_SURFACE, SIZE } from './constants';
|
|
9
9
|
import styles from './styles.module.scss';
|
|
10
|
+
import { OnColor, OnSurface, Size } from './types';
|
|
10
11
|
|
|
11
12
|
export type LinkProps = WithSupportProps<{
|
|
12
13
|
/** Текст ссылки */
|
|
@@ -36,13 +37,13 @@ export function Link({
|
|
|
36
37
|
text = '',
|
|
37
38
|
className,
|
|
38
39
|
href = '#',
|
|
39
|
-
target =
|
|
40
|
+
target = '_blank',
|
|
40
41
|
download,
|
|
41
42
|
onClick,
|
|
42
|
-
onSurface =
|
|
43
|
-
size =
|
|
43
|
+
onSurface = ON_SURFACE.Background,
|
|
44
|
+
size = SIZE.S,
|
|
44
45
|
external,
|
|
45
|
-
onColor =
|
|
46
|
+
onColor = ON_COLOR.Primary,
|
|
46
47
|
...rest
|
|
47
48
|
}: LinkProps) {
|
|
48
49
|
return (
|
|
@@ -56,15 +57,10 @@ export function Link({
|
|
|
56
57
|
data-size={size}
|
|
57
58
|
data-on-surface={onSurface}
|
|
58
59
|
data-color={onColor}
|
|
59
|
-
rel={target ===
|
|
60
|
+
rel={target === '_blank' ? 'noopener noreferrer' : undefined}
|
|
60
61
|
>
|
|
61
62
|
<TruncateString text={text} maxLines={1} />
|
|
62
63
|
{external && <ArrowLinksSVG data-test-id='link__external-icon' className={styles.icon} />}
|
|
63
64
|
</a>
|
|
64
65
|
);
|
|
65
66
|
}
|
|
66
|
-
|
|
67
|
-
Link.sizes = Size;
|
|
68
|
-
Link.targets = Target;
|
|
69
|
-
Link.onColors = OnColor;
|
|
70
|
-
Link.onSurfaces = OnSurface;
|
|
@@ -1,31 +1,31 @@
|
|
|
1
|
-
export
|
|
2
|
-
InvertNeutral
|
|
3
|
-
Neutral
|
|
4
|
-
Primary
|
|
5
|
-
Red
|
|
6
|
-
Orange
|
|
7
|
-
Yellow
|
|
8
|
-
Green
|
|
9
|
-
Blue
|
|
10
|
-
Violet
|
|
11
|
-
Pink
|
|
12
|
-
}
|
|
1
|
+
export const ON_COLOR = {
|
|
2
|
+
InvertNeutral: 'invert-neutral',
|
|
3
|
+
Neutral: 'neutral',
|
|
4
|
+
Primary: 'primary',
|
|
5
|
+
Red: 'red',
|
|
6
|
+
Orange: 'orange',
|
|
7
|
+
Yellow: 'yellow',
|
|
8
|
+
Green: 'green',
|
|
9
|
+
Blue: 'blue',
|
|
10
|
+
Violet: 'violet',
|
|
11
|
+
Pink: 'pink',
|
|
12
|
+
} as const;
|
|
13
13
|
|
|
14
|
-
export
|
|
15
|
-
S
|
|
16
|
-
M
|
|
17
|
-
L
|
|
18
|
-
}
|
|
14
|
+
export const SIZE = {
|
|
15
|
+
S: 's',
|
|
16
|
+
M: 'm',
|
|
17
|
+
L: 'l',
|
|
18
|
+
} as const;
|
|
19
19
|
|
|
20
|
-
export
|
|
21
|
-
Self
|
|
22
|
-
Blank
|
|
23
|
-
Parent
|
|
24
|
-
Top
|
|
25
|
-
}
|
|
20
|
+
export const TARGET = {
|
|
21
|
+
Self: '_self',
|
|
22
|
+
Blank: '_blank',
|
|
23
|
+
Parent: '_parent',
|
|
24
|
+
Top: '_top',
|
|
25
|
+
} as const;
|
|
26
26
|
|
|
27
|
-
export
|
|
28
|
-
Background
|
|
29
|
-
Decor
|
|
30
|
-
Accent
|
|
31
|
-
}
|
|
27
|
+
export const ON_SURFACE = {
|
|
28
|
+
Background: 'background',
|
|
29
|
+
Decor: 'decor',
|
|
30
|
+
Accent: 'accent',
|
|
31
|
+
} as const;
|
package/src/components/index.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
export * from './Link';
|
|
2
|
-
export {
|
|
2
|
+
export { ON_COLOR } from './constants';
|