import './navbar.less'; import React from 'react'; import { Dropdown } from '@components/dropdown/dropdown.jsx'; import NewBrew 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 Account from './account.navitem.jsx'; const { both: RecentNavItem } = RecentNavItems; import Nav from './nav.jsx'; const Navbar = ({ children, brew, editor, title = '', props }) => { const version = global.version || '0.0.0'; const isMac = navigator.platform.toUpperCase().includes('MAC'); const mod = isMac ? '⌘' : 'Ctrl'; const isBrew = !!brew && brew.shareId; const account = global.account; console.log(editor); const slots = React.Children.toArray(children).reduce((acc, child) => { if (React.isValidElement(child)) { if (child.type === Navbar.File) acc.file = child; if (child.type === Navbar.Edit) acc.edit = child; if (child.type === Navbar.Go) acc.go = child; } return acc; }, {}); const renderTitle = () => { const cleanTitle = title.replace(/^\/+|\/+$/g, ''); if (!isBrew) return {cleanTitle || 'Home'}; return ( {brew.title} ); }; const renderDownloadLink = () => { if (!isBrew) return Get txt; let shareLink = brew.shareId; if (brew.googleId && !brew.stubbed) { shareLink = brew.googleId + shareLink; } return ( Get txt ); }; const renderFile = () => { return ( File} icon={null} key={'file'}> Save document
{renderDownloadLink()}
Delete File Publish File Transfer File
{slots.file?.props.children}
); }; const renderEdit = () => { return ( Edit} icon={null} key={'edit'}>
{slots.edit?.props.children} editor?.undo()} kbd={mod + ' + z'} disabled={!isBrew}> Undo editor?.redo()} kbd={mod + ' + Shift + z'} disabled={!isBrew}> Redo editor?.find()} kbd={mod + ' + f'} disabled={!isBrew}> Find / Replace editor?.foldCode()} disabled={!isBrew}> Fold all lines editor?.unfoldCode()} disabled={!isBrew}> Unfold all lines
{/*
editor?.cut()} kbd={mod + ' + x'} disabled={!isBrew}> cut editor?.copy()} kbd={mod + ' + c'} disabled={!isBrew}> copy editor?.paste()} kbd={mod + ' + v'} disabled={!isBrew}> paste
*/}
); }; const renderGo = () => { return ( Go} icon={null} key={'go'}>
Patreon Vault Changelog
Recent Brews} icon={null} key={'recent'}>
); }; return ( ); }; Navbar.File = () => null; Navbar.Edit = () => null; Navbar.Go = () => null; export default Navbar;