@gravity-ui/dashkit 8.23.0 → 8.24.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/build/cjs/plugins/Title/Title.d.ts +2 -2
- package/build/cjs/plugins/Title/Title.js +11 -2
- package/build/cjs/plugins/Title/constants.d.ts +3 -0
- package/build/cjs/plugins/Title/constants.js +26 -0
- package/build/cjs/plugins/Title/index.d.ts +2 -0
- package/build/cjs/plugins/Title/index.js +3 -1
- package/build/cjs/plugins/Title/types.d.ts +5 -0
- package/build/cjs/plugins/Title/types.js +2 -0
- package/build/cjs/plugins/Title/utils.d.ts +2 -0
- package/build/cjs/plugins/Title/utils.js +7 -0
- package/build/esm/plugins/Title/Title.d.ts +2 -2
- package/build/esm/plugins/Title/Title.js +11 -2
- package/build/esm/plugins/Title/constants.d.ts +3 -0
- package/build/esm/plugins/Title/constants.js +23 -0
- package/build/esm/plugins/Title/index.d.ts +2 -0
- package/build/esm/plugins/Title/index.js +1 -0
- package/build/esm/plugins/Title/types.d.ts +5 -0
- package/build/esm/plugins/Title/types.js +1 -0
- package/build/esm/plugins/Title/utils.d.ts +2 -0
- package/build/esm/plugins/Title/utils.js +3 -0
- package/package.json +1 -1
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import { Plugin, PluginWidgetProps } from '../../typings';
|
|
3
|
-
|
|
3
|
+
import type { PluginTitleSize, TitleFontParams } from './types';
|
|
4
4
|
export interface PluginTitleProps extends PluginWidgetProps {
|
|
5
5
|
data: {
|
|
6
|
-
size: PluginTitleSize;
|
|
6
|
+
size: PluginTitleSize | TitleFontParams;
|
|
7
7
|
text: string;
|
|
8
8
|
showInTOC: boolean;
|
|
9
9
|
} & PluginWidgetProps['data'];
|
|
@@ -5,14 +5,23 @@ const tslib_1 = require("tslib");
|
|
|
5
5
|
const react_1 = tslib_1.__importDefault(require("react"));
|
|
6
6
|
const cn_1 = require("../../utils/cn");
|
|
7
7
|
const constants_1 = require("../constants");
|
|
8
|
+
const constants_2 = require("./constants");
|
|
9
|
+
const utils_1 = require("./utils");
|
|
8
10
|
const b = (0, cn_1.cn)('dashkit-plugin-title');
|
|
9
11
|
class PluginTitle extends react_1.default.Component {
|
|
10
12
|
render() {
|
|
13
|
+
var _a, _b;
|
|
11
14
|
const { data } = this.props;
|
|
12
15
|
const text = data.text ? data.text : '';
|
|
13
|
-
const size = data.size ? data.size
|
|
16
|
+
const size = (0, utils_1.isCustomSize)(data.size) ? false : data.size;
|
|
17
|
+
const styles = (0, utils_1.isCustomSize)(data.size) && ((_a = data.size) === null || _a === void 0 ? void 0 : _a.fontSize)
|
|
18
|
+
? {
|
|
19
|
+
fontSize: data.size.fontSize,
|
|
20
|
+
lineHeight: (_b = data.size.lineHeight) !== null && _b !== void 0 ? _b : constants_2.RECCOMMENDED_LINE_HEIGHT_MULTIPLIER,
|
|
21
|
+
}
|
|
22
|
+
: undefined;
|
|
14
23
|
const id = data.showInTOC && text ? encodeURIComponent(text) : undefined;
|
|
15
|
-
return (react_1.default.createElement("div", { id: id, className: b({ size }), [constants_1.PLUGIN_ROOT_ATTR_NAME]: 'title' }, text));
|
|
24
|
+
return (react_1.default.createElement("div", { id: id, style: styles, className: b({ size }), [constants_1.PLUGIN_ROOT_ATTR_NAME]: 'title' }, text));
|
|
16
25
|
}
|
|
17
26
|
}
|
|
18
27
|
exports.PluginTitle = PluginTitle;
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.RECCOMMENDED_LINE_HEIGHT_MULTIPLIER = exports.TITLE_DEFAULT_SIZES = void 0;
|
|
4
|
+
exports.TITLE_DEFAULT_SIZES = {
|
|
5
|
+
xl: {
|
|
6
|
+
fontSize: '32px',
|
|
7
|
+
lineHeight: '40px',
|
|
8
|
+
},
|
|
9
|
+
l: {
|
|
10
|
+
fontSize: '24px',
|
|
11
|
+
lineHeight: '28px',
|
|
12
|
+
},
|
|
13
|
+
m: {
|
|
14
|
+
fontSize: '20px',
|
|
15
|
+
lineHeight: '24px',
|
|
16
|
+
},
|
|
17
|
+
s: {
|
|
18
|
+
fontSize: '17px',
|
|
19
|
+
lineHeight: '24px',
|
|
20
|
+
},
|
|
21
|
+
xs: {
|
|
22
|
+
fontSize: '15px',
|
|
23
|
+
lineHeight: '20px',
|
|
24
|
+
},
|
|
25
|
+
};
|
|
26
|
+
exports.RECCOMMENDED_LINE_HEIGHT_MULTIPLIER = 1.25;
|
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.pluginTitle = void 0;
|
|
3
|
+
exports.TITLE_DEFAULT_SIZES = exports.pluginTitle = void 0;
|
|
4
4
|
const tslib_1 = require("tslib");
|
|
5
5
|
tslib_1.__exportStar(require("./Title"), exports);
|
|
6
6
|
var Title_1 = require("./Title");
|
|
7
7
|
Object.defineProperty(exports, "pluginTitle", { enumerable: true, get: function () { return tslib_1.__importDefault(Title_1).default; } });
|
|
8
|
+
var constants_1 = require("./constants");
|
|
9
|
+
Object.defineProperty(exports, "TITLE_DEFAULT_SIZES", { enumerable: true, get: function () { return constants_1.TITLE_DEFAULT_SIZES; } });
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import { Plugin, PluginWidgetProps } from '../../typings';
|
|
3
|
+
import type { PluginTitleSize, TitleFontParams } from './types';
|
|
3
4
|
import './Title.css';
|
|
4
|
-
export type PluginTitleSize = 'xl' | 'l' | 'm' | 's' | 'xs';
|
|
5
5
|
export interface PluginTitleProps extends PluginWidgetProps {
|
|
6
6
|
data: {
|
|
7
|
-
size: PluginTitleSize;
|
|
7
|
+
size: PluginTitleSize | TitleFontParams;
|
|
8
8
|
text: string;
|
|
9
9
|
showInTOC: boolean;
|
|
10
10
|
} & PluginWidgetProps['data'];
|
|
@@ -1,15 +1,24 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import { cn } from '../../utils/cn';
|
|
3
3
|
import { PLUGIN_ROOT_ATTR_NAME } from '../constants';
|
|
4
|
+
import { RECCOMMENDED_LINE_HEIGHT_MULTIPLIER } from './constants';
|
|
5
|
+
import { isCustomSize } from './utils';
|
|
4
6
|
import './Title.css';
|
|
5
7
|
const b = cn('dashkit-plugin-title');
|
|
6
8
|
export class PluginTitle extends React.Component {
|
|
7
9
|
render() {
|
|
10
|
+
var _a, _b;
|
|
8
11
|
const { data } = this.props;
|
|
9
12
|
const text = data.text ? data.text : '';
|
|
10
|
-
const size = data.size ? data.size
|
|
13
|
+
const size = isCustomSize(data.size) ? false : data.size;
|
|
14
|
+
const styles = isCustomSize(data.size) && ((_a = data.size) === null || _a === void 0 ? void 0 : _a.fontSize)
|
|
15
|
+
? {
|
|
16
|
+
fontSize: data.size.fontSize,
|
|
17
|
+
lineHeight: (_b = data.size.lineHeight) !== null && _b !== void 0 ? _b : RECCOMMENDED_LINE_HEIGHT_MULTIPLIER,
|
|
18
|
+
}
|
|
19
|
+
: undefined;
|
|
11
20
|
const id = data.showInTOC && text ? encodeURIComponent(text) : undefined;
|
|
12
|
-
return (React.createElement("div", { id: id, className: b({ size }), [PLUGIN_ROOT_ATTR_NAME]: 'title' }, text));
|
|
21
|
+
return (React.createElement("div", { id: id, style: styles, className: b({ size }), [PLUGIN_ROOT_ATTR_NAME]: 'title' }, text));
|
|
13
22
|
}
|
|
14
23
|
}
|
|
15
24
|
const plugin = {
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
export const TITLE_DEFAULT_SIZES = {
|
|
2
|
+
xl: {
|
|
3
|
+
fontSize: '32px',
|
|
4
|
+
lineHeight: '40px',
|
|
5
|
+
},
|
|
6
|
+
l: {
|
|
7
|
+
fontSize: '24px',
|
|
8
|
+
lineHeight: '28px',
|
|
9
|
+
},
|
|
10
|
+
m: {
|
|
11
|
+
fontSize: '20px',
|
|
12
|
+
lineHeight: '24px',
|
|
13
|
+
},
|
|
14
|
+
s: {
|
|
15
|
+
fontSize: '17px',
|
|
16
|
+
lineHeight: '24px',
|
|
17
|
+
},
|
|
18
|
+
xs: {
|
|
19
|
+
fontSize: '15px',
|
|
20
|
+
lineHeight: '20px',
|
|
21
|
+
},
|
|
22
|
+
};
|
|
23
|
+
export const RECCOMMENDED_LINE_HEIGHT_MULTIPLIER = 1.25;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|