import React from 'react'; import PropTypes from 'prop-types'; import cx from 'clsx'; import { motion } from 'framer-motion'; import { Link, useLocation } from 'react-router-dom'; // import { Command, Activity, Globe, Link2, Settings, File } from 'react-feather'; import { FcAreaChart, FcGlobe, FcRuler, FcDocument, FcSettings, FcLink, } from 'react-icons/fc'; import { connect } from './StateProvider'; import { getTheme, switchTheme } from '../store/app'; import SvgYacd from './SvgYacd'; import s from './SideBar.module.css'; const { useCallback } = React; // testing color icons // const icons = { // activity: Activity, // globe: Globe, // command: Command, // file: File, // settings: Settings, // link: Link2 // }; const icons = { activity: FcAreaChart, globe: FcGlobe, command: FcRuler, file: FcDocument, settings: FcSettings, link: FcLink, }; const SideBarRow = React.memo(function SideBarRow({ isActive, to, iconId, labelText, }) { const Comp = icons[iconId]; const className = cx(s.row, isActive ? s.rowActive : null); return (
{labelText}
); }); SideBarRow.propTypes = { isActive: PropTypes.bool.isRequired, to: PropTypes.string.isRequired, iconId: PropTypes.string, labelText: PropTypes.string, }; const pages = [ { to: '/', iconId: 'activity', labelText: 'Overview', }, { to: '/proxies', iconId: 'globe', labelText: 'Proxies', }, { to: '/rules', iconId: 'command', labelText: 'Rules', }, { to: '/connections', iconId: 'link', labelText: 'Conns', }, { to: '/configs', iconId: 'settings', labelText: 'Config', }, { to: '/logs', iconId: 'file', labelText: 'Logs', }, ]; function SideBar({ dispatch, theme }) { const location = useLocation(); const switchThemeHooked = useCallback(() => { dispatch(switchTheme()); }, [dispatch]); return (
{pages.map(({ to, iconId, labelText }) => ( ))}
); } function MoonA() { return ( ); } function Sun() { return ( ); } const mapState = (s) => ({ theme: getTheme(s) }); export default connect(mapState)(SideBar);