@hh.ru/magritte-ui-placeholder 6.0.2
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/Placeholder.d.ts +3 -0
- package/Placeholder.js +35 -0
- package/Placeholder.js.map +1 -0
- package/index.css +52 -0
- package/index.d.ts +3 -0
- package/index.js +9 -0
- package/index.js.map +1 -0
- package/package.json +35 -0
- package/types.d.ts +59 -0
- package/types.js +3 -0
- package/types.js.map +1 -0
- package/utils.d.ts +7 -0
- package/utils.js +20 -0
- package/utils.js.map +1 -0
package/Placeholder.d.ts
ADDED
package/Placeholder.js
ADDED
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import './index.css';
|
|
2
|
+
import { jsxs, jsx } from 'react/jsx-runtime';
|
|
3
|
+
import { useState } from 'react';
|
|
4
|
+
import classnames from 'classnames';
|
|
5
|
+
import { getContainerStyles } from './utils.js';
|
|
6
|
+
import { Title } from '@hh.ru/magritte-ui-title';
|
|
7
|
+
|
|
8
|
+
var styles = {"placeholder-container":"magritte-placeholder-container___4kN6h_6-0-2","placeholderContainer":"magritte-placeholder-container___4kN6h_6-0-2","placeholder-container_vertical-align-top":"magritte-placeholder-container_vertical-align-top___mKdWm_6-0-2","placeholderContainerVerticalAlignTop":"magritte-placeholder-container_vertical-align-top___mKdWm_6-0-2","placeholder-container_vertical-align-center":"magritte-placeholder-container_vertical-align-center___S3DkI_6-0-2","placeholderContainerVerticalAlignCenter":"magritte-placeholder-container_vertical-align-center___S3DkI_6-0-2","placeholder-container_vertical-align-bottom":"magritte-placeholder-container_vertical-align-bottom___Zo2-M_6-0-2","placeholderContainerVerticalAlignBottom":"magritte-placeholder-container_vertical-align-bottom___Zo2-M_6-0-2","placeholder-buttons":"magritte-placeholder-buttons___FO-A6_6-0-2","placeholderButtons":"magritte-placeholder-buttons___FO-A6_6-0-2","placeholder-buttons_no-stretch":"magritte-placeholder-buttons_no-stretch___04p3Z_6-0-2","placeholderButtonsNoStretch":"magritte-placeholder-buttons_no-stretch___04p3Z_6-0-2","placeholder-buttons_align-left":"magritte-placeholder-buttons_align-left___mzBmy_6-0-2","placeholderButtonsAlignLeft":"magritte-placeholder-buttons_align-left___mzBmy_6-0-2","placeholder-buttons_align-center":"magritte-placeholder-buttons_align-center___7QhoH_6-0-2","placeholderButtonsAlignCenter":"magritte-placeholder-buttons_align-center___7QhoH_6-0-2","placeholder-image-container":"magritte-placeholder-image-container___3eIPQ_6-0-2","placeholderImageContainer":"magritte-placeholder-image-container___3eIPQ_6-0-2","placeholder-image":"magritte-placeholder-image___bMcah_6-0-2","placeholderImage":"magritte-placeholder-image___bMcah_6-0-2","placeholder-image_hidden":"magritte-placeholder-image_hidden___5fOaL_6-0-2","placeholderImageHidden":"magritte-placeholder-image_hidden___5fOaL_6-0-2"};
|
|
9
|
+
|
|
10
|
+
const PLACEHOLDER_IMAGE_HEIGHT = 200;
|
|
11
|
+
const Placeholder = ({ title, titleProps, description, maxWidth, minHeight, buttonPrimary, buttonSecondary, buttonTertiary, showButtons = true, paddingTop, paddingBottom, image, imageWidth, imageHeight, verticalAlign = 'center', buttonsStretched = true, buttonsAlign = 'center', ariaLabel, dataQa, }) => {
|
|
12
|
+
const [isLoaded, setIsLoaded] = useState(false);
|
|
13
|
+
const [isLoadingError, setIsLoadingError] = useState(false);
|
|
14
|
+
const containerStyles = getContainerStyles({ paddingTop, paddingBottom, maxWidth, minHeight });
|
|
15
|
+
const hasAnyButton = !!(buttonPrimary || buttonSecondary || buttonTertiary);
|
|
16
|
+
return (jsxs("div", { className: classnames(styles.placeholderContainer, {
|
|
17
|
+
[styles.placeholderContainerVerticalAlignTop]: verticalAlign === 'top',
|
|
18
|
+
[styles.placeholderContainerVerticalAlignCenter]: verticalAlign === 'center',
|
|
19
|
+
[styles.placeholderContainerVerticalAlignBottom]: verticalAlign === 'bottom',
|
|
20
|
+
}), style: containerStyles, "data-qa": dataQa, children: [!!image && (jsx("div", { className: styles.placeholderImageContainer, children: jsx("img", { onLoad: () => {
|
|
21
|
+
setIsLoaded(true);
|
|
22
|
+
}, onError: () => {
|
|
23
|
+
setIsLoaded(false);
|
|
24
|
+
setIsLoadingError(true);
|
|
25
|
+
}, src: image, alt: ariaLabel, className: classnames(styles.placeholderImage, {
|
|
26
|
+
[styles.placeholderImageHidden]: isLoadingError,
|
|
27
|
+
}), width: imageWidth, height: !isLoaded && !imageHeight ? PLACEHOLDER_IMAGE_HEIGHT : imageHeight }) })), jsx(Title, { size: "medium", alignment: "center", Element: "h2", description: description, ...titleProps, children: title }), showButtons && hasAnyButton && (jsxs("div", { className: classnames(styles.placeholderButtons, {
|
|
28
|
+
[styles.placeholderButtonsNoStretch]: !buttonsStretched,
|
|
29
|
+
[styles.placeholderButtonsAlignLeft]: buttonsAlign === 'left',
|
|
30
|
+
[styles.placeholderButtonsAlignCenter]: buttonsAlign === 'center',
|
|
31
|
+
}), children: [buttonPrimary, buttonSecondary, buttonTertiary] }))] }));
|
|
32
|
+
};
|
|
33
|
+
|
|
34
|
+
export { Placeholder };
|
|
35
|
+
//# sourceMappingURL=Placeholder.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Placeholder.js","sources":["../src/Placeholder.tsx"],"sourcesContent":["import { FC, useState } from 'react';\nimport classnames from 'classnames';\n\nimport { PlaceholderProps } from '@hh.ru/magritte-ui-placeholder/types';\nimport { getContainerStyles } from '@hh.ru/magritte-ui-placeholder/utils';\nimport { Title } from '@hh.ru/magritte-ui-title';\n\nimport styles from './placeholder.less';\n\nconst PLACEHOLDER_IMAGE_HEIGHT = 200;\n\nexport const Placeholder: FC<PlaceholderProps> = ({\n title,\n titleProps,\n description,\n maxWidth,\n minHeight,\n buttonPrimary,\n buttonSecondary,\n buttonTertiary,\n showButtons = true,\n paddingTop,\n paddingBottom,\n image,\n imageWidth,\n imageHeight,\n verticalAlign = 'center',\n buttonsStretched = true,\n buttonsAlign = 'center',\n ariaLabel,\n dataQa,\n}) => {\n const [isLoaded, setIsLoaded] = useState(false);\n const [isLoadingError, setIsLoadingError] = useState(false);\n const containerStyles = getContainerStyles({ paddingTop, paddingBottom, maxWidth, minHeight });\n const hasAnyButton = !!(buttonPrimary || buttonSecondary || buttonTertiary);\n return (\n <div\n className={classnames(styles.placeholderContainer, {\n [styles.placeholderContainerVerticalAlignTop]: verticalAlign === 'top',\n [styles.placeholderContainerVerticalAlignCenter]: verticalAlign === 'center',\n [styles.placeholderContainerVerticalAlignBottom]: verticalAlign === 'bottom',\n })}\n style={containerStyles}\n data-qa={dataQa}\n >\n {!!image && (\n <div className={styles.placeholderImageContainer}>\n <img\n onLoad={() => {\n setIsLoaded(true);\n }}\n onError={() => {\n setIsLoaded(false);\n setIsLoadingError(true);\n }}\n src={image}\n alt={ariaLabel}\n className={classnames(styles.placeholderImage, {\n [styles.placeholderImageHidden]: isLoadingError,\n })}\n width={imageWidth}\n height={!isLoaded && !imageHeight ? PLACEHOLDER_IMAGE_HEIGHT : imageHeight}\n />\n </div>\n )}\n <Title size=\"medium\" alignment=\"center\" Element=\"h2\" description={description} {...titleProps}>\n {title}\n </Title>\n {showButtons && hasAnyButton && (\n <div\n className={classnames(styles.placeholderButtons, {\n [styles.placeholderButtonsNoStretch]: !buttonsStretched,\n [styles.placeholderButtonsAlignLeft]: buttonsAlign === 'left',\n [styles.placeholderButtonsAlignCenter]: buttonsAlign === 'center',\n })}\n >\n {buttonPrimary}\n {buttonSecondary}\n {buttonTertiary}\n </div>\n )}\n </div>\n );\n};\n"],"names":["_jsxs","_jsx"],"mappings":";;;;;;;;AASA,MAAM,wBAAwB,GAAG,GAAG,CAAC;AAExB,MAAA,WAAW,GAAyB,CAAC,EAC9C,KAAK,EACL,UAAU,EACV,WAAW,EACX,QAAQ,EACR,SAAS,EACT,aAAa,EACb,eAAe,EACf,cAAc,EACd,WAAW,GAAG,IAAI,EAClB,UAAU,EACV,aAAa,EACb,KAAK,EACL,UAAU,EACV,WAAW,EACX,aAAa,GAAG,QAAQ,EACxB,gBAAgB,GAAG,IAAI,EACvB,YAAY,GAAG,QAAQ,EACvB,SAAS,EACT,MAAM,GACT,KAAI;IACD,MAAM,CAAC,QAAQ,EAAE,WAAW,CAAC,GAAG,QAAQ,CAAC,KAAK,CAAC,CAAC;IAChD,MAAM,CAAC,cAAc,EAAE,iBAAiB,CAAC,GAAG,QAAQ,CAAC,KAAK,CAAC,CAAC;AAC5D,IAAA,MAAM,eAAe,GAAG,kBAAkB,CAAC,EAAE,UAAU,EAAE,aAAa,EAAE,QAAQ,EAAE,SAAS,EAAE,CAAC,CAAC;IAC/F,MAAM,YAAY,GAAG,CAAC,EAAE,aAAa,IAAI,eAAe,IAAI,cAAc,CAAC,CAAC;IAC5E,QACIA,cACI,SAAS,EAAE,UAAU,CAAC,MAAM,CAAC,oBAAoB,EAAE;AAC/C,YAAA,CAAC,MAAM,CAAC,oCAAoC,GAAG,aAAa,KAAK,KAAK;AACtE,YAAA,CAAC,MAAM,CAAC,uCAAuC,GAAG,aAAa,KAAK,QAAQ;AAC5E,YAAA,CAAC,MAAM,CAAC,uCAAuC,GAAG,aAAa,KAAK,QAAQ;SAC/E,CAAC,EACF,KAAK,EAAE,eAAe,aACb,MAAM,EAAA,QAAA,EAAA,CAEd,CAAC,CAAC,KAAK,KACJC,GAAK,CAAA,KAAA,EAAA,EAAA,SAAS,EAAE,MAAM,CAAC,yBAAyB,YAC5CA,GACI,CAAA,KAAA,EAAA,EAAA,MAAM,EAAE,MAAK;wBACT,WAAW,CAAC,IAAI,CAAC,CAAC;AACtB,qBAAC,EACD,OAAO,EAAE,MAAK;wBACV,WAAW,CAAC,KAAK,CAAC,CAAC;wBACnB,iBAAiB,CAAC,IAAI,CAAC,CAAC;AAC5B,qBAAC,EACD,GAAG,EAAE,KAAK,EACV,GAAG,EAAE,SAAS,EACd,SAAS,EAAE,UAAU,CAAC,MAAM,CAAC,gBAAgB,EAAE;AAC3C,wBAAA,CAAC,MAAM,CAAC,sBAAsB,GAAG,cAAc;AAClD,qBAAA,CAAC,EACF,KAAK,EAAE,UAAU,EACjB,MAAM,EAAE,CAAC,QAAQ,IAAI,CAAC,WAAW,GAAG,wBAAwB,GAAG,WAAW,EAC5E,CAAA,EAAA,CACA,CACT,EACDA,GAAC,CAAA,KAAK,EAAC,EAAA,IAAI,EAAC,QAAQ,EAAC,SAAS,EAAC,QAAQ,EAAC,OAAO,EAAC,IAAI,EAAC,WAAW,EAAE,WAAW,EAAM,GAAA,UAAU,EACxF,QAAA,EAAA,KAAK,EACF,CAAA,EACP,WAAW,IAAI,YAAY,KACxBD,IAAA,CAAA,KAAA,EAAA,EACI,SAAS,EAAE,UAAU,CAAC,MAAM,CAAC,kBAAkB,EAAE;AAC7C,oBAAA,CAAC,MAAM,CAAC,2BAA2B,GAAG,CAAC,gBAAgB;AACvD,oBAAA,CAAC,MAAM,CAAC,2BAA2B,GAAG,YAAY,KAAK,MAAM;AAC7D,oBAAA,CAAC,MAAM,CAAC,6BAA6B,GAAG,YAAY,KAAK,QAAQ;iBACpE,CAAC,EAAA,QAAA,EAAA,CAED,aAAa,EACb,eAAe,EACf,cAAc,CACb,EAAA,CAAA,CACT,CACC,EAAA,CAAA,EACR;AACN;;;;"}
|
package/index.css
ADDED
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
.magritte-placeholder-container___4kN6h_6-0-2{
|
|
2
|
+
display:flex;
|
|
3
|
+
flex-direction:column;
|
|
4
|
+
flex:1;
|
|
5
|
+
margin:auto;
|
|
6
|
+
height:inherit;
|
|
7
|
+
}
|
|
8
|
+
.magritte-placeholder-container_vertical-align-top___mKdWm_6-0-2{
|
|
9
|
+
justify-content:flex-start;
|
|
10
|
+
}
|
|
11
|
+
.magritte-placeholder-container_vertical-align-center___S3DkI_6-0-2{
|
|
12
|
+
justify-content:center;
|
|
13
|
+
}
|
|
14
|
+
.magritte-placeholder-container_vertical-align-bottom___Zo2-M_6-0-2{
|
|
15
|
+
justify-content:flex-end;
|
|
16
|
+
}
|
|
17
|
+
.magritte-placeholder-buttons___FO-A6_6-0-2{
|
|
18
|
+
display:flex;
|
|
19
|
+
flex-direction:column;
|
|
20
|
+
gap:12px;
|
|
21
|
+
margin-top:32px;
|
|
22
|
+
}
|
|
23
|
+
@media (min-width: 1020px){
|
|
24
|
+
body.magritte-old-layout .magritte-placeholder-buttons_no-stretch___04p3Z_6-0-2{
|
|
25
|
+
flex-direction:row;
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
@media (min-width: 1024px){
|
|
29
|
+
body:not(.magritte-old-layout) .magritte-placeholder-buttons_no-stretch___04p3Z_6-0-2{
|
|
30
|
+
flex-direction:row;
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
.magritte-placeholder-buttons_no-stretch___04p3Z_6-0-2.magritte-placeholder-buttons_align-left___mzBmy_6-0-2{
|
|
34
|
+
justify-content:flex-start;
|
|
35
|
+
}
|
|
36
|
+
.magritte-placeholder-buttons_no-stretch___04p3Z_6-0-2.magritte-placeholder-buttons_align-center___7QhoH_6-0-2{
|
|
37
|
+
justify-content:center;
|
|
38
|
+
}
|
|
39
|
+
.magritte-placeholder-image-container___3eIPQ_6-0-2{
|
|
40
|
+
margin-bottom:32px;
|
|
41
|
+
display:flex;
|
|
42
|
+
align-content:center;
|
|
43
|
+
justify-content:center;
|
|
44
|
+
}
|
|
45
|
+
.magritte-placeholder-image___bMcah_6-0-2{
|
|
46
|
+
max-width:100%;
|
|
47
|
+
max-height:100%;
|
|
48
|
+
object-fit:contain;
|
|
49
|
+
}
|
|
50
|
+
.magritte-placeholder-image_hidden___5fOaL_6-0-2{
|
|
51
|
+
visibility:hidden;
|
|
52
|
+
}
|
package/index.d.ts
ADDED
package/index.js
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import './index.css';
|
|
2
|
+
export * from '@hh.ru/magritte-ui-theme-provider';
|
|
3
|
+
export { Placeholder } from './Placeholder.js';
|
|
4
|
+
import 'react/jsx-runtime';
|
|
5
|
+
import 'react';
|
|
6
|
+
import 'classnames';
|
|
7
|
+
import './utils.js';
|
|
8
|
+
import '@hh.ru/magritte-ui-title';
|
|
9
|
+
//# sourceMappingURL=index.js.map
|
package/index.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;"}
|
package/package.json
ADDED
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@hh.ru/magritte-ui-placeholder",
|
|
3
|
+
"version": "6.0.2",
|
|
4
|
+
"main": "index.js",
|
|
5
|
+
"types": "index.d.ts",
|
|
6
|
+
"sideEffects": [
|
|
7
|
+
"index.css"
|
|
8
|
+
],
|
|
9
|
+
"scripts": {
|
|
10
|
+
"build": "yarn root:build $(pwd)",
|
|
11
|
+
"build-test-branch": "yarn root:build-test-branch $(pwd)",
|
|
12
|
+
"changelog": "yarn root:changelog $(pwd)",
|
|
13
|
+
"prepack": "yarn root:prepack $(pwd)",
|
|
14
|
+
"postpublish": "yarn root:postpublish $(pwd)",
|
|
15
|
+
"stylelint-test": "yarn root:stylelint-test $(pwd)",
|
|
16
|
+
"eslint-test": "yarn root:eslint-test $(pwd)",
|
|
17
|
+
"ts-config": "yarn root:ts-config $(pwd)",
|
|
18
|
+
"ts-check": "yarn root:ts-check $(pwd)",
|
|
19
|
+
"test": "jest $(pwd)"
|
|
20
|
+
},
|
|
21
|
+
"dependencies": {
|
|
22
|
+
"@hh.ru/magritte-design-tokens": "18.1.1",
|
|
23
|
+
"@hh.ru/magritte-ui-breakpoint": "4.0.1",
|
|
24
|
+
"@hh.ru/magritte-ui-theme-provider": "1.1.21",
|
|
25
|
+
"@hh.ru/magritte-ui-title": "3.0.8"
|
|
26
|
+
},
|
|
27
|
+
"peerDependencies": {
|
|
28
|
+
"classnames": ">=2.3.2",
|
|
29
|
+
"react": ">=18.2.0"
|
|
30
|
+
},
|
|
31
|
+
"publishConfig": {
|
|
32
|
+
"access": "public"
|
|
33
|
+
},
|
|
34
|
+
"gitHead": "b660dd64fca3eaad5ec44ea9a73f92bb0d9694aa"
|
|
35
|
+
}
|
package/types.d.ts
ADDED
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import { ReactElement } from 'react';
|
|
2
|
+
import { TokenBaseCoreSpace } from '@hh.ru/magritte-design-tokens/lib/types';
|
|
3
|
+
import { TitleProps } from '@hh.ru/magritte-ui-title/types';
|
|
4
|
+
type Explode<T> = keyof T extends infer K ? K extends unknown ? {
|
|
5
|
+
[I in keyof T]: I extends K ? T[I] : never;
|
|
6
|
+
} : never : never;
|
|
7
|
+
type AtMostOne<T> = Explode<Partial<T>>;
|
|
8
|
+
export type PlaceholderVerticalAlign = 'top' | 'center' | 'bottom';
|
|
9
|
+
export type PlaceholderButtonsAlign = 'left' | 'center';
|
|
10
|
+
interface PlaceholderBaseProps {
|
|
11
|
+
/** Максимальная ширина контейнера */
|
|
12
|
+
maxWidth?: number | 'fit-content';
|
|
13
|
+
/** Минимальная высота контейнера */
|
|
14
|
+
minHeight?: number;
|
|
15
|
+
/** Контент заголовка */
|
|
16
|
+
title: TitleProps['children'];
|
|
17
|
+
/** Контент подзаголовка */
|
|
18
|
+
description?: TitleProps['description'];
|
|
19
|
+
/** Пропы заголовка */
|
|
20
|
+
titleProps?: Omit<TitleProps, 'children'>;
|
|
21
|
+
/** Показывать ли кнопки */
|
|
22
|
+
showButtons?: boolean;
|
|
23
|
+
/** Верхний отступ */
|
|
24
|
+
paddingTop?: TokenBaseCoreSpace;
|
|
25
|
+
/** Нижний отступ */
|
|
26
|
+
paddingBottom?: TokenBaseCoreSpace;
|
|
27
|
+
/** Src картинки результата */
|
|
28
|
+
image?: string;
|
|
29
|
+
/** Ширина картинки результата */
|
|
30
|
+
imageWidth?: number | string;
|
|
31
|
+
/** Высота картинки результата */
|
|
32
|
+
imageHeight?: number | string;
|
|
33
|
+
/** Выравнивание контента по вертикали */
|
|
34
|
+
verticalAlign?: PlaceholderVerticalAlign;
|
|
35
|
+
/** Растяжение кнопок по ширине (false только при одной кнопке) */
|
|
36
|
+
buttonsStretched?: boolean;
|
|
37
|
+
/** Выравнивание кнопок по горизонтали */
|
|
38
|
+
buttonsAlign?: PlaceholderButtonsAlign;
|
|
39
|
+
/** Лейбл картинки для скринридеров (подставляется в alt картинки) */
|
|
40
|
+
ariaLabel?: string;
|
|
41
|
+
/** data-qa атрибут для контейнера */
|
|
42
|
+
dataQa?: string;
|
|
43
|
+
}
|
|
44
|
+
interface PlaceholderButtonsProps {
|
|
45
|
+
/** Primary кнопка (компонент Button) */
|
|
46
|
+
buttonPrimary?: ReactElement;
|
|
47
|
+
/** Secondary кнопка (компонент Button) */
|
|
48
|
+
buttonSecondary?: ReactElement;
|
|
49
|
+
/** Tertiary кнопка (компонент Button) */
|
|
50
|
+
buttonTertiary?: ReactElement;
|
|
51
|
+
}
|
|
52
|
+
type PlaceholderButtonsStretchedProps = {
|
|
53
|
+
buttonsStretched?: true;
|
|
54
|
+
} & PlaceholderButtonsProps;
|
|
55
|
+
type PlaceholderButtonsNotStretchedProps = {
|
|
56
|
+
buttonsStretched: false;
|
|
57
|
+
} & AtMostOne<PlaceholderButtonsProps>;
|
|
58
|
+
export type PlaceholderProps = PlaceholderBaseProps & (PlaceholderButtonsStretchedProps | PlaceholderButtonsNotStretchedProps);
|
|
59
|
+
export {};
|
package/types.js
ADDED
package/types.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sources":[],"sourcesContent":[],"names":[],"mappings":""}
|
package/utils.d.ts
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { PlaceholderProps } from './types';
|
|
2
|
+
export declare const getContainerStyles: ({ paddingTop, paddingBottom, maxWidth, minHeight, }: {
|
|
3
|
+
paddingTop: PlaceholderProps['paddingTop'];
|
|
4
|
+
paddingBottom: PlaceholderProps['paddingBottom'];
|
|
5
|
+
maxWidth: PlaceholderProps['maxWidth'];
|
|
6
|
+
minHeight: PlaceholderProps['minHeight'];
|
|
7
|
+
}) => Record<string, string>;
|
package/utils.js
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import './index.css';
|
|
2
|
+
const getContainerStyles = ({ paddingTop, paddingBottom, maxWidth, minHeight, }) => {
|
|
3
|
+
const containerStyles = {};
|
|
4
|
+
if (paddingTop !== undefined) {
|
|
5
|
+
containerStyles.paddingTop = `${paddingTop}px`;
|
|
6
|
+
}
|
|
7
|
+
if (paddingBottom !== undefined) {
|
|
8
|
+
containerStyles.paddingBottom = `${paddingBottom}px`;
|
|
9
|
+
}
|
|
10
|
+
if (maxWidth !== undefined) {
|
|
11
|
+
containerStyles.maxWidth = `${maxWidth}${isNaN(+maxWidth) ? '' : 'px'}`;
|
|
12
|
+
}
|
|
13
|
+
if (minHeight !== undefined) {
|
|
14
|
+
containerStyles.minHeight = `${minHeight}px`;
|
|
15
|
+
}
|
|
16
|
+
return containerStyles;
|
|
17
|
+
};
|
|
18
|
+
|
|
19
|
+
export { getContainerStyles };
|
|
20
|
+
//# sourceMappingURL=utils.js.map
|
package/utils.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"utils.js","sources":["../src/utils.ts"],"sourcesContent":["import { PlaceholderProps } from '@hh.ru/magritte-ui-placeholder/types';\n\nexport const getContainerStyles = ({\n paddingTop,\n paddingBottom,\n maxWidth,\n minHeight,\n}: {\n paddingTop: PlaceholderProps['paddingTop'];\n paddingBottom: PlaceholderProps['paddingBottom'];\n maxWidth: PlaceholderProps['maxWidth'];\n minHeight: PlaceholderProps['minHeight'];\n}): Record<string, string> => {\n const containerStyles: Record<string, string> = {};\n if (paddingTop !== undefined) {\n containerStyles.paddingTop = `${paddingTop}px`;\n }\n if (paddingBottom !== undefined) {\n containerStyles.paddingBottom = `${paddingBottom}px`;\n }\n if (maxWidth !== undefined) {\n containerStyles.maxWidth = `${maxWidth}${isNaN(+maxWidth) ? '' : 'px'}`;\n }\n if (minHeight !== undefined) {\n containerStyles.minHeight = `${minHeight}px`;\n }\n return containerStyles;\n};\n"],"names":[],"mappings":"AAEO,MAAM,kBAAkB,GAAG,CAAC,EAC/B,UAAU,EACV,aAAa,EACb,QAAQ,EACR,SAAS,GAMZ,KAA4B;IACzB,MAAM,eAAe,GAA2B,EAAE,CAAC;IACnD,IAAI,UAAU,KAAK,SAAS,EAAE;AAC1B,QAAA,eAAe,CAAC,UAAU,GAAG,CAAG,EAAA,UAAU,IAAI,CAAC;AAClD,KAAA;IACD,IAAI,aAAa,KAAK,SAAS,EAAE;AAC7B,QAAA,eAAe,CAAC,aAAa,GAAG,CAAG,EAAA,aAAa,IAAI,CAAC;AACxD,KAAA;IACD,IAAI,QAAQ,KAAK,SAAS,EAAE;QACxB,eAAe,CAAC,QAAQ,GAAG,CAAA,EAAG,QAAQ,CAAG,EAAA,KAAK,CAAC,CAAC,QAAQ,CAAC,GAAG,EAAE,GAAG,IAAI,EAAE,CAAC;AAC3E,KAAA;IACD,IAAI,SAAS,KAAK,SAAS,EAAE;AACzB,QAAA,eAAe,CAAC,SAAS,GAAG,CAAG,EAAA,SAAS,IAAI,CAAC;AAChD,KAAA;AACD,IAAA,OAAO,eAAe,CAAC;AAC3B;;;;"}
|