From ec910055b1be3619b14bf4ff26f8b0b8ccf1388f Mon Sep 17 00:00:00 2001 From: canisminor1990 Date: Sun, 9 Jul 2023 19:10:20 +0800 Subject: [PATCH] =?UTF-8?q?=E2=99=BB=EF=B8=8F=20refactor:=20remove=20monor?= =?UTF-8?q?epo?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- package.json | 15 +- packages/dumi-theme-lobehub/.fatherrc.ts | 5 - packages/dumi-theme-lobehub/package.json | 49 ---- .../src/builtins/Container/index.tsx | 36 --- .../src/builtins/Container/style.ts | 58 ---- .../src/builtins/Features/index.tsx | 26 -- .../src/builtins/Previewer/index.tsx | 28 -- .../src/builtins/Previewer/style.ts | 148 ----------- .../src/builtins/SourceCode/index.tsx | 21 -- .../src/components/ApiHeader/index.tsx | 168 ------------ .../src/components/ApiHeader/style.ts | 21 -- .../src/components/Favicons/index.tsx | 41 --- .../NativeSelect/SelectItem/index.tsx | 40 --- .../NativeSelect/SelectItem/style.ts | 51 ---- .../src/components/NativeSelect/index.tsx | 249 ------------------ .../src/components/NativeSelect/style.ts | 57 ---- .../src/components/StoreUpdater/index.tsx | 101 ------- packages/dumi-theme-lobehub/src/config.ts | 3 - .../dumi-theme-lobehub/src/hooks/useCopied.ts | 21 -- packages/dumi-theme-lobehub/src/index.ts | 3 - .../src/layouts/DemoLayout/index.tsx | 19 -- .../src/layouts/DocLayout/GlobalStyle.ts | 24 -- .../src/layouts/DocLayout/index.tsx | 139 ---------- .../src/pages/Changelog/index.tsx | 55 ---- .../src/pages/Docs/index.tsx | 51 ---- .../src/pages/Docs/styles.ts | 65 ----- .../src/pages/Home/index.tsx | 20 -- .../dumi-theme-lobehub/src/plugin/index.ts | 69 ----- .../dumi-theme-lobehub/src/plugin/utils.ts | 4 - .../slots/ApiHeader/BundlephobiaFilled.tsx | 16 -- .../src/slots/ApiHeader/Graph.tsx | 13 - .../src/slots/ApiHeader/NpmFilled.tsx | 17 -- .../src/slots/ApiHeader/PackagePhobia.tsx | 17 -- .../src/slots/ApiHeader/Unpkg.tsx | 13 - .../src/slots/ApiHeader/index.tsx | 57 ---- .../src/slots/Content/index.tsx | 36 --- .../src/slots/Content/style.ts | 79 ------ .../src/slots/ContentFooter/Linker.style.ts | 28 -- .../src/slots/ContentFooter/Linker.tsx | 56 ---- .../src/slots/ContentFooter/index.tsx | 29 -- .../src/slots/ContentTabs/index.tsx | 46 ---- .../src/slots/ContentTabs/style.ts | 34 --- .../src/slots/Features/index.tsx | 19 -- .../src/slots/Footer/columns.tsx | 88 ------- .../src/slots/Footer/index.tsx | 58 ---- .../src/slots/Footer/style.ts | 171 ------------ .../src/slots/Header/Burger.tsx | 65 ----- .../src/slots/Header/GithubButton.tsx | 17 -- .../src/slots/Header/LangSwitch.tsx | 129 --------- .../src/slots/Header/ThemeSwitch.tsx | 19 -- .../src/slots/Header/index.tsx | 42 --- .../src/slots/Hero/index.tsx | 14 - .../src/slots/Logo/index.tsx | 33 --- .../src/slots/Logo/style.ts | 18 -- .../src/slots/Navbar/index.tsx | 57 ---- .../src/slots/PreviewerActions/index.tsx | 96 ------- .../src/slots/PreviewerActions/style.ts | 20 -- .../src/slots/SearchBar/index.tsx | 36 --- .../src/slots/SearchBar/style.ts | 144 ---------- .../src/slots/Sidebar/index.tsx | 32 --- .../src/slots/Sidebar/style.ts | 86 ------ .../src/slots/Toc/index.tsx | 37 --- .../dumi-theme-lobehub/src/store/index.ts | 20 -- .../src/store/selectors/apiHeader.ts | 76 ------ .../src/store/selectors/hero.ts | 65 ----- .../src/store/selectors/index.ts | 68 ----- .../src/store/selectors/siteBasicInfo.ts | 11 - .../src/store/selectors/token.ts | 9 - .../src/store/useSiteStore.ts | 98 ------- .../src/store/useThemeStore.ts | 15 -- .../src/styles/customToken.ts | 19 -- .../dumi-theme-lobehub/src/types/config.ts | 112 -------- .../dumi-theme-lobehub/src/types/global.d.ts | 16 -- packages/dumi-theme-lobehub/src/types/hero.ts | 10 - .../dumi-theme-lobehub/src/types/index.ts | 33 --- .../dumi-theme-lobehub/tsconfig-check.json | 7 - packages/dumi-theme-lobehub/tsconfig.json | 21 -- pnpm-workspace.yaml | 3 - src/ActionIcon/style.ts | 4 +- src/CodeEditor/style.ts | 3 +- src/ColorScales/style.ts | 6 +- src/GradientButton/style.ts | 4 +- src/Header/style.ts | 12 +- src/Input/style.ts | 3 +- src/SideNav/style.ts | 27 +- 85 files changed, 39 insertions(+), 3812 deletions(-) delete mode 100644 packages/dumi-theme-lobehub/.fatherrc.ts delete mode 100644 packages/dumi-theme-lobehub/package.json delete mode 100644 packages/dumi-theme-lobehub/src/builtins/Container/index.tsx delete mode 100644 packages/dumi-theme-lobehub/src/builtins/Container/style.ts delete mode 100644 packages/dumi-theme-lobehub/src/builtins/Features/index.tsx delete mode 100644 packages/dumi-theme-lobehub/src/builtins/Previewer/index.tsx delete mode 100644 packages/dumi-theme-lobehub/src/builtins/Previewer/style.ts delete mode 100644 packages/dumi-theme-lobehub/src/builtins/SourceCode/index.tsx delete mode 100644 packages/dumi-theme-lobehub/src/components/ApiHeader/index.tsx delete mode 100644 packages/dumi-theme-lobehub/src/components/ApiHeader/style.ts delete mode 100644 packages/dumi-theme-lobehub/src/components/Favicons/index.tsx delete mode 100644 packages/dumi-theme-lobehub/src/components/NativeSelect/SelectItem/index.tsx delete mode 100644 packages/dumi-theme-lobehub/src/components/NativeSelect/SelectItem/style.ts delete mode 100644 packages/dumi-theme-lobehub/src/components/NativeSelect/index.tsx delete mode 100644 packages/dumi-theme-lobehub/src/components/NativeSelect/style.ts delete mode 100644 packages/dumi-theme-lobehub/src/components/StoreUpdater/index.tsx delete mode 100644 packages/dumi-theme-lobehub/src/config.ts delete mode 100644 packages/dumi-theme-lobehub/src/hooks/useCopied.ts delete mode 100644 packages/dumi-theme-lobehub/src/index.ts delete mode 100644 packages/dumi-theme-lobehub/src/layouts/DemoLayout/index.tsx delete mode 100644 packages/dumi-theme-lobehub/src/layouts/DocLayout/GlobalStyle.ts delete mode 100644 packages/dumi-theme-lobehub/src/layouts/DocLayout/index.tsx delete mode 100644 packages/dumi-theme-lobehub/src/pages/Changelog/index.tsx delete mode 100644 packages/dumi-theme-lobehub/src/pages/Docs/index.tsx delete mode 100644 packages/dumi-theme-lobehub/src/pages/Docs/styles.ts delete mode 100644 packages/dumi-theme-lobehub/src/pages/Home/index.tsx delete mode 100644 packages/dumi-theme-lobehub/src/plugin/index.ts delete mode 100644 packages/dumi-theme-lobehub/src/plugin/utils.ts delete mode 100644 packages/dumi-theme-lobehub/src/slots/ApiHeader/BundlephobiaFilled.tsx delete mode 100644 packages/dumi-theme-lobehub/src/slots/ApiHeader/Graph.tsx delete mode 100644 packages/dumi-theme-lobehub/src/slots/ApiHeader/NpmFilled.tsx delete mode 100644 packages/dumi-theme-lobehub/src/slots/ApiHeader/PackagePhobia.tsx delete mode 100644 packages/dumi-theme-lobehub/src/slots/ApiHeader/Unpkg.tsx delete mode 100644 packages/dumi-theme-lobehub/src/slots/ApiHeader/index.tsx delete mode 100644 packages/dumi-theme-lobehub/src/slots/Content/index.tsx delete mode 100644 packages/dumi-theme-lobehub/src/slots/Content/style.ts delete mode 100644 packages/dumi-theme-lobehub/src/slots/ContentFooter/Linker.style.ts delete mode 100644 packages/dumi-theme-lobehub/src/slots/ContentFooter/Linker.tsx delete mode 100644 packages/dumi-theme-lobehub/src/slots/ContentFooter/index.tsx delete mode 100644 packages/dumi-theme-lobehub/src/slots/ContentTabs/index.tsx delete mode 100644 packages/dumi-theme-lobehub/src/slots/ContentTabs/style.ts delete mode 100644 packages/dumi-theme-lobehub/src/slots/Features/index.tsx delete mode 100644 packages/dumi-theme-lobehub/src/slots/Footer/columns.tsx delete mode 100644 packages/dumi-theme-lobehub/src/slots/Footer/index.tsx delete mode 100644 packages/dumi-theme-lobehub/src/slots/Footer/style.ts delete mode 100644 packages/dumi-theme-lobehub/src/slots/Header/Burger.tsx delete mode 100644 packages/dumi-theme-lobehub/src/slots/Header/GithubButton.tsx delete mode 100644 packages/dumi-theme-lobehub/src/slots/Header/LangSwitch.tsx delete mode 100644 packages/dumi-theme-lobehub/src/slots/Header/ThemeSwitch.tsx delete mode 100644 packages/dumi-theme-lobehub/src/slots/Header/index.tsx delete mode 100644 packages/dumi-theme-lobehub/src/slots/Hero/index.tsx delete mode 100644 packages/dumi-theme-lobehub/src/slots/Logo/index.tsx delete mode 100644 packages/dumi-theme-lobehub/src/slots/Logo/style.ts delete mode 100644 packages/dumi-theme-lobehub/src/slots/Navbar/index.tsx delete mode 100644 packages/dumi-theme-lobehub/src/slots/PreviewerActions/index.tsx delete mode 100644 packages/dumi-theme-lobehub/src/slots/PreviewerActions/style.ts delete mode 100644 packages/dumi-theme-lobehub/src/slots/SearchBar/index.tsx delete mode 100644 packages/dumi-theme-lobehub/src/slots/SearchBar/style.ts delete mode 100644 packages/dumi-theme-lobehub/src/slots/Sidebar/index.tsx delete mode 100644 packages/dumi-theme-lobehub/src/slots/Sidebar/style.ts delete mode 100644 packages/dumi-theme-lobehub/src/slots/Toc/index.tsx delete mode 100644 packages/dumi-theme-lobehub/src/store/index.ts delete mode 100644 packages/dumi-theme-lobehub/src/store/selectors/apiHeader.ts delete mode 100644 packages/dumi-theme-lobehub/src/store/selectors/hero.ts delete mode 100644 packages/dumi-theme-lobehub/src/store/selectors/index.ts delete mode 100644 packages/dumi-theme-lobehub/src/store/selectors/siteBasicInfo.ts delete mode 100644 packages/dumi-theme-lobehub/src/store/selectors/token.ts delete mode 100644 packages/dumi-theme-lobehub/src/store/useSiteStore.ts delete mode 100644 packages/dumi-theme-lobehub/src/store/useThemeStore.ts delete mode 100644 packages/dumi-theme-lobehub/src/styles/customToken.ts delete mode 100644 packages/dumi-theme-lobehub/src/types/config.ts delete mode 100644 packages/dumi-theme-lobehub/src/types/global.d.ts delete mode 100644 packages/dumi-theme-lobehub/src/types/hero.ts delete mode 100644 packages/dumi-theme-lobehub/src/types/index.ts delete mode 100644 packages/dumi-theme-lobehub/tsconfig-check.json delete mode 100644 packages/dumi-theme-lobehub/tsconfig.json delete mode 100644 pnpm-workspace.yaml diff --git a/package.json b/package.json index 97d09e5d..7cbd93ba 100644 --- a/package.json +++ b/package.json @@ -28,17 +28,15 @@ ], "scripts": { "build": "father build", - "build:theme": "npm run build --prefix=packages/dumi-theme-lobehub", "build:watch": "father dev", "ci": "npm run lint && npm run type-check", - "clean": "rm -r es lib dist coverage .dumi/tmp .eslintcache node_modules/.cache packages/dumi-theme-lobehub/dist packages/dumi-theme-lobehub/node_modules/.cache", + "clean": "rm -r es lib dist coverage .dumi/tmp .eslintcache node_modules/.cache", "dev": "dumi dev", - "dev:theme": "npm run dev --prefix=packages/dumi-theme-lobehub", - "docs:build": "npm run build:theme && dumi build", + "docs:build": "dumi build", "doctor": "father doctor", - "lint": "eslint \"{src,tests,packages}/**/*.{js,jsx,ts,tsx}\" --fix", + "lint": "eslint \"{src,tests}/**/*.{js,jsx,ts,tsx}\" --fix", "lint:md": "remark . --quiet --frail --output", - "lint:style": "stylelint \"{src,tests,packages}/**/*.{js,jsx,ts,tsx}\" --fix", + "lint:style": "stylelint \"{src,tests}/**/*.{js,jsx,ts,tsx}\" --fix", "prepare": "husky install && npm run setup", "prepublishOnly": "father doctor && npm run build", "prettier": "prettier -c --write --no-error-on-unmatched-pattern \"**/**\"", @@ -120,14 +118,13 @@ "concurrently": "^8", "cross-env": "^7", "dumi": "^2", - "dumi-assets-types": "^1", - "dumi-theme-lobehub": "workspace:latest", + "dumi-theme-lobehub": "latest", "eslint": "^8", "father": "^4", "husky": "^8", "jsdom": "^22", "lint-staged": "^13", - "prettier": "^2", + "prettier": "^3", "react": "^18", "react-dom": "^18", "remark": "^14", diff --git a/packages/dumi-theme-lobehub/.fatherrc.ts b/packages/dumi-theme-lobehub/.fatherrc.ts deleted file mode 100644 index 4b817e06..00000000 --- a/packages/dumi-theme-lobehub/.fatherrc.ts +++ /dev/null @@ -1,5 +0,0 @@ -import { defineConfig } from 'father'; - -export default defineConfig({ - plugins: ['father-plugin-dumi-theme'], -}); diff --git a/packages/dumi-theme-lobehub/package.json b/packages/dumi-theme-lobehub/package.json deleted file mode 100644 index fcd4d9d6..00000000 --- a/packages/dumi-theme-lobehub/package.json +++ /dev/null @@ -1,49 +0,0 @@ -{ - "name": "dumi-theme-lobehub", - "version": "0.0.0", - "private": "true", - "sideEffects": false, - "main": "dist/index.js", - "module": "dist/index.js", - "types": "dist/index.d.ts", - "files": [ - "dist" - ], - "scripts": { - "build": "father build", - "dev": "father dev", - "prepare": "npm run build" - }, - "dependencies": { - "@floating-ui/react": "^0", - "@giscus/react": "^2", - "@lobehub/ui": "latest", - "ahooks": "^3", - "antd": "^5", - "antd-style": "^3", - "chalk": "^4", - "fast-deep-equal": "^3", - "lodash-es": "^4", - "lucide-react": "latest", - "polished": "^4", - "react-layout-kit": "^1", - "styled-components": "latest", - "use-merge-value": "^1", - "zustand": "^4" - }, - "devDependencies": { - "father-plugin-dumi-theme": "latest", - "history": "^5" - }, - "peerDependencies": { - "antd": ">=5", - "antd-style": ">=3", - "dumi": ">=2", - "react": ">=18", - "react-dom": ">=18" - }, - "publishConfig": { - "access": "public", - "registry": "https://registry.npmjs.org" - } -} diff --git a/packages/dumi-theme-lobehub/src/builtins/Container/index.tsx b/packages/dumi-theme-lobehub/src/builtins/Container/index.tsx deleted file mode 100644 index 2c65ebc8..00000000 --- a/packages/dumi-theme-lobehub/src/builtins/Container/index.tsx +++ /dev/null @@ -1,36 +0,0 @@ -import { Alert } from 'antd'; -import { type FC, type ReactNode } from 'react'; - -import { useStyles } from './style'; - -const Container: FC<{ - children: ReactNode; - title?: string; - type: 'info' | 'warning' | 'success' | 'error'; -}> = ({ type, title, children }) => { - const { styles, cx } = useStyles(); - - return ( -
- - {children} -
- } - message={title || type.toUpperCase()} - showIcon - type={type} - /> - - ); -}; - -export default Container; diff --git a/packages/dumi-theme-lobehub/src/builtins/Container/style.ts b/packages/dumi-theme-lobehub/src/builtins/Container/style.ts deleted file mode 100644 index 0b0bdc9d..00000000 --- a/packages/dumi-theme-lobehub/src/builtins/Container/style.ts +++ /dev/null @@ -1,58 +0,0 @@ -import { FullToken, createStyles } from 'antd-style'; - -const toCamelCase = (string_: string) => { - return string_.replaceAll(/( |^)[a-z]/g, (L) => L.toUpperCase()); -}; -export const useStyles = createStyles(({ token, prefixCls, css }) => { - // 把首字母大写 - - const overwriteAlert = (type: string) => { - const tokens = { - background: token[`color${toCamelCase(type)}Bg` as unknown as keyof FullToken], - text: token[`color${toCamelCase(type)}Text` as unknown as keyof FullToken], - }; - - return css` - .${prefixCls}-alert-${type} { - background: ${tokens.background}; - - .${prefixCls}-alert-message { - font-weight: bold; - color: ${tokens.text}; - } - - .${prefixCls}-alert-description { - .markdown { - color: ${tokens.text}; - } - } - } - `; - }; - - return { - alert: css` - border: none; - - .${prefixCls}-alert-message { - font-weight: bold; - } - `, - container: css` - margin: 8px 0; - - ${overwriteAlert('info')} - - ${overwriteAlert('warning')} - - ${overwriteAlert('success')} - - ${overwriteAlert('error')} - `, - desc: css` - p { - margin: 0; - } - `, - }; -}); diff --git a/packages/dumi-theme-lobehub/src/builtins/Features/index.tsx b/packages/dumi-theme-lobehub/src/builtins/Features/index.tsx deleted file mode 100644 index f0cc7bd4..00000000 --- a/packages/dumi-theme-lobehub/src/builtins/Features/index.tsx +++ /dev/null @@ -1,26 +0,0 @@ -import { Features } from '@lobehub/ui'; - -export default () => ( - -); diff --git a/packages/dumi-theme-lobehub/src/builtins/Previewer/index.tsx b/packages/dumi-theme-lobehub/src/builtins/Previewer/index.tsx deleted file mode 100644 index 50bd47d4..00000000 --- a/packages/dumi-theme-lobehub/src/builtins/Previewer/index.tsx +++ /dev/null @@ -1,28 +0,0 @@ -import { IPreviewerProps } from 'dumi/dist/client/theme-api/types'; -import Previewer from 'dumi/theme-default/builtins/Previewer'; - -import { useStyles } from './style'; - -export interface PreviewerProps extends IPreviewerProps { - center?: boolean; - nopadding?: boolean; - pure?: boolean; -} - -export default ({ center, codePlacement, nopadding, pure, ...props }: PreviewerProps) => { - const { styles, cx } = useStyles(pure); - - return ( -
- -
- ); -}; diff --git a/packages/dumi-theme-lobehub/src/builtins/Previewer/style.ts b/packages/dumi-theme-lobehub/src/builtins/Previewer/style.ts deleted file mode 100644 index d46753bc..00000000 --- a/packages/dumi-theme-lobehub/src/builtins/Previewer/style.ts +++ /dev/null @@ -1,148 +0,0 @@ -import { createStyles } from 'antd-style'; -import { rgba } from 'polished'; - -export const useStyles = createStyles(({ css, token, prefixCls }) => { - return { - center: css` - .dumi-default-previewer-demo { - display: flex; - align-items: center; - justify-content: center; - } - `, - container: css` - .dumi-default-previewer { - overflow: hidden; - display: flex; - flex-direction: column; - border-color: ${token.colorBorderSecondary}; - - &-demo { - flex: 1; - - &[data-iframe]::before { - background: ${token.colorFillContent}; - } - } - - &-meta { - flex: 1; - border-color: ${token.colorBorderSecondary}; - - .${prefixCls}-highlighter { - pre { - border-radius: 0 !important; - } - } - } - - &-actions:not(:last-child) { - border-color: ${token.colorBorderSecondary}; - } - - &-desc { - .markdown { - border-color: ${token.colorBorderSecondary}; - } - - h5 { - background: linear-gradient( - to top, - ${token.colorBgContainer}, - ${rgba(token.colorBgContainer, 0.95)} 50%, - ${rgba(token.colorBgContainer, 0)} 100% - ); - - a { - color: ${token.colorText}; - } - } - } - - &-tabs::after { - border-color: ${token.colorBorderSecondary}; - } - } - - .dumi-default-tabs-tab { - &-btn { - color: ${token.colorTextTertiary}; - } - - &-active { - .dumi-default-tabs-tab-btn { - color: ${token.colorText}; - } - } - } - `, - left: css` - .dumi-default-previewer { - flex-direction: row-reverse; - - &-demo { - width: 50%; - border-left: 1px solid ${token.colorBorderSecondary}; - } - - &-meta { - width: 50%; - } - } - `, - nopadding: css` - .dumi-default-previewer-demo { - padding: 0; - } - `, - pure: css` - .dumi-default-previewer { - margin: 0; - padding: 0; - border: none; - } - - .dumi-default-previewer-demo { - padding: 0; - } - - .dumi-default-previewer-meta { - display: none; - } - `, - - right: css` - .dumi-default-previewer { - flex-direction: row; - - &-demo { - width: 50%; - border-right: 1px solid ${token.colorBorderSecondary}; - } - - &-meta { - width: 50%; - } - } - `, - - top: css` - .dumi-default-previewer { - flex-direction: column-reverse; - - &-meta { - display: flex; - flex-direction: column; - } - - &-actions { - order: 1; - } - - &-desc { - order: 2; - } - } - `, - }; -}); diff --git a/packages/dumi-theme-lobehub/src/builtins/SourceCode/index.tsx b/packages/dumi-theme-lobehub/src/builtins/SourceCode/index.tsx deleted file mode 100644 index 9f1e3c17..00000000 --- a/packages/dumi-theme-lobehub/src/builtins/SourceCode/index.tsx +++ /dev/null @@ -1,21 +0,0 @@ -import { Highlighter } from '@lobehub/ui'; -import { useTheme } from 'antd-style'; -import { rgba } from 'polished'; -import { FC } from 'react'; - -interface SourceCodeProps { - children: string; - lang: string; -} - -const SourceCode: FC = ({ children, lang }) => { - const theme = useTheme(); - - return ( - - {children} - - ); -}; - -export default SourceCode; diff --git a/packages/dumi-theme-lobehub/src/components/ApiHeader/index.tsx b/packages/dumi-theme-lobehub/src/components/ApiHeader/index.tsx deleted file mode 100644 index 580978b9..00000000 --- a/packages/dumi-theme-lobehub/src/components/ApiHeader/index.tsx +++ /dev/null @@ -1,168 +0,0 @@ -import { Icon, Snippet } from '@lobehub/ui'; -import { Divider, Space, Typography } from 'antd'; -import { useResponsive } from 'antd-style'; -import { Edit3, Github } from 'lucide-react'; -import { type ReactNode, memo } from 'react'; -import { Flexbox } from 'react-layout-kit'; - -import { useStyles } from './style'; - -/** - * @title ApiHeaderProps - * @category Props - * @description ApiHeader 组件的 props 类型定义 - */ -export interface ApiHeaderProps { - /** - * @title 组件名 - * @description ApiHeader 组件的名称 - */ - componentName?: string; - /** - * @title 是否默认导入 - * @description 是否默认导入组件 - * @default false - */ - defaultImport?: boolean; - /** - * @title 描述 - * @description ApiHeader 组件的描述信息 - */ - description?: string; - /** - * @title 文档链接 - * @description ApiHeader 组件文档的链接 - */ - docUrl?: string; - /** - * @title 包名 - * @description ApiHeader 组件所在的包名 - */ - pkg?: string; - /** - * @title 源代码链接 - * @description ApiHeader 组件源代码的链接 - */ - sourceUrl?: string; - /** - * @title 标题 - * @description ApiHeader 组件的标题 - */ - title: string; -} -/** - * @title ApiHeader 配置项 - */ - -export interface ApiTitleProps extends ApiHeaderProps { - /** - * @title 服务列表 - * @description 可选,若存在则展示 API 服务列表 - */ - serviceList?: ServiceItem[]; - /** - * @title 标题 - */ - title: string; -} - -export interface ServiceItem { - /** - * @title 服务描述 - */ - children: string; - /** - * @title 服务图标 - */ - icon: ReactNode; - /** - * @title 服务标签 - */ - label: string; - /** - * @title 服务链接 - */ - url: string; -} - -export const ApiHeader = memo( - ({ - title, - componentName, - description, - defaultImport, - pkg, - sourceUrl, - docUrl, - serviceList = [], - }) => { - const { styles } = useStyles(); - const { mobile } = useResponsive(); - - const items = [ - sourceUrl && { - children: 'Source', - icon: , - url: sourceUrl, - }, - docUrl && { - children: 'Edit', - icon: , - url: docUrl, - }, - ].filter(Boolean) as ServiceItem[]; - - const importString = defaultImport - ? `import ${componentName} from '${pkg}';` - : `import { ${componentName} } from '${pkg}';`; - - return ( - - {title} - {description && ( -
- - {description} - -
- )} - - {componentName && ( -
- {importString} -
- )} - - - } wrap> - {serviceList.map((item) => ( - - - {item.icon} - {item.children} - - - ))} - - }> - {items.map((item, index) => ( - - - {item.icon} - {item.children} - - - ))} - - -
-
- ); - }, -); diff --git a/packages/dumi-theme-lobehub/src/components/ApiHeader/style.ts b/packages/dumi-theme-lobehub/src/components/ApiHeader/style.ts deleted file mode 100644 index ac8c4e96..00000000 --- a/packages/dumi-theme-lobehub/src/components/ApiHeader/style.ts +++ /dev/null @@ -1,21 +0,0 @@ -import { createStyles } from 'antd-style'; - -export const useStyles = createStyles(({ css, token, responsive: r, stylish }) => ({ - desc: css` - font-size: ${token.fontSizeLG}px; - line-height: ${token.lineHeightLG}px; - `, - label: css` - width: 80px; - `, - meta: css``, - text: css` - ${stylish.resetLinkColor} - `, - title: css` - ${r.mobile} { - margin-block: 0; - font-size: 32px !important; - } - `, -})); diff --git a/packages/dumi-theme-lobehub/src/components/Favicons/index.tsx b/packages/dumi-theme-lobehub/src/components/Favicons/index.tsx deleted file mode 100644 index c444337e..00000000 --- a/packages/dumi-theme-lobehub/src/components/Favicons/index.tsx +++ /dev/null @@ -1,41 +0,0 @@ -import { Helmet } from 'dumi'; -import { memo } from 'react'; - -const Favicons = memo(() => { - return ( - - - - - - - - - - - - ); -}); - -export default Favicons; diff --git a/packages/dumi-theme-lobehub/src/components/NativeSelect/SelectItem/index.tsx b/packages/dumi-theme-lobehub/src/components/NativeSelect/SelectItem/index.tsx deleted file mode 100644 index ea309aac..00000000 --- a/packages/dumi-theme-lobehub/src/components/NativeSelect/SelectItem/index.tsx +++ /dev/null @@ -1,40 +0,0 @@ -import { ForwardedRef, forwardRef, memo } from 'react'; - -import { useStyles } from './style'; - -interface SelectItemProps { - disabled?: boolean; - isActive?: boolean; - isSelected?: boolean; - label: any; - prefixCls: string; - ref?: ForwardedRef; - value: any; -} - -const SelectItem = memo( - forwardRef(({ value, label, prefixCls, isSelected, isActive, disabled, ...props }, reference) => { - const { styles, cx } = useStyles(prefixCls); - - return ( - - ); - }), -); - -export default SelectItem; diff --git a/packages/dumi-theme-lobehub/src/components/NativeSelect/SelectItem/style.ts b/packages/dumi-theme-lobehub/src/components/NativeSelect/SelectItem/style.ts deleted file mode 100644 index 36681623..00000000 --- a/packages/dumi-theme-lobehub/src/components/NativeSelect/SelectItem/style.ts +++ /dev/null @@ -1,51 +0,0 @@ -import { createStyles } from 'antd-style'; - -export const useStyles = createStyles(({ css, cx, token }, prefixCls) => ({ - active: cx( - `${prefixCls}-item-active`, - css` - background: ${token.colorFillTertiary}; - `, - ), - item: cx( - `${prefixCls}-item`, - - css` - all: unset; - - user-select: none; - scroll-margin: 50px; - - display: block; - - box-sizing: inherit; - width: 100%; - padding: 12px 10px; - - font-family: ${token.fontFamily}; - font-weight: normal; - line-height: 1; - color: ${token.colorText}; - - background: transparent; - border-radius: 5px; - - &:hover { - background: ${token.colorFillTertiary}; - } - `, - ), - selected: cx( - `${prefixCls}-item-selected`, - css` - font-weight: bold; - color: ${token.colorPrimaryText}; - background: ${token.colorPrimaryBg}; - - &:hover { - color: ${token.colorPrimaryTextHover}; - background: ${token.colorPrimaryBgHover}; - } - `, - ), -})); diff --git a/packages/dumi-theme-lobehub/src/components/NativeSelect/index.tsx b/packages/dumi-theme-lobehub/src/components/NativeSelect/index.tsx deleted file mode 100644 index 7e453d38..00000000 --- a/packages/dumi-theme-lobehub/src/components/NativeSelect/index.tsx +++ /dev/null @@ -1,249 +0,0 @@ -import { - FloatingFocusManager, - FloatingOverlay, - FloatingPortal, - SideObject, - autoUpdate, - flip, - inner, - offset, - shift, - size, - useClick, - useDismiss, - useFloating, - useInnerOffset, - useInteractions, - useListNavigation, - useRole, - useTypeahead, -} from '@floating-ui/react'; -import { CSSProperties, ReactNode, memo, useEffect, useRef, useState } from 'react'; -import useControlledState from 'use-merge-value'; - -import SelectItem from './SelectItem'; -import { useStyles } from './style'; - -interface OptionType { - icon?: ReactNode; - label: ReactNode; - value: string | number | null; -} -export interface NativeSelectProps { - onChange?: (index: number) => void; - options?: OptionType[]; - prefixCls?: string; - renderItem?: (item: OptionType, index: number) => ReactNode; - renderValue?: (index: number) => ReactNode; - style?: CSSProperties; - value?: number; -} - -const NativeSelect = memo( - ({ options = [], value, prefixCls, onChange, renderValue, renderItem, style }) => { - const cls = prefixCls ?? 'native-select'; - const [selectedIndex, setSelectedIndex] = useControlledState(0, { onChange, value }); - - const { styles } = useStyles(cls); - const listReference = useRef>([]); - const listContentReference = useRef>([]); - const overflowReference = useRef(null); - const allowSelectReference = useRef(false); - const allowMouseUpReference = useRef(true); - const selectTimeoutReference = useRef(); - const scrollReference = useRef(null); - - const [open, setOpen] = useState(false); - const [activeIndex, setActiveIndex] = useState(null); - const [fallback, setFallback] = useState(false); - const [innerOffset, setInnerOffset] = useState(0); - const [touch, setTouch] = useState(false); - const [blockSelection, setBlockSelection] = useState(false); - - if (!open) { - if (innerOffset !== 0) setInnerOffset(0); - - if (fallback) setFallback(false); - - if (blockSelection) setBlockSelection(false); - } - - const { x, y, strategy, refs, context } = useFloating({ - middleware: fallback - ? [ - offset(5), - touch ? shift({ crossAxis: true, padding: 10 }) : flip({ padding: 10 }), - size({ - apply({ availableHeight }) { - Object.assign(scrollReference.current?.style ?? {}, { - maxHeight: `${availableHeight}px`, - }); - }, - padding: 10, - }), - ] - : [ - inner({ - index: selectedIndex, - listRef: listReference, - minItemsVisible: touch ? 8 : 4, - offset: innerOffset, - onFallbackChange: setFallback, - overflowRef: overflowReference, - padding: 10, - referenceOverflowThreshold: 20, - scrollRef: scrollReference, - }), - offset({ crossAxis: -4 }), - ], - onOpenChange: setOpen, - open, - placement: 'bottom-start', - whileElementsMounted: autoUpdate, - }); - - const { getReferenceProps, getFloatingProps, getItemProps } = useInteractions([ - useClick(context, { event: 'mousedown' }), - useDismiss(context), - useRole(context, { role: 'listbox' }), - useInnerOffset(context, { - enabled: !fallback, - onChange: setInnerOffset, - overflowRef: overflowReference, - scrollRef: scrollReference, - }), - useListNavigation(context, { - activeIndex, - listRef: listReference, - onNavigate: setActiveIndex, - selectedIndex, - }), - useTypeahead(context, { - activeIndex, - listRef: listContentReference, - onMatch: open ? setActiveIndex : setSelectedIndex, - }), - ]); - - useEffect(() => { - if (open) { - selectTimeoutReference.current = setTimeout(() => { - allowSelectReference.current = true; - }, 300); - - return () => { - clearTimeout(selectTimeoutReference.current); - }; - } - - allowSelectReference.current = false; - allowMouseUpReference.current = true; - }, [open]); - - const { label } = options[selectedIndex] || {}; - - return ( - <> - - - - {open && ( - - -
-
- {options.map((item, index) => { - return ( - { - listReference.current[index] = node; - listContentReference.current[index] = item.label as string; - }} - value={item.value} - {...getItemProps({ - onClick() { - if (allowSelectReference.current) { - setSelectedIndex(index); - setOpen(false); - } - }, - onKeyDown() { - allowSelectReference.current = true; - }, - onMouseUp() { - if (!allowMouseUpReference.current) { - return; - } - - if (allowSelectReference.current) { - setSelectedIndex(index); - setOpen(false); - } - - // On touch devices, prevent the element from - // immediately closing `onClick` by deferring it - clearTimeout(selectTimeoutReference.current); - selectTimeoutReference.current = setTimeout(() => { - allowSelectReference.current = true; - }); - }, - onTouchStart() { - allowSelectReference.current = true; - allowMouseUpReference.current = false; - }, - })} - /> - ); - })} -
-
-
-
- )} -
- - ); - }, -); - -export default NativeSelect; diff --git a/packages/dumi-theme-lobehub/src/components/NativeSelect/style.ts b/packages/dumi-theme-lobehub/src/components/NativeSelect/style.ts deleted file mode 100644 index 4511b929..00000000 --- a/packages/dumi-theme-lobehub/src/components/NativeSelect/style.ts +++ /dev/null @@ -1,57 +0,0 @@ -import { createStyles } from 'antd-style'; - -export const useStyles = createStyles(({ css, stylish, cx, token }, prefixCls: string) => ({ - button: cx( - `${prefixCls}-button`, - css` - ${stylish.buttonDefaultHover} - all: unset; - - cursor: default; - user-select: none; - - padding: 8px; - - font-size: ${token.fontSize}px; - line-height: 0; - color: ${token.colorTextSecondary}; - - background: ${token.colorBgContainer}; - border: 1px solid ${token.colorBorder}; - border-radius: ${token.borderRadius}px; - - -webkit-tap-highlight-color: transparent; - - &:focus-visible { - border-color: ${token.colorPrimary}; - box-shadow: 0 0 0 2px ${token.colorPrimaryBg}; - } - `, - ), - container: cx( - prefixCls, - css` - user-select: none; - scrollbar-width: none; - - overflow-y: auto; - overscroll-behavior: contain; - - box-sizing: border-box; - width: 160px; - padding: 5px; - - font-size: ${token.fontSize}; - - background: ${token.colorBgElevated}; - border: 1px solid ${token.colorBorder}; - border-radius: 8px; - outline: 0; - box-shadow: ${token.boxShadowSecondary}; - - &::-webkit-scrollbar { - display: none; - } - `, - ), -})); diff --git a/packages/dumi-theme-lobehub/src/components/StoreUpdater/index.tsx b/packages/dumi-theme-lobehub/src/components/StoreUpdater/index.tsx deleted file mode 100644 index 33bd7b8a..00000000 --- a/packages/dumi-theme-lobehub/src/components/StoreUpdater/index.tsx +++ /dev/null @@ -1,101 +0,0 @@ -import { useDebounceEffect } from 'ahooks'; -import { - useLocale, - useLocation, - useNavData, - useRouteMeta, - useSidebarData, - useSiteData, - useTabMeta, -} from 'dumi'; -import isEqual from 'fast-deep-equal'; -import React, { type DependencyList, type EffectCallback, useEffect } from 'react'; - -import { SiteStore, useSiteStore } from '@/store/useSiteStore'; - -const isBrowser = typeof window !== 'undefined'; - -const SSRInit: Record = {}; - -const useReact18xUpdater = (effect: EffectCallback, deps?: DependencyList) => { - useEffect(() => { - (React as any).startTransition(() => { - effect(); - }); - }, deps); -}; -const useLegacyUpdater = (effect: EffectCallback, deps?: DependencyList) => { - useDebounceEffect( - () => { - effect(); - }, - deps, - { maxWait: 96, wait: 32 }, - ); -}; -const useUpdater = - typeof (React as any).startTransition === 'function' ? useReact18xUpdater : useLegacyUpdater; - -const useSyncState = ( - key: T, - value: SiteStore[T], - updateMethod?: (key: T, value: SiteStore[T]) => void, -) => { - const updater = updateMethod - ? updateMethod - : (key: T, value: SiteStore[T]) => useSiteStore.setState({ [key]: value }); - - // 如果是 Node 环境,直接更新一次 store - // 但是为了避免多次更新 store,所以加一个标记 - if (!isBrowser && !SSRInit[key]) { - updater(key, value); - SSRInit[key] = true; - } - - useUpdater(() => { - updater(key, value); - }, [value]); -}; - -const homeNav = { - activePath: '/', - link: '/', - title: 'Home', -}; - -export const StoreUpdater = () => { - const siteData = useSiteData(); - const sidebar = useSidebarData(); - const routeMeta = useRouteMeta(); - const tabMeta = useTabMeta(); - const navData = useNavData(); - const location = useLocation(); - const locale = useLocale(); - - useSyncState('siteData', siteData, () => { - // eslint-disable-next-line @typescript-eslint/no-unused-vars - const { setLoading, ...data } = siteData; - const { - // eslint-disable-next-line @typescript-eslint/no-unused-vars - siteData: { setLoading: _, ...previousData }, - } = useSiteStore.getState(); - - if (isEqual(data, previousData)) return; - - useSiteStore.setState({ siteData }); - }); - - useSyncState('sidebar', sidebar); - useSyncState('routeMeta', routeMeta); - useSyncState('location', location); - useSyncState('tabMeta', tabMeta); - useSyncState('locale', locale); - - useSyncState('navData', navData, () => { - const data = siteData.themeConfig.hideHomeNav ? navData : [homeNav, ...navData]; - - useSiteStore.setState({ navData: data }); - }); - - return false; -}; diff --git a/packages/dumi-theme-lobehub/src/config.ts b/packages/dumi-theme-lobehub/src/config.ts deleted file mode 100644 index 0c17e25c..00000000 --- a/packages/dumi-theme-lobehub/src/config.ts +++ /dev/null @@ -1,3 +0,0 @@ -import { SiteThemeConfig } from './types'; - -export const defineThemeConfig = (config: SiteThemeConfig) => config; diff --git a/packages/dumi-theme-lobehub/src/hooks/useCopied.ts b/packages/dumi-theme-lobehub/src/hooks/useCopied.ts deleted file mode 100644 index 360e45f4..00000000 --- a/packages/dumi-theme-lobehub/src/hooks/useCopied.ts +++ /dev/null @@ -1,21 +0,0 @@ -import { useCallback, useEffect, useMemo, useState } from 'react'; - -export const useCopied = () => { - const [copied, setCopy] = useState(false); - - useEffect(() => { - if (!copied) return; - - const timer = setTimeout(() => { - setCopy(false); - }, 2000); - - return () => { - clearTimeout(timer); - }; - }, [copied]); - - const setCopied = useCallback(() => setCopy(true), []); - - return useMemo(() => ({ copied, setCopied }), [copied]); -}; diff --git a/packages/dumi-theme-lobehub/src/index.ts b/packages/dumi-theme-lobehub/src/index.ts deleted file mode 100644 index e68e9353..00000000 --- a/packages/dumi-theme-lobehub/src/index.ts +++ /dev/null @@ -1,3 +0,0 @@ -export { defineThemeConfig } from './config'; -export { siteSelectors, type SiteStore, useSiteStore } from './store'; -export * from './types'; diff --git a/packages/dumi-theme-lobehub/src/layouts/DemoLayout/index.tsx b/packages/dumi-theme-lobehub/src/layouts/DemoLayout/index.tsx deleted file mode 100644 index 76d4fb3b..00000000 --- a/packages/dumi-theme-lobehub/src/layouts/DemoLayout/index.tsx +++ /dev/null @@ -1,19 +0,0 @@ -import { ThemeProvider } from '@lobehub/ui'; -import { useOutlet } from 'dumi'; -import isEqual from 'fast-deep-equal'; -import { memo } from 'react'; - -import Favicons from '@/components/Favicons'; -import { useThemeStore } from '@/store'; - -export default memo(() => { - const themeMode = useThemeStore((st) => st.themeMode, isEqual); - const outlet = useOutlet(); - - return ( - <> - - {outlet} - - ); -}); diff --git a/packages/dumi-theme-lobehub/src/layouts/DocLayout/GlobalStyle.ts b/packages/dumi-theme-lobehub/src/layouts/DocLayout/GlobalStyle.ts deleted file mode 100644 index 1efa8504..00000000 --- a/packages/dumi-theme-lobehub/src/layouts/DocLayout/GlobalStyle.ts +++ /dev/null @@ -1,24 +0,0 @@ -import { createGlobalStyle } from 'antd-style'; - -const GlobalStyle = createGlobalStyle` - -#nprogress { - .bar { - background: ${({ theme }) => theme.colorText}; - } - - .peg { - display: none !important; - } - - .spinner { - display: none; - } -} - - - - -`; - -export default GlobalStyle; diff --git a/packages/dumi-theme-lobehub/src/layouts/DocLayout/index.tsx b/packages/dumi-theme-lobehub/src/layouts/DocLayout/index.tsx deleted file mode 100644 index 94817204..00000000 --- a/packages/dumi-theme-lobehub/src/layouts/DocLayout/index.tsx +++ /dev/null @@ -1,139 +0,0 @@ -import { Layout, ThemeProvider } from '@lobehub/ui'; -import { extractStaticStyle, useResponsive, useTheme } from 'antd-style'; -import { Helmet, useIntl, useLocation } from 'dumi'; -import isEqual from 'fast-deep-equal'; -import { memo, useCallback, useEffect } from 'react'; -import { shallow } from 'zustand/shallow'; - -import Favicons from '@/components/Favicons'; -import { StoreUpdater } from '@/components/StoreUpdater'; -import GlobalStyle from '@/layouts/DocLayout/GlobalStyle'; -import Changelog from '@/pages/Changelog'; -import Docs from '@/pages/Docs'; -import Home from '@/pages/Home'; -import Footer from '@/slots/Footer'; -import Header from '@/slots/Header'; -import Sidebar from '@/slots/Sidebar'; -import Toc from '@/slots/Toc'; -import { - isHeroPageSel, - siteTitleSel, - tocAnchorItemSel, - useSiteStore, - useThemeStore, -} from '@/store'; -import customToken from '@/styles/customToken'; - -const DocumentLayout = memo(() => { - const intl = useIntl(); - const { hash } = useLocation(); - const theme = useTheme(); - const { mobile, laptop } = useResponsive(); - - const { loading, page, siteTitle, noToc } = useSiteStore((s) => { - const isChanlogPage = s.location.pathname === '/changelog'; - const isHomePage = isHeroPageSel(s); - let page; - - if (isHomePage) { - page = 'home'; - } else if (isChanlogPage) { - page = 'changelog'; - } else { - page = 'docs'; - } - - return { - loading: s.siteData.loading, - noToc: tocAnchorItemSel(s).length === 0, - page: page, - siteTitle: siteTitleSel(s), - }; - }, shallow); - - const fm = useSiteStore((s) => s.routeMeta.frontmatter, isEqual); - - const hideSidebar = page !== 'docs' || mobile || fm.sidebar === false; - const shouldHideToc = fm.toc === false || noToc; - const hideToc = mobile ? shouldHideToc : !laptop || shouldHideToc; - - const HelmetBlock = useCallback( - () => ( - - - {fm.title && } - {fm.description && } - {fm.description && } - {fm.keywords && } - {fm.keywords && } - {!fm.title || page === 'home' ? ( - {siteTitle} - ) : ( - - {fm.title} - {siteTitle} - - )} - - ), - [intl, fm, siteTitle, page], - ); - - // handle hash change or visit page hash after async chunk loaded - useEffect(() => { - const id = hash.replace('#', ''); - - if (!id) return; - setTimeout(() => { - const elm = document.querySelector(`#${decodeURIComponent(id)}`); - if (elm) { - elm.scrollIntoView(); - window.scrollBy({ top: -80 }); - } - }, 1); - }, [loading, hash]); - - useEffect(() => { - document.body.scrollTo(0, 0); - }, [siteTitle]); - - return ( - <> - - } - header={
} - headerHeight={mobile && page !== 'home' ? theme.headerHeight + 36 : theme.headerHeight} - sidebar={hideSidebar ? undefined : } - toc={hideToc ? undefined : } - tocWidth={hideToc ? 0 : theme.tocWidth} - > - {page === 'home' && } - {page === 'changelog' && } - {page === 'docs' && } - - - ); -}); - -// @ts-ignore -global.__ANTD_CACHE__ = extractStaticStyle.cache; - -export default memo(() => { - const themeMode = useThemeStore((st) => st.themeMode, shallow); - - return ( - <> - - - - - - - - ); -}); diff --git a/packages/dumi-theme-lobehub/src/pages/Changelog/index.tsx b/packages/dumi-theme-lobehub/src/pages/Changelog/index.tsx deleted file mode 100644 index 0aab35e3..00000000 --- a/packages/dumi-theme-lobehub/src/pages/Changelog/index.tsx +++ /dev/null @@ -1,55 +0,0 @@ -import { useResponsive } from 'antd-style'; -import { useOutlet } from 'dumi'; -import isEqual from 'fast-deep-equal'; -import { memo } from 'react'; -import { Center } from 'react-layout-kit'; -import { shallow } from 'zustand/shallow'; - -import { ApiHeader } from '@/components/ApiHeader'; -import { useStyles } from '@/pages/Docs/styles'; -import Content from '@/slots/Content'; -import { githubSel, useSiteStore } from '@/store'; - -const Changelog = memo(() => { - const outlet = useOutlet(); - const { mobile } = useResponsive(); - const { repoBase } = useSiteStore( - (s) => ({ - repoBase: githubSel(s), - }), - shallow, - ); - - const { fm } = useSiteStore( - (s) => ({ - fm: s.routeMeta.frontmatter, - }), - isEqual, - ); - - const { styles } = useStyles(); - - return ( - <> -
-
-
- -
- {outlet} -
- - ); -}); - -export default Changelog; diff --git a/packages/dumi-theme-lobehub/src/pages/Docs/index.tsx b/packages/dumi-theme-lobehub/src/pages/Docs/index.tsx deleted file mode 100644 index d3346a93..00000000 --- a/packages/dumi-theme-lobehub/src/pages/Docs/index.tsx +++ /dev/null @@ -1,51 +0,0 @@ -import { Giscus } from '@lobehub/ui'; -import { useResponsive } from 'antd-style'; -import { useOutlet } from 'dumi'; -import { memo, useCallback } from 'react'; -import { Center } from 'react-layout-kit'; -import { shallow } from 'zustand/shallow'; - -import ApiHeader from '@/slots/ApiHeader'; -import Content from '@/slots/Content'; -import { isApiPageSel, useSiteStore } from '@/store'; - -import { useStyles } from './styles'; - -const Documents = memo(() => { - const outlet = useOutlet(); - const { mobile } = useResponsive(); - const isApiPage = useSiteStore(isApiPageSel, shallow); - const { styles } = useStyles(); - - const Comment = useCallback( - () => ( - - ), - [location.pathname], - ); - return ( - <> -
-
- {isApiPage ? ( -
- -
- ) : undefined} - - {outlet} - - -
- - ); -}); - -export default Documents; diff --git a/packages/dumi-theme-lobehub/src/pages/Docs/styles.ts b/packages/dumi-theme-lobehub/src/pages/Docs/styles.ts deleted file mode 100644 index db57b914..00000000 --- a/packages/dumi-theme-lobehub/src/pages/Docs/styles.ts +++ /dev/null @@ -1,65 +0,0 @@ -import { createStyles } from 'antd-style'; - -export const useStyles = createStyles(({ cx, css, token, stylish }) => ({ - background: cx( - stylish.gradientAnimation, - css` - pointer-events: none; - - position: absolute; - z-index: 0; - top: -100px; - right: -20vw; - transform: rotate(4deg); - - width: 60vw; - height: 200px; - - opacity: 0.2; - filter: blur(100px); - `, - ), - changelog: css` - .markdown { - font-size: 16px; - - h1 { - display: none; - } - - h2, - h3 { - margin-bottom: 0; - font-size: 28px; - } - - sup { - color: ${token.colorTextDescription}; - } - - details { - font-size: 14px; - } - - summary > kbd { - margin-left: 6px; - } - - a[href='/changelog#readme-top'] { - display: block; - margin-bottom: 32px; - padding-bottom: 32px; - border-bottom: 1px solid ${token.colorBorderSecondary}; - - > img { - display: none; - } - } - } - `, - content: css` - width: 100%; - max-width: ${token.contentMaxWidth}px; - margin: 0 auto; - `, -})); diff --git a/packages/dumi-theme-lobehub/src/pages/Home/index.tsx b/packages/dumi-theme-lobehub/src/pages/Home/index.tsx deleted file mode 100644 index 8931b5a5..00000000 --- a/packages/dumi-theme-lobehub/src/pages/Home/index.tsx +++ /dev/null @@ -1,20 +0,0 @@ -import { useOutlet } from 'dumi'; -import { memo } from 'react'; -import { Flexbox } from 'react-layout-kit'; - -import Features from '@/slots/Features'; -import Hero from '@/slots/Hero'; - -const Home = memo(() => { - const outlet = useOutlet(); - - return ( - - - - {outlet} - - ); -}); - -export default Home; diff --git a/packages/dumi-theme-lobehub/src/plugin/index.ts b/packages/dumi-theme-lobehub/src/plugin/index.ts deleted file mode 100644 index 4728cd05..00000000 --- a/packages/dumi-theme-lobehub/src/plugin/index.ts +++ /dev/null @@ -1,69 +0,0 @@ -import { extractStaticStyle } from 'antd-style'; -import chalk from 'chalk'; -import type { IApi } from 'dumi'; -import fs from 'node:fs'; -import { join } from 'node:path'; - -import { getHash } from './utils'; - -/* - * SSR 抽取样式 - */ -const SSRPlugin = (api: IApi) => { - api.describe({ - key: '@', - }); - - // 如果没有开启 SSR,则啥也不做 - if (!api.userConfig.ssr) return; - - api.logger.info('detect ssr config, when building html will extract css.'); - - const writeCSSFile = (key: string, hashKey: string, cssString: string) => { - const fileName = `ssr-${key}.${getHash(hashKey)}.css`; - - const filePath = join(api.paths.absOutputPath, fileName); - - if (!fs.existsSync(filePath)) { - api.logger.event(chalk.grey(`write to: ${filePath}`)); - fs.writeFileSync(filePath, cssString, 'utf8'); - } - - return fileName; - }; - - const addLinkStyle = (html: string, cssFile: string) => { - const prefix = api.userConfig.publicPath || api.config.publicPath; - - return html.replace('', ``); - }; - - api.modifyExportHTMLFiles((files) => - files - // exclude dynamic route path, to avoid deploy failed by `:id` directory - .filter((f) => !f.path.includes(':')) - - .map((file) => { - const antdCache = (global as any).__ANTD_CACHE__; - - // 提取 antd-style 样式到独立 css 文件 - const styles = extractStaticStyle(file.content, { antdCache }); - - for (const result of styles) { - api.logger.event( - `${chalk.yellow(file.path)} include ${chalk.blue`[${result.key}]`} ${chalk.yellow( - result.ids.length, - )} styles`, - ); - - const cssFile = writeCSSFile(result.key, result.ids.join(''), result.css); - - file.content = addLinkStyle(file.content, cssFile); - } - - return file; - }), - ); -}; - -export default SSRPlugin; diff --git a/packages/dumi-theme-lobehub/src/plugin/utils.ts b/packages/dumi-theme-lobehub/src/plugin/utils.ts deleted file mode 100644 index 2212c5a1..00000000 --- a/packages/dumi-theme-lobehub/src/plugin/utils.ts +++ /dev/null @@ -1,4 +0,0 @@ -import { createHash } from 'node:crypto'; - -export const getHash = (string_: string, length = 8) => - createHash('md5').update(string_).digest('hex').slice(0, length); diff --git a/packages/dumi-theme-lobehub/src/slots/ApiHeader/BundlephobiaFilled.tsx b/packages/dumi-theme-lobehub/src/slots/ApiHeader/BundlephobiaFilled.tsx deleted file mode 100644 index c5321f45..00000000 --- a/packages/dumi-theme-lobehub/src/slots/ApiHeader/BundlephobiaFilled.tsx +++ /dev/null @@ -1,16 +0,0 @@ -import { memo } from 'react'; - -export default memo(() => ( - - - -)); diff --git a/packages/dumi-theme-lobehub/src/slots/ApiHeader/Graph.tsx b/packages/dumi-theme-lobehub/src/slots/ApiHeader/Graph.tsx deleted file mode 100644 index 216fd573..00000000 --- a/packages/dumi-theme-lobehub/src/slots/ApiHeader/Graph.tsx +++ /dev/null @@ -1,13 +0,0 @@ -import { memo } from 'react'; - -export default memo(() => ( - - - -)); diff --git a/packages/dumi-theme-lobehub/src/slots/ApiHeader/NpmFilled.tsx b/packages/dumi-theme-lobehub/src/slots/ApiHeader/NpmFilled.tsx deleted file mode 100644 index f5680515..00000000 --- a/packages/dumi-theme-lobehub/src/slots/ApiHeader/NpmFilled.tsx +++ /dev/null @@ -1,17 +0,0 @@ -import { memo } from 'react'; - -export default memo(() => ( - - - -)); diff --git a/packages/dumi-theme-lobehub/src/slots/ApiHeader/PackagePhobia.tsx b/packages/dumi-theme-lobehub/src/slots/ApiHeader/PackagePhobia.tsx deleted file mode 100644 index 4dc93f9f..00000000 --- a/packages/dumi-theme-lobehub/src/slots/ApiHeader/PackagePhobia.tsx +++ /dev/null @@ -1,17 +0,0 @@ -import { memo } from 'react'; - -export default memo(() => ( - - - - - - - - - -)); diff --git a/packages/dumi-theme-lobehub/src/slots/ApiHeader/Unpkg.tsx b/packages/dumi-theme-lobehub/src/slots/ApiHeader/Unpkg.tsx deleted file mode 100644 index 6b1248c2..00000000 --- a/packages/dumi-theme-lobehub/src/slots/ApiHeader/Unpkg.tsx +++ /dev/null @@ -1,13 +0,0 @@ -import { memo } from 'react'; - -export default memo(() => ( - - - -)); diff --git a/packages/dumi-theme-lobehub/src/slots/ApiHeader/index.tsx b/packages/dumi-theme-lobehub/src/slots/ApiHeader/index.tsx deleted file mode 100644 index cc8cf8d3..00000000 --- a/packages/dumi-theme-lobehub/src/slots/ApiHeader/index.tsx +++ /dev/null @@ -1,57 +0,0 @@ -import isEqual from 'fast-deep-equal'; -import { memo, useMemo } from 'react'; - -import { ApiHeader as Header } from '@/components/ApiHeader'; -import { apiHeaderSel, useSiteStore } from '@/store'; - -import BundlephobiaFilled from './BundlephobiaFilled'; -import Graph from './Graph'; -import NpmFilled from './NpmFilled'; -import PackagePhobia from './PackagePhobia'; -import Unpkg from './Unpkg'; - -const ApiHeader = memo(() => { - const props = useSiteStore(apiHeaderSel, isEqual); - const { pkg } = props; - - const packages = useMemo(() => { - const packageURL = encodeURIComponent(String(pkg)); - return [ - { - children: 'NPM', - icon: , - label: 'NPM', - url: `https://www.npmjs.com/package/${packageURL}`, - }, - { - children: 'UNPKG', - icon: , - label: 'Check package files', - url: `https://unpkg.com/browse/${packageURL}/`, - }, - { - children: 'BundlePhobia', - icon: , - label: 'Check bundle size', - url: `https://bundlephobia.com/package/${packageURL}`, - }, - { - children: 'PackagePhobia', - icon: , - label: 'Check package size', - url: `https://packagephobia.com/result?p=${packageURL}`, - }, - - { - children: 'Anvaka Graph', - icon: , - label: 'Dependence graph', - url: `https://npm.anvaka.com/#/view/2d/${encodeURIComponent(packageURL)}`, - }, - ]; - }, [pkg]); - - return
; -}); - -export default ApiHeader; diff --git a/packages/dumi-theme-lobehub/src/slots/Content/index.tsx b/packages/dumi-theme-lobehub/src/slots/Content/index.tsx deleted file mode 100644 index e185edbd..00000000 --- a/packages/dumi-theme-lobehub/src/slots/Content/index.tsx +++ /dev/null @@ -1,36 +0,0 @@ -import { Skeleton, Typography } from 'antd'; -import { useResponsive } from 'antd-style'; -import { memo } from 'react'; -import { Flexbox } from 'react-layout-kit'; - -import ContentFooter from '@/slots/ContentFooter'; -import { useSiteStore } from '@/store'; -import { DivProps } from '@/types'; - -import { useStyles } from './style'; - -const Content = memo(({ children, ...props }) => { - const loading = useSiteStore((s) => s.siteData.loading); - - const { styles, cx } = useStyles(); - const { mobile } = useResponsive(); - - return ( - - -
- -
- {children} -
-
- -
- ); -}); - -export default Content; diff --git a/packages/dumi-theme-lobehub/src/slots/Content/style.ts b/packages/dumi-theme-lobehub/src/slots/Content/style.ts deleted file mode 100644 index 8bdbe317..00000000 --- a/packages/dumi-theme-lobehub/src/slots/Content/style.ts +++ /dev/null @@ -1,79 +0,0 @@ -import { createStyles } from 'antd-style'; - -export const useStyles = createStyles(({ token, responsive, css, stylish }) => ({ - content: css` - flex: 1; - - box-sizing: border-box; - width: 100%; - min-height: 400px; - padding: 24px 48px; - - background-color: ${token.colorBgContainer}; - border-radius: 10px; - - &:has([data-page-tabs='true']) { - padding-top: 8px; - } - - ${responsive.mobile} { - padding: 8px 16px; - border-radius: 0; - } - - .markdown { - ${stylish.markdown}; - h2, - h3 { - &[id^='version'] { - color: ${token.colorText}; - } - } - - h1, - h2, - h3, - h4, - h5, - h6 { - transition: all 400ms ${token.motionEaseOut}; - - > a[aria-hidden]:first-child { - float: left; - - width: 20px; - margin-inline-start: -24px; - padding-inline-end: 4px; - - font-size: inherit; - line-height: inherit; - color: ${token.colorText}; - text-align: right; - - &:hover { - border: 0; - } - - > .icon-link::before { - content: '#'; - font-size: inherit; - color: ${token.colorTextTertiary}; - } - } - - &:hover { - color: ${token.colorText}; - } - - &:not(:hover) > a[aria-hidden]:first-child > .icon-link { - visibility: hidden; - } - } - - ol, - ul { - padding-inline-start: 18px; - } - } - `, -})); diff --git a/packages/dumi-theme-lobehub/src/slots/ContentFooter/Linker.style.ts b/packages/dumi-theme-lobehub/src/slots/ContentFooter/Linker.style.ts deleted file mode 100644 index e69b0916..00000000 --- a/packages/dumi-theme-lobehub/src/slots/ContentFooter/Linker.style.ts +++ /dev/null @@ -1,28 +0,0 @@ -import { createStyles } from 'antd-style'; - -export const useStyles = createStyles(({ token, css }) => ({ - alignmentEnd: css` - justify-content: flex-end; - `, - container: css` - cursor: pointer; - - min-width: 250px; - padding: 16px 24px; - - background: ${token.colorBgContainer}; - border-radius: 8px; - - &:hover { - background: ${token.colorFillTertiary}; - } - `, - nav: css` - font-size: 12px; - color: ${token.colorTextTertiary}; - `, - - title: css` - font-size: 16px; - `, -})); diff --git a/packages/dumi-theme-lobehub/src/slots/ContentFooter/Linker.tsx b/packages/dumi-theme-lobehub/src/slots/ContentFooter/Linker.tsx deleted file mode 100644 index 1fed8ec1..00000000 --- a/packages/dumi-theme-lobehub/src/slots/ContentFooter/Linker.tsx +++ /dev/null @@ -1,56 +0,0 @@ -import { Icon } from '@lobehub/ui'; -import { Link } from 'dumi'; -import { ArrowLeft, ArrowRight } from 'lucide-react'; -import { memo, useMemo } from 'react'; -import { Flexbox } from 'react-layout-kit'; - -import { useStyles } from './Linker.style'; - -interface LinkerProps { - link: string; - title: string; - type?: 'prev' | 'next'; -} - -const Linker = memo(({ title, link, type }) => { - const { styles, cx } = useStyles(); - const navContent = useMemo(() => { - switch (type) { - case 'prev': { - return ( - <> - - Previous - - ); - } - case 'next': { - return ( - <> - Next - - - ); - } - } - }, [type]); - - return ( - - - - {navContent} - - - {title} - - - - ); -}); - -export default Linker; diff --git a/packages/dumi-theme-lobehub/src/slots/ContentFooter/index.tsx b/packages/dumi-theme-lobehub/src/slots/ContentFooter/index.tsx deleted file mode 100644 index c3e9f935..00000000 --- a/packages/dumi-theme-lobehub/src/slots/ContentFooter/index.tsx +++ /dev/null @@ -1,29 +0,0 @@ -import { useResponsive } from 'antd-style'; -import isEqual from 'fast-deep-equal'; -import { memo } from 'react'; -import { Flexbox } from 'react-layout-kit'; - -import { contentBottomSel, useSiteStore } from '@/store'; - -import Linker from './Linker'; - -const ContentFooter = memo(() => { - const { prev, next } = useSiteStore(contentBottomSel, isEqual); - const { mobile } = useResponsive(); - - return ( - - {prev ? :
} - {next ? :
} - - ); -}); - -export default ContentFooter; diff --git a/packages/dumi-theme-lobehub/src/slots/ContentTabs/index.tsx b/packages/dumi-theme-lobehub/src/slots/ContentTabs/index.tsx deleted file mode 100644 index a6234214..00000000 --- a/packages/dumi-theme-lobehub/src/slots/ContentTabs/index.tsx +++ /dev/null @@ -1,46 +0,0 @@ -import { Tabs } from 'antd'; -import { useIntl, useRouteMeta } from 'dumi'; -import { memo } from 'react'; - -import { useStyles } from './style'; - -type IContentTabs = ReturnType['tabs']; - -export interface ContentTabsProps { - onChange: (tab?: NonNullable[0]) => void; - tabKey: string | undefined; - tabs: IContentTabs; -} - -const ContentTabs = memo(({ tabs, tabKey: key, onChange }) => { - const intl = useIntl(); - const { styles } = useStyles(); - // TODO: tab.Extra & tab.Action render - - return tabs && tabs?.length > 0 ? ( - ({ - key: tab.key, - label: tab.titleIntlId - ? intl.formatMessage({ id: tab.titleIntlId }) - : tab.meta.frontmatter.title, - value: tab.key, - })), - ]} - onChange={(key) => { - if (key === 'default') { - onChange(); - } else { - onChange(tabs.find((t) => t.key === key)); - } - }} - /> - ) : undefined; -}); - -export default ContentTabs; diff --git a/packages/dumi-theme-lobehub/src/slots/ContentTabs/style.ts b/packages/dumi-theme-lobehub/src/slots/ContentTabs/style.ts deleted file mode 100644 index 1fee1894..00000000 --- a/packages/dumi-theme-lobehub/src/slots/ContentTabs/style.ts +++ /dev/null @@ -1,34 +0,0 @@ -import { createStyles } from 'antd-style'; - -export const useStyles = createStyles(({ token, prefixCls, css }) => { - const prefix = `.${prefixCls}-tabs`; - - const marginBlock = 8; - - return { - cls: css` - ${prefix}-tab + ${prefix}-tab { - margin: 8px 4px !important; - margin-block: ${marginBlock}px; - padding: 0 12px !important; - } - - ${prefix}-tab { - color: ${token.colorTextSecondary}; - transition: background-color 150ms ease-out; - - &:first-child { - margin-block: ${marginBlock}px; - margin-inline: 0 4px; - padding: 4px 12px !important; - } - - &:hover { - color: ${token.colorText} !important; - background: ${token.colorFillTertiary}; - border-radius: 6px; - } - } - `, - }; -}); diff --git a/packages/dumi-theme-lobehub/src/slots/Features/index.tsx b/packages/dumi-theme-lobehub/src/slots/Features/index.tsx deleted file mode 100644 index 129fbc0a..00000000 --- a/packages/dumi-theme-lobehub/src/slots/Features/index.tsx +++ /dev/null @@ -1,19 +0,0 @@ -import { Features as F } from '@lobehub/ui'; -import { useTheme } from 'antd-style'; -import isEqual from 'fast-deep-equal'; -import { memo } from 'react'; - -import { featuresSel, useSiteStore } from '@/store'; - -const Features = memo(() => { - const features = useSiteStore(featuresSel, isEqual); - const theme = useTheme(); - - if (!features?.length) return; - - return ( - - ); -}); - -export default Features; diff --git a/packages/dumi-theme-lobehub/src/slots/Footer/columns.tsx b/packages/dumi-theme-lobehub/src/slots/Footer/columns.tsx deleted file mode 100644 index 6dc453db..00000000 --- a/packages/dumi-theme-lobehub/src/slots/Footer/columns.tsx +++ /dev/null @@ -1,88 +0,0 @@ -import { Icon } from '@lobehub/ui'; -import { Link } from 'dumi'; -import { Bug, FileClock, GitFork, Github } from 'lucide-react'; -import { FooterColumn, FooterColumnItem } from 'rc-footer/es/column'; - -interface GetColumnParameters { - github?: string; -} -export const getColumns = ({ github }: GetColumnParameters) => { - const resources: FooterColumn = { - items: [ - { - description: 'AIGC Components', - openExternal: true, - title: 'Lobe UI', - url: 'https://github.com/lobehub/lobe-ui', - }, - { - description: 'Chatbot Client', - openExternal: true, - title: 'Lobe Chat', - url: 'https://github.com/lobehub/lobe-chat', - }, - { - description: 'Node Flow Editor', - openExternal: true, - title: 'Lobe Flow', - url: 'https://github.com/lobehub/lobe-flow', - }, - ], - title: 'Resources', - }; - const community: FooterColumn = { - items: [ - github && { - icon: , - openExternal: true, - title: 'Report Bug', - url: `${github}/issues/new/choose`, - }, - github && { - icon: , - openExternal: true, - title: 'Request Feature', - url: `${github}/issues/new/choose`, - }, - ].filter(Boolean) as FooterColumnItem[], - title: 'Community', - }; - - const help: FooterColumn = { - items: [ - github && { - icon: , - openExternal: true, - title: 'GitHub', - url: github, - }, - { - LinkComponent: Link, - icon: , - title: 'Changelog', - url: '/changelog', - }, - ].filter(Boolean) as FooterColumnItem[], - title: 'Help', - }; - - const more: FooterColumn = { - items: [ - { - description: 'AI Commit CLI', - openExternal: true, - title: '💌 Lobe Commit', - url: 'https://github.com/lobehub/lobe-commit', - }, - { - description: 'Lint Config', - openExternal: true, - title: '📐 Lobe Lint', - url: 'https://github.com/lobehub/lobe-lint', - }, - ], - title: 'More Products', - }; - - return [resources, community, help, more]; -}; diff --git a/packages/dumi-theme-lobehub/src/slots/Footer/index.tsx b/packages/dumi-theme-lobehub/src/slots/Footer/index.tsx deleted file mode 100644 index 81f85ec3..00000000 --- a/packages/dumi-theme-lobehub/src/slots/Footer/index.tsx +++ /dev/null @@ -1,58 +0,0 @@ -import { Footer as Foot, FooterProps } from '@lobehub/ui'; -import { Divider } from 'antd'; -import { useResponsive } from 'antd-style'; -import isEqual from 'fast-deep-equal'; -import { memo } from 'react'; -import { Center, Flexbox } from 'react-layout-kit'; -import { shallow } from 'zustand/shallow'; - -import { githubSel, useSiteStore } from '@/store'; -import { IFooter } from '@/types'; - -import { getColumns } from './columns'; -import { useStyles } from './style'; - -const Footer = memo(() => { - const { themeConfig, pkg } = useSiteStore((s) => s.siteData, isEqual); - const githubUrl = useSiteStore(githubSel, shallow); - const { styles, theme } = useStyles(); - const { mobile } = useResponsive(); - - if (!themeConfig.footer) return; - - const footer = themeConfig.footerConfig as IFooter; - - const columns = - footer?.columns === false - ? undefined - : getColumns({ github: githubUrl || (pkg as any).homepage }); - - const bottomFooter = footer?.bottom || themeConfig.footer; - - return ( - - Copyright © 2022-{new Date().getFullYear()} - - - ) : ( -
- Copyright © 2022-{new Date().getFullYear()} - -
- ) - } - columns={columns} - contentMaxWidth={theme.contentMaxWidth} - theme={footer?.theme || (theme.appearance as FooterProps['theme'])} - /> - ); -}); - -export default Footer; diff --git a/packages/dumi-theme-lobehub/src/slots/Footer/style.ts b/packages/dumi-theme-lobehub/src/slots/Footer/style.ts deleted file mode 100644 index f9d679e9..00000000 --- a/packages/dumi-theme-lobehub/src/slots/Footer/style.ts +++ /dev/null @@ -1,171 +0,0 @@ -import { createStyles } from 'antd-style'; - -export const useStyles = createStyles(({ css, responsive, token }) => { - const prefix = `rc-footer`; - - return { - container: css` - grid-area: footer; - align-self: stretch; - - color: ${token.colorTextDescription}; - text-align: center; - - border-top: 1px solid ${token.colorSplit}; - - ${responsive.mobile} { - flex-direction: column; - border: none; - } - `, - footer: css` - font-size: 14px; - line-height: 1.5; - color: ${token.colorTextSecondary}; - background-color: ${token.colorBgLayout}; - - &.${prefix} { - a { - color: ${token.colorTextTertiary}; - text-decoration: none; - transition: all 0.3s; - - &:hover { - color: ${token.colorLinkHover}; - } - } - } - - .${prefix} { - &-container { - width: 100%; - max-width: ${token.contentMaxWidth}px; - margin: auto; - padding: 60px 0 20px; - } - - &-columns { - display: flex; - justify-content: space-around; - } - - &-column { - h2 { - position: relative; - - margin: 0 auto; - - font-size: 16px; - font-weight: 500; - color: ${token.colorText}; - } - - &-icon { - position: relative; - top: -1px; - - display: inline-block; - - width: 22px; - margin-inline-end: 0.5em; - - text-align: center; - vertical-align: middle; - - > span, - > svg, - img { - display: block; - width: 100%; - } - } - } - - &-item { - margin: 12px 0; - - &-icon { - position: relative; - top: -1px; - - display: inline-block; - - width: 16px; - margin-inline-end: 0.4em; - - text-align: center; - vertical-align: middle; - - > span, - > svg, - img { - display: block; - width: 100%; - } - } - - &-separator { - margin: 0 0.3em; - } - } - - &-bottom { - &-container { - width: 100%; - max-width: 1200px; - margin: 0 auto; - padding: 16px 0; - - font-size: 16px; - line-height: 32px; - text-align: center; - - border-top: 1px solid ${token.colorBorderSecondary}; - } - } - - &-light { - color: rgba(0, 0, 0, 85%); - background-color: transparent; - - h2, - a { - color: rgba(0, 0, 0, 85%); - } - } - - &-light &-bottom-container { - border-top-color: #e8e8e8; - } - - &-light &-item-separator, - &-light &-item-description { - color: rgba(0, 0, 0, 45%); - } - } - - ${responsive.mobile} { - .${prefix} { - text-align: center; - - &-container { - padding: 40px 0; - } - - &-columns { - display: block; - } - - &-column { - display: block; - margin-bottom: 40px; - - &:last-child { - margin-bottom: 0; - } - } - } - } - `, - }; -}); diff --git a/packages/dumi-theme-lobehub/src/slots/Header/Burger.tsx b/packages/dumi-theme-lobehub/src/slots/Header/Burger.tsx deleted file mode 100644 index b785d497..00000000 --- a/packages/dumi-theme-lobehub/src/slots/Header/Burger.tsx +++ /dev/null @@ -1,65 +0,0 @@ -import { BurgerProps, Burger as Menu } from '@lobehub/ui'; -import { Link } from 'dumi'; -import isEqual from 'fast-deep-equal'; -import { uniq } from 'lodash-es'; -import { memo, useMemo, useState } from 'react'; -import { shallow } from 'zustand/shallow'; - -import { activePathSel, useSiteStore } from '@/store'; - -const Burger = memo(() => { - const [opened, setOpened] = useState(false); - - const nav = useSiteStore((s) => s.navData, isEqual); - const sidebar = useSiteStore((s) => s.sidebar, isEqual); - const { pathname, activePath } = useSiteStore( - (s) => ({ - activePath: activePathSel(s), - pathname: s.location.pathname, - }), - shallow, - ); - - const items: BurgerProps['items'] = useMemo(() => { - const sidebarItems = sidebar?.map((group) => { - return ( - !group.link && { - children: group.children.map((item) => ({ - key: `s-${item.link}`, - label: ( - { - setOpened(false); - }} - to={item.link} - > - {item.title} - - ), - })), - label: group.title, - type: 'group', - } - ); - }); - return nav.map((item) => { - return { - children: (item.activePath || item.link) === activePath && sidebarItems, - key: item.activePath! || item.link, - label: {item.title}, - }; - }); - }, [nav, activePath, sidebar]); - - return ( - - ); -}); - -export default Burger; diff --git a/packages/dumi-theme-lobehub/src/slots/Header/GithubButton.tsx b/packages/dumi-theme-lobehub/src/slots/Header/GithubButton.tsx deleted file mode 100644 index 8a2c8be1..00000000 --- a/packages/dumi-theme-lobehub/src/slots/Header/GithubButton.tsx +++ /dev/null @@ -1,17 +0,0 @@ -import { ActionIcon } from '@lobehub/ui'; -import { Github } from 'lucide-react'; -import { memo } from 'react'; - -import { githubSel, useSiteStore } from '@/store'; - -const GithubButton = memo(() => { - const repoUrl = useSiteStore(githubSel); - - return repoUrl ? ( - - - - ) : undefined; -}); - -export default GithubButton; diff --git a/packages/dumi-theme-lobehub/src/slots/Header/LangSwitch.tsx b/packages/dumi-theme-lobehub/src/slots/Header/LangSwitch.tsx deleted file mode 100644 index f99502d3..00000000 --- a/packages/dumi-theme-lobehub/src/slots/Header/LangSwitch.tsx +++ /dev/null @@ -1,129 +0,0 @@ -import { Button } from 'antd'; -import { Link, history, useLocation, useSiteData } from 'dumi'; -import { memo, useEffect, useState } from 'react'; - -import NativeSelect from '@/components/NativeSelect'; -import { useSiteStore } from '@/store'; - -type ILocaleItem = ReturnType['locales'][0]; - -function getTargetLocalePath({ - pathname, - current, - target, -}: { - current: ILocaleItem; - pathname: string; - target: ILocaleItem; -}) { - const clearPath = - 'base' in current - ? // handle '/en-US/a' => '/a' or '/en-US' => '' => '/' - pathname.replace(current.base.replace(/\/$/, ''), '') || '/' - : pathname.replace(new RegExp(`${current.suffix}$`), ''); - - return 'base' in target - ? `${ - // for `/` base, strip duplicated leading slash - target.base.replace(/\/$/, '') - }${clearPath}` - // for `/` clearPath, strip duplicated ending slash - .replace(/([^/])\/$/, '$1') - : `${clearPath}${target.suffix}`; -} - -const languageMap: Record = { - 'de-DE': '🇩🇪', - 'en-US': '🇺🇸', - 'es-ES': '🇪🇸', - 'fr-FR': '🇫🇷', - 'it-IT': '🇮🇹', - 'jp-JP': '🇯🇵', - 'ko-KR': '🇰🇷', - 'pt-BR': '🇧🇷', - 'ru-RU': '🇷🇺', - 'tr-TR': '🇹🇷', - 'vi-VN': '🇻🇳', - 'zh-CN': '🇨🇳', -}; - -const displayLangMap: Record = { - 'en-US': 'EN', - 'zh-CN': '中', -}; - -const SingleSwitch = memo<{ current: ILocaleItem; locale: ILocaleItem }>(({ locale, current }) => { - const { pathname } = useLocation(); - const [path, setPath] = useState(() => - getTargetLocalePath({ current, pathname, target: locale }), - ); - - useEffect(() => { - setPath(getTargetLocalePath({ current, pathname, target: locale })); - }, [pathname, current.id, locale.id]); - - return ( - - - - ); -}); - -const LangSwitch = memo(() => { - const locales = useSiteStore((s) => s.siteData.locales); - const current = useSiteStore((s) => s.locale); - - // do not render in single language - if (locales.length <= 1) return; - - return locales.length > 2 ? ( - { - console.log( - getTargetLocalePath({ - current, - pathname: location.pathname, - target: locales[index], - }), - ); - - history.push( - getTargetLocalePath({ - current, - pathname: location.pathname, - target: locales[index], - }), - ); - }} - options={locales.map((item) => ({ - label: displayLangMap[item.id], - value: item.id, - }))} - renderItem={(item, index) => `${languageMap[locales[index].id]} ${locales[index].name}`} - style={{ - alignItems: 'center', - display: 'flex', - height: 32, - justifyContent: 'center', - minWidth: 32, - padding: 0, - }} - value={locales.findIndex((l) => l.id === current.id)} - /> - ) : ( - // single language switch - id !== current.id)!} /> - ); -}); - -export default LangSwitch; diff --git a/packages/dumi-theme-lobehub/src/slots/Header/ThemeSwitch.tsx b/packages/dumi-theme-lobehub/src/slots/Header/ThemeSwitch.tsx deleted file mode 100644 index 7ab69e89..00000000 --- a/packages/dumi-theme-lobehub/src/slots/Header/ThemeSwitch.tsx +++ /dev/null @@ -1,19 +0,0 @@ -import { ThemeSwitch as ThemeSwitchButton } from '@lobehub/ui'; -import { memo } from 'react'; - -import { useThemeStore } from '@/store/useThemeStore'; - -const ThemeSwitch = memo(() => { - const themeMode = useThemeStore((s) => s.themeMode); - - return ( - { - useThemeStore.setState({ themeMode }); - }} - themeMode={themeMode} - /> - ); -}); - -export default ThemeSwitch; diff --git a/packages/dumi-theme-lobehub/src/slots/Header/index.tsx b/packages/dumi-theme-lobehub/src/slots/Header/index.tsx deleted file mode 100644 index abc31e3d..00000000 --- a/packages/dumi-theme-lobehub/src/slots/Header/index.tsx +++ /dev/null @@ -1,42 +0,0 @@ -import { Header as Head } from '@lobehub/ui'; -import { useResponsive } from 'antd-style'; -import { memo } from 'react'; - -import Logo from '@/slots/Logo'; -import Navbar from '@/slots/Navbar'; -import SearchBar from '@/slots/SearchBar'; -import { useSiteStore } from '@/store/useSiteStore'; - -import Burger from './Burger'; -import GithubButton from './GithubButton'; -import LangSwitch from './LangSwitch'; -import ThemeSwitch from './ThemeSwitch'; - -const Header = memo(() => { - const hasHeader = useSiteStore((s) => Boolean(s.routeMeta.frontmatter)); - - const { mobile } = useResponsive(); - if (!hasHeader) return; - - return ( - - ) : ( - <> - {' '} - - - - - - ) - } - logo={} - nav={mobile ? : } - /> - ); -}); - -export default Header; diff --git a/packages/dumi-theme-lobehub/src/slots/Hero/index.tsx b/packages/dumi-theme-lobehub/src/slots/Hero/index.tsx deleted file mode 100644 index 35bb4910..00000000 --- a/packages/dumi-theme-lobehub/src/slots/Hero/index.tsx +++ /dev/null @@ -1,14 +0,0 @@ -import { Hero as H } from '@lobehub/ui'; -import { memo } from 'react'; - -import { heroActionsSel, heroDescSel, heroTitleSel, useSiteStore } from '@/store'; - -const Hero = memo(() => { - const title = useSiteStore(heroTitleSel); - const description = useSiteStore(heroDescSel); - const actions = useSiteStore(heroActionsSel); - - return ; -}); - -export default Hero; diff --git a/packages/dumi-theme-lobehub/src/slots/Logo/index.tsx b/packages/dumi-theme-lobehub/src/slots/Logo/index.tsx deleted file mode 100644 index bbac4d8c..00000000 --- a/packages/dumi-theme-lobehub/src/slots/Logo/index.tsx +++ /dev/null @@ -1,33 +0,0 @@ -import { Logo as SiteLogo } from '@lobehub/ui'; -import { useResponsive } from 'antd-style'; -import { Link } from 'dumi'; -import isEqual from 'fast-deep-equal'; -import { memo } from 'react'; - -import { useSiteStore } from '@/store/useSiteStore'; - -import { useStyles } from './style'; - -const Logo = memo(() => { - const themeConfig = useSiteStore((s) => s.siteData.themeConfig, isEqual); - const locale = useSiteStore((s) => s.locale, isEqual); - const { styles, cx } = useStyles(); - const { mobile } = useResponsive(); - - return ( - themeConfig && ( - - {themeConfig.logo ? ( - <> - - {themeConfig.name} - - ) : ( - - )} - - ) - ); -}); - -export default Logo; diff --git a/packages/dumi-theme-lobehub/src/slots/Logo/style.ts b/packages/dumi-theme-lobehub/src/slots/Logo/style.ts deleted file mode 100644 index 36a8f47a..00000000 --- a/packages/dumi-theme-lobehub/src/slots/Logo/style.ts +++ /dev/null @@ -1,18 +0,0 @@ -import { createStyles } from 'antd-style'; - -export const useStyles = createStyles( - ({ css, responsive, token }) => css` - display: inline-flex; - align-items: center; - - font-size: 22px; - font-weight: 500; - line-height: 1; - color: ${token.colorText}; - text-decoration: none; - - ${responsive.mobile} { - font-size: 18px; - } - `, -); diff --git a/packages/dumi-theme-lobehub/src/slots/Navbar/index.tsx b/packages/dumi-theme-lobehub/src/slots/Navbar/index.tsx deleted file mode 100644 index 2c305ba2..00000000 --- a/packages/dumi-theme-lobehub/src/slots/Navbar/index.tsx +++ /dev/null @@ -1,57 +0,0 @@ -import { TabsNav } from '@lobehub/ui'; -import { createStyles } from 'antd-style'; -import { Link, history } from 'dumi'; -import NavbarExtra from 'dumi/theme-default/slots/NavbarExtra'; -import { memo } from 'react'; -import { shallow } from 'zustand/shallow'; - -import { activePathSel, useSiteStore } from '@/store'; - -const useStyles = createStyles(({ css, stylish, token, responsive }) => { - return { - link: css` - ${stylish.resetLinkColor} - `, - tabs: css` - .ant-tabs-tab-active a { - color: ${token.colorText} !important; - } - ${responsive.mobile} { - display: none; - } - `, - }; -}); -const Navbar = memo(() => { - const { styles } = useStyles(); - - const nav = useSiteStore((s) => s.navData, shallow); - const activePath = useSiteStore(activePathSel); - - return ( - <> - ({ - key: String(item.activePath! || item.link), - label: ( - - {item.title} - - ), - }))} - onChange={(path) => { - const url = nav.find((index) => index.activePath === path || index.link === path)?.link; - - if (!url) return; - - history.push(url); - }} - /> - - - ); -}); - -export default Navbar; diff --git a/packages/dumi-theme-lobehub/src/slots/PreviewerActions/index.tsx b/packages/dumi-theme-lobehub/src/slots/PreviewerActions/index.tsx deleted file mode 100644 index 17ecf5ad..00000000 --- a/packages/dumi-theme-lobehub/src/slots/PreviewerActions/index.tsx +++ /dev/null @@ -1,96 +0,0 @@ -import { ActionIcon, TabsNav } from '@lobehub/ui'; -import { type IPreviewerProps, openCodeSandbox, openStackBlitz, useIntl } from 'dumi'; -import SourceCode from 'dumi/theme/builtins/SourceCode'; -import { Code, Code2, Codesandbox, MonitorUp, Zap } from 'lucide-react'; -import { type FC, type ReactNode, useState } from 'react'; - -import { useStyles } from './style'; - -const SIZE = { blockSize: 24, fontSize: 16, strokeWidth: 2 }; - -export interface IPreviewerActionsProps extends IPreviewerProps { - demoContainer: HTMLDivElement | HTMLIFrameElement; - /** - * disabled actions - */ - disabledActions?: ('CSB' | 'STACKBLITZ' | 'EXTERNAL' | 'HTML2SKETCH')[]; - extra?: ReactNode; - forceShowCode?: boolean; -} - -const PreviewerActions: FC = (props) => { - const intl = useIntl(); - const files = Object.entries(props.asset.dependencies).filter(([, { type }]) => type === 'FILE'); - const [activeKey, setActiveKey] = useState(0); - const [showCode, setShowCode] = useState(props.forceShowCode || props.defaultShowCode); - const isSingleFile = files.length === 1; - const lang = (files[activeKey][0].match(/\.([^.]+)$/)?.[1] || 'text') as any; - const { styles } = useStyles(); - - return ( - <> -
- {!props.disabledActions?.includes('CSB') && ( - openCodeSandbox(props)} - size={SIZE} - title={intl.formatMessage({ - id: 'previewer.actions.codesandbox', - })} - /> - )} - {!props.disabledActions?.includes('STACKBLITZ') && ( - openStackBlitz(props)} - size={SIZE} - title={intl.formatMessage({ - id: 'previewer.actions.stackblitz', - })} - /> - )} - {!props.disabledActions?.includes('EXTERNAL') && ( - - - - )} - {!props.forceShowCode && ( - setShowCode((previous) => !previous)} - size={SIZE} - title={intl.formatMessage({ - id: `previewer.actions.code.${showCode ? 'shrink' : 'expand'}`, - })} - /> - )} -
- {showCode && ( - <> -
- {!isSingleFile && ( - ({ - key: String(index), - label: filename, - }))} - onChange={(key) => setActiveKey(Number(key))} - /> - )} -
- {files[activeKey][1].value} - - )} - - ); -}; - -export default PreviewerActions; diff --git a/packages/dumi-theme-lobehub/src/slots/PreviewerActions/style.ts b/packages/dumi-theme-lobehub/src/slots/PreviewerActions/style.ts deleted file mode 100644 index be632568..00000000 --- a/packages/dumi-theme-lobehub/src/slots/PreviewerActions/style.ts +++ /dev/null @@ -1,20 +0,0 @@ -import { createStyles } from 'antd-style'; - -export const useStyles = createStyles(({ token, css }) => { - return { - actionBar: css` - display: flex; - gap: 8px; - align-items: center; - justify-content: center; - - height: 36px; - `, - tabs: css` - padding: 0 12px; - background: ${token.colorBgLayout}; - border-top: 1px dashed ${token.colorBorderSecondary}; - border-bottom: 1px dashed ${token.colorBorderSecondary}; - `, - }; -}); diff --git a/packages/dumi-theme-lobehub/src/slots/SearchBar/index.tsx b/packages/dumi-theme-lobehub/src/slots/SearchBar/index.tsx deleted file mode 100644 index 8742e475..00000000 --- a/packages/dumi-theme-lobehub/src/slots/SearchBar/index.tsx +++ /dev/null @@ -1,36 +0,0 @@ -import { SearchBar as Input } from '@lobehub/ui'; -import { useSiteSearch } from 'dumi'; -import SearchResult from 'dumi/theme-default/slots/SearchResult'; -import { memo, useState } from 'react'; - -import { useStyles } from './style'; - -const SearchBar = memo(() => { - const { styles } = useStyles(); - const [focusing, setFocusing] = useState(false); - const { keywords, setKeywords, result, loading } = useSiteSearch(); - - return ( -
- { - setTimeout(() => { - setFocusing(false); - }, 1); - }} - onChange={(e: any) => setKeywords(e.target.value)} - onFocus={() => setFocusing(true)} - spotlight - /> - - {keywords.trim() && focusing && (result.length > 0 || !loading) && ( -
- -
- )} -
- ); -}); - -export default SearchBar; diff --git a/packages/dumi-theme-lobehub/src/slots/SearchBar/style.ts b/packages/dumi-theme-lobehub/src/slots/SearchBar/style.ts deleted file mode 100644 index 55a837db..00000000 --- a/packages/dumi-theme-lobehub/src/slots/SearchBar/style.ts +++ /dev/null @@ -1,144 +0,0 @@ -import { createStyles } from 'antd-style'; - -export const useStyles = createStyles(({ token, responsive, css, cx }) => { - return { - container: css` - position: relative; - - // TODO: support search for mobile devices - ${responsive.mobile} { - display: none; - } - `, - input: css` - box-sizing: border-box; - width: 280px; - height: ${token.controlHeightLG}px; - padding: 0; - padding-inline-start: 40px; - padding-inline-end: 12px; - - font-size: 14px; - color: ${token.colorTextSecondary}; - - background-color: transparent; - border: 1px solid ${token.colorBorder}; - border-radius: 20px; - outline: none; - - transition: all 0.3s; - - &::input-placeholder { - color: ${token.colorTextPlaceholder}; - } - - &:focus { - background: ${token.colorBgElevated}; - border-color: ${token.colorBorderSecondary}; - - ~ .site-header-shortcut { - opacity: 0; - } - } - `, - popover: css` - position: absolute; - top: 100%; - inset-inline-end: 0; - - overflow: auto; - overscroll-behavior: contain; - flex: 1; - - width: 540px; - min-height: 60px; - max-height: 400px; - margin-top: 8px; - - background-color: ${token.colorBgElevated}; - border: 1px solid ${token.colorBorder}; - border-radius: ${token.borderRadiusLG}px; - box-shadow: ${token.boxShadow}; - - -webkit-overflow-scrolling: touch; - - .dumi-default-search-result { - > dl { - > dt { - color: ${token.colorText}; - background: ${token.colorFillTertiary}; - } - - > dd { - > a { - > h4 { - color: ${token.colorTextSecondary}; - } - - > p { - color: ${token.colorTextDescription}; - } - - &:hover { - background: ${token.colorFillSecondary}; - } - } - - + dd { - border-color: ${token.colorBorderSecondary}; - } - } - } - - mark { - color: #000; - background: ${token.yellow9}; - } - } - `, - - shortcut: cx( - 'site-header-shortcut', - css` - pointer-events: none; - - position: absolute; - top: 50%; - inset-inline-end: 11px; - transform: translateY(-50%); - - display: inline-block; - - padding: 4px 8px; - - font-size: 12px; - line-height: 1; - color: ${token.colorTextDescription}; - white-space: nowrap; - - background-color: ${token.colorFillSecondary}; - border: 1px solid ${token.colorBorderSecondary}; - border-radius: 11px; - - transition: all 0.3s; - - ${responsive.mobile} { - display: none; - } - `, - ), - svg: cx( - css` - position: absolute; - top: 50%; - inset-inline-start: 16px; - transform: translateY(-50%); - - width: 16px; - margin-top: 1px; - - color: ${token.colorTextPlaceholder}; - `, - ), - }; -}); diff --git a/packages/dumi-theme-lobehub/src/slots/Sidebar/index.tsx b/packages/dumi-theme-lobehub/src/slots/Sidebar/index.tsx deleted file mode 100644 index d1ac3a98..00000000 --- a/packages/dumi-theme-lobehub/src/slots/Sidebar/index.tsx +++ /dev/null @@ -1,32 +0,0 @@ -import { NavLink } from 'dumi'; -import isEqual from 'fast-deep-equal'; -import { memo } from 'react'; - -import { useSiteStore } from '@/store/useSiteStore'; - -import { useStyles } from './style'; - -const Sidebar = memo(() => { - const sidebar = useSiteStore((s) => s.sidebar, isEqual); - const { styles } = useStyles(); - const isEmptySideBar = !sidebar || sidebar.length === 0; - - return isEmptySideBar ? undefined : ( -
- {sidebar.map((item, index) => ( -
- {item.title &&
{item.title}
} - {item.children.map((child) => ( -
- - {child.title} - -
- ))} -
- ))} -
- ); -}); - -export default Sidebar; diff --git a/packages/dumi-theme-lobehub/src/slots/Sidebar/style.ts b/packages/dumi-theme-lobehub/src/slots/Sidebar/style.ts deleted file mode 100644 index 815e5068..00000000 --- a/packages/dumi-theme-lobehub/src/slots/Sidebar/style.ts +++ /dev/null @@ -1,86 +0,0 @@ -import { createStyles } from 'antd-style'; - -export const useStyles = createStyles(({ css, token }) => ({ - sidebar: css` - margin-top: ${token.headerHeight}px; - `, - sidebarInner: css` - overflow: auto; - width: 100%; - height: 100%; - padding: 16px; - - dl { - margin: 0; - padding: 0; - line-height: 1; - - > dt { - overflow: hidden; - - margin: 8px 0; - - font-weight: 500; - color: ${token.colorText}; - text-overflow: ellipsis; - text-transform: uppercase; - white-space: nowrap; - } - - > dd { - margin: 0; - padding: 2px 0; - - > a { - overflow: hidden; - display: block; - - padding: 6px 12px; - - font-size: ${token.fontSize}px; - line-height: ${token.lineHeight}; - color: ${token.colorTextSecondary}; - text-decoration: none; - text-overflow: ellipsis; - white-space: nowrap; - - border-radius: 6px; - - transition: color 600ms ${token.motionEaseOut}, - background-color 100ms ${token.motionEaseOut}; - - &:hover { - color: ${token.colorText}; - background: ${token.colorFillTertiary}; - } - - &:active { - color: ${token.colorText}; - background-color: ${token.colorFill}; - } - - &.active { - color: ${token.colorText}; - background-color: ${token.colorFillSecondary}; - - &:hover { - color: ${token.colorText}; - background: ${token.colorFillSecondary}; - } - - &:active { - color: ${token.colorText}; - background-color: ${token.colorFill}; - } - } - } - } - - + dl { - margin-top: 16px; - padding-top: 16px; - border-top: 1px dashed ${token.colorBorder}; - } - } - `, -})); diff --git a/packages/dumi-theme-lobehub/src/slots/Toc/index.tsx b/packages/dumi-theme-lobehub/src/slots/Toc/index.tsx deleted file mode 100644 index 7cc9bdd6..00000000 --- a/packages/dumi-theme-lobehub/src/slots/Toc/index.tsx +++ /dev/null @@ -1,37 +0,0 @@ -import { Toc as T } from '@lobehub/ui'; -import { useResponsive, useTheme } from 'antd-style'; -import isEqual from 'fast-deep-equal'; -import { memo, useEffect, useState } from 'react'; - -import { tocAnchorItemSel, useSiteStore } from '@/store'; - -const GAP = 48; - -const Toc = memo(() => { - const items = useSiteStore(tocAnchorItemSel, isEqual); - const { mobile } = useResponsive(); - const theme = useTheme(); - const [spacing, setSpacing] = useState(GAP); - - useEffect(() => { - const ApiTitle = document.querySelector('#api-header'); - if (ApiTitle) setSpacing(ApiTitle.clientHeight + GAP); - }, [window.location.href, items]); - - if (items?.length < 1) return; - - return ( - <> - {!mobile &&
} - document.body} - headerHeight={theme.headerHeight} - isMobile={mobile} - items={items} - tocWidth={theme.tocWidth} - /> - - ); -}); - -export default Toc; diff --git a/packages/dumi-theme-lobehub/src/store/index.ts b/packages/dumi-theme-lobehub/src/store/index.ts deleted file mode 100644 index 39e0a087..00000000 --- a/packages/dumi-theme-lobehub/src/store/index.ts +++ /dev/null @@ -1,20 +0,0 @@ -import { apiHeaderSel, flattenSidebarSel, tokenSel } from './selectors'; - -export * from './selectors'; -export * from './useSiteStore'; -export * from './useThemeStore'; - -/** - * @title 数据选择器 - */ -export const siteSelectors = { - /** - * @title API 头部选择器 - */ - apiHeader: apiHeaderSel, - /** - * @title 扁平化侧边栏选择器 - */ - flattenSidebar: flattenSidebarSel, - token: tokenSel, -}; diff --git a/packages/dumi-theme-lobehub/src/store/selectors/apiHeader.ts b/packages/dumi-theme-lobehub/src/store/selectors/apiHeader.ts deleted file mode 100644 index 5e31c043..00000000 --- a/packages/dumi-theme-lobehub/src/store/selectors/apiHeader.ts +++ /dev/null @@ -1,76 +0,0 @@ -import type { ApiHeaderProps } from '../../components/ApiHeader'; -import type { ApiHeaderConfig } from '../../types/config'; -import type { SiteStore } from '../useSiteStore'; -import { githubSel } from './siteBasicInfo'; - -export * from './hero'; - -const haseUrl = (config: false | string | undefined) => { - if (config === false) return false; - - return typeof config === 'string'; -}; - -export const isApiPageSel = (s: SiteStore) => { - const fm = s.routeMeta.frontmatter; - - if (s.siteData.themeConfig.apiHeader === false || fm.apiHeader === false) return false; - - if (fm.apiHeader) return true; - - const baseMatch = ['/api', '/components', ...(s.siteData.themeConfig.apiHeader?.match || [])]; - - return baseMatch.some((path) => s.location.pathname.startsWith(path)); -}; - -export const apiHeaderSel = (s: SiteStore): ApiHeaderProps => { - const REPO_BASE = githubSel(s); - const fm = s.routeMeta.frontmatter; - const localeId = s.locale.id; - - // 统一的路径匹配替换方法 - const replaceUrl = (rawString: string) => { - return rawString - .replace('{github}', REPO_BASE) - .replace('{atomId}', fm.atomId || '') - .replace('{title}', fm.title) - .replace('{locale}', localeId); - }; - - const { - pkg: package_ = s.siteData.pkg.name, - sourceUrl: sourceUrlMatch, - docUrl: documentUrlMatch, - } = (s.siteData.themeConfig.apiHeader || {}) as ApiHeaderConfig; - - // 1. 兜底默认使用文档的 apiHeader.pkg - // 2. 如果 themeConfig 里配置了 pkg, 则使用配置的 pkg - // 3. 兜底使用 package.json 中的 name - const displayPackage = fm.apiHeader?.pkg || package_; - - // 1. 默认使用文档的 fm.atomId - // 2. 兜底到文档 title - const componentName = fm.atomId || fm.title; - - // 1. 优先选择使用文档 apiHeader.defaultImport - // 2. 默认使用 false - const defaultImport = fm.apiHeader?.defaultImport || false; - - const sourceUrl = - fm.apiHeader?.sourceUrl || - (haseUrl(sourceUrlMatch) ? replaceUrl(sourceUrlMatch as string) : undefined); - - const documentUrl = - fm.apiHeader?.docUrl || - (haseUrl(documentUrlMatch) ? replaceUrl(documentUrlMatch as string) : undefined); - - return { - componentName, - defaultImport, - description: fm.description, - docUrl: documentUrl, - pkg: displayPackage, - sourceUrl, - title: fm.title, - }; -}; diff --git a/packages/dumi-theme-lobehub/src/store/selectors/hero.ts b/packages/dumi-theme-lobehub/src/store/selectors/hero.ts deleted file mode 100644 index b0fd3d67..00000000 --- a/packages/dumi-theme-lobehub/src/store/selectors/hero.ts +++ /dev/null @@ -1,65 +0,0 @@ -import { type FeatureItem } from '@lobehub/ui'; - -import { SiteStore } from '../useSiteStore'; - -export const isHeroPageSel = (s: SiteStore) => Boolean(s.routeMeta.frontmatter.hero); - -const localeValueSel = (s: SiteStore, value: any) => { - if (!value) return; - - if (value[s.locale.id]) return value[s.locale.id]; - - return value; -}; - -/** - * Hero Title 选择器 - * 选择逻辑:优先使用 hero 配置的 title, 再兜底到 themeConfig 中的 name - */ -export const heroTitleSel = (s: SiteStore) => - s.routeMeta.frontmatter.hero?.title || - // 从 hero 的 title 中选择 - localeValueSel(s, s.siteData.themeConfig.hero)?.title || - // @deprecated 1.0 正式版本移除 - // 从 hero 的 title 中选择 - localeValueSel(s, s.siteData.themeConfig.title) || - s.siteData.themeConfig.name; - -/** - * Hero description 选择器 - * 选择逻辑:优先使用 hero 配置的 description, 再兜底到 themeConfig 中的 name - */ -export const heroDescSel = (s: SiteStore) => - s.routeMeta.frontmatter.hero?.description || - // 从 hero 的 description 中选择 - localeValueSel(s, s.siteData.themeConfig.hero)?.description || - // @deprecated 1.0 正式版本移除 - // 从 hero 的 description 中选择 - localeValueSel(s, s.siteData.themeConfig.description); - -/** - * Hero Action 选择器 - * 选择逻辑:优先使用 hero 配置的 actions, 再兜底到 themeConfig 中的 actions - */ -export const heroActionsSel = (s: SiteStore) => - s.routeMeta.frontmatter.hero?.actions || - // 从 hero 的 actions 中选择 - localeValueSel(s, s.siteData.themeConfig.hero)?.actions || - // @deprecated 1.0 正式版本移除 - localeValueSel(s, s.siteData.themeConfig.actions); - -/** - * Features 选择器 - */ -export const featuresSel = (s: SiteStore): FeatureItem[] => { - if (!isHeroPageSel(s)) return []; - - return ( - localeValueSel(s, s.siteData.themeConfig.hero)?.features || - // @deprecated 1.0 正式版本移除 - localeValueSel(s, s.siteData.themeConfig.features) || - // 在themeConfig 没有配置的话,尝试兜底到 frontmatter 中的配置 - s.routeMeta.frontmatter.features || - [] - ); -}; diff --git a/packages/dumi-theme-lobehub/src/store/selectors/index.ts b/packages/dumi-theme-lobehub/src/store/selectors/index.ts deleted file mode 100644 index 6603fae7..00000000 --- a/packages/dumi-theme-lobehub/src/store/selectors/index.ts +++ /dev/null @@ -1,68 +0,0 @@ -import { ISidebarItem } from 'dumi/dist/client/theme-api/types'; - -import { AnchorItem } from '../../types'; -import { SiteStore } from '../useSiteStore'; - -export * from './apiHeader'; -export * from './hero'; -export * from './siteBasicInfo'; -export * from './token'; - -export const activePathSel = (s: SiteStore) => { - if (s.location.pathname === '/') return '/'; - - const item = s.navData - .filter((index) => index.link !== '/') - .find((index) => s.location.pathname.startsWith(String(index.activePath! || index.link))); - - return item?.activePath || item?.link || ''; -}; - -/** - * toc 锚点选择器 - * @param s - */ -export const tocAnchorItemSel = (s: SiteStore) => { - let { toc, frontmatter } = s.routeMeta; - - if (s.tabMeta?.toc) toc = s.tabMeta.toc; - - if (s.tabMeta?.frontmatter) frontmatter = s.tabMeta.frontmatter as any; - - const shouldKeepWith = (depth: number) => { - if (!frontmatter.tocDepth) return true; - - if (typeof frontmatter.tocDepth === 'number' && frontmatter.tocDepth > depth - 1) return true; - }; - - return toc.reduce((result, item) => { - if (item.depth === 2 && shouldKeepWith(2)) { - result.push({ ...item }); - } else if (item.depth === 3 && shouldKeepWith(3)) { - const parent = result.at(-1); - - if (parent) { - parent.children = parent.children || []; - parent.children.push({ ...item }); - } - } - - return result; - }, []); -}; - -/** - * 将 sidebar 信息扁平化 - * @param s - */ -export const flattenSidebarSel = (s: SiteStore): ISidebarItem[] => { - return s.sidebar?.map((index) => index.children).flat() || []; -}; - -export const contentBottomSel = (s: SiteStore) => { - const dataFlatten = flattenSidebarSel(s); - const path = s.location.pathname; - const currentIndex = dataFlatten.findIndex((item) => item.link === path); - - return { currentIndex, next: dataFlatten[currentIndex + 1], prev: dataFlatten[currentIndex - 1] }; -}; diff --git a/packages/dumi-theme-lobehub/src/store/selectors/siteBasicInfo.ts b/packages/dumi-theme-lobehub/src/store/selectors/siteBasicInfo.ts deleted file mode 100644 index 5c8f2f31..00000000 --- a/packages/dumi-theme-lobehub/src/store/selectors/siteBasicInfo.ts +++ /dev/null @@ -1,11 +0,0 @@ -import { SiteStore } from '../useSiteStore'; - -/** - * 站点标题选择器 - */ -export const siteTitleSel = (s: SiteStore) => s.siteData.themeConfig.title; - -export const githubSel = (s: SiteStore) => - // 优先取 socialLinks 里的 github - // TODO: 后面的 github 在 1.0 里废弃 - s.siteData.themeConfig.socialLinks?.github || s.siteData.themeConfig.github; diff --git a/packages/dumi-theme-lobehub/src/store/selectors/token.ts b/packages/dumi-theme-lobehub/src/store/selectors/token.ts deleted file mode 100644 index b25a072c..00000000 --- a/packages/dumi-theme-lobehub/src/store/selectors/token.ts +++ /dev/null @@ -1,9 +0,0 @@ -import { merge } from 'lodash-es'; - -import { SiteStore } from '../useSiteStore'; - -export const tokenSel = (s: SiteStore) => { - const fm = s.routeMeta.frontmatter; - - return merge({}, fm.token, s.siteData.themeConfig.siteToken); -}; diff --git a/packages/dumi-theme-lobehub/src/store/useSiteStore.ts b/packages/dumi-theme-lobehub/src/store/useSiteStore.ts deleted file mode 100644 index 0f13b0ba..00000000 --- a/packages/dumi-theme-lobehub/src/store/useSiteStore.ts +++ /dev/null @@ -1,98 +0,0 @@ -import { AtomAsset } from 'dumi-assets-types'; -import { - ILocale, - ILocalesConfig, - INavItem, - IPreviewerProps, - IRouteMeta, - ISidebarGroup, - IThemeConfig, -} from 'dumi/dist/client/theme-api/types'; -import { PICKED_PKG_FIELDS } from 'dumi/dist/constants'; -import type { Location } from 'history'; -import { ComponentType } from 'react'; -import { create } from 'zustand'; -import { devtools } from 'zustand/middleware'; - -export type NavData = (INavItem & { children?: INavItem[] | undefined })[]; - -export interface ISiteData { - components: Record; - demos: Record< - string, - { - asset: IPreviewerProps['asset']; - component: ComponentType; - routeId: string; - } - >; - entryExports: Record; - - loading: boolean; - locales: ILocalesConfig; - pkg: Partial>; - setLoading: (status: boolean) => void; - themeConfig: IThemeConfig; -} - -export interface SiteStore { - locale: ILocale; - location: Location; - navData: NavData; - routeMeta: IRouteMeta; - sidebar?: ISidebarGroup[]; - siteData: ISiteData; - tabMeta?: NonNullable[0]['meta']; -} - -const initialState: SiteStore = { - locale: { id: 'zh-CN', name: '中文', suffix: '' }, - location: { - hash: '', - key: '', - pathname: '', - search: '', - state: '', - }, - navData: [], - - routeMeta: { - // @ts-ignore - frontmatter: {}, - - tabs: undefined, - - texts: [], - - toc: [], - }, - - sidebar: [], - - siteData: { - components: {}, - - demos: {}, - - entryExports: {}, - - loading: true, - - locales: [], - - pkg: {}, - // @ts-ignore - setLoading: undefined, - // @ts-ignore - themeConfig: {}, - }, -}; - -export const useSiteStore = create()( - devtools( - () => ({ - ...initialState, - }), - { name: '@' }, - ), -); diff --git a/packages/dumi-theme-lobehub/src/store/useThemeStore.ts b/packages/dumi-theme-lobehub/src/store/useThemeStore.ts deleted file mode 100644 index 7f0b2822..00000000 --- a/packages/dumi-theme-lobehub/src/store/useThemeStore.ts +++ /dev/null @@ -1,15 +0,0 @@ -import type { ThemeMode } from 'antd-style'; -import { create } from 'zustand'; -import { persist } from 'zustand/middleware'; - -interface Store { - themeMode: ThemeMode; -} -export const useThemeStore = create()( - persist( - () => ({ - themeMode: 'auto' as ThemeMode, - }), - { name: 'ANTD_STYLE_DOC_STORE' }, - ), -); diff --git a/packages/dumi-theme-lobehub/src/styles/customToken.ts b/packages/dumi-theme-lobehub/src/styles/customToken.ts deleted file mode 100644 index 5c5d17d8..00000000 --- a/packages/dumi-theme-lobehub/src/styles/customToken.ts +++ /dev/null @@ -1,19 +0,0 @@ -import { GetCustomToken } from 'antd-style'; - -export interface SiteCustomToken { - contentMaxWidth: number; - footerHeight: number; - headerHeight: number; - sidebarWidth: number; - tocWidth: number; -} - -const generateCustomToken: GetCustomToken = () => ({ - contentMaxWidth: 960, - footerHeight: 300, - headerHeight: 64, - sidebarWidth: 240, - tocWidth: 176, -}); - -export default generateCustomToken; diff --git a/packages/dumi-theme-lobehub/src/types/config.ts b/packages/dumi-theme-lobehub/src/types/config.ts deleted file mode 100644 index 5816a927..00000000 --- a/packages/dumi-theme-lobehub/src/types/config.ts +++ /dev/null @@ -1,112 +0,0 @@ -import { FooterColumn } from 'rc-footer/es/column'; - -import { SiteCustomToken } from '../styles/customToken'; -import { IHero } from './hero'; - -export interface ApiHeaderConfig { - /** - * @title 文档链接 - * @description 点击 ApiHeader 组件的文档链接跳转的地址 - */ - docUrl?: string | false; - /** - * @title 匹配路由 - * @description ApiHeader 组件的匹配路由 - * @default ["/api", "/components"] - */ - match?: string[]; - /** - * @title 组件库包名 - * @description 可以从 package.json 中引入名称 - */ - pkg?: string; - /** - * @title 源代码链接 - * @description 点击 ApiHeader 组件的源代码链接跳转的地址 - */ - sourceUrl?: string | false; -} - -/** - * @title 页面底部 Footer 组件的配置 - */ -export interface IFooter { - /** - * @title 底部内容 - */ - bottom?: string; - /** - * @title 列配置 - */ - columns?: FooterColumn[] | false; - /** - * @title 主题 - * @enum ['dark', 'light'] - * @enumNames ['黑色', '白色'] - */ - theme?: 'dark' | 'light'; -} - -/** - * 网站主题配置 - */ -export interface SiteThemeConfig { - /** - * API 文档页头部配置 - * @type ApiHeaderConfig | false - */ - apiHeader?: ApiHeaderConfig | false; - /** - * 网站页脚 - * @type string | false - */ - footer?: string | false; - /** - * 网站页脚配置 - * @type IFooter - */ - footerConfig?: IFooter; - /** - * 导航栏 Github 图标链接,如不配置该字段,则不展示。 - */ - github?: string; - /** - * 网站首页头部 - * @type IHero | Record - */ - hero?: IHero | Record; - /** - * 是否隐藏首页的 nav tab,配置为 `false` 则不展示首页的 tab - */ - hideHomeNav?: boolean; - /** - * 网站 logo 图片链接 - */ - logo?: string; - /** - * 网站名称 - */ - name?: string; - - /** - * 网站主题 Token 配置 - */ - siteToken?: SiteConfigToken; - socialLinks?: { - facebook?: string; - github?: string; - gitlab?: string; - linkedin?: string; - twitter?: string; - weibo?: string; - yueque?: string; - zhihu?: string; - }; -} - -export type SiteConfigToken = Partial< - Pick< - SiteCustomToken, - 'headerHeight' | 'footerHeight' | 'sidebarWidth' | 'tocWidth' | 'contentMaxWidth' - > ->; diff --git a/packages/dumi-theme-lobehub/src/types/global.d.ts b/packages/dumi-theme-lobehub/src/types/global.d.ts deleted file mode 100644 index 6e85f720..00000000 --- a/packages/dumi-theme-lobehub/src/types/global.d.ts +++ /dev/null @@ -1,16 +0,0 @@ -import type { LobeCustomStylish, LobeCustomToken } from '@lobehub/ui'; -import 'antd-style'; -import { AntdToken } from 'antd-style/lib/types/theme'; - -import { SiteCustomToken } from '@/styles/customToken'; - -declare module 'antd-style' { - // eslint-disable-next-line @typescript-eslint/no-empty-interface - export interface CustomToken extends LobeCustomToken, SiteCustomToken {} - // eslint-disable-next-line @typescript-eslint/no-empty-interface - export interface CustomStylish extends LobeCustomStylish {} -} - -declare module 'styled-components' { - export interface DefaultTheme extends AntdToken, LobeCustomToken, SiteCustomToken {} -} diff --git a/packages/dumi-theme-lobehub/src/types/hero.ts b/packages/dumi-theme-lobehub/src/types/hero.ts deleted file mode 100644 index ab9fd77e..00000000 --- a/packages/dumi-theme-lobehub/src/types/hero.ts +++ /dev/null @@ -1,10 +0,0 @@ -import { type FeatureItem, type HeroAction } from '@lobehub/ui'; - -export type ImageContainerType = 'light' | 'primary' | 'soon'; - -export interface IHero { - actions: HeroAction[]; - description?: string; - features?: FeatureItem[]; - title?: string; -} diff --git a/packages/dumi-theme-lobehub/src/types/index.ts b/packages/dumi-theme-lobehub/src/types/index.ts deleted file mode 100644 index d79dab49..00000000 --- a/packages/dumi-theme-lobehub/src/types/index.ts +++ /dev/null @@ -1,33 +0,0 @@ -import { type HTMLAttributes } from 'react'; - -export * from './config'; -export * from './hero'; - -/** - * @title 锚点项 - */ -export interface AnchorItem { - /** - * @title 子锚点项 - * @description 若存在子锚点项,则该锚点项为父锚点项 - */ - children?: AnchorItem[]; - /** - * @title 锚点项 ID - */ - id: string; - /** - * @title 锚点项标题 - */ - title: string; -} - -export type DivProps = HTMLAttributes; - -export type SvgProps = HTMLAttributes; - -export type ImgProps = HTMLAttributes; - -export type InputProps = HTMLAttributes; - -export type TextAreaProps = HTMLAttributes; diff --git a/packages/dumi-theme-lobehub/tsconfig-check.json b/packages/dumi-theme-lobehub/tsconfig-check.json deleted file mode 100644 index 09029c65..00000000 --- a/packages/dumi-theme-lobehub/tsconfig-check.json +++ /dev/null @@ -1,7 +0,0 @@ -{ - "compilerOptions": { - "noEmit": true - }, - "exclude": ["example"], - "extends": "./tsconfig.json" -} diff --git a/packages/dumi-theme-lobehub/tsconfig.json b/packages/dumi-theme-lobehub/tsconfig.json deleted file mode 100644 index 94415f2f..00000000 --- a/packages/dumi-theme-lobehub/tsconfig.json +++ /dev/null @@ -1,21 +0,0 @@ -{ - "compilerOptions": { - "baseUrl": ".", - "declaration": true, - "downlevelIteration": true, - "esModuleInterop": true, - "jsx": "react-jsx", - "lib": ["dom", "dom.iterable", "esnext"], - "paths": { - "@@/*": ["../../.dumi/tmp/*"], - "@/*": ["src/*"], - "dumi/theme/*": ["../../.dumi/tmp/dumi/theme/*"], - "@lobehub/ui": ["../../src"], - "@lobehub/ui/*": ["../../src/*", "*"] - }, - "resolveJsonModule": true, - "skipLibCheck": true, - "strict": true - }, - "include": ["src", "typings", "../../.dumi/**/*", "*.ts"] -} diff --git a/pnpm-workspace.yaml b/pnpm-workspace.yaml deleted file mode 100644 index 27cbc3b2..00000000 --- a/pnpm-workspace.yaml +++ /dev/null @@ -1,3 +0,0 @@ -packages: - - 'packages/**' - - . diff --git a/src/ActionIcon/style.ts b/src/ActionIcon/style.ts index f5d6ecfd..28ff0b93 100644 --- a/src/ActionIcon/style.ts +++ b/src/ActionIcon/style.ts @@ -19,7 +19,9 @@ export const useStyles = createStyles( background: ${active ? token.colorFillTertiary : 'transparent'}; - transition: color 600ms ${token.motionEaseOut}, scale 400ms ${token.motionEaseOut}, + transition: + color 600ms ${token.motionEaseOut}, + scale 400ms ${token.motionEaseOut}, background-color 100ms ${token.motionEaseOut}; &:hover { diff --git a/src/CodeEditor/style.ts b/src/CodeEditor/style.ts index 689fce0d..780a24c9 100644 --- a/src/CodeEditor/style.ts +++ b/src/CodeEditor/style.ts @@ -12,7 +12,8 @@ export const useStyles = createStyles( border: 1px solid ${type === 'block' ? 'transparent' : token.colorBorderSecondary}; border-radius: ${token.borderRadius}px; - transition: background-color 100ms ${token.motionEaseOut}, + transition: + background-color 100ms ${token.motionEaseOut}, border-color 200ms ${token.motionEaseOut}; &:hover { diff --git a/src/ColorScales/style.ts b/src/ColorScales/style.ts index 3f71671d..a1702b98 100644 --- a/src/ColorScales/style.ts +++ b/src/ColorScales/style.ts @@ -15,7 +15,11 @@ export const useStyles = createStyles(({ css, token }) => ({ width: 48px; height: 32px; - background-position: 0 0, 0 8px, 8px -8px, -8px 0; + background-position: + 0 0, + 0 8px, + 8px -8px, + -8px 0; background-size: 16px 16px; transition: scale 400ms ${token.motionEaseOut}; diff --git a/src/GradientButton/style.ts b/src/GradientButton/style.ts index 5bf467f2..ad14d3d7 100644 --- a/src/GradientButton/style.ts +++ b/src/GradientButton/style.ts @@ -32,7 +32,9 @@ export const useStyles = createStyles(({ css, token, isDarkMode, stylish }) => { padding: 1px; - mask: linear-gradient(#fff 0 0) content-box, linear-gradient(#fff 0 0); + mask: + linear-gradient(#fff 0 0) content-box, + linear-gradient(#fff 0 0); mask-composite: xor; } diff --git a/src/Header/style.ts b/src/Header/style.ts index 5a336aa9..9efde3e5 100644 --- a/src/Header/style.ts +++ b/src/Header/style.ts @@ -12,13 +12,11 @@ export const useStyles = createStyles(({ css, responsive, token, cx }) => ({ padding: 0 12px; } `, - header: cx( - css` - grid-area: head; - align-self: stretch; - width: 100%; - `, - ), + header: cx(css` + grid-area: head; + align-self: stretch; + width: 100%; + `), left: css` z-index: 10; `, diff --git a/src/Input/style.ts b/src/Input/style.ts index 869ef2c6..048cf2d4 100644 --- a/src/Input/style.ts +++ b/src/Input/style.ts @@ -5,7 +5,8 @@ export const useStyles = createStyles( const typeStylish = css` background-color: ${type === 'block' ? token.colorFillTertiary : 'transparent'}; border: 1px solid ${type === 'block' ? 'transparent' : token.colorBorder}; - transition: background-color 100ms ${token.motionEaseOut}, + transition: + background-color 100ms ${token.motionEaseOut}, border-color 200ms ${token.motionEaseOut}; &:hover { diff --git a/src/SideNav/style.ts b/src/SideNav/style.ts index 25028ff5..977ae4bf 100644 --- a/src/SideNav/style.ts +++ b/src/SideNav/style.ts @@ -1,20 +1,19 @@ import { createStyles } from 'antd-style'; export const useStyles = createStyles( - ({ css, token }) => - css` - display: flex; - flex: none; - flex-direction: column; - align-items: center; - justify-content: space-between; + ({ css, token }) => css` + display: flex; + flex: none; + flex-direction: column; + align-items: center; + justify-content: space-between; - width: 64px; - height: 100%; - min-height: 640px; - padding: 16px 0; + width: 64px; + height: 100%; + min-height: 640px; + padding: 16px 0; - background: ${token.colorBgContainer}; - border-right: 1px solid ${token.colorBorder}; - `, + background: ${token.colorBgContainer}; + border-right: 1px solid ${token.colorBorder}; + `, );