-
Notifications
You must be signed in to change notification settings - Fork 14
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add standalone navigation (#693)
* feat: add standalone navigation
- Loading branch information
1 parent
c683873
commit 38d5b88
Showing
13 changed files
with
82 additions
and
21 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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<ClassNameProps>) => { | ||
const theme = useTheme(); | ||
|
||
return <div className={rootCn({theme}, className)}>{children}</div>; | ||
}; | ||
|
||
export default RootCn; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
12 changes: 12 additions & 0 deletions
12
src/navigation/components/NavigationItem/hooks/useNavigationItemMap.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
import {useContext} from 'react'; | ||
|
||
import isEmpty from 'lodash/isEmpty'; | ||
|
||
import {navItemMap as NavItemMapDefault} from '../../../../constructor-items'; | ||
import {InnerContext} from '../../../../context/innerContext'; | ||
|
||
export const useNavigationItemMap = () => { | ||
const {navItemMap} = useContext(InnerContext); | ||
|
||
return isEmpty(navItemMap) ? NavItemMapDefault : navItemMap; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
import React from 'react'; | ||
|
||
import RootCn from '../../../components/RootCn'; | ||
|
||
import Navigation, {NavigationProps} from './../../components/Navigation/Navigation'; | ||
|
||
const Standalone = (props: NavigationProps) => ( | ||
<RootCn> | ||
<Navigation {...props} /> | ||
</RootCn> | ||
); | ||
|
||
export default Standalone; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export {default as Navigation} from './components/Standalone'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,11 @@ | ||
import {withNaming} from '@bem-react/classname'; | ||
|
||
import {UIKIT_ROOT_CLASS} from '../components/constants'; | ||
|
||
export const NAMESPACE = 'pc-'; | ||
|
||
export const cn = withNaming({e: '__', m: '_'}); | ||
export const block = withNaming({n: NAMESPACE, e: '__', m: '_'}); | ||
export const rootCn = cn(UIKIT_ROOT_CLASS); | ||
|
||
export type CnBlock = ReturnType<typeof cn>; |