@meduza/ui-kit-2 0.1.18 → 0.1.20
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/Cover/Cover.types.d.ts +21 -1
- package/dist/DotsOnImage/DotsOnImage.types.d.ts +1 -1
- package/dist/Image/Image.types.d.ts +1 -6
- package/dist/ListBlock/ListBlock.stories.d.ts +2 -1
- package/dist/ListBlock/ListBlock.types.d.ts +7 -1
- package/dist/RelatedBlock/RelatedBlock.types.d.ts +14 -1
- package/dist/RelatedRichBlock/RelatedRichBlock.stories.d.ts +10 -0
- package/dist/RelatedRichBlock/RelatedRichBlock.types.d.ts +4 -0
- package/dist/RelatedRichBlock/index.d.ts +3 -0
- package/dist/RichTitle/RichTitle.types.d.ts +8 -1
- package/dist/SimpleTitle/SimpleTitle.types.d.ts +6 -1
- package/dist/SourceBlock/SourceBlock.types.d.ts +12 -1
- package/dist/index.d.ts +1 -0
- package/dist/types.d.ts +6 -0
- package/dist/ui-kit-2.cjs.development.js +97 -7
- package/dist/ui-kit-2.cjs.development.js.map +1 -1
- package/dist/ui-kit-2.cjs.production.min.js +1 -1
- package/dist/ui-kit-2.cjs.production.min.js.map +1 -1
- package/dist/ui-kit-2.esm.js +97 -8
- package/dist/ui-kit-2.esm.js.map +1 -1
- package/dist/ui-kit.css +1240 -1042
- package/dist/utils/converCase.d.ts +2 -0
- package/dist/utils/generateGradient.d.ts +1 -1
- package/package.json +4 -1
- package/src/.DS_Store +0 -0
- package/src/BookmarkButton/BookmarkButton.test.tsx +17 -4
- package/src/Button/Button.module.css +2 -0
- package/src/CardTitle/CardTitle.test.tsx +4 -3
- package/src/ChapterBlock/ChapterBlock.test.tsx +4 -3
- package/src/Cover/Cover.test.tsx +3 -3
- package/src/Cover/Cover.types.ts +22 -1
- package/src/Cover/index.tsx +1 -1
- package/src/DocumentItemsCount/DocumentItemsCount.test.tsx +4 -3
- package/src/DotsOnImage/DotsOnImage.test.tsx +4 -2
- package/src/DotsOnImage/DotsOnImage.types.ts +1 -1
- package/src/EmbedBlock/EmbedBlock.test.tsx +16 -3
- package/src/EmbedBlock/index.tsx +1 -1
- package/src/GroupedBlock/GroupedBlock.test.tsx +5 -3
- package/src/HalfBlock/HalfBlock.test.tsx +4 -3
- package/src/Image/Image.test.tsx +3 -0
- package/src/Image/Image.types.ts +1 -6
- package/src/Image/RenderPicture.tsx +1 -1
- package/src/ImportantLead/ImportantLead.test.tsx +10 -8
- package/src/ImportantLead/mock.json +6 -0
- package/src/Lazy/Lazy.test.tsx +3 -0
- package/src/ListBlock/ListBlock.stories.tsx +2 -1
- package/src/ListBlock/ListBlock.test.tsx +8 -4
- package/src/ListBlock/ListBlock.types.ts +6 -1
- package/src/ListBlock/index.tsx +1 -1
- package/src/ListBlock/mock.json +1 -1
- package/src/MaterialNote/MaterialNote.test.tsx +4 -3
- package/src/Meta/Meta.module.css +1 -1
- package/src/QuoteBlock/QuoteBlock.test.tsx +4 -3
- package/src/RawHtmlBlock/RawHtmlBlock.test.tsx +18 -9
- package/src/RawHtmlBlock/mock.json +6 -0
- package/src/RelatedBlock/RelatedBlock.test.tsx +4 -3
- package/src/RelatedBlock/RelatedBlock.types.ts +14 -1
- package/src/RelatedRichBlock/RelatedRichBlock.module.css +165 -0
- package/src/RelatedRichBlock/RelatedRichBlock.stories.module.css +12 -0
- package/src/RelatedRichBlock/RelatedRichBlock.stories.tsx +55 -0
- package/src/RelatedRichBlock/RelatedRichBlock.test.tsx +20 -0
- package/src/RelatedRichBlock/RelatedRichBlock.types.ts +4 -0
- package/src/RelatedRichBlock/index.tsx +105 -0
- package/src/RelatedRichBlock/mock.json +354 -0
- package/src/RenderBlocks/RenderBlocks.stories.tsx +4 -1
- package/src/RenderBlocks/RenderBlocks.test.tsx +15 -9
- package/src/RenderBlocks/mock.json +10 -0
- package/src/RichTitle/RichTitle.module.css +37 -7
- package/src/RichTitle/RichTitle.test.tsx +4 -3
- package/src/RichTitle/RichTitle.types.ts +8 -1
- package/src/SimpleBlock/SimpleBlock.test.tsx +16 -9
- package/src/SimpleBlock/mock.json +6 -0
- package/src/SimpleTitle/SimpleTitle.test.tsx +4 -3
- package/src/SimpleTitle/SimpleTitle.types.ts +6 -1
- package/src/SourceBlock/SourceBlock.test.tsx +4 -3
- package/src/SourceBlock/SourceBlock.types.ts +13 -1
- package/src/Spoiler/Spoiler.test.tsx +4 -3
- package/src/Table/Table.test.tsx +3 -3
- package/src/Timestamp/Timestamp.test.tsx +4 -3
- package/src/ToolbarButton/ToolbarButton.test.tsx +8 -3
- package/src/_storybook/PreviewWrapper/PreviewWrapper.module.css +3 -1
- package/src/index.tsx +1 -0
- package/src/types.ts +6 -0
- package/src/utils/{toCamel.ts → converCase.ts} +3 -0
- package/src/utils/generateGradient.ts +21 -15
- package/dist/utils/toCamel.d.ts +0 -1
|
@@ -1,4 +1,24 @@
|
|
|
1
|
+
import { OptimizedImageItem } from '../types';
|
|
1
2
|
export interface CoverProps {
|
|
2
|
-
block:
|
|
3
|
+
block: {
|
|
4
|
+
only_on?: string;
|
|
5
|
+
data: {
|
|
6
|
+
blocks: any;
|
|
7
|
+
cover: {
|
|
8
|
+
credit?: string;
|
|
9
|
+
caption?: string;
|
|
10
|
+
cc: string;
|
|
11
|
+
urls: {
|
|
12
|
+
w325: OptimizedImageItem;
|
|
13
|
+
w600: OptimizedImageItem;
|
|
14
|
+
};
|
|
15
|
+
mobile_ratio: number;
|
|
16
|
+
gradients: {
|
|
17
|
+
text_rgb: string;
|
|
18
|
+
bg_rgb: string;
|
|
19
|
+
};
|
|
20
|
+
};
|
|
21
|
+
};
|
|
22
|
+
};
|
|
3
23
|
styleContext?: string[] | string;
|
|
4
24
|
}
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
+
import { ListBlockProps } from './ListBlock.types';
|
|
2
3
|
declare const _default: {
|
|
3
4
|
title: string;
|
|
4
|
-
component: React.FC<
|
|
5
|
+
component: React.FC<ListBlockProps>;
|
|
5
6
|
parameters: {
|
|
6
7
|
themeWrapperSideBySide: boolean;
|
|
7
8
|
};
|
|
@@ -1,4 +1,17 @@
|
|
|
1
1
|
export interface RelatedBlockProps {
|
|
2
|
-
block:
|
|
2
|
+
block: {
|
|
3
|
+
data: {
|
|
4
|
+
title: string;
|
|
5
|
+
related: {
|
|
6
|
+
title: string;
|
|
7
|
+
second_title?: string;
|
|
8
|
+
layout: string;
|
|
9
|
+
url?: string;
|
|
10
|
+
full_url?: string;
|
|
11
|
+
id: string;
|
|
12
|
+
}[];
|
|
13
|
+
};
|
|
14
|
+
only_on?: string;
|
|
15
|
+
};
|
|
3
16
|
styleContext?: string[] | string;
|
|
4
17
|
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
declare const _default: {
|
|
3
|
+
title: string;
|
|
4
|
+
component: React.FC<import("./RelatedRichBlock.types").RelatedRichBlockProps>;
|
|
5
|
+
parameters: {
|
|
6
|
+
themeWrapperSideBySide: boolean;
|
|
7
|
+
};
|
|
8
|
+
};
|
|
9
|
+
export default _default;
|
|
10
|
+
export declare const Default: React.FC;
|
package/dist/index.d.ts
CHANGED
package/dist/types.d.ts
ADDED
|
@@ -377,6 +377,9 @@ var toCamel = function toCamel(s) {
|
|
|
377
377
|
return str.toUpperCase().replace('_', '');
|
|
378
378
|
});
|
|
379
379
|
};
|
|
380
|
+
var toCapitalize = function toCapitalize(s) {
|
|
381
|
+
return s[0].toUpperCase() + s.slice(1);
|
|
382
|
+
};
|
|
380
383
|
|
|
381
384
|
var RenderPicture = function RenderPicture(_ref) {
|
|
382
385
|
var source = _ref.source,
|
|
@@ -1396,7 +1399,7 @@ var EmbedBlockContainer = function EmbedBlockContainer(_ref) {
|
|
|
1396
1399
|
styleContext = _ref.styleContext,
|
|
1397
1400
|
lang = _ref.lang;
|
|
1398
1401
|
|
|
1399
|
-
if (block.data.wrap_with_iframe) {
|
|
1402
|
+
if (block.data && block.data.wrap_with_iframe) {
|
|
1400
1403
|
return React__default.createElement(IframeBlock, {
|
|
1401
1404
|
block: block,
|
|
1402
1405
|
styleContext: styleContext,
|
|
@@ -1467,9 +1470,12 @@ var ChapterBlock = function ChapterBlock(_ref) {
|
|
|
1467
1470
|
}));
|
|
1468
1471
|
};
|
|
1469
1472
|
|
|
1470
|
-
var generateGradient = function generateGradient(color) {
|
|
1471
|
-
var
|
|
1472
|
-
|
|
1473
|
+
var generateGradient = function generateGradient(color, type) {
|
|
1474
|
+
var steps = {
|
|
1475
|
+
mediaBlockBottom: [[0, 7], [0.08, 12], [0.16, 17], [0.22, 21], [0.32, 26], [0.42, 32], [0.52, 38], [0.62, 47], [0.72, 57], [0.82, 65], [1, 82]],
|
|
1476
|
+
mediaBlockTop: [[0.5, 0], [0, 97]]
|
|
1477
|
+
};
|
|
1478
|
+
var gradient = steps[type].map(function (i) {
|
|
1473
1479
|
return "rgba(" + color + ", " + i[0] + ") " + i[1] + "%";
|
|
1474
1480
|
});
|
|
1475
1481
|
return "linear-gradient(-180deg, " + gradient + ")";
|
|
@@ -1494,7 +1500,7 @@ var SimpleTitle = function SimpleTitle(_ref) {
|
|
|
1494
1500
|
}, first);
|
|
1495
1501
|
};
|
|
1496
1502
|
|
|
1497
|
-
var styles$n = {"root":"RichTitle-module_root__BK_WT","slide":"RichTitle-module_slide__1A-gB","game":"RichTitle-module_game__1g8Bn","half":"RichTitle-module_half__10GRI","featured":"RichTitle-module_featured__wJfaQ","mobile":"RichTitle-module_mobile__1Cb6E","desktop":"RichTitle-module_desktop__2ixSQ"};
|
|
1503
|
+
var styles$n = {"root":"RichTitle-module_root__BK_WT","slide":"RichTitle-module_slide__1A-gB","game":"RichTitle-module_game__1g8Bn","half":"RichTitle-module_half__10GRI","featured":"RichTitle-module_featured__wJfaQ","isInMediaBlock":"RichTitle-module_isInMediaBlock__3RDw4","mobile":"RichTitle-module_mobile__1Cb6E","desktop":"RichTitle-module_desktop__2ixSQ"};
|
|
1498
1504
|
|
|
1499
1505
|
var RichTitle = function RichTitle(_ref) {
|
|
1500
1506
|
var _ref$block = _ref.block,
|
|
@@ -1575,7 +1581,8 @@ var ListBlock = function ListBlock(_ref) {
|
|
|
1575
1581
|
}
|
|
1576
1582
|
|
|
1577
1583
|
return React__default.createElement(TagName, {
|
|
1578
|
-
className: makeClassName(classNames)
|
|
1584
|
+
className: makeClassName(classNames),
|
|
1585
|
+
"data-testid": "list-block"
|
|
1579
1586
|
}, data.map(function (item, index) {
|
|
1580
1587
|
return React__default.createElement("li", {
|
|
1581
1588
|
key: index,
|
|
@@ -2095,7 +2102,7 @@ var Cover = function Cover(_ref) {
|
|
|
2095
2102
|
if (gradients) {
|
|
2096
2103
|
var theme = [gradients.text_rgb === '0,0,0' ? 'dark' : 'light'];
|
|
2097
2104
|
classNames = makeStyleContext(classNames, theme, styles$w);
|
|
2098
|
-
style.backgroundImage = generateGradient(gradients.bg_rgb);
|
|
2105
|
+
style.backgroundImage = generateGradient(gradients.bg_rgb, 'mediaBlockBottom');
|
|
2099
2106
|
}
|
|
2100
2107
|
|
|
2101
2108
|
var renderCC = function renderCC(context) {
|
|
@@ -2368,6 +2375,88 @@ var ToolbarButton = function ToolbarButton(_ref) {
|
|
|
2368
2375
|
}, children));
|
|
2369
2376
|
};
|
|
2370
2377
|
|
|
2378
|
+
var styles$B = {"root":"RelatedRichBlock-module_root__3NYmj","overlay":"RelatedRichBlock-module_overlay__3XSg_","overlayHeader":"RelatedRichBlock-module_overlayHeader__2Nmbv","isRich":"RelatedRichBlock-module_isRich__1LnA4","body":"RelatedRichBlock-module_body__1ZHZS","isCard":"RelatedRichBlock-module_isCard__2naDz","hasGradient":"RelatedRichBlock-module_hasGradient__27LOk","cover":"RelatedRichBlock-module_cover__3yygp","tag":"RelatedRichBlock-module_tag__3OLyG","dark":"RelatedRichBlock-module_dark__3Y1fE","light":"RelatedRichBlock-module_light__2mUxL","mobile":"RelatedRichBlock-module_mobile__JpCS4","desktop":"RelatedRichBlock-module_desktop__trL0D"};
|
|
2379
|
+
|
|
2380
|
+
/* eslint-disable react/jsx-no-target-blank */
|
|
2381
|
+
var RelatedRichBlock = function RelatedRichBlock(_ref) {
|
|
2382
|
+
var _ref$block = _ref.block,
|
|
2383
|
+
onlyOn = _ref$block.only_on,
|
|
2384
|
+
_ref$block$data = _ref$block.data,
|
|
2385
|
+
blocks = _ref$block$data.blocks,
|
|
2386
|
+
fallback = _ref$block$data.fallback,
|
|
2387
|
+
url = _ref$block$data.url,
|
|
2388
|
+
_ref$block$data$cover = _ref$block$data.cover,
|
|
2389
|
+
urls = _ref$block$data$cover.urls,
|
|
2390
|
+
gradients = _ref$block$data$cover.gradients,
|
|
2391
|
+
tag = _ref$block$data$cover.tag,
|
|
2392
|
+
layout = _ref$block$data$cover.layout,
|
|
2393
|
+
ratio = _ref$block$data$cover.ratio,
|
|
2394
|
+
styleContext = _ref.styleContext;
|
|
2395
|
+
var style = {};
|
|
2396
|
+
var styleHeader = {};
|
|
2397
|
+
|
|
2398
|
+
var _useState = React.useState(false),
|
|
2399
|
+
isRich = _useState[0],
|
|
2400
|
+
setIsRich = _useState[1];
|
|
2401
|
+
|
|
2402
|
+
var cardType = "is" + toCapitalize(layout);
|
|
2403
|
+
React.useEffect(function () {
|
|
2404
|
+
// setIsRich(Math.random() >= 0.5)
|
|
2405
|
+
setIsRich(true);
|
|
2406
|
+
}, []);
|
|
2407
|
+
var classNames = [[styles$B.root, true], [styles$B[cardType], !!layout && !!styles$B[cardType]], [styles$B.hasGradient, !!gradients], [styles$B[onlyOn], !!onlyOn && !!styles$B[onlyOn]]];
|
|
2408
|
+
|
|
2409
|
+
if (styleContext) {
|
|
2410
|
+
classNames = makeStyleContext(classNames, styleContext, styles$B);
|
|
2411
|
+
}
|
|
2412
|
+
|
|
2413
|
+
if (gradients) {
|
|
2414
|
+
var theme = [gradients.text_rgb === '0,0,0' ? 'dark' : 'light'];
|
|
2415
|
+
classNames = makeStyleContext(classNames, theme, styles$B);
|
|
2416
|
+
styleHeader.backgroundImage = generateGradient(gradients.bg_rgb, 'mediaBlockTop');
|
|
2417
|
+
style.backgroundImage = generateGradient(gradients.bg_rgb, 'mediaBlockBottom');
|
|
2418
|
+
}
|
|
2419
|
+
|
|
2420
|
+
if (!isRich) {
|
|
2421
|
+
return React__default.createElement(RelatedBlock, {
|
|
2422
|
+
block: fallback
|
|
2423
|
+
});
|
|
2424
|
+
}
|
|
2425
|
+
|
|
2426
|
+
return React__default.createElement("a", {
|
|
2427
|
+
"data-testid": "related-rich-block",
|
|
2428
|
+
className: makeClassName(classNames),
|
|
2429
|
+
href: url,
|
|
2430
|
+
target: "_blank"
|
|
2431
|
+
}, layout === 'rich' && React__default.createElement(React__default.Fragment, null, React__default.createElement("div", {
|
|
2432
|
+
className: styles$B.overlay,
|
|
2433
|
+
style: style
|
|
2434
|
+
}), React__default.createElement("div", {
|
|
2435
|
+
className: styles$B.overlayHeader,
|
|
2436
|
+
style: styleHeader
|
|
2437
|
+
})), React__default.createElement("div", {
|
|
2438
|
+
className: styles$B.tag
|
|
2439
|
+
}, React__default.createElement(Tag, {
|
|
2440
|
+
size: "small",
|
|
2441
|
+
theme: "inherit",
|
|
2442
|
+
styleContext: "rich"
|
|
2443
|
+
}, tag)), React__default.createElement("div", {
|
|
2444
|
+
className: styles$B.cover
|
|
2445
|
+
}, React__default.createElement(Image, {
|
|
2446
|
+
optimized: urls,
|
|
2447
|
+
ratio: ratio,
|
|
2448
|
+
display: "narrow"
|
|
2449
|
+
})), React__default.createElement("div", {
|
|
2450
|
+
className: styles$B.body
|
|
2451
|
+
}, blocks.map(function (item) {
|
|
2452
|
+
return React__default.createElement(RenderBlocks, {
|
|
2453
|
+
key: item.id,
|
|
2454
|
+
block: item,
|
|
2455
|
+
styleContext: [].concat(styleContext, ['isInMediaBlock'])
|
|
2456
|
+
});
|
|
2457
|
+
})));
|
|
2458
|
+
};
|
|
2459
|
+
|
|
2371
2460
|
exports.BookmarkButton = BookmarkButton;
|
|
2372
2461
|
exports.Button = Button;
|
|
2373
2462
|
exports.CardTitle = CardTitle;
|
|
@@ -2396,6 +2485,7 @@ exports.Primary = Primary;
|
|
|
2396
2485
|
exports.QuoteBlock = QuoteBlock;
|
|
2397
2486
|
exports.RawHtmlBlock = RawHtmlBlock;
|
|
2398
2487
|
exports.RelatedBlock = RelatedBlock;
|
|
2488
|
+
exports.RelatedRichBlock = RelatedRichBlock;
|
|
2399
2489
|
exports.RenderBlocks = RenderBlocks;
|
|
2400
2490
|
exports.RichTitle = RichTitle;
|
|
2401
2491
|
exports.Secondary = Secondary;
|