@cloud-ru/ds-site-section 0.0.0-stage → 1.1.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 +10 -0
- package/LICENSE +201 -0
- package/README.md +340 -2
- package/dist/cjs/components/SectionBasic/SectionBasic.d.ts +42 -0
- package/dist/cjs/components/SectionBasic/SectionBasic.js +18 -0
- package/dist/cjs/components/SectionBasic/index.d.ts +1 -0
- package/dist/cjs/components/SectionBasic/index.js +17 -0
- package/dist/cjs/components/index.d.ts +1 -0
- package/dist/cjs/components/index.js +17 -0
- package/dist/cjs/constants.d.ts +46 -0
- package/dist/cjs/constants.js +41 -0
- package/dist/cjs/helperComponents/BackgroundLayer/BackgroundLayer.d.ts +8 -0
- package/dist/cjs/helperComponents/BackgroundLayer/BackgroundLayer.js +15 -0
- package/dist/cjs/helperComponents/BackgroundLayer/index.d.ts +1 -0
- package/dist/cjs/helperComponents/BackgroundLayer/index.js +17 -0
- package/dist/cjs/helperComponents/BackgroundLayer/styles.module.css +216 -0
- package/dist/cjs/helperComponents/BackgroundLayer/utils.d.ts +9 -0
- package/dist/cjs/helperComponents/BackgroundLayer/utils.js +12 -0
- package/dist/cjs/helperComponents/BgLocal/BgLocal.d.ts +7 -0
- package/dist/cjs/helperComponents/BgLocal/BgLocal.js +21 -0
- package/dist/cjs/helperComponents/BgLocal/index.d.ts +1 -0
- package/dist/cjs/helperComponents/BgLocal/index.js +17 -0
- package/dist/cjs/helperComponents/BgLocal/styles.module.css +18 -0
- package/dist/cjs/helperComponents/SectionFilter/SectionFilter.d.ts +7 -0
- package/dist/cjs/helperComponents/SectionFilter/SectionFilter.js +15 -0
- package/dist/cjs/helperComponents/SectionFilter/index.d.ts +1 -0
- package/dist/cjs/helperComponents/SectionFilter/index.js +17 -0
- package/dist/cjs/helperComponents/SectionFilter/styles.module.css +10 -0
- package/dist/cjs/helperComponents/SectionFooter/SectionFooter.d.ts +10 -0
- package/dist/cjs/helperComponents/SectionFooter/SectionFooter.js +17 -0
- package/dist/cjs/helperComponents/SectionFooter/index.d.ts +1 -0
- package/dist/cjs/helperComponents/SectionFooter/index.js +17 -0
- package/dist/cjs/helperComponents/SectionFooter/styles.module.css +6 -0
- package/dist/cjs/helperComponents/SectionWrapper/SectionWrapper.d.ts +22 -0
- package/dist/cjs/helperComponents/SectionWrapper/SectionWrapper.js +25 -0
- package/dist/cjs/helperComponents/SectionWrapper/index.d.ts +1 -0
- package/dist/cjs/helperComponents/SectionWrapper/index.js +17 -0
- package/dist/cjs/helperComponents/SectionWrapper/styles.module.css +101 -0
- package/dist/cjs/helperComponents/index.d.ts +5 -0
- package/dist/cjs/helperComponents/index.js +21 -0
- package/dist/cjs/index.d.ts +4 -0
- package/dist/cjs/index.js +20 -0
- package/dist/cjs/locale/index.d.ts +19 -0
- package/dist/cjs/locale/index.js +10 -0
- package/dist/cjs/package.json +3 -0
- package/dist/cjs/style.css +351 -0
- package/dist/cjs/types.d.ts +44 -0
- package/dist/cjs/types.js +2 -0
- package/dist/esm/components/SectionBasic/SectionBasic.d.ts +42 -0
- package/dist/esm/components/SectionBasic/SectionBasic.js +15 -0
- package/dist/esm/components/SectionBasic/index.d.ts +1 -0
- package/dist/esm/components/SectionBasic/index.js +1 -0
- package/dist/esm/components/index.d.ts +1 -0
- package/dist/esm/components/index.js +1 -0
- package/dist/esm/constants.d.ts +46 -0
- package/dist/esm/constants.js +38 -0
- package/dist/esm/helperComponents/BackgroundLayer/BackgroundLayer.d.ts +8 -0
- package/dist/esm/helperComponents/BackgroundLayer/BackgroundLayer.js +9 -0
- package/dist/esm/helperComponents/BackgroundLayer/index.d.ts +1 -0
- package/dist/esm/helperComponents/BackgroundLayer/index.js +1 -0
- package/dist/esm/helperComponents/BackgroundLayer/styles.module.css +216 -0
- package/dist/esm/helperComponents/BackgroundLayer/utils.d.ts +9 -0
- package/dist/esm/helperComponents/BackgroundLayer/utils.js +9 -0
- package/dist/esm/helperComponents/BgLocal/BgLocal.d.ts +7 -0
- package/dist/esm/helperComponents/BgLocal/BgLocal.js +15 -0
- package/dist/esm/helperComponents/BgLocal/index.d.ts +1 -0
- package/dist/esm/helperComponents/BgLocal/index.js +1 -0
- package/dist/esm/helperComponents/BgLocal/styles.module.css +18 -0
- package/dist/esm/helperComponents/SectionFilter/SectionFilter.d.ts +7 -0
- package/dist/esm/helperComponents/SectionFilter/SectionFilter.js +9 -0
- package/dist/esm/helperComponents/SectionFilter/index.d.ts +1 -0
- package/dist/esm/helperComponents/SectionFilter/index.js +1 -0
- package/dist/esm/helperComponents/SectionFilter/styles.module.css +10 -0
- package/dist/esm/helperComponents/SectionFooter/SectionFooter.d.ts +10 -0
- package/dist/esm/helperComponents/SectionFooter/SectionFooter.js +11 -0
- package/dist/esm/helperComponents/SectionFooter/index.d.ts +1 -0
- package/dist/esm/helperComponents/SectionFooter/index.js +1 -0
- package/dist/esm/helperComponents/SectionFooter/styles.module.css +6 -0
- package/dist/esm/helperComponents/SectionWrapper/SectionWrapper.d.ts +22 -0
- package/dist/esm/helperComponents/SectionWrapper/SectionWrapper.js +19 -0
- package/dist/esm/helperComponents/SectionWrapper/index.d.ts +1 -0
- package/dist/esm/helperComponents/SectionWrapper/index.js +1 -0
- package/dist/esm/helperComponents/SectionWrapper/styles.module.css +101 -0
- package/dist/esm/helperComponents/index.d.ts +5 -0
- package/dist/esm/helperComponents/index.js +5 -0
- package/dist/esm/index.d.ts +4 -0
- package/dist/esm/index.js +4 -0
- package/dist/esm/locale/index.d.ts +19 -0
- package/dist/esm/locale/index.js +7 -0
- package/dist/esm/style.css +351 -0
- package/dist/esm/types.d.ts +44 -0
- package/dist/esm/types.js +1 -0
- package/dist/tsconfig.cjs.tsbuildinfo +1 -0
- package/dist/tsconfig.esm.tsbuildinfo +1 -0
- package/package.json +54 -3
- package/src/components/SectionBasic/SectionBasic.tsx +110 -0
- package/src/components/SectionBasic/index.ts +1 -0
- package/src/components/index.ts +1 -0
- package/src/constants.ts +43 -0
- package/src/helperComponents/BackgroundLayer/BackgroundLayer.tsx +27 -0
- package/src/helperComponents/BackgroundLayer/index.ts +1 -0
- package/src/helperComponents/BackgroundLayer/styles.module.scss +16 -0
- package/src/helperComponents/BackgroundLayer/utils.ts +13 -0
- package/src/helperComponents/BgLocal/BgLocal.tsx +26 -0
- package/src/helperComponents/BgLocal/index.ts +1 -0
- package/src/helperComponents/BgLocal/styles.module.scss +22 -0
- package/src/helperComponents/SectionFilter/SectionFilter.tsx +21 -0
- package/src/helperComponents/SectionFilter/index.ts +1 -0
- package/src/helperComponents/SectionFilter/styles.module.scss +13 -0
- package/src/helperComponents/SectionFooter/SectionFooter.tsx +36 -0
- package/src/helperComponents/SectionFooter/index.ts +1 -0
- package/src/helperComponents/SectionFooter/styles.module.scss +8 -0
- package/src/helperComponents/SectionWrapper/SectionWrapper.tsx +62 -0
- package/src/helperComponents/SectionWrapper/index.ts +1 -0
- package/src/helperComponents/SectionWrapper/styles.module.scss +122 -0
- package/src/helperComponents/index.ts +5 -0
- package/src/index.ts +4 -0
- package/src/locale/index.ts +11 -0
- package/src/types.ts +55 -0
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
import { LAYOUT_TYPE, useAdaptiveLayout } from '@cloud-ru/ds-adaptive';
|
|
2
|
+
import { FieldSelectProps } from '@cloud-ru/ds-fields';
|
|
3
|
+
import { PaginationProps } from '@cloud-ru/ds-pagination';
|
|
4
|
+
import { SectionTitle, SectionTitleProps } from '@cloud-ru/ds-site-section-title';
|
|
5
|
+
import { SIZE, TabsSegmented, TabsSegmentedItem } from '@cloud-ru/ds-site-tabs-segmented';
|
|
6
|
+
import { WithSupportProps } from '@cloud-ru/ds-utils';
|
|
7
|
+
import { ReactNode } from 'react';
|
|
8
|
+
|
|
9
|
+
import { SECTION_CONTAINER_BACKGROUND_TYPE, TEST_IDS } from '../../constants';
|
|
10
|
+
import { SectionFilter, SectionFooter, SectionWrapper } from '../../helperComponents';
|
|
11
|
+
import { SectionBackground, SectionContainer, SectionContainerBackground, SectionMoreButton } from '../../types';
|
|
12
|
+
|
|
13
|
+
export type SectionBasicProps = WithSupportProps<
|
|
14
|
+
Pick<SectionTitleProps, 'title' | 'description' | 'titleTag'> & {
|
|
15
|
+
/**
|
|
16
|
+
* Ширина и отступы секции: `new` — целевой вид, `old` — совместимость со страницами до редизайна.
|
|
17
|
+
* Временная настройка на период редизайна, задаётся явно.
|
|
18
|
+
*/
|
|
19
|
+
container: SectionContainer;
|
|
20
|
+
/** Внешний слой фона во всю ширину экрана (Figma `sectionBackground`): тема и заливка. */
|
|
21
|
+
background?: SectionBackground;
|
|
22
|
+
/**
|
|
23
|
+
* Блок по ширине `container` (Figma `contentWrapper` + `bgLocal`): тема блока и всего содержимого и заливка —
|
|
24
|
+
* подложка, картинка или акцентный цвет. Тема не задана — тема внешнего слоя.
|
|
25
|
+
*/
|
|
26
|
+
containerBackground?: SectionContainerBackground;
|
|
27
|
+
/** HTML-атрибут `id` секции — якорь для навигации по странице. */
|
|
28
|
+
id?: string;
|
|
29
|
+
/** Содержимое секции между фильтрами и футером. */
|
|
30
|
+
children?: ReactNode;
|
|
31
|
+
/** Вкладки под заголовком. Без `tabBarValue` / `defaultTabBarValue` изначально выбрана первая доступная. */
|
|
32
|
+
tabBarItems?: TabsSegmentedItem[];
|
|
33
|
+
/** Выбранная вкладка (controlled), например из параметра URL `?tab=ai`. */
|
|
34
|
+
tabBarValue?: string;
|
|
35
|
+
/** Изначально выбранная вкладка (uncontrolled). */
|
|
36
|
+
defaultTabBarValue?: string;
|
|
37
|
+
/** Колбэк выбора вкладки: значение `value` выбранного элемента `tabBarItems`. */
|
|
38
|
+
onTabBarChange?(value: string): void;
|
|
39
|
+
/** Поля-фильтры под вкладками. Рендерятся как `FieldSelect` размера `l`. */
|
|
40
|
+
filterItems?: FieldSelectProps[];
|
|
41
|
+
/** Пагинация в футере. */
|
|
42
|
+
pagination?: PaginationProps;
|
|
43
|
+
/** Кнопка «Показать еще» в футере. */
|
|
44
|
+
moreButton?: SectionMoreButton;
|
|
45
|
+
/** CSS-класс корня. */
|
|
46
|
+
className?: string;
|
|
47
|
+
}
|
|
48
|
+
>;
|
|
49
|
+
|
|
50
|
+
const DEFAULT_CONTAINER_BACKGROUND: SectionContainerBackground = { type: SECTION_CONTAINER_BACKGROUND_TYPE.Bg };
|
|
51
|
+
|
|
52
|
+
export function SectionBasic({
|
|
53
|
+
container,
|
|
54
|
+
background,
|
|
55
|
+
containerBackground = DEFAULT_CONTAINER_BACKGROUND,
|
|
56
|
+
id,
|
|
57
|
+
children,
|
|
58
|
+
title,
|
|
59
|
+
description,
|
|
60
|
+
titleTag,
|
|
61
|
+
tabBarItems,
|
|
62
|
+
tabBarValue,
|
|
63
|
+
defaultTabBarValue,
|
|
64
|
+
onTabBarChange,
|
|
65
|
+
filterItems,
|
|
66
|
+
pagination,
|
|
67
|
+
moreButton,
|
|
68
|
+
className,
|
|
69
|
+
...rest
|
|
70
|
+
}: SectionBasicProps) {
|
|
71
|
+
const { layoutType } = useAdaptiveLayout();
|
|
72
|
+
const hasTitle = Boolean(title || description);
|
|
73
|
+
const hasFooter = Boolean(pagination || moreButton);
|
|
74
|
+
// Figma (container=new): на desktop вкладки size=l, на tablet и mobile — size=m. Для old так же.
|
|
75
|
+
const tabsSize = layoutType === LAYOUT_TYPE.Desktop || layoutType === LAYOUT_TYPE.DesktopSmall ? SIZE.L : SIZE.M;
|
|
76
|
+
|
|
77
|
+
return (
|
|
78
|
+
<SectionWrapper
|
|
79
|
+
id={id}
|
|
80
|
+
container={container}
|
|
81
|
+
background={background}
|
|
82
|
+
containerBackground={containerBackground}
|
|
83
|
+
className={className}
|
|
84
|
+
data-test-id={TEST_IDS.root}
|
|
85
|
+
{...rest}
|
|
86
|
+
>
|
|
87
|
+
{hasTitle && (
|
|
88
|
+
<SectionTitle
|
|
89
|
+
title={title}
|
|
90
|
+
description={description}
|
|
91
|
+
titleTag={titleTag}
|
|
92
|
+
data-test-id={TEST_IDS.sectionTitle}
|
|
93
|
+
/>
|
|
94
|
+
)}
|
|
95
|
+
{tabBarItems && tabBarItems.length > 0 && (
|
|
96
|
+
<TabsSegmented
|
|
97
|
+
items={tabBarItems}
|
|
98
|
+
value={tabBarValue}
|
|
99
|
+
defaultValue={defaultTabBarValue}
|
|
100
|
+
onChange={onTabBarChange}
|
|
101
|
+
size={tabsSize}
|
|
102
|
+
data-test-id={TEST_IDS.tabs}
|
|
103
|
+
/>
|
|
104
|
+
)}
|
|
105
|
+
{filterItems && filterItems.length > 0 && <SectionFilter items={filterItems} />}
|
|
106
|
+
{children}
|
|
107
|
+
{hasFooter && <SectionFooter pagination={pagination} moreButton={moreButton} />}
|
|
108
|
+
</SectionWrapper>
|
|
109
|
+
);
|
|
110
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './SectionBasic';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './SectionBasic';
|
package/src/constants.ts
ADDED
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import { BACKGROUND_PREDEFINED_FILL } from '@cloud-ru/ds-materials';
|
|
2
|
+
|
|
3
|
+
const PREFIX = 'section-basic';
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Ширина и отступы секции. Временная настройка на период редизайна: задаётся явно в каждом месте использования.
|
|
7
|
+
*/
|
|
8
|
+
export const CONTAINER = {
|
|
9
|
+
/** Целевой вид: секция шире, отступы меньше. */
|
|
10
|
+
New: 'new',
|
|
11
|
+
/** Визуальная совместимость со страницами до редизайна. */
|
|
12
|
+
Old: 'old',
|
|
13
|
+
} as const;
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* Подложка фона секции (Figma `sectionBackground.appearance`): набор `BACKGROUND_PREDEFINED_FILL` из `@cloud-ru/ds-materials`
|
|
17
|
+
* и `neutralBackground` — подложка секции по умолчанию.
|
|
18
|
+
*/
|
|
19
|
+
export const SECTION_BACKGROUND_FILL = {
|
|
20
|
+
...BACKGROUND_PREDEFINED_FILL,
|
|
21
|
+
NeutralBackground: 'neutralBackground',
|
|
22
|
+
} as const;
|
|
23
|
+
|
|
24
|
+
/** Тип фона блока по ширине `container` (Figma `bgLocal.type`). */
|
|
25
|
+
export const SECTION_CONTAINER_BACKGROUND_TYPE = {
|
|
26
|
+
/** Подложка из `SECTION_BACKGROUND_FILL`. */
|
|
27
|
+
Bg: 'bg',
|
|
28
|
+
/** Картинка во весь блок. */
|
|
29
|
+
Image: 'image',
|
|
30
|
+
/** Акцентный цвет бренда. */
|
|
31
|
+
Accent: 'accent',
|
|
32
|
+
} as const;
|
|
33
|
+
|
|
34
|
+
export const TEST_IDS = {
|
|
35
|
+
root: PREFIX,
|
|
36
|
+
sectionTitle: `${PREFIX}__section-title`,
|
|
37
|
+
tabs: `${PREFIX}__tabs`,
|
|
38
|
+
filters: `${PREFIX}__filters`,
|
|
39
|
+
containerBackground: `${PREFIX}__container-background`,
|
|
40
|
+
footer: `${PREFIX}__footer`,
|
|
41
|
+
pagination: `${PREFIX}__pagination`,
|
|
42
|
+
moreButton: `${PREFIX}__more-button`,
|
|
43
|
+
} as const;
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { extractSupportProps, WithSupportProps } from '@cloud-ru/ds-utils';
|
|
2
|
+
|
|
3
|
+
import { SectionBackgroundFill } from '../../types';
|
|
4
|
+
import styles from './styles.module.scss';
|
|
5
|
+
import { sectionBackgroundFillToAcrylic } from './utils';
|
|
6
|
+
|
|
7
|
+
export type BackgroundLayerProps = WithSupportProps<{
|
|
8
|
+
/** Подложка. */
|
|
9
|
+
fill: SectionBackgroundFill;
|
|
10
|
+
}>;
|
|
11
|
+
|
|
12
|
+
/** Слой-подложка секции (Figma `sectionBackground`): материал из `SECTION_BACKGROUND_FILL`, растянутый на родителя. */
|
|
13
|
+
export function BackgroundLayer({ fill, ...rest }: BackgroundLayerProps) {
|
|
14
|
+
const { appearance, level } = sectionBackgroundFillToAcrylic(fill);
|
|
15
|
+
|
|
16
|
+
return (
|
|
17
|
+
<span
|
|
18
|
+
className={styles.backgroundLayer}
|
|
19
|
+
data-acrylic-appearance={appearance}
|
|
20
|
+
data-acrylic-level={level}
|
|
21
|
+
aria-hidden
|
|
22
|
+
{...extractSupportProps(rest)}
|
|
23
|
+
>
|
|
24
|
+
<span className={styles.acrylic} />
|
|
25
|
+
</span>
|
|
26
|
+
);
|
|
27
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './BackgroundLayer';
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
@use '@cloud-ru/ds-materials' as m;
|
|
2
|
+
|
|
3
|
+
.acrylic {
|
|
4
|
+
position: absolute;
|
|
5
|
+
inset: 0;
|
|
6
|
+
border-radius: inherit;
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
.backgroundLayer {
|
|
10
|
+
pointer-events: none;
|
|
11
|
+
position: absolute;
|
|
12
|
+
inset: 0;
|
|
13
|
+
border-radius: inherit;
|
|
14
|
+
|
|
15
|
+
@include m.with-material('acrylic', #{acrylic});
|
|
16
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { ACRYLIC_LEVEL, backgroundPredefinedFillToAcrylic } from '@cloud-ru/ds-materials';
|
|
2
|
+
|
|
3
|
+
import { SECTION_BACKGROUND_FILL } from '../../constants';
|
|
4
|
+
import { SectionBackgroundFill } from '../../types';
|
|
5
|
+
|
|
6
|
+
/** Пара `data-acrylic-appearance` / `data-acrylic-level` для подложки секции. */
|
|
7
|
+
export function sectionBackgroundFillToAcrylic(fill: SectionBackgroundFill) {
|
|
8
|
+
if (fill === SECTION_BACKGROUND_FILL.NeutralBackground) {
|
|
9
|
+
return { appearance: 'neutral', level: ACRYLIC_LEVEL.Default } as const;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
return backgroundPredefinedFillToAcrylic(fill);
|
|
13
|
+
}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { SECTION_BACKGROUND_FILL, SECTION_CONTAINER_BACKGROUND_TYPE, TEST_IDS } from '../../constants';
|
|
2
|
+
import { SectionContainerBackground } from '../../types';
|
|
3
|
+
import { BackgroundLayer } from '../BackgroundLayer';
|
|
4
|
+
import styles from './styles.module.scss';
|
|
5
|
+
|
|
6
|
+
export type BgLocalProps = {
|
|
7
|
+
/** Фон блока. */
|
|
8
|
+
background: SectionContainerBackground;
|
|
9
|
+
};
|
|
10
|
+
|
|
11
|
+
/** Фон блока по ширине `container` (Figma `bgLocal`): подложка, картинка или акцентный цвет. Декоративный слой. */
|
|
12
|
+
export function BgLocal({ background }: BgLocalProps) {
|
|
13
|
+
switch (background.type) {
|
|
14
|
+
case SECTION_CONTAINER_BACKGROUND_TYPE.Image:
|
|
15
|
+
return <img className={styles.image} src={background.src} alt='' data-test-id={TEST_IDS.containerBackground} />;
|
|
16
|
+
case SECTION_CONTAINER_BACKGROUND_TYPE.Accent:
|
|
17
|
+
return <span className={styles.accent} aria-hidden data-test-id={TEST_IDS.containerBackground} />;
|
|
18
|
+
default:
|
|
19
|
+
return (
|
|
20
|
+
<BackgroundLayer
|
|
21
|
+
fill={background.fill ?? SECTION_BACKGROUND_FILL.NeutralBackground}
|
|
22
|
+
data-test-id={TEST_IDS.containerBackground}
|
|
23
|
+
/>
|
|
24
|
+
);
|
|
25
|
+
}
|
|
26
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './BgLocal';
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
@use '@cloud-ru/ds-figma-variables/build/scss/styles/styles.module' as base;
|
|
2
|
+
|
|
3
|
+
@mixin layer {
|
|
4
|
+
pointer-events: none;
|
|
5
|
+
position: absolute;
|
|
6
|
+
inset: 0;
|
|
7
|
+
border-radius: inherit;
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
.accent {
|
|
11
|
+
@include layer;
|
|
12
|
+
|
|
13
|
+
background-color: base.$sn-theme-color-primary-accent;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
.image {
|
|
17
|
+
@include layer;
|
|
18
|
+
|
|
19
|
+
width: 100%;
|
|
20
|
+
height: 100%;
|
|
21
|
+
object-fit: cover;
|
|
22
|
+
}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { FieldSelect, FieldSelectProps } from '@cloud-ru/ds-fields';
|
|
2
|
+
import cn from 'classnames';
|
|
3
|
+
|
|
4
|
+
import { TEST_IDS } from '../../constants';
|
|
5
|
+
import styles from './styles.module.scss';
|
|
6
|
+
|
|
7
|
+
export type SectionFilterProps = {
|
|
8
|
+
/** Настройки полей-фильтров. Размер поля фиксирован — `l`. */
|
|
9
|
+
items: FieldSelectProps[];
|
|
10
|
+
};
|
|
11
|
+
|
|
12
|
+
/** Ряд фильтров секции (Figma `sectionFilter`): поля делят ширину поровну и переносятся на новую строку. */
|
|
13
|
+
export function SectionFilter({ items }: SectionFilterProps) {
|
|
14
|
+
return (
|
|
15
|
+
<div className={styles.sectionFilter} data-test-id={TEST_IDS.filters}>
|
|
16
|
+
{items.map((item, index) => (
|
|
17
|
+
<FieldSelect key={item.id ?? index} {...item} className={cn(styles.filter, item.className)} size='l' />
|
|
18
|
+
))}
|
|
19
|
+
</div>
|
|
20
|
+
);
|
|
21
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './SectionFilter';
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
@use '@cloud-ru/ds-figma-variables/build/scss/styles/styles.module' as base;
|
|
2
|
+
|
|
3
|
+
.sectionFilter {
|
|
4
|
+
display: flex;
|
|
5
|
+
flex-wrap: wrap;
|
|
6
|
+
gap: base.$sn-density-spacing-interval-l;
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
.filter {
|
|
10
|
+
flex: 1 1 0;
|
|
11
|
+
// Figma: minWidth 328 у поля фильтра — ширина, при которой ряд переносится. Токена такого размера нет.
|
|
12
|
+
min-width: min(328px, 100%);
|
|
13
|
+
}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { Button } from '@cloud-ru/ds-button';
|
|
2
|
+
import { Pagination, PaginationProps } from '@cloud-ru/ds-pagination';
|
|
3
|
+
|
|
4
|
+
import { TEST_IDS } from '../../constants';
|
|
5
|
+
import { siteSectionLocale } from '../../locale';
|
|
6
|
+
import { SectionMoreButton } from '../../types';
|
|
7
|
+
import styles from './styles.module.scss';
|
|
8
|
+
|
|
9
|
+
export type SectionFooterProps = {
|
|
10
|
+
/** Настройки пагинации. */
|
|
11
|
+
pagination?: PaginationProps;
|
|
12
|
+
/** Кнопка «Показать еще». */
|
|
13
|
+
moreButton?: SectionMoreButton;
|
|
14
|
+
};
|
|
15
|
+
|
|
16
|
+
/** Футер секции (Figma `sectionFooter`): пагинация и кнопка «Показать еще» по центру. */
|
|
17
|
+
export function SectionFooter({ pagination, moreButton }: SectionFooterProps) {
|
|
18
|
+
const { t } = siteSectionLocale.useTranslations();
|
|
19
|
+
|
|
20
|
+
return (
|
|
21
|
+
<div className={styles.sectionFooter} data-test-id={TEST_IDS.footer}>
|
|
22
|
+
{pagination && <Pagination data-test-id={TEST_IDS.pagination} {...pagination} />}
|
|
23
|
+
{moreButton && (
|
|
24
|
+
<Button
|
|
25
|
+
{...(moreButton.href ? { as: 'a', href: moreButton.href } : { type: 'button' })}
|
|
26
|
+
label={moreButton.label ?? t('showMore')}
|
|
27
|
+
onClick={moreButton.onClick}
|
|
28
|
+
view='outline'
|
|
29
|
+
appearance='neutral'
|
|
30
|
+
size='l'
|
|
31
|
+
data-test-id={moreButton['data-test-id'] ?? TEST_IDS.moreButton}
|
|
32
|
+
/>
|
|
33
|
+
)}
|
|
34
|
+
</div>
|
|
35
|
+
);
|
|
36
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './SectionFooter';
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
import { useAdaptiveLayout } from '@cloud-ru/ds-adaptive';
|
|
2
|
+
import { ChildThemeProvider, ThemeAppearance } from '@cloud-ru/ds-theme';
|
|
3
|
+
import { extractSupportProps, WithSupportProps } from '@cloud-ru/ds-utils';
|
|
4
|
+
import cn from 'classnames';
|
|
5
|
+
import { ReactNode } from 'react';
|
|
6
|
+
|
|
7
|
+
import { SECTION_BACKGROUND_FILL } from '../../constants';
|
|
8
|
+
import { SectionBackground, SectionContainer, SectionContainerBackground } from '../../types';
|
|
9
|
+
import { BackgroundLayer } from '../BackgroundLayer';
|
|
10
|
+
import { BgLocal } from '../BgLocal';
|
|
11
|
+
import styles from './styles.module.scss';
|
|
12
|
+
|
|
13
|
+
export type SectionWrapperProps = WithSupportProps<{
|
|
14
|
+
/** Ширина и отступы секции. */
|
|
15
|
+
container: SectionContainer;
|
|
16
|
+
/** Внешний слой фона. */
|
|
17
|
+
background?: SectionBackground;
|
|
18
|
+
/** Блок по ширине `container`. */
|
|
19
|
+
containerBackground: SectionContainerBackground;
|
|
20
|
+
/** HTML-атрибут `id` секции — якорь для навигации по странице. */
|
|
21
|
+
id?: string;
|
|
22
|
+
/** CSS-класс корня. */
|
|
23
|
+
className?: string;
|
|
24
|
+
children: ReactNode;
|
|
25
|
+
}>;
|
|
26
|
+
|
|
27
|
+
const EMPTY_THEME: Partial<ThemeAppearance> = {};
|
|
28
|
+
|
|
29
|
+
/**
|
|
30
|
+
* Каркас секции (Figma `sectionBasic`): внешний фон во всю ширину и блок по ширине `container` со своим фоном.
|
|
31
|
+
* У каждого слоя своя тема, поэтому блок может быть тёмным на светлом фоне и наоборот. Темы ставятся
|
|
32
|
+
* обёртками провайдера (классы `sn-*` в разметке), поэтому они есть и в SSR-HTML.
|
|
33
|
+
*/
|
|
34
|
+
export function SectionWrapper({
|
|
35
|
+
container,
|
|
36
|
+
background,
|
|
37
|
+
containerBackground,
|
|
38
|
+
id,
|
|
39
|
+
className,
|
|
40
|
+
children,
|
|
41
|
+
...rest
|
|
42
|
+
}: SectionWrapperProps) {
|
|
43
|
+
const { layoutType } = useAdaptiveLayout();
|
|
44
|
+
|
|
45
|
+
return (
|
|
46
|
+
<section
|
|
47
|
+
id={id}
|
|
48
|
+
className={cn(styles.sectionWrapper, className)}
|
|
49
|
+
data-layout-type={layoutType}
|
|
50
|
+
data-container={container}
|
|
51
|
+
{...extractSupportProps(rest)}
|
|
52
|
+
>
|
|
53
|
+
<ChildThemeProvider value={background?.theme ?? EMPTY_THEME} className={styles.background}>
|
|
54
|
+
<BackgroundLayer fill={background?.fill ?? SECTION_BACKGROUND_FILL.NeutralBackground} />
|
|
55
|
+
<ChildThemeProvider value={containerBackground.theme ?? EMPTY_THEME} className={styles.contentWrapper}>
|
|
56
|
+
<BgLocal background={containerBackground} />
|
|
57
|
+
<div className={styles.content}>{children}</div>
|
|
58
|
+
</ChildThemeProvider>
|
|
59
|
+
</ChildThemeProvider>
|
|
60
|
+
</section>
|
|
61
|
+
);
|
|
62
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './SectionWrapper';
|
|
@@ -0,0 +1,122 @@
|
|
|
1
|
+
@use '@cloud-ru/ds-figma-variables/build/scss/styles/styles.module' as base;
|
|
2
|
+
|
|
3
|
+
// Отступы из Figma (sectionBasic → device=*, container=*): внешние (вокруг блока) и внутренние (внутри блока),
|
|
4
|
+
// шаг между блоками. Совпадают не с platform-интервалами, поэтому заданы примитивами.
|
|
5
|
+
$new-desktop: (
|
|
6
|
+
'outer-block': base.$sn-primitive-dimension-24,
|
|
7
|
+
'outer-inline': base.$sn-primitive-dimension-16,
|
|
8
|
+
'inner-block': base.$sn-primitive-dimension-48,
|
|
9
|
+
'inner-inline': base.$sn-primitive-dimension-32,
|
|
10
|
+
'gap': base.$sn-primitive-dimension-40,
|
|
11
|
+
);
|
|
12
|
+
$old-desktop: (
|
|
13
|
+
'outer-block': 0,
|
|
14
|
+
'outer-inline': base.$sn-primitive-dimension-16,
|
|
15
|
+
'inner-block': base.$sn-primitive-dimension-56,
|
|
16
|
+
'inner-inline': base.$sn-primitive-dimension-96,
|
|
17
|
+
'gap': base.$sn-primitive-dimension-40,
|
|
18
|
+
);
|
|
19
|
+
$containers: (
|
|
20
|
+
'new': (
|
|
21
|
+
// Figma: максимальная ширина блока. Токена такой ширины нет (view/page: 720/960/1280/full).
|
|
22
|
+
'max-width': 1824px,
|
|
23
|
+
'layouts': (
|
|
24
|
+
'desktop': $new-desktop,
|
|
25
|
+
'desktopSmall': $new-desktop,
|
|
26
|
+
'tablet': (
|
|
27
|
+
'outer-block': base.$sn-primitive-dimension-16,
|
|
28
|
+
'outer-inline': base.$sn-primitive-dimension-8,
|
|
29
|
+
'inner-block': base.$sn-primitive-dimension-24,
|
|
30
|
+
'inner-inline': base.$sn-primitive-dimension-16,
|
|
31
|
+
'gap': base.$sn-primitive-dimension-32,
|
|
32
|
+
),
|
|
33
|
+
'mobile': (
|
|
34
|
+
'outer-block': base.$sn-primitive-dimension-16,
|
|
35
|
+
'outer-inline': 0,
|
|
36
|
+
'inner-block': base.$sn-primitive-dimension-24,
|
|
37
|
+
'inner-inline': base.$sn-primitive-dimension-16,
|
|
38
|
+
'gap': base.$sn-primitive-dimension-24,
|
|
39
|
+
),
|
|
40
|
+
),
|
|
41
|
+
),
|
|
42
|
+
'old': (
|
|
43
|
+
// Figma: максимальная ширина блока, контент внутри — 1216. Токена такой ширины нет.
|
|
44
|
+
'max-width': 1408px,
|
|
45
|
+
'layouts': (
|
|
46
|
+
'desktop': $old-desktop,
|
|
47
|
+
'desktopSmall': $old-desktop,
|
|
48
|
+
'tablet': (
|
|
49
|
+
'outer-block': 0,
|
|
50
|
+
'outer-inline': base.$sn-primitive-dimension-16,
|
|
51
|
+
'inner-block': base.$sn-primitive-dimension-40,
|
|
52
|
+
'inner-inline': base.$sn-primitive-dimension-24,
|
|
53
|
+
'gap': base.$sn-primitive-dimension-32,
|
|
54
|
+
),
|
|
55
|
+
'mobile': (
|
|
56
|
+
'outer-block': 0,
|
|
57
|
+
'outer-inline': 0,
|
|
58
|
+
'inner-block': base.$sn-primitive-dimension-32,
|
|
59
|
+
'inner-inline': base.$sn-primitive-dimension-16,
|
|
60
|
+
'gap': base.$sn-primitive-dimension-24,
|
|
61
|
+
),
|
|
62
|
+
),
|
|
63
|
+
),
|
|
64
|
+
);
|
|
65
|
+
|
|
66
|
+
.sectionWrapper {
|
|
67
|
+
width: 100%;
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
// Внешний слой во всю ширину: обёртка провайдера темы `background.theme`.
|
|
71
|
+
.background {
|
|
72
|
+
position: relative;
|
|
73
|
+
box-sizing: border-box;
|
|
74
|
+
|
|
75
|
+
@each $container, $config in $containers {
|
|
76
|
+
@each $layout, $spacing in base.simple-var($config, 'layouts') {
|
|
77
|
+
.sectionWrapper[data-container='#{$container}'][data-layout-type='#{$layout}'] & {
|
|
78
|
+
padding: base.simple-var($spacing, 'outer-block') base.simple-var($spacing, 'outer-inline');
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
.contentWrapper {
|
|
85
|
+
position: relative;
|
|
86
|
+
box-sizing: border-box;
|
|
87
|
+
margin-inline: auto;
|
|
88
|
+
border-radius: base.$sn-density-radius-2xs;
|
|
89
|
+
|
|
90
|
+
@each $container, $config in $containers {
|
|
91
|
+
.sectionWrapper[data-container='#{$container}'] & {
|
|
92
|
+
max-width: base.simple-var($config, 'max-width');
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
@each $layout, $spacing in base.simple-var($config, 'layouts') {
|
|
96
|
+
.sectionWrapper[data-container='#{$container}'][data-layout-type='#{$layout}'] & {
|
|
97
|
+
padding: base.simple-var($spacing, 'inner-block') base.simple-var($spacing, 'inner-inline');
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
// Цвет текста задаётся здесь, в теме блока: иначе текст содержимого наследует цвет страницы
|
|
104
|
+
// и пропадает, когда тема блока отличается от темы страницы.
|
|
105
|
+
.content {
|
|
106
|
+
position: relative;
|
|
107
|
+
|
|
108
|
+
display: flex;
|
|
109
|
+
flex-direction: column;
|
|
110
|
+
|
|
111
|
+
min-width: 0;
|
|
112
|
+
|
|
113
|
+
color: base.$sn-theme-color-available-version-textMain;
|
|
114
|
+
|
|
115
|
+
@each $container, $config in $containers {
|
|
116
|
+
@each $layout, $spacing in base.simple-var($config, 'layouts') {
|
|
117
|
+
.sectionWrapper[data-container='#{$container}'][data-layout-type='#{$layout}'] & {
|
|
118
|
+
gap: base.simple-var($spacing, 'gap');
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
}
|
package/src/index.ts
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { defineLocale, defineMessages } from '@cloud-ru/ds-locale';
|
|
2
|
+
|
|
3
|
+
const SITE_SECTION_MESSAGES = defineMessages({
|
|
4
|
+
'en-GB': { showMore: 'Show more' },
|
|
5
|
+
'ru-RU': { showMore: 'Показать еще' },
|
|
6
|
+
});
|
|
7
|
+
|
|
8
|
+
export type SiteSectionMessages = (typeof SITE_SECTION_MESSAGES)['en-GB'];
|
|
9
|
+
|
|
10
|
+
/** locale пакета: `siteSectionLocale.useTranslations()` в коде, `.extend(...)` в сервисе. */
|
|
11
|
+
export const siteSectionLocale = defineLocale('@cloud-ru/ds-site-section', SITE_SECTION_MESSAGES);
|
package/src/types.ts
ADDED
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import { ThemeAppearance } from '@cloud-ru/ds-theme';
|
|
2
|
+
import { ValueOf } from '@cloud-ru/ds-utils';
|
|
3
|
+
import { MouseEvent } from 'react';
|
|
4
|
+
|
|
5
|
+
import { CONTAINER, SECTION_BACKGROUND_FILL, SECTION_CONTAINER_BACKGROUND_TYPE } from './constants';
|
|
6
|
+
|
|
7
|
+
export type SectionContainer = ValueOf<typeof CONTAINER>;
|
|
8
|
+
|
|
9
|
+
export type SectionBackgroundFill = ValueOf<typeof SECTION_BACKGROUND_FILL>;
|
|
10
|
+
|
|
11
|
+
export type SectionContainerBackgroundType = ValueOf<typeof SECTION_CONTAINER_BACKGROUND_TYPE>;
|
|
12
|
+
|
|
13
|
+
/** Внешний слой фона во всю ширину экрана (Figma `sectionBackground`). */
|
|
14
|
+
export type SectionBackground = {
|
|
15
|
+
/** Тема слоя. Не задана — тема страницы. */
|
|
16
|
+
theme?: Partial<ThemeAppearance>;
|
|
17
|
+
/** Заливка. По умолчанию `neutralBackground`. */
|
|
18
|
+
fill?: SectionBackgroundFill;
|
|
19
|
+
};
|
|
20
|
+
|
|
21
|
+
/** Заливка блока по ширине `container` (Figma `bgLocal.type`). Набор полей зависит от `type`. */
|
|
22
|
+
export type SectionContainerFill =
|
|
23
|
+
| {
|
|
24
|
+
/** Подложка. */
|
|
25
|
+
type: typeof SECTION_CONTAINER_BACKGROUND_TYPE.Bg;
|
|
26
|
+
/** Подложка. По умолчанию `neutralBackground`. */
|
|
27
|
+
fill?: SectionBackgroundFill;
|
|
28
|
+
}
|
|
29
|
+
| {
|
|
30
|
+
/** Картинка во весь блок, кадрируется по размеру блока. */
|
|
31
|
+
type: typeof SECTION_CONTAINER_BACKGROUND_TYPE.Image;
|
|
32
|
+
/** URL картинки. Картинка декоративная, у `<img>` пустой `alt`. */
|
|
33
|
+
src: string;
|
|
34
|
+
}
|
|
35
|
+
| {
|
|
36
|
+
/** Акцентный цвет бренда (`primary/accent`). */
|
|
37
|
+
type: typeof SECTION_CONTAINER_BACKGROUND_TYPE.Accent;
|
|
38
|
+
};
|
|
39
|
+
|
|
40
|
+
/** Блок по ширине `container` (Figma `contentWrapper` + `bgLocal`): тема и заливка. */
|
|
41
|
+
export type SectionContainerBackground = SectionContainerFill & {
|
|
42
|
+
/** Тема блока и всего содержимого. Не задана — тема внешнего слоя. */
|
|
43
|
+
theme?: Partial<ThemeAppearance>;
|
|
44
|
+
};
|
|
45
|
+
|
|
46
|
+
export type SectionMoreButton = {
|
|
47
|
+
/** Текст кнопки. По умолчанию — «Показать еще» из локали пакета. */
|
|
48
|
+
label?: string;
|
|
49
|
+
/** Ссылка. Если задана, кнопка рендерится как `<a>`. */
|
|
50
|
+
href?: string;
|
|
51
|
+
/** Колбэк клика. */
|
|
52
|
+
onClick?(event: MouseEvent<HTMLElement>): void;
|
|
53
|
+
/** Тестовый id кнопки. По умолчанию — `TEST_IDS.moreButton`. */
|
|
54
|
+
'data-test-id'?: string;
|
|
55
|
+
};
|