// @flow import * as PAGES from 'constants/pages'; import * as ICONS from 'constants/icons'; import { SETTINGS_GRP } from 'constants/settings'; import type { Node } from 'react'; import React from 'react'; import { useHistory } from 'react-router-dom'; import classnames from 'classnames'; import Button from 'component/button'; // @if TARGET='app' import { IS_MAC } from 'component/app/view'; // @endif import { useIsMediumScreen } from 'effects/use-screensize'; type SideNavLink = { title: string, link?: string, route?: string, section?: string, onClick?: () => any, icon: string, extra?: Node, }; const SIDE_LINKS: Array = [ { title: 'Appearance', link: `/$/${PAGES.SETTINGS}#${SETTINGS_GRP.APPEARANCE}`, section: SETTINGS_GRP.APPEARANCE, icon: ICONS.APPEARANCE, }, { title: 'Account', link: `/$/${PAGES.SETTINGS}#${SETTINGS_GRP.ACCOUNT}`, section: SETTINGS_GRP.ACCOUNT, icon: ICONS.ACCOUNT, }, { title: 'Content settings', link: `/$/${PAGES.SETTINGS}#${SETTINGS_GRP.CONTENT}`, section: SETTINGS_GRP.CONTENT, icon: ICONS.CONTENT, }, { title: 'System', link: `/$/${PAGES.SETTINGS}#${SETTINGS_GRP.SYSTEM}`, section: SETTINGS_GRP.SYSTEM, icon: ICONS.SETTINGS, }, ]; export default function SettingsSideNavigation() { const sidebarOpen = true; const isMediumScreen = useIsMediumScreen(); const isAbsolute = isMediumScreen; const microNavigation = !sidebarOpen || isMediumScreen; const { location } = useHistory(); // This sidebar could be called from Settings or from a Settings Sub Page. // - "#" navigation = don't record to history, just scroll. // - "/" navigation = record sub-page navigation to history. const scrollInstead = location.pathname === `/$/${PAGES.SETTINGS}`; function scrollToSection(section: string) { const TOP_MARGIN_PX = 20; const element = document.getElementById(section); if (element) { window.scrollTo(0, element.offsetTop - TOP_MARGIN_PX); } } if (isMediumScreen) { // I think it's ok to hide it for now on medium/small screens given that // we are using a scrolling Settings Page that displays everything. If we // really need this, most likely we can display it as a Tab at the top // of the page. return null; } return (
{isMediumScreen && sidebarOpen && ( <> )}
); }