import { useState, useCallback } from 'react'; import { HashRouter, NavLink, useNavigate } from 'react-router-dom'; import { Willow } from '@svar-ui/react-core'; import Router from './Router'; import { links } from '../routes'; import { GitHubLogoIcon, LogoIcon } from '../assets/icons'; import './Index.css'; function DemoExplorerContent({ productTag, publicName, skins, Globals, Button, Segmented, }) { const navigate = useNavigate(); const [skin, setSkin] = useState(skins[0].id); const [title, setTitle] = useState(''); const [githubLink, setGithubLink] = useState(''); const [show, setShow] = useState(true); const baseLink = 'https://github.com/svar-widgets/react-' + productTag + '/tree/main/demos/cases/'; const handleRouteChange = useCallback((path) => { const parts = path.split('/'); const page = parts[1]; const newSkin = parts[2]; setSkin(newSkin); const targetPage = `/${page}/:skin`; const matched = links.find((a) => a[0] === targetPage); if (matched) { setTitle(matched[1]); const name = matched[3] || matched[1]; setGithubLink(`${baseLink}${name}.jsx`); } }, []); const handleSkinChange = ({ value }) => { setSkin(value); const currentPath = window.location.hash.slice(1); const parts = currentPath.split('/'); if (parts[1]) { navigate(`/${parts[1]}/${value}`); } }; const toggleSidebar = () => { setShow(!show); }; const SkinComponent = skins.find((s) => s.id === skin).Component; return (
Logo icon

React {publicName}

{links.map((data) => ( `wx-demos demo ${isActive ? 'active' : ''}` } > {data[1]} {data[4] && data[4].pro && PRO} ))}
{!show && (
)}
{title}
setShow(false)} role="none" >
); } export default function DemoExplorer(props) { return ( <> ); }