@snack-uikit/code-editor 0.6.5-preview-6c5a9bc3.0 → 0.7.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 +1 -1
- package/dist/cjs/components/CodeEditor.d.ts +3 -3
- package/dist/cjs/components/CodeEditor.js +4 -4
- package/dist/cjs/components/CopyButton/CopyButton.d.ts +1 -1
- package/dist/cjs/components/CopyButton/CopyButton.js +3 -3
- package/dist/cjs/components/styles.module.css +3 -3
- package/dist/cjs/components/utils.d.ts +1 -1
- package/dist/cjs/components/utils.js +5 -6
- package/dist/esm/components/CodeEditor.d.ts +3 -3
- package/dist/esm/components/CodeEditor.js +3 -3
- package/dist/esm/components/CopyButton/CopyButton.d.ts +1 -1
- package/dist/esm/components/CopyButton/CopyButton.js +2 -2
- package/dist/esm/components/styles.module.css +3 -3
- package/dist/esm/components/utils.d.ts +1 -1
- package/dist/esm/components/utils.js +4 -5
- package/package.json +6 -4
- package/src/components/CodeEditor.tsx +6 -6
- package/src/components/CopyButton/CopyButton.tsx +3 -3
- package/src/components/styles.module.scss +4 -4
- package/src/components/utils.ts +5 -5
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.7.0 (2025-05-28)
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
### Features
|
|
10
|
+
|
|
11
|
+
* **PDS-2227:** add copy button for code editor ([6891964](https://git.sbercloud.tech/sbercloud-ui/tokens-design-system/snack-uikit/commits/6891964be3dffecab54a3a226f250f6d303da7e9))
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
|
|
6
17
|
## 0.6.4 (2025-05-16)
|
|
7
18
|
|
|
8
19
|
### Only dependencies have been changed
|
package/README.md
CHANGED
|
@@ -15,7 +15,7 @@
|
|
|
15
15
|
| jsonSchema* | `JsonSchema` | - | Схема для валидации |
|
|
16
16
|
| themeName | `string` | - | Название текущей темы. Значение не важно, важно что смена значения запускает пересчет стилей. |
|
|
17
17
|
| hasBackground | `boolean` | true | Включение/отключение псевдобекграунда |
|
|
18
|
-
|
|
|
18
|
+
| hasHeader | `boolean` | - | Включение/отключение шапки |
|
|
19
19
|
| onCopyClick | `() => void` | - | Клик по кнопке копирования |
|
|
20
20
|
| defaultValue | `string` | - | Default value of the current model |
|
|
21
21
|
| defaultLanguage | `string` | - | Default language of the current model |
|
|
@@ -10,12 +10,12 @@ export type CodeEditorProps = WithSupportProps<{
|
|
|
10
10
|
*/
|
|
11
11
|
hasBackground?: boolean;
|
|
12
12
|
/**
|
|
13
|
-
* Включение/отключение шапки
|
|
13
|
+
* Включение/отключение шапки
|
|
14
14
|
*/
|
|
15
|
-
|
|
15
|
+
hasHeader?: boolean;
|
|
16
16
|
/**
|
|
17
17
|
* Клик по кнопке копирования
|
|
18
18
|
*/
|
|
19
19
|
onCopyClick?(): void;
|
|
20
20
|
}> & (EditorBaseProps | EditorWithJsonSchemaProps);
|
|
21
|
-
export declare function CodeEditor({ themeName, className, theme, options, loading, hasBackground, onMount, language, onCopyClick,
|
|
21
|
+
export declare function CodeEditor({ themeName, className, theme, options, loading, hasBackground, onMount, language, onCopyClick, hasHeader, ...props }: CodeEditorProps): import("react/jsx-runtime").JSX.Element;
|
|
@@ -40,9 +40,9 @@ function CodeEditor(_a) {
|
|
|
40
40
|
onMount,
|
|
41
41
|
language,
|
|
42
42
|
onCopyClick,
|
|
43
|
-
|
|
43
|
+
hasHeader
|
|
44
44
|
} = _a,
|
|
45
|
-
props = __rest(_a, ["themeName", "className", "theme", "options", "loading", "hasBackground", "onMount", "language", "onCopyClick", "
|
|
45
|
+
props = __rest(_a, ["themeName", "className", "theme", "options", "loading", "hasBackground", "onMount", "language", "onCopyClick", "hasHeader"]);
|
|
46
46
|
const monaco = (0, react_1.useMonaco)();
|
|
47
47
|
const [wrapperElement, setWrapperElement] = (0, react_2.useState)(null);
|
|
48
48
|
const {
|
|
@@ -119,10 +119,10 @@ function CodeEditor(_a) {
|
|
|
119
119
|
className: className
|
|
120
120
|
}, (0, utils_1.extractSupportProps)(props), {
|
|
121
121
|
ref: setWrapperElement,
|
|
122
|
-
children: [
|
|
122
|
+
children: [hasHeader && (0, jsx_runtime_1.jsxs)("div", {
|
|
123
123
|
className: styles_module_scss_1.default.headline,
|
|
124
124
|
children: [language && (0, jsx_runtime_1.jsx)(typography_1.Typography.SansLabelS, {
|
|
125
|
-
children: (0, utils_2.
|
|
125
|
+
children: (0, utils_2.uppercaseFirstLetter)(language)
|
|
126
126
|
}), (0, jsx_runtime_1.jsx)(CopyButton_1.CopyButton, {
|
|
127
127
|
valueToCopy: props.value || '',
|
|
128
128
|
size: 's',
|
|
@@ -4,6 +4,6 @@ export type CopyButtonProps = WithSupportProps<{
|
|
|
4
4
|
valueToCopy: string | number;
|
|
5
5
|
size?: ButtonFunctionProps['size'];
|
|
6
6
|
className?: string;
|
|
7
|
-
onClick
|
|
7
|
+
onClick?(): void;
|
|
8
8
|
}>;
|
|
9
9
|
export declare function CopyButton({ valueToCopy, size, className, onClick, ...rest }: CopyButtonProps): import("react/jsx-runtime").JSX.Element;
|
|
@@ -19,7 +19,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
19
19
|
exports.CopyButton = CopyButton;
|
|
20
20
|
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
21
21
|
const react_1 = require("react");
|
|
22
|
-
const
|
|
22
|
+
const ft_copy_to_clipboard_1 = require("@cloud-ru/ft-copy-to-clipboard");
|
|
23
23
|
const button_1 = require("@snack-uikit/button");
|
|
24
24
|
const icons_1 = require("@snack-uikit/icons");
|
|
25
25
|
const locale_1 = require("@snack-uikit/locale");
|
|
@@ -43,11 +43,11 @@ function CopyButton(_a) {
|
|
|
43
43
|
const closeChecked = () => setIsCheckedOpen(false);
|
|
44
44
|
const handleClick = event => {
|
|
45
45
|
event.stopPropagation();
|
|
46
|
-
valueToCopy && (0,
|
|
46
|
+
valueToCopy && (0, ft_copy_to_clipboard_1.copyToClipboard)(String(valueToCopy));
|
|
47
47
|
openChecked();
|
|
48
48
|
clearTimeout(timerId.current);
|
|
49
49
|
timerId.current = setTimeout(closeChecked, 1000);
|
|
50
|
-
onClick === null || onClick === void 0 ? void 0 : onClick(
|
|
50
|
+
onClick === null || onClick === void 0 ? void 0 : onClick();
|
|
51
51
|
};
|
|
52
52
|
(0, react_1.useEffect)(() => () => {
|
|
53
53
|
closeChecked();
|
|
@@ -13,9 +13,9 @@
|
|
|
13
13
|
}
|
|
14
14
|
|
|
15
15
|
.headline{
|
|
16
|
-
min-height:var(--size-
|
|
17
|
-
padding-left:var(--space-
|
|
18
|
-
padding-right:var(--space-
|
|
16
|
+
min-height:var(--size-code-editor-headline-min-height, 36px);
|
|
17
|
+
padding-left:var(--space-code-editor-headline-horizontal-padding, 12px);
|
|
18
|
+
padding-right:var(--space-code-editor-headline-horizontal-padding, 12px);
|
|
19
19
|
display:flex;
|
|
20
20
|
align-items:center;
|
|
21
21
|
justify-content:space-between;
|
|
@@ -3,4 +3,4 @@ import { JsonSchema } from './types';
|
|
|
3
3
|
export declare function rgb2hsl(HTMLcolor: string): number[];
|
|
4
4
|
export declare function isDark(color: string): boolean;
|
|
5
5
|
export declare const getJsonSchema: (jsonSchema?: JsonSchema) => SchemasSettings | undefined;
|
|
6
|
-
export declare function
|
|
6
|
+
export declare function uppercaseFirstLetter(value: string): string;
|
|
@@ -11,7 +11,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
11
11
|
exports.getJsonSchema = void 0;
|
|
12
12
|
exports.rgb2hsl = rgb2hsl;
|
|
13
13
|
exports.isDark = isDark;
|
|
14
|
-
exports.
|
|
14
|
+
exports.uppercaseFirstLetter = uppercaseFirstLetter;
|
|
15
15
|
const chroma_js_1 = __importDefault(require("chroma-js"));
|
|
16
16
|
const constants_1 = require("./constants");
|
|
17
17
|
function rgb2hsl(HTMLcolor) {
|
|
@@ -52,11 +52,10 @@ const getJsonSchema = jsonSchema => jsonSchema && Object.assign(Object.assign({}
|
|
|
52
52
|
fileMatch: [jsonSchema.fileMatch]
|
|
53
53
|
});
|
|
54
54
|
exports.getJsonSchema = getJsonSchema;
|
|
55
|
-
function
|
|
56
|
-
|
|
55
|
+
function uppercaseFirstLetter(value) {
|
|
56
|
+
const trimmedValue = value.trim();
|
|
57
|
+
if (trimmedValue.length === 0) {
|
|
57
58
|
return value;
|
|
58
59
|
}
|
|
59
|
-
|
|
60
|
-
valueLetters[0] = valueLetters[0].toUpperCase();
|
|
61
|
-
return valueLetters.join('');
|
|
60
|
+
return trimmedValue[0].toUpperCase() + trimmedValue.slice(1);
|
|
62
61
|
}
|
|
@@ -10,12 +10,12 @@ export type CodeEditorProps = WithSupportProps<{
|
|
|
10
10
|
*/
|
|
11
11
|
hasBackground?: boolean;
|
|
12
12
|
/**
|
|
13
|
-
* Включение/отключение шапки
|
|
13
|
+
* Включение/отключение шапки
|
|
14
14
|
*/
|
|
15
|
-
|
|
15
|
+
hasHeader?: boolean;
|
|
16
16
|
/**
|
|
17
17
|
* Клик по кнопке копирования
|
|
18
18
|
*/
|
|
19
19
|
onCopyClick?(): void;
|
|
20
20
|
}> & (EditorBaseProps | EditorWithJsonSchemaProps);
|
|
21
|
-
export declare function CodeEditor({ themeName, className, theme, options, loading, hasBackground, onMount, language, onCopyClick,
|
|
21
|
+
export declare function CodeEditor({ themeName, className, theme, options, loading, hasBackground, onMount, language, onCopyClick, hasHeader, ...props }: CodeEditorProps): import("react/jsx-runtime").JSX.Element;
|
|
@@ -20,9 +20,9 @@ import { CODE_EDITOR_OPTIONS, DEFAULT_THEME_OPTIONS, DEFAULT_THEME_VALUES } from
|
|
|
20
20
|
import { CopyButton } from './CopyButton';
|
|
21
21
|
import { useApplyJsonSchema, useCalculatedThemeValues } from './hooks';
|
|
22
22
|
import styles from './styles.module.css';
|
|
23
|
-
import { isDark,
|
|
23
|
+
import { isDark, uppercaseFirstLetter } from './utils';
|
|
24
24
|
export function CodeEditor(_a) {
|
|
25
|
-
var { themeName, className, theme, options, loading, hasBackground = true, onMount, language, onCopyClick,
|
|
25
|
+
var { themeName, className, theme, options, loading, hasBackground = true, onMount, language, onCopyClick, hasHeader } = _a, props = __rest(_a, ["themeName", "className", "theme", "options", "loading", "hasBackground", "onMount", "language", "onCopyClick", "hasHeader"]);
|
|
26
26
|
const monaco = useMonaco();
|
|
27
27
|
const [wrapperElement, setWrapperElement] = useState(null);
|
|
28
28
|
const { jsonSchemaProps, jsonSchemaOptions } = useApplyJsonSchema(language, 'jsonSchema' in props ? props.jsonSchema : undefined);
|
|
@@ -89,5 +89,5 @@ export function CodeEditor(_a) {
|
|
|
89
89
|
fontFamily: themeValues.mono.body.s['font-family'],
|
|
90
90
|
}
|
|
91
91
|
: DEFAULT_THEME_OPTIONS.mono.s)), options)), [options, themeValues === null || themeValues === void 0 ? void 0 : themeValues.mono, jsonSchemaOptions]);
|
|
92
|
-
return (_jsxs("div", Object.assign({ className: className }, extractSupportProps(props), { ref: setWrapperElement, children: [
|
|
92
|
+
return (_jsxs("div", Object.assign({ className: className }, extractSupportProps(props), { ref: setWrapperElement, children: [hasHeader && (_jsxs("div", { className: styles.headline, children: [language && _jsx(Typography.SansLabelS, { children: uppercaseFirstLetter(language) }), _jsx(CopyButton, { valueToCopy: props.value || '', size: 's', onClick: onCopyClick })] })), _jsx(Editor, Object.assign({}, jsonSchemaProps, props, { theme: theme !== null && theme !== void 0 ? theme : (dark ? 'snackDark' : 'snack'), className: cn({ [styles.editor]: hasBackground }), loading: loading !== null && loading !== void 0 ? loading : _jsx(Spinner, {}), options: mergedOptions, onMount: onEditorMount, language: language }))] })));
|
|
93
93
|
}
|
|
@@ -4,6 +4,6 @@ export type CopyButtonProps = WithSupportProps<{
|
|
|
4
4
|
valueToCopy: string | number;
|
|
5
5
|
size?: ButtonFunctionProps['size'];
|
|
6
6
|
className?: string;
|
|
7
|
-
onClick
|
|
7
|
+
onClick?(): void;
|
|
8
8
|
}>;
|
|
9
9
|
export declare function CopyButton({ valueToCopy, size, className, onClick, ...rest }: CopyButtonProps): import("react/jsx-runtime").JSX.Element;
|
|
@@ -11,7 +11,7 @@ var __rest = (this && this.__rest) || function (s, e) {
|
|
|
11
11
|
};
|
|
12
12
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
13
13
|
import { useEffect, useRef, useState } from 'react';
|
|
14
|
-
import { copyToClipboard } from '@cloud-ru/
|
|
14
|
+
import { copyToClipboard } from '@cloud-ru/ft-copy-to-clipboard';
|
|
15
15
|
import { ButtonFunction } from '@snack-uikit/button';
|
|
16
16
|
import { CheckSVG, CopySVG } from '@snack-uikit/icons';
|
|
17
17
|
import { useLocale } from '@snack-uikit/locale';
|
|
@@ -31,7 +31,7 @@ export function CopyButton(_a) {
|
|
|
31
31
|
openChecked();
|
|
32
32
|
clearTimeout(timerId.current);
|
|
33
33
|
timerId.current = setTimeout(closeChecked, 1000);
|
|
34
|
-
onClick === null || onClick === void 0 ? void 0 : onClick(
|
|
34
|
+
onClick === null || onClick === void 0 ? void 0 : onClick();
|
|
35
35
|
};
|
|
36
36
|
useEffect(() => () => {
|
|
37
37
|
closeChecked();
|
|
@@ -13,9 +13,9 @@
|
|
|
13
13
|
}
|
|
14
14
|
|
|
15
15
|
.headline{
|
|
16
|
-
min-height:var(--size-
|
|
17
|
-
padding-left:var(--space-
|
|
18
|
-
padding-right:var(--space-
|
|
16
|
+
min-height:var(--size-code-editor-headline-min-height, 36px);
|
|
17
|
+
padding-left:var(--space-code-editor-headline-horizontal-padding, 12px);
|
|
18
|
+
padding-right:var(--space-code-editor-headline-horizontal-padding, 12px);
|
|
19
19
|
display:flex;
|
|
20
20
|
align-items:center;
|
|
21
21
|
justify-content:space-between;
|
|
@@ -3,4 +3,4 @@ import { JsonSchema } from './types';
|
|
|
3
3
|
export declare function rgb2hsl(HTMLcolor: string): number[];
|
|
4
4
|
export declare function isDark(color: string): boolean;
|
|
5
5
|
export declare const getJsonSchema: (jsonSchema?: JsonSchema) => SchemasSettings | undefined;
|
|
6
|
-
export declare function
|
|
6
|
+
export declare function uppercaseFirstLetter(value: string): string;
|
|
@@ -38,11 +38,10 @@ export function isDark(color) {
|
|
|
38
38
|
return (h < 0.55 && l >= 0.5) || (h >= 0.55 && l >= 0.75);
|
|
39
39
|
}
|
|
40
40
|
export const getJsonSchema = (jsonSchema) => jsonSchema && Object.assign(Object.assign({}, jsonSchema), { uri: (jsonSchema === null || jsonSchema === void 0 ? void 0 : jsonSchema.uri) || DEFAULT_SCHEMA_URI, fileMatch: [jsonSchema.fileMatch] });
|
|
41
|
-
export function
|
|
42
|
-
|
|
41
|
+
export function uppercaseFirstLetter(value) {
|
|
42
|
+
const trimmedValue = value.trim();
|
|
43
|
+
if (trimmedValue.length === 0) {
|
|
43
44
|
return value;
|
|
44
45
|
}
|
|
45
|
-
|
|
46
|
-
valueLetters[0] = valueLetters[0].toUpperCase();
|
|
47
|
-
return valueLetters.join('');
|
|
46
|
+
return trimmedValue[0].toUpperCase() + trimmedValue.slice(1);
|
|
48
47
|
}
|
package/package.json
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
"publishConfig": {
|
|
5
5
|
"access": "public"
|
|
6
6
|
},
|
|
7
|
-
"version": "0.
|
|
7
|
+
"version": "0.7.0",
|
|
8
8
|
"sideEffects": [
|
|
9
9
|
"*.css",
|
|
10
10
|
"*.woff",
|
|
@@ -36,12 +36,11 @@
|
|
|
36
36
|
"license": "Apache-2.0",
|
|
37
37
|
"scripts": {},
|
|
38
38
|
"dependencies": {
|
|
39
|
-
"@cloud-ru/
|
|
39
|
+
"@cloud-ru/ft-copy-to-clipboard": "0.1.0",
|
|
40
40
|
"@monaco-editor/react": "4.6.0",
|
|
41
41
|
"@snack-uikit/button": "0.19.11",
|
|
42
42
|
"@snack-uikit/icons": "0.26.3",
|
|
43
43
|
"@snack-uikit/loaders": "0.9.5",
|
|
44
|
-
"@snack-uikit/locale": "0.14.1-preview-6c5a9bc3.0",
|
|
45
44
|
"@snack-uikit/tooltip": "0.17.2",
|
|
46
45
|
"@snack-uikit/typography": "0.8.7",
|
|
47
46
|
"@snack-uikit/utils": "3.8.2",
|
|
@@ -49,8 +48,11 @@
|
|
|
49
48
|
"classnames": "2.5.1",
|
|
50
49
|
"monaco-yaml": "5.2.3"
|
|
51
50
|
},
|
|
51
|
+
"peerDependencies": {
|
|
52
|
+
"@snack-uikit/locale": "*"
|
|
53
|
+
},
|
|
52
54
|
"devDependencies": {
|
|
53
55
|
"@types/chroma-js": "2.4.4"
|
|
54
56
|
},
|
|
55
|
-
"gitHead": "
|
|
57
|
+
"gitHead": "bfec8dd0ba3b8e294440db45599d9770216e602f"
|
|
56
58
|
}
|
|
@@ -11,7 +11,7 @@ import { CopyButton } from './CopyButton';
|
|
|
11
11
|
import { useApplyJsonSchema, useCalculatedThemeValues } from './hooks';
|
|
12
12
|
import styles from './styles.module.scss';
|
|
13
13
|
import { EditorBaseProps, EditorWithJsonSchemaProps } from './types';
|
|
14
|
-
import { isDark,
|
|
14
|
+
import { isDark, uppercaseFirstLetter } from './utils';
|
|
15
15
|
|
|
16
16
|
export type CodeEditorProps = WithSupportProps<{
|
|
17
17
|
/**
|
|
@@ -23,9 +23,9 @@ export type CodeEditorProps = WithSupportProps<{
|
|
|
23
23
|
*/
|
|
24
24
|
hasBackground?: boolean;
|
|
25
25
|
/**
|
|
26
|
-
* Включение/отключение шапки
|
|
26
|
+
* Включение/отключение шапки
|
|
27
27
|
*/
|
|
28
|
-
|
|
28
|
+
hasHeader?: boolean;
|
|
29
29
|
/**
|
|
30
30
|
* Клик по кнопке копирования
|
|
31
31
|
*/
|
|
@@ -43,7 +43,7 @@ export function CodeEditor({
|
|
|
43
43
|
onMount,
|
|
44
44
|
language,
|
|
45
45
|
onCopyClick,
|
|
46
|
-
|
|
46
|
+
hasHeader,
|
|
47
47
|
...props
|
|
48
48
|
}: CodeEditorProps) {
|
|
49
49
|
const monaco = useMonaco();
|
|
@@ -144,9 +144,9 @@ export function CodeEditor({
|
|
|
144
144
|
|
|
145
145
|
return (
|
|
146
146
|
<div className={className} {...extractSupportProps(props)} ref={setWrapperElement}>
|
|
147
|
-
{
|
|
147
|
+
{hasHeader && (
|
|
148
148
|
<div className={styles.headline}>
|
|
149
|
-
{language && <Typography.SansLabelS>{
|
|
149
|
+
{language && <Typography.SansLabelS>{uppercaseFirstLetter(language)}</Typography.SansLabelS>}
|
|
150
150
|
<CopyButton valueToCopy={props.value || ''} size={'s'} onClick={onCopyClick} />
|
|
151
151
|
</div>
|
|
152
152
|
)}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { MouseEventHandler, useEffect, useRef, useState } from 'react';
|
|
2
2
|
|
|
3
|
-
import { copyToClipboard } from '@cloud-ru/
|
|
3
|
+
import { copyToClipboard } from '@cloud-ru/ft-copy-to-clipboard';
|
|
4
4
|
import { ButtonFunction, ButtonFunctionProps } from '@snack-uikit/button';
|
|
5
5
|
import { CheckSVG, CopySVG } from '@snack-uikit/icons';
|
|
6
6
|
import { useLocale } from '@snack-uikit/locale';
|
|
@@ -13,7 +13,7 @@ export type CopyButtonProps = WithSupportProps<{
|
|
|
13
13
|
valueToCopy: string | number;
|
|
14
14
|
size?: ButtonFunctionProps['size'];
|
|
15
15
|
className?: string;
|
|
16
|
-
onClick
|
|
16
|
+
onClick?(): void;
|
|
17
17
|
}>;
|
|
18
18
|
|
|
19
19
|
export function CopyButton({ valueToCopy, size = 's', className, onClick, ...rest }: CopyButtonProps) {
|
|
@@ -29,7 +29,7 @@ export function CopyButton({ valueToCopy, size = 's', className, onClick, ...res
|
|
|
29
29
|
openChecked();
|
|
30
30
|
clearTimeout(timerId.current);
|
|
31
31
|
timerId.current = setTimeout(closeChecked, 1000);
|
|
32
|
-
onClick?.(
|
|
32
|
+
onClick?.();
|
|
33
33
|
};
|
|
34
34
|
|
|
35
35
|
useEffect(
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
@use '@snack-uikit/figma-tokens/build/scss/styles-theme-variables' as var;
|
|
2
|
-
@use '@snack-uikit/figma-tokens/build/scss/components/styles-tokens-
|
|
2
|
+
@use '@snack-uikit/figma-tokens/build/scss/components/styles-tokens-codeEditor' as stc;
|
|
3
3
|
|
|
4
4
|
|
|
5
5
|
|
|
@@ -22,12 +22,12 @@
|
|
|
22
22
|
}
|
|
23
23
|
|
|
24
24
|
.headline {
|
|
25
|
-
@include
|
|
25
|
+
@include stc.composite-var(stc.$code-editor-headline);
|
|
26
26
|
|
|
27
27
|
display: flex;
|
|
28
28
|
align-items: center;
|
|
29
29
|
justify-content: space-between;
|
|
30
30
|
|
|
31
|
-
background-color:
|
|
32
|
-
border-color:
|
|
31
|
+
background-color: stc.$sys-neutral-background;
|
|
32
|
+
border-color: stc.$sys-neutral-decor-default;
|
|
33
33
|
}
|
package/src/components/utils.ts
CHANGED
|
@@ -57,12 +57,12 @@ export function isDark(color: string) {
|
|
|
57
57
|
export const getJsonSchema = (jsonSchema?: JsonSchema): SchemasSettings | undefined =>
|
|
58
58
|
jsonSchema && { ...jsonSchema, uri: jsonSchema?.uri || DEFAULT_SCHEMA_URI, fileMatch: [jsonSchema.fileMatch] };
|
|
59
59
|
|
|
60
|
-
export function
|
|
61
|
-
|
|
60
|
+
export function uppercaseFirstLetter(value: string) {
|
|
61
|
+
const trimmedValue = value.trim();
|
|
62
|
+
|
|
63
|
+
if (trimmedValue.length === 0) {
|
|
62
64
|
return value;
|
|
63
65
|
}
|
|
64
66
|
|
|
65
|
-
|
|
66
|
-
valueLetters[0] = valueLetters[0].toUpperCase();
|
|
67
|
-
return valueLetters.join('');
|
|
67
|
+
return trimmedValue[0].toUpperCase() + trimmedValue.slice(1);
|
|
68
68
|
}
|