diff --git a/website/src/components/Adapter.tsx b/website/src/components/Adapter.tsx index 42fd868e..b956bbfc 100644 --- a/website/src/components/Adapter.tsx +++ b/website/src/components/Adapter.tsx @@ -1,5 +1,48 @@ import React from "react"; +import { usePagination } from "react-use-pagination"; -export default function Adapter() { - return <>; +import adapters from "../../static/adapters.json"; +import { useFilteredObjs } from "../libs/store"; +import Paginate from "./Paginate"; + +export default function Adapter(): JSX.Element { + const { + filter, + setFilter, + filteredObjs: filteredAdapters, + } = useFilteredObjs(adapters); + + const props = usePagination({ + totalItems: filteredAdapters.length, + initialPageSize: 10, + }); + const { startIndex, endIndex } = props; + const currentAdapters = filteredAdapters.slice(startIndex, endIndex + 1); + + return ( + <> +
+ setFilter(event.target.value)} + /> + +
+
+ +
+
+ {currentAdapters.map((driver, index) => ( +

{driver.name}

+ ))} +
+
+ +
+ + ); } diff --git a/website/src/components/Bot.tsx b/website/src/components/Bot.tsx index 63fd515c..d690e5ac 100644 --- a/website/src/components/Bot.tsx +++ b/website/src/components/Bot.tsx @@ -1,5 +1,48 @@ import React from "react"; +import { usePagination } from "react-use-pagination"; -export default function Bot() { - return <>; +import bots from "../../static/bots.json"; +import { useFilteredObjs } from "../libs/store"; +import Paginate from "./Paginate"; + +export default function Adapter(): JSX.Element { + const { + filter, + setFilter, + filteredObjs: filteredBots, + } = useFilteredObjs(bots); + + const props = usePagination({ + totalItems: filteredBots.length, + initialPageSize: 10, + }); + const { startIndex, endIndex } = props; + const currentBots = filteredBots.slice(startIndex, endIndex + 1); + + return ( + <> +
+ setFilter(event.target.value)} + /> + +
+
+ +
+
+ {currentBots.map((driver, index) => ( +

{driver.name}

+ ))} +
+
+ +
+ + ); } diff --git a/website/src/components/Card/index.tsx b/website/src/components/Card/index.tsx new file mode 100644 index 00000000..b5fb74dc --- /dev/null +++ b/website/src/components/Card/index.tsx @@ -0,0 +1,23 @@ +import React from "react"; + +import Link from "@docusaurus/Link"; + +import type { Obj } from "../../libs/store"; + +export default function Card({ + name, + desc, + author, + homepage, +}: Obj): JSX.Element { + return ( +
+
+ {name} + {homepage && } +
+
{desc}
+
{author}
+
+ ); +} diff --git a/website/src/components/Driver.tsx b/website/src/components/Driver.tsx index fb8971ec..a8d1f027 100644 --- a/website/src/components/Driver.tsx +++ b/website/src/components/Driver.tsx @@ -17,7 +17,7 @@ export default function Driver(): JSX.Element { initialPageSize: 10, }); const { startIndex, endIndex } = props; - const currentDrivers = filteredDrivers.slice(startIndex, endIndex); + const currentDrivers = filteredDrivers.slice(startIndex, endIndex + 1); return ( <> @@ -28,7 +28,7 @@ export default function Driver(): JSX.Element { placeholder="搜索驱动器" onChange={(event) => setFilter(event.target.value)} /> - diff --git a/website/src/components/Paginate.tsx b/website/src/components/Paginate/index.tsx similarity index 68% rename from website/src/components/Paginate.tsx rename to website/src/components/Paginate/index.tsx index 3fd1c4a9..67d748df 100644 --- a/website/src/components/Paginate.tsx +++ b/website/src/components/Paginate/index.tsx @@ -4,6 +4,8 @@ import { usePagination } from "react-use-pagination"; import { FontAwesomeIcon } from "@fortawesome/react-fontawesome"; +import styles from "./styles.module.css"; + export default function Paginate({ totalPages, setPage, @@ -20,7 +22,15 @@ export default function Paginate({ } previousLabel={} nextLabel={} diff --git a/website/src/components/Paginate/styles.module.css b/website/src/components/Paginate/styles.module.css new file mode 100644 index 00000000..4d6d1caa --- /dev/null +++ b/website/src/components/Paginate/styles.module.css @@ -0,0 +1,29 @@ +.container { + @apply w-full max-w-full inline-flex justify-center items-center m-0 pl-0 list-none; +} + +.li { + @apply flex items-center; +} + +.a { + height: 34px; + width: auto; + min-width: 34px; + @apply m-1 px-1 border-2 rounded shadow-lg text-center; + @apply text-black; + @apply bg-light-nonepress-100; +} + +:global(.dark) .a { + @apply text-white bg-dark-nonepress-100; +} + +.active { + @apply bg-hero text-white border-hero; +} + + +.disabled { + @apply opacity-60 pointer-events-none; +} diff --git a/website/src/components/Plugin.tsx b/website/src/components/Plugin.tsx index ef4c6684..50ab9795 100644 --- a/website/src/components/Plugin.tsx +++ b/website/src/components/Plugin.tsx @@ -1,5 +1,49 @@ import React from "react"; +import { usePagination } from "react-use-pagination"; -export default function Plugin() { - return <>; +import plugins from "../../static/plugins.json"; +import { useFilteredObjs } from "../libs/store"; +import Card from "./Card"; +import Paginate from "./Paginate"; + +export default function Adapter(): JSX.Element { + const { + filter, + setFilter, + filteredObjs: filteredPlugins, + } = useFilteredObjs(plugins); + + const props = usePagination({ + totalItems: filteredPlugins.length, + initialPageSize: 10, + }); + const { startIndex, endIndex } = props; + const currentPlugins = filteredPlugins.slice(startIndex, endIndex + 1); + + return ( + <> +
+ setFilter(event.target.value)} + /> + +
+
+ +
+
+ {currentPlugins.map((driver, index) => ( + + ))} +
+
+ +
+ + ); } diff --git a/website/src/libs/store.ts b/website/src/libs/store.ts index 13da1518..ddfdf9a0 100644 --- a/website/src/libs/store.ts +++ b/website/src/libs/store.ts @@ -1,11 +1,11 @@ import { useState } from "react"; -type Tag = { +export type Tag = { label: string; color: string; }; -type Obj = { +export type Obj = { module_name?: string; project_link?: string; name: string; diff --git a/website/src/pages/store.mdx b/website/src/pages/store.mdx index 8c6910ff..24037f56 100644 --- a/website/src/pages/store.mdx +++ b/website/src/pages/store.mdx @@ -14,7 +14,7 @@ import Bot from "../components/Bot"; # 商店
- + diff --git a/website/static/adapters.json b/website/static/adapters.json index 7a76e548..bec23133 100644 --- a/website/static/adapters.json +++ b/website/static/adapters.json @@ -1,13 +1,13 @@ [ { - "module_name": "nonebot.adapters.cqhttp", - "project_link": "nonebot-adapter-cqhttp", - "name": "cqhttp", - "desc": "OneBot(CQHTTP) 协议", + "module_name": "nonebot.adapters.onebot.v11", + "project_link": "nonebot-adapter-onebot", + "name": "OneBot V11", + "desc": "OneBot V11 协议", "author": "yanyongyu", - "homepage": "https://github.com/nonebot/nonebot2/tree/master/packages/nonebot-adapter-cqhttp", + "homepage": "https://github.com/nonebot/adapter-onebot", "tags": [], - "is_official": false + "is_official": true }, { "module_name": "nonebot.adapters.ding", @@ -15,9 +15,9 @@ "name": "ding", "desc": "钉钉协议", "author": "Artin", - "homepage": "https://github.com/nonebot/nonebot2/tree/master/packages/nonebot-adapter-ding", + "homepage": "https://github.com/nonebot/adapter-ding", "tags": [], - "is_official": false + "is_official": true }, { "module_name": "nonebot.adapters.mirai", @@ -25,9 +25,9 @@ "name": "mirai", "desc": "Mirai-Api-HTTP 协议", "author": "Mix", - "homepage": "https://github.com/nonebot/nonebot2/tree/master/packages/nonebot-adapter-mirai", + "homepage": "https://github.com/nonebot/adapter-mirai", "tags": [], - "is_official": false + "is_official": true }, { "module_name": "nonebot.adapters.feishu", @@ -35,8 +35,28 @@ "name": "feishu", "desc": "飞书协议", "author": "StarHeartHunt", - "homepage": "https://github.com/nonebot/nonebot2/tree/master/packages/nonebot-adapter-feishu", + "homepage": "https://github.com/nonebot/adapter-feishu", "tags": [], - "is_official": false + "is_official": true + }, + { + "module_name": "nonebot.adapters.telegram", + "project_link": "nonebot-adapter-telegram", + "name": "telegram", + "desc": "Telegram 协议", + "author": "StarHeartHunt", + "homepage": "https://github.com/nonebot/adapter-telegram", + "tags": [], + "is_official": true + }, + { + "module_name": "nonebot.adapters.qqguild", + "project_link": "nonebot-adapter-qqguild", + "name": "QQ 频道", + "desc": "QQ 频道官方机器人", + "author": "yanyongyu", + "homepage": "https://github.com/nonebot/adapter-qqguild", + "tags": [], + "is_official": true } ] diff --git a/website/static/plugins.json b/website/static/plugins.json index 9e039904..90233bc6 100644 --- a/website/static/plugins.json +++ b/website/static/plugins.json @@ -7,7 +7,7 @@ "author": "yanyongyu", "homepage": "https://github.com/cscs181/QQ-GitHub-Bot/tree/master/src/plugins/nonebot_plugin_status", "tags": [], - "is_official": false + "is_official": true }, { "module_name": "haruka_bot", @@ -37,7 +37,7 @@ "name": "NoneBot离线文档", "homepage": "https://github.com/nonebot/nonebot2/tree/master/packages/nonebot-plugin-docs", "tags": [], - "is_official": false + "is_official": true }, { "module_name": "nonebot_plugin_sentry", @@ -47,17 +47,7 @@ "name": "Sentry日志监控", "homepage": "https://github.com/cscs181/QQ-GitHub-Bot/tree/master/src/plugins/nonebot_plugin_sentry", "tags": [], - "is_official": false - }, - { - "module_name": "nonebot_plugin_test", - "project_link": "nonebot-plugin-test", - "author": "yanyongyu", - "desc": "在浏览器中测试你的 NoneBot 机器人", - "name": "前端测试机器人插件", - "homepage": "https://github.com/nonebot/plugin-test", - "tags": [], - "is_official": false + "is_official": true }, { "module_name": "nonebot_plugin_apscheduler", @@ -67,7 +57,7 @@ "name": "定时任务", "homepage": "https://github.com/nonebot/plugin-apscheduler", "tags": [], - "is_official": false + "is_official": true }, { "module_name": "nonebot_plugin_picsearcher", @@ -287,7 +277,7 @@ "author": "yanyongyu", "homepage": "https://github.com/nonebot/plugin-localstore", "tags": [], - "is_official": false + "is_official": true }, { "module_name": "nonebot_plugin_puppet", @@ -497,7 +487,7 @@ "author": "mnixry", "homepage": "https://github.com/mnixry/nonebot-plugin-filehost", "tags": [], - "is_official": false + "is_official": true }, { "module_name": "nonebot_plugin_simplemusic",