diff --git a/README.md b/README.md index 3ef46f997..f22dff1cb 100644 --- a/README.md +++ b/README.md @@ -162,6 +162,16 @@ const Page: React.FC = ({children}) => ( ); ``` +### Navigation + +Page navigation can also be used separately from the constructor: + +```jsx +import {Navigation} from '@gravity-ui/page-constructor'; + +const Page: React.FC = ({data, logo}) => ; +``` + ### Blocks Each block is an atomic top-level component. They're stored in the `src/units/constructor/blocks` directory. diff --git a/src/components/RootCn/index.tsx b/src/components/RootCn/index.tsx new file mode 100644 index 000000000..e08862d09 --- /dev/null +++ b/src/components/RootCn/index.tsx @@ -0,0 +1,13 @@ +import React, {PropsWithChildren} from 'react'; + +import {useTheme} from '../../context/theme'; +import {ClassNameProps} from '../../models'; +import {rootCn} from '../../utils'; + +const RootCn = ({className, children}: PropsWithChildren) => { + const theme = useTheme(); + + return
{children}
; +}; + +export default RootCn; diff --git a/src/containers/PageConstructor/PageConstructor.tsx b/src/containers/PageConstructor/PageConstructor.tsx index 87e80f48b..393c7f16c 100644 --- a/src/containers/PageConstructor/PageConstructor.tsx +++ b/src/containers/PageConstructor/PageConstructor.tsx @@ -3,7 +3,7 @@ import React, {useMemo} from 'react'; import '@doc-tools/transform/dist/js/yfm'; import BackgroundMedia from '../../components/BackgroundMedia/BackgroundMedia'; -import {UIKIT_ROOT_CLASS} from '../../components/constants'; +import RootCn from '../../components/RootCn'; import {blockMap, navItemMap, subBlockMap} from '../../constructor-items'; import {AnimateContext} from '../../context/animateContext'; import {InnerContext} from '../../context/innerContext'; @@ -23,7 +23,6 @@ import { } from '../../models'; import Layout from '../../navigation/containers/Layout/Layout'; import { - cn as blockOrigin, block as cnBlock, getCustomItems, getCustomTypes, @@ -39,7 +38,6 @@ import {ConstructorRow} from './components/ConstructorRow'; import './PageConstructor.scss'; const b = cnBlock('page-constructor'); -const ycr = blockOrigin(UIKIT_ROOT_CLASS); export type ItemMap = typeof blockMap & typeof subBlockMap & CustomItems; @@ -99,7 +97,7 @@ export const Constructor = (props: PageConstructorProps) => { return ( -
+
{themedBackground && ( @@ -118,7 +116,7 @@ export const Constructor = (props: PageConstructorProps) => {
-
+
); }; diff --git a/src/index.ts b/src/index.ts index 782c057db..bfe2de1e3 100644 --- a/src/index.ts +++ b/src/index.ts @@ -12,5 +12,6 @@ export * from './utils'; export * from './schema'; export * from './hooks'; export * from './icons'; +export * from './navigation'; export {BREAKPOINTS} from './constants'; diff --git a/src/navigation/components/Navigation/Navigation.scss b/src/navigation/components/Navigation/Navigation.scss index d51792bc2..f7ec5d4cc 100644 --- a/src/navigation/components/Navigation/Navigation.scss +++ b/src/navigation/components/Navigation/Navigation.scss @@ -4,13 +4,6 @@ $block: '.#{$ns}navigation'; #{$block} { - $root: &; - $navigationZIndex: 98; - - position: sticky; - z-index: $navigationZIndex; - top: 0; - display: flex; justify-content: center; align-items: center; diff --git a/src/navigation/components/Navigation/Navigation.tsx b/src/navigation/components/Navigation/Navigation.tsx index 3a1fa11f2..bf7eb481d 100644 --- a/src/navigation/components/Navigation/Navigation.tsx +++ b/src/navigation/components/Navigation/Navigation.tsx @@ -4,7 +4,7 @@ import debounce from 'lodash/debounce'; import OutsideClick from '../../../components/OutsideClick/OutsideClick'; import {Col, Grid, Row} from '../../../grid'; -import {HeaderData, ThemedNavigationLogoData} from '../../../models'; +import {ClassNameProps, HeaderData, ThemedNavigationLogoData} from '../../../models'; import {block} from '../../../utils'; import {getNavigationItemWithIconSize} from '../../utils'; import DesktopNavigation from '../DesktopNavigation/DesktopNavigation'; @@ -14,12 +14,12 @@ import './Navigation.scss'; const b = block('navigation'); -export interface NavigationProps { +export interface NavigationProps extends ClassNameProps { logo: ThemedNavigationLogoData; data: HeaderData; } -export const Navigation: React.FC = ({data, logo}) => { +export const Navigation: React.FC = ({data, logo, className}) => { const {leftItems, rightItems, iconSize = 20, withBorder = false} = data; const [isSidebarOpened, setIsSidebarOpened] = useState(false); const [activeItemId, setActiveItemId] = useState(undefined); @@ -56,7 +56,7 @@ export const Navigation: React.FC = ({data, logo}) => { }); return ( - +