import MusicNoteIcon from '@mui/icons-material/MusicNote';
import {HomeIcon} from '@mui/icons-material';
import CodeIcon from '@mui/icons-material/Code';
import OndemandVideoIcon from '@mui/icons-material/OndemandVideo';
import SportsEsportsIcon from '@mui/icons-material/SportsEsports';
import LiveTvIcon from '@mui/icons-material/LiveTv';
import SchoolIcon from '@mui/icons-material/School';
import FaceRetouchingNaturalIcon from '@mui/icons-material/FaceRetouchingNatural';
import CheckroomIcon from '@mui/icons-material/Checkroom';
import GraphicEqIcon from '@mui/icons-material/GraphicEq';
import TheaterComedyIcon from '@mui/icons-material/TheaterComedy';
import FitnessCenterIcon from '@mui/icons-material/FitnessCenter';
import DeveloperModeIcon from '@mui/icons-material/DeveloperMode';
export const logo = 'https://i.ibb.co/s9Qys2j/logo.png';
export const categories = [
{ name: 'New', icon: <HomeIcon /> },
{ name: 'JS Mastery', icon: <CodeIcon />, },
{ name: 'Coding', icon: <CodeIcon />, },
{ name: 'ReactJS', icon: <CodeIcon />, },
{ name: 'NextJS', icon: <CodeIcon />, },
{ name: 'Music', icon: <MusicNoteIcon /> },
{ name: 'Education', icon: <SchoolIcon />, },
{ name: 'Podcast', icon: <GraphicEqIcon />, },
{ name: 'Movie', icon: <OndemandVideoIcon />, },
{ name: 'Gaming', icon: <SportsEsportsIcon />, },
{ name: 'Live', icon: <LiveTvIcon />, },
{ name: 'Sport', icon: <FitnessCenterIcon />, },
{ name: 'Fashion', icon: <CheckroomIcon />, },
{ name: 'Beauty', icon: <FaceRetouchingNaturalIcon />, },
{ name: 'Comedy', icon: <TheaterComedyIcon />, },
{ name: 'Gym', icon: <FitnessCenterIcon />, },
{ name: 'Crypto', icon: <DeveloperModeIcon />, },
];
export const demoThumbnailUrl = 'https://i.ibb.co/G2L2Gwp/API-Course.png';
export const demoChannelUrl = '/channel/UCmXmlB4-HJytD7wek0Uo97A';
export const demoVideoUrl = '/video/GDa8kZLNhJ4';
export const demoChannelTitle = 'JavaScript Mastery';
export const demoVideoTitle = 'Build and Deploy 5 JavaScript & React API Projects in 10 Hours - Full Course | RapidAPI';
export const demoProfilePicture
在侧边栏组件中使用这个js文件
import React from "react";
import { Button, Stack } from "@mui/material";
import { categories } from "../utils/constants";
const Sidebar = () => {
const selectedCategory = 'New';
return (
<Stack
direction="row"
sx={{
overflowY: "auto",
height: { sx: "auto", md: "95%" },
flexDirection: { md: "column" },
}}
>
{categories.map((category) => (
<button
className="category-btn"
onClick={() => {}}
style={{
background: category.name === selectedCategory && "#FC1503",
color: "white",
}}
key={category.name}
>
<span style={{ color: category.name === selectedCategory ? "white" : "red", marginRight: "15px" }}>
{category.icon}
</span>
<span style={{ opacity: category.name === selectedCategory ? "1" : "0.8" }}>
{category.name}
</span>
</button>
))}
</Stack>
)
}
export default Sidebar;
错误消息“SyntaxError: Unexpected token '<'" happens because JSX elements cannot be directly placed within JavaScript arrays unless they are compiled. To resolve this issue, store the icon components (like HomeIcon instead of ) in the array and then render them as components within your Sidebar component.