import './navbar.less'; import React from 'react'; import { Dropdown } from '@components/dropdown/dropdown.jsx'; import NewBrewNavItem from './newbrew.navitem'; import PrintNavItem from './print.navitem.jsx'; import ShareNavItem from './share.navitem.jsx'; import HelpNavItem from './help.navitem.jsx'; import RecentNavItems from './recent.navitem.jsx'; import MetadataNavItem from './metadata.navitem.jsx'; import AccountNavItem from './account.navitem.jsx'; const { both: RecentNavItem } = RecentNavItems; import Nav from './nav.jsx'; const Navbar = ({ children, brew, pageName, editor, title, currentPage, props })=>{ const isMac = navigator.platform.toUpperCase().includes('MAC'); const mod = isMac ? '⌘' : 'Ctrl'; const navSlots = React.Children.toArray(children).reduce((slots, child)=>{ if(!React.isValidElement(child)) return slots; const content = child.props.children; //To create new items inside the dropdowns call them with Navbar.[DropdownName] if(child.type === Navbar.File) slots.file = content; else if(child.type === Navbar.Edit) slots.edit = content; else if(child.type === Navbar.Go) slots.go = content; else if(child.type === Navbar.Help) slots.help = content; //create a new dropdown with Navbar.Menu else if(child.type === Navbar.Menu) slots.menu = content; return slots; }, {}); const renderFile = ()=>{ let shareLink = brew?.shareId; if(brew?.googleId && !brew?.stubbed) { shareLink = brew?.googleId + shareLink; } return ( File} icon={null} key={'file'}>
Clone Brew
Download raw text
{navSlots.file}
); }; const renderEdit = ()=>{ return ( Edit} icon={null} key={'edit'}>
editor?.undo()} kbd={`${mod} + z`} disabled={!editor}> Undo editor?.redo()} kbd={`${mod} + Shift + z`} disabled={!editor}> Redo editor?.find()} kbd={`${mod} + f`} disabled={!editor}> Find / Replace editor?.foldCode()} disabled={!editor}> Fold all lines editor?.unfoldCode()} disabled={!editor}> Unfold all lines
{navSlots.edit}
); }; const renderGo = ()=>{ return ( Go} icon={null} key={'go'}>
Patreon
{navSlots.go}
); }; const renderHelp = ()=>{ return Help} icon={null} key={'help'}>
Changelog Github
{navSlots.help}
; }; return ( ); }; Navbar.File = ({ children })=>children; Navbar.Edit = ({ children })=>children; Navbar.Go = ({ children })=>children; Navbar.Help = ({ children })=>children; Navbar.Menu = ({ children })=>children; export default Navbar;