diff --git a/src/components/Member/index.tsx b/src/components/Member/index.tsx index 1abfbad..07d54b6 100644 --- a/src/components/Member/index.tsx +++ b/src/components/Member/index.tsx @@ -2,11 +2,20 @@ import { Avatar } from "@/components/ui/avatar" import { memberData } from "@/components/Member/memberData"; import GithubIcon from '@site/static/img/github.svg'; import React, { useState, useMemo, useEffect } from 'react'; +import './styles.module.css'; export default function Component() { const data = memberData const [activeYear, setActiveYear] = useState(Object.keys(data)[0]); // 默认为第一个年份 const [activeFocus, setActiveFocus] = useState('All'); // 默认选中所有 focus + const [isExpanded, setIsExpanded] = useState(false); // 默认不展开年份选择 + + const imgPrefix = "https://img.w2fzu.com/member/" + const githubPrefix = "https://github.com/" + const visibleYearsCount = 3; // 可见年份数量 + + const sortedYears = Object.keys(data).sort((a, b) => b.localeCompare(a)); + const displayedYears = isExpanded ? sortedYears : sortedYears.slice(0, visibleYearsCount); // 我们创建一个 state 来存储 LazyLoad 组件 const [LazyLoad, setLazyLoad] = useState(null); @@ -51,22 +60,29 @@ export default function Component() { return (
{/* 年份选择 */} -
- {Object.keys(data).map((year) => ( +
+ {displayedYears.map((year) => (
setActiveYear(year)} - > - {year} ({data[year].length}) + key={year} + className={`px-4 py-2 mr-2 mb-2 whitespace-nowrap rounded text-sm font-medium transition ease-in-out duration-300 cursor-pointer + ${activeYear === year ? 'bg-[var(--ifm-color-primary)] text-white' : 'text-[var(--ifm-color-primary)] bg-gray-200 hover:bg-[var(--ifm-color-primary-lightest)] hover:text-[var(--ifm-color-primary-dark)]'}`} + onClick={() => setActiveYear(year)} + > + {year} ({data[year].length})
- - ))} + {Object.keys(data).length > visibleYearsCount && ( + + )}

{(parseInt(activeYear,10) - 1) + " - " + activeYear + "学年"}

+

注:方向按成为正式成员时的聚焦方向归类,有多个方向以优先级最高的方向作为分类依据

{/* Focus 选择 */}
{focusOptionsWithCount.map(({ focus, count }) => ( @@ -90,7 +106,7 @@ export default function Component() { {LazyLoad ? ( - {member.name} + {member.name} ) : (
Loading...
@@ -101,7 +117,7 @@ export default function Component() {

{member.major}

{member.github !== "null" && ( diff --git a/src/components/Member/memberData.ts b/src/components/Member/memberData.ts index 5018584..e27a1a6 100644 --- a/src/components/Member/memberData.ts +++ b/src/components/Member/memberData.ts @@ -7,12 +7,7 @@ type MemberData = Record export const memberData: MemberData = { - "2023": [ - // { avatar: "/placeholder-avatar.jpg", name: "John Doe", profession: "Software Engineer" }, - // { avatar: "/placeholder-avatar.jpg", name: "Jane Smith", profession: "Product Manager" }, - // { avatar: "/placeholder-avatar.jpg", name: "Michael Johnson", profession: "UI/UX Designer" }, - // { avatar: "/placeholder-avatar.jpg", name: "Emily Davis", profession: "Data Analyst" }, - ], + "2023": [], "2022": [ { avatar: "2022/frontends_python_zyy.jpg", name: "张艺耀", focus: "前端", major:"21级人工智能", github: "1379255913" }, { avatar: "2022/frontends_python_wy.jpg", name: "吴悠", focus: "Python", major:"21级给排水", github: "null" }, @@ -67,4 +62,16 @@ export const memberData: MemberData = { { avatar: "2022/art_lxy.jpg", name: "林心悦", focus: "美术", major:"21级数媒", github: "null" }, { avatar: "2022/art_hcx.jpg", name: "黄晨曦", focus: "美术", major:"21级信管", github: "mmmki" }, ], + "2021": [], + "2020": [], + "2019": [], + "2018": [], + "2017": [], + "2016": [], + "2015": [], + "2014": [], + "2013": [], + "2012": [], + "2011": [], + "2010": [], } diff --git a/src/components/Member/styles.module.css b/src/components/Member/styles.module.css new file mode 100644 index 0000000..43780fd --- /dev/null +++ b/src/components/Member/styles.module.css @@ -0,0 +1,20 @@ +/* 在你的 CSS 文件中添加以下样式 */ +/* 自定义滚动条的样式 */ +.scrollbar-custom::-webkit-scrollbar { + width: 10px; /* 设置滚动条的宽度 */ +} + +.scrollbar-custom::-webkit-scrollbar-track { + background: #f1f1f1; /* 设置滚动条的背景色 */ + border-radius: 10px; /* 设置滚动条的圆角 */ +} + +.scrollbar-custom::-webkit-scrollbar-thumb { + background: #888; /* 设置滚动条的颜色 */ + border-radius: 10px; /* 设置滚动条的圆角 */ + border: 3px solid #f1f1f1; /* 设置滚动条的边框 */ +} + +.scrollbar-custom::-webkit-scrollbar-thumb:hover { + background: #555; /* 设置滚动条鼠标悬停时的颜色 */ +}