@vnejs/uis.react.text 0.1.2 → 0.1.4
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/dist/Text.d.ts +0 -1
- package/dist/Text.d.ts.map +1 -1
- package/dist/Text.js +2 -3
- package/dist/Text.js.map +1 -1
- package/dist/Text.styles.d.ts +2 -0
- package/dist/Text.styles.d.ts.map +1 -0
- package/dist/Text.styles.js +52 -0
- package/dist/Text.styles.js.map +1 -0
- package/package.json +12 -17
- package/src/Text.stories.tsx +41 -0
- package/src/Text.styles.ts +54 -0
- package/src/Text.tsx +87 -0
- package/src/index.ts +1 -0
- package/tsconfig.json +18 -0
- package/dist/Text.styl +0 -40
package/dist/Text.d.ts
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import "./Text.styl";
|
|
2
1
|
export declare const Text: {
|
|
3
2
|
({ isActive, isSelected, isHoverable, isDisabled, isCurrent, isNotRender, isInlineBlock, text, textPrefix, color, colorPrefix, size, className, padding, width, marginTop, marginRight, font, whiteSpace, align, weight, weightPrefix, opacity, transition, onClick, value, }: {
|
|
4
3
|
isActive?: boolean;
|
package/dist/Text.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Text.d.ts","sourceRoot":"","sources":["../src/Text.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"Text.d.ts","sourceRoot":"","sources":["../src/Text.tsx"],"names":[],"mappings":"AAMA,eAAO,MAAM,IAAI;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CA4EhB,CAAC"}
|
package/dist/Text.js
CHANGED
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
2
|
import { useCallback, useMemo } from "react";
|
|
3
|
-
import {
|
|
4
|
-
import "./Text.
|
|
5
|
-
const b = cn("Text");
|
|
3
|
+
import { getVneLength } from "@vnejs/uis.utils";
|
|
4
|
+
import { b } from "./Text.styles.js";
|
|
6
5
|
export const Text = ({ isActive = false, isSelected = false, isHoverable = false, isDisabled = false, isCurrent = false, isNotRender = false, isInlineBlock = false, text = "", textPrefix = "", color = "", colorPrefix = "", size = 96, className = "", padding = 0, width = 0, marginTop = 0, marginRight = 0, font = "", whiteSpace = "", align = "", weight = null, weightPrefix = null, opacity = null, transition = 300, onClick, value, }) => {
|
|
7
6
|
const style = useMemo(() => {
|
|
8
7
|
const result = {};
|
package/dist/Text.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Text.js","sourceRoot":"","sources":["../src/Text.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,WAAW,EAAE,OAAO,EAAE,MAAM,OAAO,CAAC;AAE7C,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"Text.js","sourceRoot":"","sources":["../src/Text.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,WAAW,EAAE,OAAO,EAAE,MAAM,OAAO,CAAC;AAE7C,OAAO,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAC;AAEhD,OAAO,EAAE,CAAC,EAAE,MAAM,kBAAkB,CAAC;AAErC,MAAM,CAAC,MAAM,IAAI,GAAG,CAAC,EACnB,QAAQ,GAAG,KAAK,EAChB,UAAU,GAAG,KAAK,EAClB,WAAW,GAAG,KAAK,EACnB,UAAU,GAAG,KAAK,EAClB,SAAS,GAAG,KAAK,EACjB,WAAW,GAAG,KAAK,EACnB,aAAa,GAAG,KAAK,EACrB,IAAI,GAAG,EAAE,EACT,UAAU,GAAG,EAAE,EACf,KAAK,GAAG,EAAE,EACV,WAAW,GAAG,EAAE,EAChB,IAAI,GAAG,EAAE,EACT,SAAS,GAAG,EAAE,EACd,OAAO,GAAG,CAAC,EACX,KAAK,GAAG,CAAC,EACT,SAAS,GAAG,CAAC,EACb,WAAW,GAAG,CAAC,EACf,IAAI,GAAG,EAAE,EACT,UAAU,GAAG,EAA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AE,IAAI,EAAE,MAAM,EAAE,MAAM,EAAE,QAAQ,EAAE,CAAC;AACtD,IAAI,CAAC,MAAM,GAAG,EAAE,IAAI,EAAE,MAAM,EAAE,MAAM,EAAE,QAAQ,EAAE,KAAK,EAAE,OAAO,EAAE,CAAC;AACjE,IAAI,CAAC,MAAM,GAAG,EAAE,IAAI,EAAE,MAAM,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,EAAE,QAAQ,EAAE,OAAO,EAAE,SAAS,EAAE,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Text.styles.d.ts","sourceRoot":"","sources":["../src/Text.styles.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,CAAC,4BAAa,CAAC"}
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import { cn, getVneLength, injectStyles, sel } from "@vnejs/uis.utils";
|
|
2
|
+
export const b = cn("Text");
|
|
3
|
+
const CSS = `
|
|
4
|
+
${sel(b())} {
|
|
5
|
+
--vne-text-color-disabled: var(--vne-color-disabled, rgba(255, 255, 255, 30%));
|
|
6
|
+
--vne-text-color-primary: var(--vne-color-primary, rgba(255, 255, 255, 60%));
|
|
7
|
+
--vne-text-color-selected: var(--vne-color-selected, rgba(255, 255, 255, 75%));
|
|
8
|
+
--vne-text-color-active: var(--vne-color-active, rgba(255, 255, 255, 90%));
|
|
9
|
+
display: block;
|
|
10
|
+
user-select: none;
|
|
11
|
+
font-weight: 400;
|
|
12
|
+
color: var(--vne-text-color-primary);
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
${sel(b({ isDisabled: true }))} {
|
|
16
|
+
color: var(--vne-text-color-disabled);
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
${sel(b({ isSelected: true }))} {
|
|
20
|
+
color: var(--vne-text-color-selected);
|
|
21
|
+
font-weight: bold;
|
|
22
|
+
text-shadow: 0 0 ${getVneLength(12)} rgba(255, 255, 255, 90%);
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
${sel(b({ isActive: true }))} {
|
|
26
|
+
color: var(--vne-text-color-active);
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
${sel(b({ isCurrent: true }))} {
|
|
30
|
+
text-decoration: underline;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
${sel(b({ isHoverable: true }))}[vne-cursor-target],
|
|
34
|
+
.TextHoverParent[vne-cursor-target] ${sel(b())},
|
|
35
|
+
.TextHoverSibling[vne-cursor-target] ~ ${sel(b())} {
|
|
36
|
+
color: var(--vne-text-color-active);
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
${sel(b({ align: "center" }))} {
|
|
40
|
+
text-align: center;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
${sel(b({ align: "right" }))} {
|
|
44
|
+
text-align: right;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
${sel(b({ isInlineBlock: true }))} {
|
|
48
|
+
display: inline-block;
|
|
49
|
+
}
|
|
50
|
+
`;
|
|
51
|
+
injectStyles(CSS);
|
|
52
|
+
//# sourceMappingURL=Text.styles.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Text.styles.js","sourceRoot":"","sources":["../src/Text.styles.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,EAAE,EAAE,YAAY,EAAE,YAAY,EAAE,GAAG,EAAE,MAAM,kBAAkB,CAAC;AAEvE,MAAM,CAAC,MAAM,CAAC,GAAG,EAAE,CAAC,MAAM,CAAC,CAAC;AAE5B,MAAM,GAAG,GAAG;EACV,GAAG,CAAC,CAAC,EAAE,CAAC;;;;;;;;;;;EAWR,GAAG,CAAC,CAAC,CAAC,EAAE,UAAU,EAAE,IAAI,EAAE,CAAC,CAAC;;;;EAI5B,GAAG,CAAC,CAAC,CAAC,EAAE,UAAU,EAAE,IAAI,EAAE,CAAC,CAAC;;;qBAGT,YAAY,CAAC,EAAE,CAAC;;;EAGnC,GAAG,CAAC,CAAC,CAAC,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC,CAAC;;;;EAI1B,GAAG,CAAC,CAAC,CAAC,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC,CAAC;;;;EAI3B,GAAG,CAAC,CAAC,CAAC,EAAE,WAAW,EAAE,IAAI,EAAE,CAAC,CAAC;sCACO,GAAG,CAAC,CAAC,EAAE,CAAC;yCACL,GAAG,CAAC,CAAC,EAAE,CAAC;;;;EAI/C,GAAG,CAAC,CAAC,CAAC,EAAE,KAAK,EAAE,QAAQ,EAAE,CAAC,CAAC;;;;EAI3B,GAAG,CAAC,CAAC,CAAC,EAAE,KAAK,EAAE,OAAO,EAAE,CAAC,CAAC;;;;EAI1B,GAAG,CAAC,CAAC,CAAC,EAAE,aAAa,EAAE,IAAI,EAAE,CAAC,CAAC;;;CAGhC,CAAC;AAEF,YAAY,CAAC,GAAG,CAAC,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,31 +1,26 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@vnejs/uis.react.text",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.4",
|
|
4
4
|
"main": "dist/index.js",
|
|
5
5
|
"types": "dist/index.d.ts",
|
|
6
6
|
"scripts": {
|
|
7
|
-
"build": "
|
|
8
|
-
"publish:major:
|
|
9
|
-
"publish:minor:
|
|
10
|
-
"publish:patch:
|
|
11
|
-
"publish:major": "
|
|
12
|
-
"publish:minor": "
|
|
13
|
-
"publish:patch": "
|
|
7
|
+
"build": "npx @vnejs/monorepo package",
|
|
8
|
+
"publish:major:uis:react": "npm run publish:major",
|
|
9
|
+
"publish:minor:uis:react": "npm run publish:minor",
|
|
10
|
+
"publish:patch:uis:react": "npm run publish:patch",
|
|
11
|
+
"publish:major": "npx @vnejs/monorepo publish major --access public",
|
|
12
|
+
"publish:minor": "npx @vnejs/monorepo publish minor --access public",
|
|
13
|
+
"publish:patch": "npx @vnejs/monorepo publish patch --access public"
|
|
14
14
|
},
|
|
15
15
|
"peerDependencies": {
|
|
16
|
-
"@
|
|
17
|
-
"@vnejs/uis.utils": "~0.1.0",
|
|
18
|
-
"react": "19.2.4",
|
|
19
|
-
"react-dom": "19.2.4"
|
|
16
|
+
"@vnejs/uis.utils": "~0.1.0"
|
|
20
17
|
},
|
|
21
18
|
"devDependencies": {
|
|
22
|
-
"@vnejs/uis.react": "~0.1.0"
|
|
23
|
-
"typescript": "^5.7.3",
|
|
24
|
-
"@types/react": "^19.0.10",
|
|
25
|
-
"@types/react-dom": "^19.0.4"
|
|
19
|
+
"@vnejs/uis.react": "~0.1.0"
|
|
26
20
|
},
|
|
27
21
|
"files": [
|
|
28
22
|
"dist",
|
|
29
|
-
"
|
|
23
|
+
"src",
|
|
24
|
+
"tsconfig.json"
|
|
30
25
|
]
|
|
31
26
|
}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { renderWithVneWrap, VneWrap } from "@vnejs/uis.react";
|
|
2
|
+
|
|
3
|
+
import { Text, Flex } from "@vnejs/uis.react";
|
|
4
|
+
|
|
5
|
+
export const Common = {
|
|
6
|
+
args: {
|
|
7
|
+
...VneWrap.DEFAULT_ARGS,
|
|
8
|
+
|
|
9
|
+
text: "In a loose sense the edge of the criterion the general features and possibilities of the existing network the final phase and cannot be developed under such circumstances.",
|
|
10
|
+
whiteSpace: Text.WHITESPACES.WRAP,
|
|
11
|
+
size: 48,
|
|
12
|
+
font: "Arial",
|
|
13
|
+
|
|
14
|
+
isSelected: false,
|
|
15
|
+
isActive: false,
|
|
16
|
+
isDisabled: false,
|
|
17
|
+
},
|
|
18
|
+
};
|
|
19
|
+
|
|
20
|
+
export default {
|
|
21
|
+
title: "Primitives/Text",
|
|
22
|
+
render: renderWithVneWrap(({ ...args }) => (
|
|
23
|
+
<Flex
|
|
24
|
+
align={Flex.ALIGN.CENTER}
|
|
25
|
+
justify={Flex.JUSTIFY.CENTER}
|
|
26
|
+
direction={Flex.DIRECTION.COLUMN}
|
|
27
|
+
height={2160}
|
|
28
|
+
>
|
|
29
|
+
<Text {...args} />
|
|
30
|
+
</Flex>
|
|
31
|
+
)),
|
|
32
|
+
argTypes: {
|
|
33
|
+
// engine
|
|
34
|
+
...VneWrap.ARGS,
|
|
35
|
+
|
|
36
|
+
// Text
|
|
37
|
+
size: { control: { type: "number", min: 24, max: 180, step: 6 } },
|
|
38
|
+
whiteSpace: { control: { type: "select" }, options: Object.values(Text.WHITESPACES) },
|
|
39
|
+
font: { control: { type: "select" }, options: ["Times New Roman", "Arial", "monospace"] },
|
|
40
|
+
},
|
|
41
|
+
};
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import { cn, getVneLength, injectStyles, sel } from "@vnejs/uis.utils";
|
|
2
|
+
|
|
3
|
+
export const b = cn("Text");
|
|
4
|
+
|
|
5
|
+
const CSS = `
|
|
6
|
+
${sel(b())} {
|
|
7
|
+
--vne-text-color-disabled: var(--vne-color-disabled, rgba(255, 255, 255, 30%));
|
|
8
|
+
--vne-text-color-primary: var(--vne-color-primary, rgba(255, 255, 255, 60%));
|
|
9
|
+
--vne-text-color-selected: var(--vne-color-selected, rgba(255, 255, 255, 75%));
|
|
10
|
+
--vne-text-color-active: var(--vne-color-active, rgba(255, 255, 255, 90%));
|
|
11
|
+
display: block;
|
|
12
|
+
user-select: none;
|
|
13
|
+
font-weight: 400;
|
|
14
|
+
color: var(--vne-text-color-primary);
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
${sel(b({ isDisabled: true }))} {
|
|
18
|
+
color: var(--vne-text-color-disabled);
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
${sel(b({ isSelected: true }))} {
|
|
22
|
+
color: var(--vne-text-color-selected);
|
|
23
|
+
font-weight: bold;
|
|
24
|
+
text-shadow: 0 0 ${getVneLength(12)} rgba(255, 255, 255, 90%);
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
${sel(b({ isActive: true }))} {
|
|
28
|
+
color: var(--vne-text-color-active);
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
${sel(b({ isCurrent: true }))} {
|
|
32
|
+
text-decoration: underline;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
${sel(b({ isHoverable: true }))}[vne-cursor-target],
|
|
36
|
+
.TextHoverParent[vne-cursor-target] ${sel(b())},
|
|
37
|
+
.TextHoverSibling[vne-cursor-target] ~ ${sel(b())} {
|
|
38
|
+
color: var(--vne-text-color-active);
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
${sel(b({ align: "center" }))} {
|
|
42
|
+
text-align: center;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
${sel(b({ align: "right" }))} {
|
|
46
|
+
text-align: right;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
${sel(b({ isInlineBlock: true }))} {
|
|
50
|
+
display: inline-block;
|
|
51
|
+
}
|
|
52
|
+
`;
|
|
53
|
+
|
|
54
|
+
injectStyles(CSS);
|
package/src/Text.tsx
ADDED
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
import { useCallback, useMemo } from "react";
|
|
2
|
+
|
|
3
|
+
import { getVneLength } from "@vnejs/uis.utils";
|
|
4
|
+
|
|
5
|
+
import { b } from "./Text.styles.js";
|
|
6
|
+
|
|
7
|
+
export const Text = ({
|
|
8
|
+
isActive = false,
|
|
9
|
+
isSelected = false,
|
|
10
|
+
isHoverable = false,
|
|
11
|
+
isDisabled = false,
|
|
12
|
+
isCurrent = false,
|
|
13
|
+
isNotRender = false,
|
|
14
|
+
isInlineBlock = false,
|
|
15
|
+
text = "",
|
|
16
|
+
textPrefix = "",
|
|
17
|
+
color = "",
|
|
18
|
+
colorPrefix = "",
|
|
19
|
+
size = 96,
|
|
20
|
+
className = "",
|
|
21
|
+
padding = 0,
|
|
22
|
+
width = 0,
|
|
23
|
+
marginTop = 0,
|
|
24
|
+
marginRight = 0,
|
|
25
|
+
font = "",
|
|
26
|
+
whiteSpace = "",
|
|
27
|
+
align = "",
|
|
28
|
+
weight = null,
|
|
29
|
+
weightPrefix = null,
|
|
30
|
+
opacity = null,
|
|
31
|
+
transition = 300,
|
|
32
|
+
onClick,
|
|
33
|
+
value,
|
|
34
|
+
}) => {
|
|
35
|
+
const style = useMemo(() => {
|
|
36
|
+
const result: Record<string, any> = {};
|
|
37
|
+
|
|
38
|
+
if (font) result.fontFamily = font;
|
|
39
|
+
if (color) result.color = color;
|
|
40
|
+
if (weight) result.fontWeight = weight;
|
|
41
|
+
if (whiteSpace) result.whiteSpace = whiteSpace;
|
|
42
|
+
if (transition !== null) result.transition = transition ? `${transition}ms` : "none";
|
|
43
|
+
if (opacity !== null) result.opacity = opacity;
|
|
44
|
+
|
|
45
|
+
if (size) {
|
|
46
|
+
result.fontSize = `round(down, calc(${getVneLength(size)} * var(--vne-text-size-multiplicator, 1)), 1px)`;
|
|
47
|
+
result.lineHeight = `round(down, calc(${getVneLength(1.25 * size)} * var(--vne-text-size-multiplicator, 1)), 1px)`;
|
|
48
|
+
}
|
|
49
|
+
if (padding) result.padding = getVneLength(padding);
|
|
50
|
+
if (width) result.width = getVneLength(width);
|
|
51
|
+
if (marginTop) result.marginTop = getVneLength(marginTop);
|
|
52
|
+
if (marginRight) result.marginRight = getVneLength(marginRight);
|
|
53
|
+
|
|
54
|
+
return result;
|
|
55
|
+
}, [font, color, whiteSpace, size, weight, padding, marginTop, opacity, width, transition]);
|
|
56
|
+
|
|
57
|
+
const stylePrefix = useMemo(() => {
|
|
58
|
+
const result: Record<string, any> = {};
|
|
59
|
+
|
|
60
|
+
if (colorPrefix) result.color = colorPrefix;
|
|
61
|
+
if (weightPrefix) result.fontWeight = weightPrefix;
|
|
62
|
+
|
|
63
|
+
return result;
|
|
64
|
+
}, [colorPrefix, weightPrefix]);
|
|
65
|
+
|
|
66
|
+
const onClickHandler = useCallback(() => !isDisabled && onClick && onClick(value), [value, onClick, isDisabled]);
|
|
67
|
+
|
|
68
|
+
const isRealHovered = useMemo(() => isHoverable && !isDisabled, [isHoverable, isDisabled]);
|
|
69
|
+
|
|
70
|
+
if (isNotRender) return null;
|
|
71
|
+
|
|
72
|
+
return (
|
|
73
|
+
<div
|
|
74
|
+
className={b({ isActive, isHoverable: isRealHovered, isSelected, isDisabled, isCurrent, isInlineBlock, align }, [className])}
|
|
75
|
+
style={style}
|
|
76
|
+
onClick={onClickHandler}
|
|
77
|
+
vne-cursor-type={isRealHovered ? "pointer" : ""}
|
|
78
|
+
>
|
|
79
|
+
{textPrefix && <span style={stylePrefix}>{textPrefix}</span>}
|
|
80
|
+
{text}
|
|
81
|
+
</div>
|
|
82
|
+
);
|
|
83
|
+
};
|
|
84
|
+
|
|
85
|
+
Text.WHITESPACES = { WRAP: "wrap", NOWRAP: "nowrap" };
|
|
86
|
+
Text.ALIGNS = { LEFT: "left", CENTER: "center", RIGHT: "right" };
|
|
87
|
+
Text.WEIGHT = { BOLD: "bold", NORMAL: "normal", BOLDER: "bolder", LIGHTER: "lighter" };
|
package/src/index.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "./Text";
|
package/tsconfig.json
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
{
|
|
2
|
+
"extends": "../../../tsconfig.react.base.json",
|
|
3
|
+
"compilerOptions": {
|
|
4
|
+
"outDir": "dist",
|
|
5
|
+
"rootDir": "src"
|
|
6
|
+
},
|
|
7
|
+
"include": [
|
|
8
|
+
"src/**/*.ts",
|
|
9
|
+
"src/**/*.tsx",
|
|
10
|
+
"../../../globals.d.ts",
|
|
11
|
+
"../../../peer-modules.d.ts"
|
|
12
|
+
],
|
|
13
|
+
"exclude": [
|
|
14
|
+
"dist",
|
|
15
|
+
"node_modules",
|
|
16
|
+
"src/**/*.stories.tsx"
|
|
17
|
+
]
|
|
18
|
+
}
|
package/dist/Text.styl
DELETED
|
@@ -1,40 +0,0 @@
|
|
|
1
|
-
.Text
|
|
2
|
-
--vne-text-color-disabled: var(--vne-color-disabled, rgba(255, 255, 255, 30%));
|
|
3
|
-
--vne-text-color-primary: var(--vne-color-primary, rgba(255, 255, 255, 60%));
|
|
4
|
-
--vne-text-color-selected: var(--vne-color-selected, rgba(255, 255, 255, 75%));
|
|
5
|
-
--vne-text-color-active: var(--vne-color-active, rgba(255, 255, 255, 90%));
|
|
6
|
-
|
|
7
|
-
display: block
|
|
8
|
-
user-select: none
|
|
9
|
-
font-weight: 400
|
|
10
|
-
|
|
11
|
-
color: var(--vne-text-color-primary)
|
|
12
|
-
|
|
13
|
-
&_isDisabled
|
|
14
|
-
color: var(--vne-text-color-disabled);
|
|
15
|
-
|
|
16
|
-
&_isSelected
|
|
17
|
-
color: var(--vne-text-color-selected);
|
|
18
|
-
|
|
19
|
-
&_isActive
|
|
20
|
-
color: var(--vne-text-color-active);
|
|
21
|
-
|
|
22
|
-
&_isCurrent
|
|
23
|
-
text-decoration: underline
|
|
24
|
-
|
|
25
|
-
&_isSelected
|
|
26
|
-
font-weight: bold
|
|
27
|
-
text-shadow: 0 0 s('round(down, min(calc(12 * 100vw / 3840), calc(12 * 100vh / 2160)), 1px)') rgba(255, 255, 255, 90%)
|
|
28
|
-
|
|
29
|
-
&_isHoverable[vne-cursor-target],
|
|
30
|
-
.TextHoverParent[vne-cursor-target] &,
|
|
31
|
-
.TextHoverSibling[vne-cursor-target] ~ &
|
|
32
|
-
color: var(--vne-text-color-active);
|
|
33
|
-
|
|
34
|
-
&_align_center
|
|
35
|
-
text-align: center
|
|
36
|
-
&_align_right
|
|
37
|
-
text-align: right
|
|
38
|
-
|
|
39
|
-
&_isInlineBlock
|
|
40
|
-
display: inline-block
|