@gravity-ui/page-constructor 8.13.2 → 8.14.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/build/cjs/blocks/Footer/Footer.css +53 -0
- package/build/cjs/blocks/Footer/Footer.d.ts +5 -0
- package/build/cjs/blocks/Footer/Footer.js +34 -0
- package/build/cjs/blocks/Footer/Footer.js.map +1 -0
- package/build/cjs/blocks/Footer/components/CopyrightFloor/CopyrightFloor.css +201 -0
- package/build/cjs/blocks/Footer/components/CopyrightFloor/CopyrightFloor.d.ts +6 -0
- package/build/cjs/blocks/Footer/components/CopyrightFloor/CopyrightFloor.js +142 -0
- package/build/cjs/blocks/Footer/components/CopyrightFloor/CopyrightFloor.js.map +1 -0
- package/build/cjs/blocks/Footer/components/CopyrightFloor/index.d.ts +1 -0
- package/build/cjs/blocks/Footer/components/CopyrightFloor/index.js +6 -0
- package/build/cjs/blocks/Footer/components/CopyrightFloor/index.js.map +1 -0
- package/build/cjs/blocks/Footer/components/DisclaimerFloor/DisclaimerFloor.css +28 -0
- package/build/cjs/blocks/Footer/components/DisclaimerFloor/DisclaimerFloor.d.ts +6 -0
- package/build/cjs/blocks/Footer/components/DisclaimerFloor/DisclaimerFloor.js +18 -0
- package/build/cjs/blocks/Footer/components/DisclaimerFloor/DisclaimerFloor.js.map +1 -0
- package/build/cjs/blocks/Footer/components/DisclaimerFloor/index.d.ts +1 -0
- package/build/cjs/blocks/Footer/components/DisclaimerFloor/index.js +6 -0
- package/build/cjs/blocks/Footer/components/DisclaimerFloor/index.js.map +1 -0
- package/build/cjs/blocks/Footer/components/LangSwitcher/LangSwitcher.css +14 -0
- package/build/cjs/blocks/Footer/components/LangSwitcher/LangSwitcher.d.ts +11 -0
- package/build/cjs/blocks/Footer/components/LangSwitcher/LangSwitcher.js +38 -0
- package/build/cjs/blocks/Footer/components/LangSwitcher/LangSwitcher.js.map +1 -0
- package/build/cjs/blocks/Footer/components/LangSwitcher/index.d.ts +1 -0
- package/build/cjs/blocks/Footer/components/LangSwitcher/index.js +6 -0
- package/build/cjs/blocks/Footer/components/LangSwitcher/index.js.map +1 -0
- package/build/cjs/blocks/Footer/components/NavigationFloor/NavigationFloor.css +93 -0
- package/build/cjs/blocks/Footer/components/NavigationFloor/NavigationFloor.d.ts +12 -0
- package/build/cjs/blocks/Footer/components/NavigationFloor/NavigationFloor.js +37 -0
- package/build/cjs/blocks/Footer/components/NavigationFloor/NavigationFloor.js.map +1 -0
- package/build/cjs/blocks/Footer/components/NavigationFloor/index.d.ts +1 -0
- package/build/cjs/blocks/Footer/components/NavigationFloor/index.js +6 -0
- package/build/cjs/blocks/Footer/components/NavigationFloor/index.js.map +1 -0
- package/build/cjs/blocks/Footer/components/SocialFloor/SocialFloor.css +77 -0
- package/build/cjs/blocks/Footer/components/SocialFloor/SocialFloor.d.ts +6 -0
- package/build/cjs/blocks/Footer/components/SocialFloor/SocialFloor.js +38 -0
- package/build/cjs/blocks/Footer/components/SocialFloor/SocialFloor.js.map +1 -0
- package/build/cjs/blocks/Footer/components/SocialFloor/index.d.ts +1 -0
- package/build/cjs/blocks/Footer/components/SocialFloor/index.js +6 -0
- package/build/cjs/blocks/Footer/components/SocialFloor/index.js.map +1 -0
- package/build/cjs/blocks/Footer/hooks/useLogoImageProps.d.ts +2 -0
- package/build/cjs/blocks/Footer/hooks/useLogoImageProps.js +21 -0
- package/build/cjs/blocks/Footer/hooks/useLogoImageProps.js.map +1 -0
- package/build/cjs/blocks/Footer/hooks/useOverflowListItems.d.ts +18 -0
- package/build/cjs/blocks/Footer/hooks/useOverflowListItems.js +108 -0
- package/build/cjs/blocks/Footer/hooks/useOverflowListItems.js.map +1 -0
- package/build/cjs/blocks/Footer/schema.d.ts +347 -0
- package/build/cjs/blocks/Footer/schema.js +123 -0
- package/build/cjs/blocks/Footer/schema.js.map +1 -0
- package/build/cjs/blocks/index.d.ts +1 -0
- package/build/cjs/blocks/index.js +3 -1
- package/build/cjs/blocks/index.js.map +1 -1
- package/build/cjs/blocks/validators.d.ts +1 -0
- package/build/cjs/blocks/validators.js +1 -0
- package/build/cjs/blocks/validators.js.map +1 -1
- package/build/cjs/components/BrandFooter/BrandFooter.css +2 -2
- package/build/cjs/constructor-items.d.ts +2 -1
- package/build/cjs/constructor-items.js +1 -0
- package/build/cjs/constructor-items.js.map +1 -1
- package/build/cjs/containers/PageConstructor/PageConstructor.d.ts +0 -1
- package/build/cjs/containers/PageConstructor/PageConstructor.js +0 -1
- package/build/cjs/containers/PageConstructor/PageConstructor.js.map +1 -1
- package/build/cjs/models/constructor-items/blocks.d.ts +77 -2
- package/build/cjs/models/constructor-items/blocks.js +1 -0
- package/build/cjs/models/constructor-items/blocks.js.map +1 -1
- package/build/cjs/models/navigation.d.ts +1 -0
- package/build/cjs/models/navigation.js.map +1 -1
- package/build/cjs/navigation/components/NavigationItem/components/NavigationDropdown/NavigationDropdown.d.ts +1 -1
- package/build/cjs/navigation/components/NavigationItem/components/NavigationDropdown/NavigationDropdown.js +2 -2
- package/build/cjs/navigation/components/NavigationItem/components/NavigationDropdown/NavigationDropdown.js.map +1 -1
- package/build/cjs/navigation/components/NavigationItem/hooks/useNavigationItemMap.d.ts +1 -1
- package/build/cjs/navigation/components/NavigationPopup/NavigationPopup.d.ts +1 -1
- package/build/cjs/navigation/components/NavigationPopup/NavigationPopup.js +2 -2
- package/build/cjs/navigation/components/NavigationPopup/NavigationPopup.js.map +1 -1
- package/build/cjs/navigation/hooks/useActiveNavItem.d.ts +2 -0
- package/build/cjs/navigation/models.d.ts +1 -0
- package/build/cjs/navigation/models.js.map +1 -1
- package/build/cjs/navigation/utils.d.ts +1 -0
- package/build/cjs/schema/constants.js +2 -0
- package/build/cjs/schema/constants.js.map +1 -1
- package/build/cjs/schema/validators/blocks.d.ts +1 -0
- package/build/cjs/schema/validators/blocks.js +1 -0
- package/build/cjs/schema/validators/blocks.js.map +1 -1
- package/build/cjs/text-transform/config.js +13 -0
- package/build/cjs/text-transform/config.js.map +1 -1
- package/build/esm/blocks/Footer/Footer.css +53 -0
- package/build/esm/blocks/Footer/Footer.d.ts +6 -0
- package/build/esm/blocks/Footer/Footer.js +31 -0
- package/build/esm/blocks/Footer/Footer.js.map +1 -0
- package/build/esm/blocks/Footer/components/CopyrightFloor/CopyrightFloor.css +201 -0
- package/build/esm/blocks/Footer/components/CopyrightFloor/CopyrightFloor.d.ts +7 -0
- package/build/esm/blocks/Footer/components/CopyrightFloor/CopyrightFloor.js +138 -0
- package/build/esm/blocks/Footer/components/CopyrightFloor/CopyrightFloor.js.map +1 -0
- package/build/esm/blocks/Footer/components/CopyrightFloor/index.d.ts +1 -0
- package/build/esm/blocks/Footer/components/CopyrightFloor/index.js +2 -0
- package/build/esm/blocks/Footer/components/CopyrightFloor/index.js.map +1 -0
- package/build/esm/blocks/Footer/components/DisclaimerFloor/DisclaimerFloor.css +28 -0
- package/build/esm/blocks/Footer/components/DisclaimerFloor/DisclaimerFloor.d.ts +7 -0
- package/build/esm/blocks/Footer/components/DisclaimerFloor/DisclaimerFloor.js +15 -0
- package/build/esm/blocks/Footer/components/DisclaimerFloor/DisclaimerFloor.js.map +1 -0
- package/build/esm/blocks/Footer/components/DisclaimerFloor/index.d.ts +1 -0
- package/build/esm/blocks/Footer/components/DisclaimerFloor/index.js +2 -0
- package/build/esm/blocks/Footer/components/DisclaimerFloor/index.js.map +1 -0
- package/build/esm/blocks/Footer/components/LangSwitcher/LangSwitcher.css +14 -0
- package/build/esm/blocks/Footer/components/LangSwitcher/LangSwitcher.d.ts +12 -0
- package/build/esm/blocks/Footer/components/LangSwitcher/LangSwitcher.js +34 -0
- package/build/esm/blocks/Footer/components/LangSwitcher/LangSwitcher.js.map +1 -0
- package/build/esm/blocks/Footer/components/LangSwitcher/index.d.ts +1 -0
- package/build/esm/blocks/Footer/components/LangSwitcher/index.js +2 -0
- package/build/esm/blocks/Footer/components/LangSwitcher/index.js.map +1 -0
- package/build/esm/blocks/Footer/components/NavigationFloor/NavigationFloor.css +93 -0
- package/build/esm/blocks/Footer/components/NavigationFloor/NavigationFloor.d.ts +13 -0
- package/build/esm/blocks/Footer/components/NavigationFloor/NavigationFloor.js +33 -0
- package/build/esm/blocks/Footer/components/NavigationFloor/NavigationFloor.js.map +1 -0
- package/build/esm/blocks/Footer/components/NavigationFloor/index.d.ts +1 -0
- package/build/esm/blocks/Footer/components/NavigationFloor/index.js +2 -0
- package/build/esm/blocks/Footer/components/NavigationFloor/index.js.map +1 -0
- package/build/esm/blocks/Footer/components/SocialFloor/SocialFloor.css +77 -0
- package/build/esm/blocks/Footer/components/SocialFloor/SocialFloor.d.ts +7 -0
- package/build/esm/blocks/Footer/components/SocialFloor/SocialFloor.js +35 -0
- package/build/esm/blocks/Footer/components/SocialFloor/SocialFloor.js.map +1 -0
- package/build/esm/blocks/Footer/components/SocialFloor/index.d.ts +1 -0
- package/build/esm/blocks/Footer/components/SocialFloor/index.js +2 -0
- package/build/esm/blocks/Footer/components/SocialFloor/index.js.map +1 -0
- package/build/esm/blocks/Footer/hooks/useLogoImageProps.d.ts +2 -0
- package/build/esm/blocks/Footer/hooks/useLogoImageProps.js +17 -0
- package/build/esm/blocks/Footer/hooks/useLogoImageProps.js.map +1 -0
- package/build/esm/blocks/Footer/hooks/useOverflowListItems.d.ts +18 -0
- package/build/esm/blocks/Footer/hooks/useOverflowListItems.js +104 -0
- package/build/esm/blocks/Footer/hooks/useOverflowListItems.js.map +1 -0
- package/build/esm/blocks/Footer/schema.d.ts +347 -0
- package/build/esm/blocks/Footer/schema.js +120 -0
- package/build/esm/blocks/Footer/schema.js.map +1 -0
- package/build/esm/blocks/index.d.ts +1 -0
- package/build/esm/blocks/index.js +1 -0
- package/build/esm/blocks/index.js.map +1 -1
- package/build/esm/blocks/validators.d.ts +1 -0
- package/build/esm/blocks/validators.js +1 -0
- package/build/esm/blocks/validators.js.map +1 -1
- package/build/esm/components/BrandFooter/BrandFooter.css +2 -2
- package/build/esm/constructor-items.d.ts +2 -1
- package/build/esm/constructor-items.js +2 -1
- package/build/esm/constructor-items.js.map +1 -1
- package/build/esm/containers/PageConstructor/PageConstructor.d.ts +0 -1
- package/build/esm/containers/PageConstructor/PageConstructor.js +0 -1
- package/build/esm/containers/PageConstructor/PageConstructor.js.map +1 -1
- package/build/esm/models/constructor-items/blocks.d.ts +77 -2
- package/build/esm/models/constructor-items/blocks.js +1 -0
- package/build/esm/models/constructor-items/blocks.js.map +1 -1
- package/build/esm/models/navigation.d.ts +1 -0
- package/build/esm/models/navigation.js.map +1 -1
- package/build/esm/navigation/components/NavigationItem/components/NavigationDropdown/NavigationDropdown.d.ts +1 -1
- package/build/esm/navigation/components/NavigationItem/components/NavigationDropdown/NavigationDropdown.js +2 -2
- package/build/esm/navigation/components/NavigationItem/components/NavigationDropdown/NavigationDropdown.js.map +1 -1
- package/build/esm/navigation/components/NavigationItem/hooks/useNavigationItemMap.d.ts +1 -1
- package/build/esm/navigation/components/NavigationPopup/NavigationPopup.d.ts +1 -1
- package/build/esm/navigation/components/NavigationPopup/NavigationPopup.js +2 -2
- package/build/esm/navigation/components/NavigationPopup/NavigationPopup.js.map +1 -1
- package/build/esm/navigation/hooks/useActiveNavItem.d.ts +2 -0
- package/build/esm/navigation/models.d.ts +1 -0
- package/build/esm/navigation/models.js.map +1 -1
- package/build/esm/navigation/utils.d.ts +1 -0
- package/build/esm/schema/constants.js +3 -1
- package/build/esm/schema/constants.js.map +1 -1
- package/build/esm/schema/validators/blocks.d.ts +1 -0
- package/build/esm/schema/validators/blocks.js +1 -0
- package/build/esm/schema/validators/blocks.js.map +1 -1
- package/build/esm/text-transform/config.js +13 -0
- package/build/esm/text-transform/config.js.map +1 -1
- package/package.json +1 -1
- package/schema/index.js +1 -1
- package/server/models/constructor-items/blocks.d.ts +77 -2
- package/server/models/constructor-items/blocks.js +1 -0
- package/server/models/navigation.d.ts +1 -0
- package/server/text-transform/config.js +10 -0
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
/* use this for style redefinitions to awoid problems with
|
|
2
|
+
unpredictable css rules order in build */
|
|
3
|
+
.pc-footer-block__disclaimer-floor-content {
|
|
4
|
+
font-size: var(--g-text-body-2-font-size);
|
|
5
|
+
line-height: var(--g-text-body-2-line-height);
|
|
6
|
+
color: var(--g-color-text-secondary);
|
|
7
|
+
}
|
|
8
|
+
.pc-footer-block__disclaimer-floor-content .yfm {
|
|
9
|
+
margin: 0;
|
|
10
|
+
}
|
|
11
|
+
.pc-footer-block__disclaimer-floor-content .yfm a {
|
|
12
|
+
color: var(--g-color-text-secondary);
|
|
13
|
+
text-decoration: underline;
|
|
14
|
+
}
|
|
15
|
+
.pc-footer-block__disclaimer-floor-content .yfm a:hover {
|
|
16
|
+
color: var(--g-color-text-primary);
|
|
17
|
+
}
|
|
18
|
+
.pc-footer-block__disclaimer-floor-content_align_center {
|
|
19
|
+
text-align: center;
|
|
20
|
+
}
|
|
21
|
+
.pc-footer-block__disclaimer-floor-content_align_left {
|
|
22
|
+
text-align: left;
|
|
23
|
+
}
|
|
24
|
+
@media (max-width: 577px) {
|
|
25
|
+
.pc-footer-block__floor_disclaimer.col {
|
|
26
|
+
padding: 24px 0;
|
|
27
|
+
}
|
|
28
|
+
}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { FooterBlockProps } from "../../../../models/index.js";
|
|
2
|
+
import './DisclaimerFloor.css';
|
|
3
|
+
type DisclaimerFloorProps = {
|
|
4
|
+
disclaimer: NonNullable<FooterBlockProps['disclaimer']>;
|
|
5
|
+
};
|
|
6
|
+
export declare const DisclaimerFloor: ({ disclaimer }: DisclaimerFloorProps) => import("react/jsx-runtime").JSX.Element;
|
|
7
|
+
export {};
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { YFMWrapper } from "../../../../components/index.js";
|
|
3
|
+
import { Col } from "../../../../grid/index.js";
|
|
4
|
+
import { block } from "../../../../utils/index.js";
|
|
5
|
+
import './DisclaimerFloor.css';
|
|
6
|
+
const b = block('footer-block');
|
|
7
|
+
export const DisclaimerFloor = ({ disclaimer }) => {
|
|
8
|
+
return (_jsx(Col, { sizes: { all: 12 }, className: b('floor', { disclaimer: true }), children: _jsx("div", { className: b('disclaimer-floor-content', {
|
|
9
|
+
align: disclaimer.align || 'left',
|
|
10
|
+
}), children: _jsx(YFMWrapper, { content: disclaimer.text, modifiers: {
|
|
11
|
+
constructor: true,
|
|
12
|
+
'constructor-notice': true,
|
|
13
|
+
} }) }) }));
|
|
14
|
+
};
|
|
15
|
+
//# sourceMappingURL=DisclaimerFloor.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"DisclaimerFloor.js","sourceRoot":"../../../../../../src","sources":["blocks/Footer/components/DisclaimerFloor/DisclaimerFloor.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAC,UAAU,EAAC,wCAA+B;AAClD,OAAO,EAAC,GAAG,EAAC,kCAAyB;AAErC,OAAO,EAAC,KAAK,EAAC,mCAA0B;AAExC,OAAO,uBAAuB,CAAC;AAE/B,MAAM,CAAC,GAAG,KAAK,CAAC,cAAc,CAAC,CAAC;AAMhC,MAAM,CAAC,MAAM,eAAe,GAAG,CAAC,EAAC,UAAU,EAAuB,EAAE,EAAE;IAClE,OAAO,CACH,KAAC,GAAG,IAAC,KAAK,EAAE,EAAC,GAAG,EAAE,EAAE,EAAC,EAAE,SAAS,EAAE,CAAC,CAAC,OAAO,EAAE,EAAC,UAAU,EAAE,IAAI,EAAC,CAAC,YAC5D,cACI,SAAS,EAAE,CAAC,CAAC,0BAA0B,EAAE;gBACrC,KAAK,EAAE,UAAU,CAAC,KAAK,IAAI,MAAM;aACpC,CAAC,YAEF,KAAC,UAAU,IACP,OAAO,EAAE,UAAU,CAAC,IAAI,EACxB,SAAS,EAAE;oBACP,WAAW,EAAE,IAAI;oBACjB,oBAAoB,EAAE,IAAI;iBAC7B,GACH,GACA,GACJ,CACT,CAAC;AACN,CAAC,CAAC","sourcesContent":["import {YFMWrapper} from '../../../../components';\nimport {Col} from '../../../../grid';\nimport {FooterBlockProps} from '../../../../models';\nimport {block} from '../../../../utils';\n\nimport './DisclaimerFloor.scss';\n\nconst b = block('footer-block');\n\ntype DisclaimerFloorProps = {\n disclaimer: NonNullable<FooterBlockProps['disclaimer']>;\n};\n\nexport const DisclaimerFloor = ({disclaimer}: DisclaimerFloorProps) => {\n return (\n <Col sizes={{all: 12}} className={b('floor', {disclaimer: true})}>\n <div\n className={b('disclaimer-floor-content', {\n align: disclaimer.align || 'left',\n })}\n >\n <YFMWrapper\n content={disclaimer.text}\n modifiers={{\n constructor: true,\n 'constructor-notice': true,\n }}\n />\n </div>\n </Col>\n );\n};\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { DisclaimerFloor } from "./DisclaimerFloor.js";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"../../../../../../src","sources":["blocks/Footer/components/DisclaimerFloor/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,eAAe,EAAC,6BAA0B","sourcesContent":["export {DisclaimerFloor} from './DisclaimerFloor';\n"]}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/* use this for style redefinitions to awoid problems with
|
|
2
|
+
unpredictable css rules order in build */
|
|
3
|
+
.pc-footer-block__links-floor-right .pc-lang-switcher {
|
|
4
|
+
height: var(--g-spacing-9);
|
|
5
|
+
padding: 0;
|
|
6
|
+
cursor: pointer;
|
|
7
|
+
}
|
|
8
|
+
.pc-footer-block__links-floor-right .pc-lang-switcher .pc-content-wrapper__text {
|
|
9
|
+
font-size: var(--g-text-body-2-font-size);
|
|
10
|
+
line-height: var(--g-text-body-2-line-height);
|
|
11
|
+
}
|
|
12
|
+
.pc-footer-block__links-floor-right .pc-lang-switcher:hover .pc-content-wrapper__text {
|
|
13
|
+
color: var(--g-color-text-secondary);
|
|
14
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { ImageProps } from "../../../../models/index.js";
|
|
2
|
+
import './LangSwitcher.css';
|
|
3
|
+
type LanguageSwitcherProps = {
|
|
4
|
+
buttonText?: string;
|
|
5
|
+
items: {
|
|
6
|
+
text: string;
|
|
7
|
+
href: string;
|
|
8
|
+
}[];
|
|
9
|
+
image?: ImageProps;
|
|
10
|
+
};
|
|
11
|
+
export declare const LangSwitcher: ({ buttonText, items, image }: LanguageSwitcherProps) => import("react/jsx-runtime").JSX.Element;
|
|
12
|
+
export {};
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import * as React from 'react';
|
|
3
|
+
import { InnerContext } from "../../../../context/innerContext/index.js";
|
|
4
|
+
import { NavigationItemType, } from "../../../../models/index.js";
|
|
5
|
+
import { block } from "../../../../utils/index.js";
|
|
6
|
+
import './LangSwitcher.css';
|
|
7
|
+
const b = block('lang-switcher');
|
|
8
|
+
export const LangSwitcher = ({ buttonText, items, image }) => {
|
|
9
|
+
const [isActive, setIsActive] = React.useState(false);
|
|
10
|
+
const { navItemMap } = React.useContext(InnerContext);
|
|
11
|
+
const navigationItems = React.useMemo(() => items.map((item) => ({
|
|
12
|
+
type: NavigationItemType.Link,
|
|
13
|
+
text: item.text,
|
|
14
|
+
url: item.href,
|
|
15
|
+
})), [items]);
|
|
16
|
+
const hidePopup = React.useCallback(() => {
|
|
17
|
+
setIsActive(false);
|
|
18
|
+
}, []);
|
|
19
|
+
const onClick = React.useCallback((event) => {
|
|
20
|
+
event.stopPropagation();
|
|
21
|
+
setIsActive((active) => !active);
|
|
22
|
+
}, []);
|
|
23
|
+
const text = buttonText ?? 'Language';
|
|
24
|
+
const data = {
|
|
25
|
+
type: NavigationItemType.Dropdown,
|
|
26
|
+
text,
|
|
27
|
+
items: navigationItems,
|
|
28
|
+
isActive,
|
|
29
|
+
hidePopup,
|
|
30
|
+
};
|
|
31
|
+
const NavigationDropdown = navItemMap[NavigationItemType.Dropdown];
|
|
32
|
+
return (_jsx(NavigationDropdown, { data: data, text: text, type: NavigationItemType.Dropdown, items: navigationItems, isActive: isActive, hidePopup: hidePopup, onClick: onClick, className: b(), placement: "top-start", icon: image, iconSize: 20 }));
|
|
33
|
+
};
|
|
34
|
+
//# sourceMappingURL=LangSwitcher.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"LangSwitcher.js","sourceRoot":"../../../../../../src","sources":["blocks/Footer/components/LangSwitcher/LangSwitcher.tsx"],"names":[],"mappings":";AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAE/B,OAAO,EAAC,YAAY,EAAC,kDAAyC;AAC9D,OAAO,EAGH,kBAAkB,GAErB,oCAA2B;AAC5B,OAAO,EAAC,KAAK,EAAC,mCAA0B;AAExC,OAAO,oBAAoB,CAAC;AAW5B,MAAM,CAAC,GAAG,KAAK,CAAC,eAAe,CAAC,CAAC;AAEjC,MAAM,CAAC,MAAM,YAAY,GAAG,CAAC,EAAC,UAAU,EAAE,KAAK,EAAE,KAAK,EAAwB,EAAE,EAAE;IAC9E,MAAM,CAAC,QAAQ,EAAE,WAAW,CAAC,GAAG,KAAK,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC;IACtD,MAAM,EAAC,UAAU,EAAC,GAAG,KAAK,CAAC,UAAU,CAAC,YAAY,CAAC,CAAC;IAEpD,MAAM,eAAe,GAAG,KAAK,CAAC,OAAO,CACjC,GAAG,EAAE,CACD,KAAK,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,CAAC;QACjB,IAAI,EAAE,kBAAkB,CAAC,IAAI;QAC7B,IAAI,EAAE,IAAI,CAAC,IAAI;QACf,GAAG,EAAE,IAAI,CAAC,IAAI;KACjB,CAAC,CAAC,EACP,CAAC,KAAK,CAAC,CACV,CAAC;IAEF,MAAM,SAAS,GAAG,KAAK,CAAC,WAAW,CAAC,GAAG,EAAE;QACrC,WAAW,CAAC,KAAK,CAAC,CAAC;IACvB,CAAC,EAAE,EAAE,CAAC,CAAC;IAEP,MAAM,OAAO,GAAG,KAAK,CAAC,WAAW,CAAC,CAAC,KAAuB,EAAE,EAAE;QAC1D,KAAK,CAAC,eAAe,EAAE,CAAC;QACxB,WAAW,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC,CAAC,MAAM,CAAC,CAAC;IACrC,CAAC,EAAE,EAAE,CAAC,CAAC;IAEP,MAAM,IAAI,GAAG,UAAU,IAAI,UAAU,CAAC;IACtC,MAAM,IAAI,GAA2B;QACjC,IAAI,EAAE,kBAAkB,CAAC,QAAQ;QACjC,IAAI;QACJ,KAAK,EAAE,eAAe;QACtB,QAAQ;QACR,SAAS;KACZ,CAAC;IAEF,MAAM,kBAAkB,GAAG,UAAU,CAAC,kBAAkB,CAAC,QAAQ,CAAC,CAAC;IAEnE,OAAO,CACH,KAAC,kBAAkB,IACf,IAAI,EAAE,IAAI,EACV,IAAI,EAAE,IAAI,EACV,IAAI,EAAE,kBAAkB,CAAC,QAAQ,EACjC,KAAK,EAAE,eAAe,EACtB,QAAQ,EAAE,QAAQ,EAClB,SAAS,EAAE,SAAS,EACpB,OAAO,EAAE,OAAO,EAChB,SAAS,EAAE,CAAC,EAAE,EACd,SAAS,EAAC,WAAW,EACrB,IAAI,EAAE,KAAK,EACX,QAAQ,EAAE,EAAE,GACd,CACL,CAAC;AACN,CAAC,CAAC","sourcesContent":["import * as React from 'react';\n\nimport {InnerContext} from '../../../../context/innerContext';\nimport {\n ImageProps,\n NavigationDropdownItem,\n NavigationItemType,\n NavigationLinkItem,\n} from '../../../../models';\nimport {block} from '../../../../utils';\n\nimport './LangSwitcher.scss';\n\ntype LanguageSwitcherProps = {\n buttonText?: string;\n items: {\n text: string;\n href: string;\n }[];\n image?: ImageProps;\n};\n\nconst b = block('lang-switcher');\n\nexport const LangSwitcher = ({buttonText, items, image}: LanguageSwitcherProps) => {\n const [isActive, setIsActive] = React.useState(false);\n const {navItemMap} = React.useContext(InnerContext);\n\n const navigationItems = React.useMemo<NavigationLinkItem[]>(\n () =>\n items.map((item) => ({\n type: NavigationItemType.Link,\n text: item.text,\n url: item.href,\n })),\n [items],\n );\n\n const hidePopup = React.useCallback(() => {\n setIsActive(false);\n }, []);\n\n const onClick = React.useCallback((event: React.MouseEvent) => {\n event.stopPropagation();\n setIsActive((active) => !active);\n }, []);\n\n const text = buttonText ?? 'Language';\n const data: NavigationDropdownItem = {\n type: NavigationItemType.Dropdown,\n text,\n items: navigationItems,\n isActive,\n hidePopup,\n };\n\n const NavigationDropdown = navItemMap[NavigationItemType.Dropdown];\n\n return (\n <NavigationDropdown\n data={data}\n text={text}\n type={NavigationItemType.Dropdown}\n items={navigationItems}\n isActive={isActive}\n hidePopup={hidePopup}\n onClick={onClick}\n className={b()}\n placement=\"top-start\"\n icon={image}\n iconSize={20}\n />\n );\n};\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { LangSwitcher } from "./LangSwitcher.js";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"../../../../../../src","sources":["blocks/Footer/components/LangSwitcher/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,YAAY,EAAC,0BAAuB","sourcesContent":["export {LangSwitcher} from './LangSwitcher';\n"]}
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
/* use this for style redefinitions to awoid problems with
|
|
2
|
+
unpredictable css rules order in build */
|
|
3
|
+
.pc-footer-block .pc-footer-block__floor.pc-footer-block__floor_navigation {
|
|
4
|
+
margin: 0 auto;
|
|
5
|
+
padding: 32px 0 var(--g-spacing-10);
|
|
6
|
+
border: none;
|
|
7
|
+
}
|
|
8
|
+
.pc-footer-block__floor .pc-footer-block__columns-container {
|
|
9
|
+
padding: 0;
|
|
10
|
+
}
|
|
11
|
+
.pc-footer-block__floor_logo-placement_left .pc-footer-block__logo-col.col {
|
|
12
|
+
padding: 0 0 32px;
|
|
13
|
+
}
|
|
14
|
+
.pc-footer-block__floor_logo-placement_left .pc-footer-block__logo-col.col .row {
|
|
15
|
+
margin: 0;
|
|
16
|
+
}
|
|
17
|
+
.pc-footer-block__floor_logo-placement_top {
|
|
18
|
+
padding-top: 0;
|
|
19
|
+
}
|
|
20
|
+
.pc-footer-block__floor_logo-placement_top .pc-footer-block__logo-col_top.col {
|
|
21
|
+
padding: 0 0 24px;
|
|
22
|
+
margin-bottom: 32px;
|
|
23
|
+
border-bottom: 1px solid var(--g-color-line-generic);
|
|
24
|
+
}
|
|
25
|
+
.pc-footer-block__column {
|
|
26
|
+
min-width: 0;
|
|
27
|
+
padding-right: 16px;
|
|
28
|
+
}
|
|
29
|
+
.pc-footer-block__column-inner {
|
|
30
|
+
display: flex;
|
|
31
|
+
flex-direction: column;
|
|
32
|
+
gap: 20px;
|
|
33
|
+
}
|
|
34
|
+
.pc-footer-block__nav-row {
|
|
35
|
+
width: calc(100% + 24px);
|
|
36
|
+
min-width: 0;
|
|
37
|
+
gap: 48px 0;
|
|
38
|
+
}
|
|
39
|
+
@media (min-width: 1081px) {
|
|
40
|
+
.pc-footer-block__nav-row_custom-columns > .pc-footer-block__column {
|
|
41
|
+
flex: 0 0 var(--pc-footer-navigation-column-width);
|
|
42
|
+
max-width: var(--pc-footer-navigation-column-width);
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
.pc-footer-block__column-title {
|
|
46
|
+
font-size: var(--g-text-subheader-3-font-size);
|
|
47
|
+
line-height: var(--g-text-subheader-3-line-height);
|
|
48
|
+
font-weight: var(--g-text-accent-font-weight);
|
|
49
|
+
color: var(--g-color-text-primary);
|
|
50
|
+
margin: 0;
|
|
51
|
+
}
|
|
52
|
+
.pc-footer-block__links {
|
|
53
|
+
list-style: none;
|
|
54
|
+
margin: 0;
|
|
55
|
+
padding: 0;
|
|
56
|
+
}
|
|
57
|
+
.pc-footer-block__link-item {
|
|
58
|
+
margin: 0;
|
|
59
|
+
}
|
|
60
|
+
.pc-footer-block__link-item:not(:last-child) {
|
|
61
|
+
margin-bottom: 16px;
|
|
62
|
+
}
|
|
63
|
+
.pc-footer-block__link {
|
|
64
|
+
font-size: var(--g-text-body-2-font-size);
|
|
65
|
+
line-height: var(--g-text-body-2-line-height);
|
|
66
|
+
outline: none;
|
|
67
|
+
color: var(--g-color-text-link);
|
|
68
|
+
text-decoration: none;
|
|
69
|
+
cursor: pointer;
|
|
70
|
+
color: var(--g-color-text-primary);
|
|
71
|
+
text-decoration: none;
|
|
72
|
+
line-height: var(--g-text-body-2-line-height);
|
|
73
|
+
}
|
|
74
|
+
.utilityfocus .pc-footer-block__link:focus {
|
|
75
|
+
outline: 2px solid #ffdb4d;
|
|
76
|
+
}
|
|
77
|
+
.pc-footer-block__link:hover, .pc-footer-block__link:active {
|
|
78
|
+
--pc-text-header-color: var(--g-color-text-link-hover);
|
|
79
|
+
color: var(--g-color-text-link-hover);
|
|
80
|
+
}
|
|
81
|
+
.pc-footer-block__link:hover {
|
|
82
|
+
color: var(--g-color-text-secondary);
|
|
83
|
+
}
|
|
84
|
+
@media (max-width: 1081px) {
|
|
85
|
+
.pc-footer-block__floor_logo-placement_top .pc-footer-block__logo-col.col {
|
|
86
|
+
padding: 0 0 32px;
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
@media (max-width: 769px) {
|
|
90
|
+
.pc-footer-block__floor_navigation .pc-footer-block__logo {
|
|
91
|
+
height: 48px;
|
|
92
|
+
}
|
|
93
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import type { GridColumnSizesType } from "../../../../grid/index.js";
|
|
3
|
+
import { FooterLinkColumn } from "../../../../models/index.js";
|
|
4
|
+
import './NavigationFloor.css';
|
|
5
|
+
type NavigationFloorProps = {
|
|
6
|
+
columns: FooterLinkColumn[];
|
|
7
|
+
logoContent: React.ReactNode;
|
|
8
|
+
colSizes?: GridColumnSizesType;
|
|
9
|
+
columnsPerRow?: number;
|
|
10
|
+
logoPlacement?: 'left' | 'top';
|
|
11
|
+
};
|
|
12
|
+
export declare const NavigationFloor: ({ columns, logoContent, colSizes, columnsPerRow, logoPlacement, }: NavigationFloorProps) => import("react/jsx-runtime").JSX.Element;
|
|
13
|
+
export {};
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import * as React from 'react';
|
|
3
|
+
import { Link } from '@gravity-ui/uikit';
|
|
4
|
+
import { Col, Row } from "../../../../grid/index.js";
|
|
5
|
+
import { block } from "../../../../utils/index.js";
|
|
6
|
+
import './NavigationFloor.css';
|
|
7
|
+
const b = block('footer-block');
|
|
8
|
+
const DEFAULT_COL_SIZES_WITH_LOGO = { all: 6, sm: 4, md: 3, lg: 3 };
|
|
9
|
+
const DEFAULT_COL_SIZES_WITHOUT_LOGO = { all: 6, sm: 4, md: 3, lg: 3 };
|
|
10
|
+
const DEFAULT_LOGO_COL_SIZES = { all: 12, md: 4 };
|
|
11
|
+
function NavigationColumns({ columns, hasLogo, colSizes, columnsPerRow }) {
|
|
12
|
+
const defaultColSizes = hasLogo
|
|
13
|
+
? DEFAULT_COL_SIZES_WITH_LOGO
|
|
14
|
+
: DEFAULT_COL_SIZES_WITHOUT_LOGO;
|
|
15
|
+
const resolvedColSizes = React.useMemo(() => ({
|
|
16
|
+
all: colSizes?.all ?? defaultColSizes.all,
|
|
17
|
+
sm: colSizes?.sm ?? defaultColSizes.sm,
|
|
18
|
+
md: colSizes?.md ?? defaultColSizes.md,
|
|
19
|
+
lg: colSizes?.lg ?? defaultColSizes.lg,
|
|
20
|
+
}), [colSizes, defaultColSizes]);
|
|
21
|
+
const customColumnsStyle = columnsPerRow
|
|
22
|
+
? {
|
|
23
|
+
'--pc-footer-navigation-column-width': `${100 / columnsPerRow}%`,
|
|
24
|
+
}
|
|
25
|
+
: undefined;
|
|
26
|
+
return (_jsx(Col, { className: b('columns-container'), children: _jsx(Row, { className: b('nav-row', { 'custom-columns': Boolean(columnsPerRow) }), style: customColumnsStyle, children: columns.map((column, columnIndex) => (_jsx(Col, { className: b('column'), sizes: resolvedColSizes, children: _jsxs("div", { className: b('column-inner'), children: [_jsx("h6", { className: b('column-title'), children: column.title }), _jsx("ul", { className: b('links'), children: column.links.map((link, linkIndex) => (_jsx("li", { className: b('link-item'), children: _jsx(Link, { href: link.url, className: b('link'), title: link.urlTitle, target: link.target, children: link.text }) }, linkIndex))) })] }) }, columnIndex))) }) }));
|
|
27
|
+
}
|
|
28
|
+
export const NavigationFloor = ({ columns, logoContent, colSizes, columnsPerRow, logoPlacement, }) => {
|
|
29
|
+
const isTopLogoPlacement = logoPlacement === 'top';
|
|
30
|
+
const hasSideLogo = Boolean(logoContent) && !isTopLogoPlacement;
|
|
31
|
+
return (_jsxs(Row, { className: b('floor', { navigation: true, 'logo-placement': logoPlacement }), children: [logoContent && isTopLogoPlacement && (_jsx(Col, { className: b('logo-col', { top: true }), sizes: { all: 12 }, children: logoContent })), logoContent && !isTopLogoPlacement && (_jsx(Col, { className: b('logo-col'), sizes: DEFAULT_LOGO_COL_SIZES, children: _jsx(Row, { children: logoContent }) })), _jsx(NavigationColumns, { columns: columns, hasLogo: hasSideLogo, colSizes: colSizes, columnsPerRow: columnsPerRow })] }));
|
|
32
|
+
};
|
|
33
|
+
//# sourceMappingURL=NavigationFloor.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"NavigationFloor.js","sourceRoot":"../../../../../../src","sources":["blocks/Footer/components/NavigationFloor/NavigationFloor.tsx"],"names":[],"mappings":"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","sourcesContent":["import * as React from 'react';\n\nimport {Link} from '@gravity-ui/uikit';\n\nimport type {GridColumnSizesType} from '../../../../grid';\nimport {Col, Row} from '../../../../grid';\nimport {FooterLinkColumn} from '../../../../models';\nimport {block} from '../../../../utils';\n\nimport './NavigationFloor.scss';\n\nconst b = block('footer-block');\n\nconst DEFAULT_COL_SIZES_WITH_LOGO: GridColumnSizesType = {all: 6, sm: 4, md: 3, lg: 3};\nconst DEFAULT_COL_SIZES_WITHOUT_LOGO: GridColumnSizesType = {all: 6, sm: 4, md: 3, lg: 3};\nconst DEFAULT_LOGO_COL_SIZES: GridColumnSizesType = {all: 12, md: 4};\n\ntype NavigationColumnsProps = {\n columns: FooterLinkColumn[];\n hasLogo: boolean;\n colSizes?: GridColumnSizesType;\n columnsPerRow?: number;\n};\n\nfunction NavigationColumns({columns, hasLogo, colSizes, columnsPerRow}: NavigationColumnsProps) {\n const defaultColSizes: GridColumnSizesType = hasLogo\n ? DEFAULT_COL_SIZES_WITH_LOGO\n : DEFAULT_COL_SIZES_WITHOUT_LOGO;\n const resolvedColSizes: GridColumnSizesType = React.useMemo(\n () => ({\n all: colSizes?.all ?? defaultColSizes.all,\n sm: colSizes?.sm ?? defaultColSizes.sm,\n md: colSizes?.md ?? defaultColSizes.md,\n lg: colSizes?.lg ?? defaultColSizes.lg,\n }),\n [colSizes, defaultColSizes],\n );\n const customColumnsStyle = columnsPerRow\n ? ({\n '--pc-footer-navigation-column-width': `${100 / columnsPerRow}%`,\n } as React.CSSProperties)\n : undefined;\n\n return (\n <Col className={b('columns-container')}>\n <Row\n className={b('nav-row', {'custom-columns': Boolean(columnsPerRow)})}\n style={customColumnsStyle}\n >\n {columns.map((column, columnIndex) => (\n <Col key={columnIndex} className={b('column')} sizes={resolvedColSizes}>\n <div className={b('column-inner')}>\n <h6 className={b('column-title')}>{column.title}</h6>\n <ul className={b('links')}>\n {column.links.map((link, linkIndex) => (\n <li key={linkIndex} className={b('link-item')}>\n <Link\n href={link.url}\n className={b('link')}\n title={link.urlTitle}\n target={link.target}\n >\n {link.text}\n </Link>\n </li>\n ))}\n </ul>\n </div>\n </Col>\n ))}\n </Row>\n </Col>\n );\n}\n\ntype NavigationFloorProps = {\n columns: FooterLinkColumn[];\n logoContent: React.ReactNode;\n colSizes?: GridColumnSizesType;\n columnsPerRow?: number;\n logoPlacement?: 'left' | 'top';\n};\n\nexport const NavigationFloor = ({\n columns,\n logoContent,\n colSizes,\n columnsPerRow,\n logoPlacement,\n}: NavigationFloorProps) => {\n const isTopLogoPlacement = logoPlacement === 'top';\n const hasSideLogo = Boolean(logoContent) && !isTopLogoPlacement;\n\n return (\n <Row className={b('floor', {navigation: true, 'logo-placement': logoPlacement})}>\n {logoContent && isTopLogoPlacement && (\n <Col className={b('logo-col', {top: true})} sizes={{all: 12}}>\n {logoContent}\n </Col>\n )}\n {logoContent && !isTopLogoPlacement && (\n <Col className={b('logo-col')} sizes={DEFAULT_LOGO_COL_SIZES}>\n <Row>{logoContent}</Row>\n </Col>\n )}\n <NavigationColumns\n columns={columns}\n hasLogo={hasSideLogo}\n colSizes={colSizes}\n columnsPerRow={columnsPerRow}\n />\n </Row>\n );\n};\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { NavigationFloor } from "./NavigationFloor.js";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"../../../../../../src","sources":["blocks/Footer/components/NavigationFloor/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,eAAe,EAAC,6BAA0B","sourcesContent":["export {NavigationFloor} from './NavigationFloor';\n"]}
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
/* use this for style redefinitions to awoid problems with
|
|
2
|
+
unpredictable css rules order in build */
|
|
3
|
+
.pc-footer-block__social-floor-inner {
|
|
4
|
+
display: flex;
|
|
5
|
+
flex-wrap: wrap;
|
|
6
|
+
align-items: center;
|
|
7
|
+
gap: 24px;
|
|
8
|
+
}
|
|
9
|
+
.pc-footer-block__social-floor-inner_title-position_top {
|
|
10
|
+
flex-direction: column;
|
|
11
|
+
align-items: unset;
|
|
12
|
+
}
|
|
13
|
+
.pc-footer-block__social-floor-inner_links-position_center {
|
|
14
|
+
align-items: center;
|
|
15
|
+
}
|
|
16
|
+
.pc-footer-block__social-floor-inner_links-position_center .pc-footer-block__social-icons-list {
|
|
17
|
+
justify-content: center;
|
|
18
|
+
}
|
|
19
|
+
.pc-footer-block__social-floor-inner_size_m .pc-footer-block__social-icons-list {
|
|
20
|
+
gap: 24px;
|
|
21
|
+
}
|
|
22
|
+
.pc-footer-block__social-floor-inner_size_m .pc-footer-block__social-icon-item {
|
|
23
|
+
width: 32px;
|
|
24
|
+
height: 32px;
|
|
25
|
+
}
|
|
26
|
+
.pc-footer-block__social-floor-inner_size_l .pc-footer-block__social-icons-list {
|
|
27
|
+
gap: var(--g-spacing-10);
|
|
28
|
+
}
|
|
29
|
+
.pc-footer-block__social-floor-inner_size_l .pc-footer-block__social-icon-item {
|
|
30
|
+
width: 48px;
|
|
31
|
+
height: 48px;
|
|
32
|
+
}
|
|
33
|
+
.pc-footer-block__social-icon-item {
|
|
34
|
+
margin-right: 0;
|
|
35
|
+
}
|
|
36
|
+
.pc-footer-block__social-floor-title {
|
|
37
|
+
font-size: var(--g-text-body-3-font-size);
|
|
38
|
+
line-height: var(--g-text-body-3-line-height);
|
|
39
|
+
font-weight: var(--g-text-accent-font-weight);
|
|
40
|
+
margin: 0;
|
|
41
|
+
color: var(--g-color-text-primary);
|
|
42
|
+
}
|
|
43
|
+
.pc-footer-block__social-icons-list {
|
|
44
|
+
display: flex;
|
|
45
|
+
flex-wrap: wrap;
|
|
46
|
+
align-items: center;
|
|
47
|
+
list-style: none;
|
|
48
|
+
margin: 0;
|
|
49
|
+
padding: 0;
|
|
50
|
+
}
|
|
51
|
+
.pc-footer-block__social-icons-item {
|
|
52
|
+
margin: 0;
|
|
53
|
+
transition: transform 200ms ease-in-out;
|
|
54
|
+
}
|
|
55
|
+
.pc-footer-block__social-icons-item:hover {
|
|
56
|
+
transform: translateY(-4px);
|
|
57
|
+
}
|
|
58
|
+
.pc-footer-block__social-icon-link, .pc-footer-block__social-icon-link:hover {
|
|
59
|
+
text-decoration: none;
|
|
60
|
+
color: var(--g-color-text-primary);
|
|
61
|
+
}
|
|
62
|
+
.pc-footer-block__social-icon-item {
|
|
63
|
+
margin-right: 0;
|
|
64
|
+
}
|
|
65
|
+
.pc-footer-block__social-icon-item_size_m {
|
|
66
|
+
width: 32px;
|
|
67
|
+
height: 32px;
|
|
68
|
+
}
|
|
69
|
+
.pc-footer-block__social-icon-item_size_l {
|
|
70
|
+
width: 48px;
|
|
71
|
+
height: 48px;
|
|
72
|
+
}
|
|
73
|
+
@media (max-width: 577px) {
|
|
74
|
+
.pc-footer-block__floor_social.col {
|
|
75
|
+
padding: 24px 0;
|
|
76
|
+
}
|
|
77
|
+
}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { FooterBlockProps } from "../../../../models/index.js";
|
|
2
|
+
import './SocialFloor.css';
|
|
3
|
+
type SocialFloorProps = {
|
|
4
|
+
contacts: NonNullable<FooterBlockProps['contacts']>;
|
|
5
|
+
};
|
|
6
|
+
export declare const SocialFloor: ({ contacts }: SocialFloorProps) => import("react/jsx-runtime").JSX.Element | null;
|
|
7
|
+
export {};
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { Flex, Link, Tooltip } from '@gravity-ui/uikit';
|
|
3
|
+
import { Image } from "../../../../components/index.js";
|
|
4
|
+
import { useTheme } from "../../../../context/theme/index.js";
|
|
5
|
+
import { Col } from "../../../../grid/index.js";
|
|
6
|
+
import { block, getThemedValue } from "../../../../utils/index.js";
|
|
7
|
+
import { useLogoImageProps } from "../../hooks/useLogoImageProps.js";
|
|
8
|
+
import './SocialFloor.css';
|
|
9
|
+
const b = block('footer-block');
|
|
10
|
+
const SocialIconItem = ({ contact, theme }) => {
|
|
11
|
+
const iconResolved = contact.icon && getThemedValue(contact.icon, theme);
|
|
12
|
+
const iconProps = useLogoImageProps(iconResolved);
|
|
13
|
+
if (!iconProps) {
|
|
14
|
+
return null;
|
|
15
|
+
}
|
|
16
|
+
const content = (_jsx("li", { className: b('social-icons-item'), children: _jsx(Link, { className: b('social-icon-link'), href: contact.url, target: "_blank", rel: "noopener noreferrer", children: _jsx(Flex, { direction: "column", alignItems: "center", gap: 2, children: _jsx(Image, { ...iconProps, alt: contact.urlTitle ?? '', className: b('social-icon-item') }) }) }) }));
|
|
17
|
+
return contact.urlTitle ? (_jsx(Tooltip, { content: contact.urlTitle, openDelay: 500, children: content })) : (content);
|
|
18
|
+
};
|
|
19
|
+
const SocialIcons = ({ links, theme }) => {
|
|
20
|
+
if (!links?.length)
|
|
21
|
+
return null;
|
|
22
|
+
return (_jsx("ul", { className: b('social-icons-list'), children: links.map((contact, index) => (_jsx(SocialIconItem, { contact: contact, theme: theme }, index))) }));
|
|
23
|
+
};
|
|
24
|
+
export const SocialFloor = ({ contacts }) => {
|
|
25
|
+
const theme = useTheme();
|
|
26
|
+
if (!contacts.links?.length) {
|
|
27
|
+
return null;
|
|
28
|
+
}
|
|
29
|
+
return (_jsx(Col, { sizes: { all: 12 }, className: b('floor', { social: true }), children: _jsxs("div", { className: b('social-floor-inner', {
|
|
30
|
+
'title-position': contacts.titlePosition || 'top',
|
|
31
|
+
'links-position': contacts.linksPosition || 'left',
|
|
32
|
+
size: contacts.iconsSize ?? 'l',
|
|
33
|
+
}), children: [contacts.title && _jsx("h3", { className: b('social-floor-title'), children: contacts.title }), _jsx(SocialIcons, { links: contacts.links, theme: theme })] }) }));
|
|
34
|
+
};
|
|
35
|
+
//# sourceMappingURL=SocialFloor.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"SocialFloor.js","sourceRoot":"../../../../../../src","sources":["blocks/Footer/components/SocialFloor/SocialFloor.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAC,IAAI,EAAE,IAAI,EAAE,OAAO,EAAC,MAAM,mBAAmB,CAAC;AAEtD,OAAO,EAAC,KAAK,EAAC,wCAA+B;AAC7C,OAAO,EAAC,QAAQ,EAAC,2CAAkC;AACnD,OAAO,EAAC,GAAG,EAAC,kCAAyB;AAErC,OAAO,EAAC,KAAK,EAAE,cAAc,EAAC,mCAA0B;AACxD,OAAO,EAAC,iBAAiB,EAAC,yCAAsC;AAEhE,OAAO,mBAAmB,CAAC;AAE3B,MAAM,CAAC,GAAG,KAAK,CAAC,cAAc,CAAC,CAAC;AAgBhC,MAAM,cAAc,GAAG,CAAC,EAAC,OAAO,EAAE,KAAK,EAAsB,EAAE,EAAE;IAC7D,MAAM,YAAY,GAAG,OAAO,CAAC,IAAI,IAAI,cAAc,CAAC,OAAO,CAAC,IAAI,EAAE,KAAK,CAAC,CAAC;IACzE,MAAM,SAAS,GAAG,iBAAiB,CAAC,YAAY,CAAC,CAAC;IAElD,IAAI,CAAC,SAAS,EAAE,CAAC;QACb,OAAO,IAAI,CAAC;IAChB,CAAC;IAED,MAAM,OAAO,GAAG,CACZ,aAAI,SAAS,EAAE,CAAC,CAAC,mBAAmB,CAAC,YACjC,KAAC,IAAI,IACD,SAAS,EAAE,CAAC,CAAC,kBAAkB,CAAC,EAChC,IAAI,EAAE,OAAO,CAAC,GAAG,EACjB,MAAM,EAAC,QAAQ,EACf,GAAG,EAAC,qBAAqB,YAEzB,KAAC,IAAI,IAAC,SAAS,EAAC,QAAQ,EAAC,UAAU,EAAC,QAAQ,EAAC,GAAG,EAAE,CAAC,YAC/C,KAAC,KAAK,OACE,SAAS,EACb,GAAG,EAAE,OAAO,CAAC,QAAQ,IAAI,EAAE,EAC3B,SAAS,EAAE,CAAC,CAAC,kBAAkB,CAAC,GAClC,GACC,GACJ,GACN,CACR,CAAC;IAEF,OAAO,OAAO,CAAC,QAAQ,CAAC,CAAC,CAAC,CACtB,KAAC,OAAO,IAAC,OAAO,EAAE,OAAO,CAAC,QAAQ,EAAE,SAAS,EAAE,GAAG,YAC7C,OAAO,GACF,CACb,CAAC,CAAC,CAAC,CACA,OAAO,CACV,CAAC;AACN,CAAC,CAAC;AAEF,MAAM,WAAW,GAAG,CAAC,EAAC,KAAK,EAAE,KAAK,EAAmB,EAAE,EAAE;IACrD,IAAI,CAAC,KAAK,EAAE,MAAM;QAAE,OAAO,IAAI,CAAC;IAEhC,OAAO,CACH,aAAI,SAAS,EAAE,CAAC,CAAC,mBAAmB,CAAC,YAChC,KAAK,CAAC,GAAG,CAAC,CAAC,OAAO,EAAE,KAAK,EAAE,EAAE,CAAC,CAC3B,KAAC,cAAc,IAAa,OAAO,EAAE,OAAO,EAAE,KAAK,EAAE,KAAK,IAArC,KAAK,CAAoC,CACjE,CAAC,GACD,CACR,CAAC;AACN,CAAC,CAAC;AAEF,MAAM,CAAC,MAAM,WAAW,GAAG,CAAC,EAAC,QAAQ,EAAmB,EAAE,EAAE;IACxD,MAAM,KAAK,GAAG,QAAQ,EAAE,CAAC;IAEzB,IAAI,CAAC,QAAQ,CAAC,KAAK,EAAE,MAAM,EAAE,CAAC;QAC1B,OAAO,IAAI,CAAC;IAChB,CAAC;IAED,OAAO,CACH,KAAC,GAAG,IAAC,KAAK,EAAE,EAAC,GAAG,EAAE,EAAE,EAAC,EAAE,SAAS,EAAE,CAAC,CAAC,OAAO,EAAE,EAAC,MAAM,EAAE,IAAI,EAAC,CAAC,YACxD,eACI,SAAS,EAAE,CAAC,CAAC,oBAAoB,EAAE;gBAC/B,gBAAgB,EAAE,QAAQ,CAAC,aAAa,IAAI,KAAK;gBACjD,gBAAgB,EAAE,QAAQ,CAAC,aAAa,IAAI,MAAM;gBAClD,IAAI,EAAE,QAAQ,CAAC,SAAS,IAAI,GAAG;aAClC,CAAC,aAED,QAAQ,CAAC,KAAK,IAAI,aAAI,SAAS,EAAE,CAAC,CAAC,oBAAoB,CAAC,YAAG,QAAQ,CAAC,KAAK,GAAM,EAChF,KAAC,WAAW,IAAC,KAAK,EAAE,QAAQ,CAAC,KAAK,EAAE,KAAK,EAAE,KAAK,GAAI,IAClD,GACJ,CACT,CAAC;AACN,CAAC,CAAC","sourcesContent":["import {Flex, Link, Tooltip} from '@gravity-ui/uikit';\n\nimport {Image} from '../../../../components';\nimport {useTheme} from '../../../../context/theme';\nimport {Col} from '../../../../grid';\nimport type {FooterBlockProps, FooterContactItem} from '../../../../models';\nimport {block, getThemedValue} from '../../../../utils';\nimport {useLogoImageProps} from '../../hooks/useLogoImageProps';\n\nimport './SocialFloor.scss';\n\nconst b = block('footer-block');\n\ntype SocialFloorProps = {\n contacts: NonNullable<FooterBlockProps['contacts']>;\n};\n\ntype SocialIconsProps = {\n links: SocialFloorProps['contacts']['links'];\n theme: ReturnType<typeof useTheme>;\n};\n\ntype SocialIconItemProps = {\n contact: FooterContactItem;\n theme: ReturnType<typeof useTheme>;\n};\n\nconst SocialIconItem = ({contact, theme}: SocialIconItemProps) => {\n const iconResolved = contact.icon && getThemedValue(contact.icon, theme);\n const iconProps = useLogoImageProps(iconResolved);\n\n if (!iconProps) {\n return null;\n }\n\n const content = (\n <li className={b('social-icons-item')}>\n <Link\n className={b('social-icon-link')}\n href={contact.url}\n target=\"_blank\"\n rel=\"noopener noreferrer\"\n >\n <Flex direction=\"column\" alignItems=\"center\" gap={2}>\n <Image\n {...iconProps}\n alt={contact.urlTitle ?? ''}\n className={b('social-icon-item')}\n />\n </Flex>\n </Link>\n </li>\n );\n\n return contact.urlTitle ? (\n <Tooltip content={contact.urlTitle} openDelay={500}>\n {content}\n </Tooltip>\n ) : (\n content\n );\n};\n\nconst SocialIcons = ({links, theme}: SocialIconsProps) => {\n if (!links?.length) return null;\n\n return (\n <ul className={b('social-icons-list')}>\n {links.map((contact, index) => (\n <SocialIconItem key={index} contact={contact} theme={theme} />\n ))}\n </ul>\n );\n};\n\nexport const SocialFloor = ({contacts}: SocialFloorProps) => {\n const theme = useTheme();\n\n if (!contacts.links?.length) {\n return null;\n }\n\n return (\n <Col sizes={{all: 12}} className={b('floor', {social: true})}>\n <div\n className={b('social-floor-inner', {\n 'title-position': contacts.titlePosition || 'top',\n 'links-position': contacts.linksPosition || 'left',\n size: contacts.iconsSize ?? 'l',\n })}\n >\n {contacts.title && <h3 className={b('social-floor-title')}>{contacts.title}</h3>}\n <SocialIcons links={contacts.links} theme={theme} />\n </div>\n </Col>\n );\n};\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { SocialFloor } from "./SocialFloor.js";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"../../../../../../src","sources":["blocks/Footer/components/SocialFloor/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,WAAW,EAAC,yBAAsB","sourcesContent":["export {SocialFloor} from './SocialFloor';\n"]}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import { getMediaImage } from "../../../components/Media/Image/utils.js";
|
|
3
|
+
export function useLogoImageProps(logoImage) {
|
|
4
|
+
return React.useMemo(() => {
|
|
5
|
+
if (!logoImage) {
|
|
6
|
+
return null;
|
|
7
|
+
}
|
|
8
|
+
const resolved = getMediaImage(logoImage);
|
|
9
|
+
if (typeof resolved === 'string') {
|
|
10
|
+
return { src: resolved };
|
|
11
|
+
}
|
|
12
|
+
return resolved && typeof resolved === 'object'
|
|
13
|
+
? resolved
|
|
14
|
+
: null;
|
|
15
|
+
}, [logoImage]);
|
|
16
|
+
}
|
|
17
|
+
//# sourceMappingURL=useLogoImageProps.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useLogoImageProps.js","sourceRoot":"../../../../../src","sources":["blocks/Footer/hooks/useLogoImageProps.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAE/B,OAAO,EAAC,aAAa,EAAC,iDAA8C;AAGpE,MAAM,UAAU,iBAAiB,CAC7B,SAAkC;IAElC,OAAO,KAAK,CAAC,OAAO,CAAC,GAAG,EAAE;QACtB,IAAI,CAAC,SAAS,EAAE,CAAC;YACb,OAAO,IAAI,CAAC;QAChB,CAAC;QAED,MAAM,QAAQ,GAAG,aAAa,CAAC,SAAS,CAAC,CAAC;QAC1C,IAAI,OAAO,QAAQ,KAAK,QAAQ,EAAE,CAAC;YAC/B,OAAO,EAAC,GAAG,EAAE,QAAQ,EAAC,CAAC;QAC3B,CAAC;QAED,OAAO,QAAQ,IAAI,OAAO,QAAQ,KAAK,QAAQ;YAC3C,CAAC,CAAE,QAA+C;YAClD,CAAC,CAAC,IAAI,CAAC;IACf,CAAC,EAAE,CAAC,SAAS,CAAC,CAAC,CAAC;AACpB,CAAC","sourcesContent":["import * as React from 'react';\n\nimport {getMediaImage} from '../../../components/Media/Image/utils';\nimport type {ImageProps as ModelImageProps} from '../../../models';\n\nexport function useLogoImageProps(\n logoImage?: ModelImageProps | null,\n): Record<string, unknown> | null {\n return React.useMemo(() => {\n if (!logoImage) {\n return null;\n }\n\n const resolved = getMediaImage(logoImage);\n if (typeof resolved === 'string') {\n return {src: resolved};\n }\n\n return resolved && typeof resolved === 'object'\n ? (resolved as unknown as Record<string, unknown>)\n : null;\n }, [logoImage]);\n}\n"]}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import { DropdownMenuItem } from '@gravity-ui/uikit';
|
|
3
|
+
import { LinkProps } from "../../../models/index.js";
|
|
4
|
+
export type LinkItem = Required<Pick<LinkProps, 'text' | 'url'>>;
|
|
5
|
+
type UseOverflowListItemsProps = {
|
|
6
|
+
isDropdown?: boolean;
|
|
7
|
+
containerRef: React.RefObject<HTMLElement>;
|
|
8
|
+
items?: LinkItem[];
|
|
9
|
+
itemSelector: string;
|
|
10
|
+
moreButtonWidth?: number;
|
|
11
|
+
};
|
|
12
|
+
type OverflowListItemsResult = {
|
|
13
|
+
visibleItems: LinkItem[];
|
|
14
|
+
hiddenItems: DropdownMenuItem[];
|
|
15
|
+
measured: boolean;
|
|
16
|
+
};
|
|
17
|
+
export declare function useOverflowListItems({ isDropdown, containerRef, items, itemSelector, moreButtonWidth, }: UseOverflowListItemsProps): OverflowListItemsResult;
|
|
18
|
+
export {};
|
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import { useResizeObserver } from '@gravity-ui/uikit';
|
|
3
|
+
import throttleFn from "lodash/throttle.js";
|
|
4
|
+
function parseCssPixelValue(value) {
|
|
5
|
+
const parsedValue = parseFloat(value);
|
|
6
|
+
return Number.isNaN(parsedValue) ? 0 : parsedValue;
|
|
7
|
+
}
|
|
8
|
+
function getElementWidth(element) {
|
|
9
|
+
return Math.ceil(Math.max(element.scrollWidth, element.getBoundingClientRect().width));
|
|
10
|
+
}
|
|
11
|
+
export function useOverflowListItems({ isDropdown = false, containerRef, items, itemSelector, moreButtonWidth = 0, }) {
|
|
12
|
+
const [containerWidth, setContainerWidth] = React.useState(0);
|
|
13
|
+
const [itemWidths, setItemWidths] = React.useState([]);
|
|
14
|
+
const [itemGap, setItemGap] = React.useState(0);
|
|
15
|
+
const itemsCount = items?.length ?? 0;
|
|
16
|
+
const areItemsMeasured = !isDropdown || itemWidths.length === itemsCount;
|
|
17
|
+
const updateItemWidths = React.useCallback(() => {
|
|
18
|
+
if (!containerRef.current || !itemsCount) {
|
|
19
|
+
setItemWidths([]);
|
|
20
|
+
return;
|
|
21
|
+
}
|
|
22
|
+
const itemElements = Array.from(containerRef.current.querySelectorAll(itemSelector));
|
|
23
|
+
if (itemElements.length !== itemsCount) {
|
|
24
|
+
return;
|
|
25
|
+
}
|
|
26
|
+
const listElement = itemElements[0]?.parentElement;
|
|
27
|
+
setItemWidths(itemElements.map(getElementWidth));
|
|
28
|
+
if (listElement) {
|
|
29
|
+
const listStyles = window.getComputedStyle(listElement);
|
|
30
|
+
setItemGap(parseCssPixelValue(listStyles.columnGap));
|
|
31
|
+
}
|
|
32
|
+
}, [containerRef, itemSelector, itemsCount]);
|
|
33
|
+
React.useEffect(() => {
|
|
34
|
+
setItemWidths((currentItemWidths) => (currentItemWidths.length ? [] : currentItemWidths));
|
|
35
|
+
}, [items, isDropdown]);
|
|
36
|
+
React.useLayoutEffect(() => {
|
|
37
|
+
if (isDropdown && !areItemsMeasured) {
|
|
38
|
+
updateItemWidths();
|
|
39
|
+
}
|
|
40
|
+
}, [areItemsMeasured, isDropdown, updateItemWidths]);
|
|
41
|
+
React.useEffect(() => {
|
|
42
|
+
if (!isDropdown || typeof document === 'undefined' || !('fonts' in document)) {
|
|
43
|
+
return undefined;
|
|
44
|
+
}
|
|
45
|
+
let cancelled = false;
|
|
46
|
+
document.fonts.ready.then(() => {
|
|
47
|
+
if (!cancelled) {
|
|
48
|
+
setItemWidths((currentItemWidths) => currentItemWidths.length ? [] : currentItemWidths);
|
|
49
|
+
}
|
|
50
|
+
});
|
|
51
|
+
return () => {
|
|
52
|
+
cancelled = true;
|
|
53
|
+
};
|
|
54
|
+
}, [items, isDropdown]);
|
|
55
|
+
const updateContainerSize = React.useMemo(() => throttleFn(() => {
|
|
56
|
+
if (!containerRef.current) {
|
|
57
|
+
return;
|
|
58
|
+
}
|
|
59
|
+
setContainerWidth(containerRef.current.clientWidth);
|
|
60
|
+
}, 100), [containerRef]);
|
|
61
|
+
useResizeObserver({ ref: containerRef, onResize: updateContainerSize });
|
|
62
|
+
const isMeasured = containerWidth > 0 && areItemsMeasured;
|
|
63
|
+
const { visibleItems, hiddenItems } = React.useMemo(() => {
|
|
64
|
+
if (!isDropdown) {
|
|
65
|
+
return {
|
|
66
|
+
visibleItems: items ?? [],
|
|
67
|
+
hiddenItems: [],
|
|
68
|
+
};
|
|
69
|
+
}
|
|
70
|
+
if (!isMeasured) {
|
|
71
|
+
return {
|
|
72
|
+
visibleItems: items ?? [],
|
|
73
|
+
hiddenItems: [],
|
|
74
|
+
};
|
|
75
|
+
}
|
|
76
|
+
const linksCount = itemWidths.length;
|
|
77
|
+
let visibleItemsCount = 0;
|
|
78
|
+
let remainingContainerWidth = containerWidth;
|
|
79
|
+
for (const width of itemWidths) {
|
|
80
|
+
const isMoreThanOneItemLeft = linksCount !== visibleItemsCount + 1;
|
|
81
|
+
const currentItemWidth = width + (visibleItemsCount === 0 ? 0 : itemGap);
|
|
82
|
+
remainingContainerWidth -= currentItemWidth;
|
|
83
|
+
const hasNoSpaceForTheLastItem = remainingContainerWidth < 0;
|
|
84
|
+
if (remainingContainerWidth < moreButtonWidth &&
|
|
85
|
+
(isMoreThanOneItemLeft || hasNoSpaceForTheLastItem)) {
|
|
86
|
+
break;
|
|
87
|
+
}
|
|
88
|
+
visibleItemsCount++;
|
|
89
|
+
}
|
|
90
|
+
visibleItemsCount = Math.max(visibleItemsCount, 1);
|
|
91
|
+
return {
|
|
92
|
+
visibleItems: items?.slice(0, visibleItemsCount) ?? [],
|
|
93
|
+
hiddenItems: transformItemsToDropdownMenuItems(items?.slice(visibleItemsCount) ?? []),
|
|
94
|
+
};
|
|
95
|
+
}, [containerWidth, isMeasured, itemGap, itemWidths, items, moreButtonWidth, isDropdown]);
|
|
96
|
+
return { visibleItems, hiddenItems, measured: isMeasured };
|
|
97
|
+
}
|
|
98
|
+
function transformItemsToDropdownMenuItems(items) {
|
|
99
|
+
return items.map((item) => ({
|
|
100
|
+
text: item.text,
|
|
101
|
+
href: item.url,
|
|
102
|
+
}));
|
|
103
|
+
}
|
|
104
|
+
//# sourceMappingURL=useOverflowListItems.js.map
|