rht02251745
This commit is contained in:
parent
d2c595422c
commit
19b6cbd0ed
|
@ -9,6 +9,7 @@ import {
|
|||
import { CourseDto, TaxonomySlug, TermDto } from "@nice/common";
|
||||
import { api } from "@nice/client";
|
||||
import CourseCard from "../../courses/components/CourseCard";
|
||||
import { CoursesSectionTag } from "./CoursesSectionTag";
|
||||
interface GetTaxonomyProps {
|
||||
categories: string[];
|
||||
isLoading: boolean;
|
||||
|
@ -106,51 +107,16 @@ const CoursesSection: React.FC<CoursesSectionProps> = ({
|
|||
<Spin className="m-3" />
|
||||
) : (
|
||||
<>
|
||||
<Tag
|
||||
color={
|
||||
selectedCategory === "全部"
|
||||
? "blue"
|
||||
: "default"
|
||||
}
|
||||
onClick={() => setSelectedCategory("全部")}
|
||||
className={`px-6 py-2 text-base cursor-pointer rounded-full transition-all duration-300 ${
|
||||
selectedCategory === "全部"
|
||||
? "bg-blue-600 text-white shadow-lg"
|
||||
: "bg-white text-gray-600 hover:bg-gray-100"
|
||||
}`}>
|
||||
全部
|
||||
</Tag>
|
||||
{gateGory.categories.map((category) => (
|
||||
<Tag
|
||||
key={category}
|
||||
color={
|
||||
selectedCategory === category
|
||||
? "blue"
|
||||
: "default"
|
||||
}
|
||||
onClick={() => {
|
||||
setSelectedCategory(category);
|
||||
}}
|
||||
className={`px-6 py-2 text-base cursor-pointer rounded-full transition-all duration-300 ${
|
||||
selectedCategory === category
|
||||
? "bg-blue-600 text-white shadow-lg"
|
||||
: "bg-white text-gray-600 hover:bg-gray-100"
|
||||
}`}>
|
||||
{category}
|
||||
</Tag>
|
||||
{['全部',...gateGory.categories].map((category) => (
|
||||
<CoursesSectionTag category= {category} selectedCategory={selectedCategory} setSelectedCategory={setSelectedCategory}/>
|
||||
))}
|
||||
</>
|
||||
)}
|
||||
</div>
|
||||
|
||||
<div className="grid grid-cols-1 md:grid-cols-2 lg:grid-cols-4 gap-8">
|
||||
{displayedCourses.length === 0 ? (
|
||||
<div className="col-span-full">
|
||||
<Empty
|
||||
description="暂无课程"
|
||||
image={Empty.PRESENTED_IMAGE_DEFAULT}
|
||||
/>
|
||||
</div>
|
||||
{isDataLoading ? (
|
||||
<Spin className="m-3" />
|
||||
) : (
|
||||
displayedCourses?.map((course) => (
|
||||
<CourseCard course={course}></CourseCard>
|
||||
|
|
|
@ -0,0 +1,24 @@
|
|||
import { Tag } from "antd";
|
||||
|
||||
export function CoursesSectionTag({category, selectedCategory, setSelectedCategory}) {
|
||||
return (
|
||||
<>
|
||||
<Tag
|
||||
key={category}
|
||||
color={
|
||||
selectedCategory === category
|
||||
? "blue"
|
||||
: "default"
|
||||
}
|
||||
onClick={() => {
|
||||
setSelectedCategory(category);
|
||||
}}
|
||||
className={`px-6 py-2 text-base cursor-pointer rounded-full transition-all duration-300 ${selectedCategory === category
|
||||
? "bg-blue-600 text-white shadow-lg"
|
||||
: "bg-white text-gray-600 hover:bg-gray-100"
|
||||
}`}>
|
||||
{category}
|
||||
</Tag>
|
||||
</>
|
||||
)
|
||||
}
|
Loading…
Reference in New Issue