From 15f2803f8b440f6a285e8cd353cdf94ef2acee5c Mon Sep 17 00:00:00 2001 From: canisminor1990 Date: Mon, 5 Jun 2023 18:06:30 +0800 Subject: [PATCH] =?UTF-8?q?=E2=99=BB=EF=B8=8F=20refactor(dumi-theme):=20sp?= =?UTF-8?q?lit=20site=20token=20and=20stylish?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/ISSUE_TEMPLATE/1_bug_report.yml | 20 ++-- .github/ISSUE_TEMPLATE/2_feature_request.yml | 14 +-- .github/ISSUE_TEMPLATE/3_question.yml | 12 +- .github/dependabot.yml | 10 +- .github/workflows/contributor-help.yml | 2 +- .github/workflows/issue-check-inactive.yml | 8 +- .github/workflows/issue-close-require.yml | 6 +- .github/workflows/issue-remove-inactive.yml | 6 +- package.json | 12 +- .../src/builtins/SourceCode/index.tsx | 1 + .../src/components/ApiHeader/index.tsx | 2 +- .../src/components/Features/Item.tsx | 2 +- .../src/components/Features/index.tsx | 2 +- .../src/components/Hero/HeroButton/index.tsx | 1 + .../src/components/NativeSelect/index.tsx | 8 +- .../src/components/Toc/style.ts | 1 + .../src/layouts/DocLayout/index.tsx | 9 +- .../src/pages/Home/index.tsx | 1 + .../dumi-theme-lobehub/src/plugin/index.ts | 1 + .../src/slots/ContentFooter/index.tsx | 1 + .../src/slots/ContentTabs/index.tsx | 2 +- .../src/slots/ContentTabs/style.ts | 1 + .../src/slots/Features/index.tsx | 2 +- .../src/slots/Footer/columns.tsx | 1 + .../src/slots/Footer/index.tsx | 1 + .../src/slots/Header/index.tsx | 2 +- .../src/slots/Navbar/index.tsx | 2 + .../src/slots/SearchBar/Mask.tsx | 3 +- .../src/store/selectors/apiHeader.ts | 2 +- .../src/store/selectors/hero.ts | 2 +- .../src/store/selectors/index.ts | 4 + .../src/styles/customStylish.ts | 103 ++++++++++++++++++ .../src/styles/customToken.ts | 37 +++++++ src/ActionIcon/demos/CustomSize.tsx | 1 + src/ActionIcon/demos/index.tsx | 1 + src/ActionIcon/index.tsx | 1 + src/Chat/store/messageReducer.test.ts | 6 + src/Chat/store/messageReducer.ts | 4 + src/Chat/store/store.ts | 7 ++ src/Chat/utils/fetch.ts | 2 + src/ColorScales/ScaleRow.tsx | 2 + src/ColorScales/index.tsx | 5 +- src/ContextMenu/MenuItem/index.tsx | 1 + src/ContextMenu/index.tsx | 2 + .../ChatList/MessageItem/Content.tsx | 3 +- src/Conversation/ChatList/index.tsx | 2 +- src/Conversation/InputArea/index.tsx | 1 + src/DraggablePanel/demos/index.tsx | 1 + src/DraggablePanel/index.tsx | 1 + src/EditableMessage/demos/index.tsx | 2 + src/EditableText/index.tsx | 1 + src/Highlighter/demos/index.tsx | 2 + src/Icon/demos/CustomSize.tsx | 1 + src/Icon/demos/index.tsx | 1 + src/Icon/index.tsx | 2 + src/Input/demos/TextArea.tsx | 1 + src/Input/demos/index.tsx | 1 + src/Input/index.tsx | 2 + src/Logo/demos/ExtraText.tsx | 1 + src/Logo/demos/index.tsx | 1 + src/Logo/index.tsx | 1 + src/Markdown/Code.tsx | 1 + src/Markdown/CodeBlock.tsx | 2 + src/Markdown/demos/index.tsx | 1 + src/Markdown/index.tsx | 1 + src/MessageModal/demos/index.tsx | 1 + src/SearchBar/demos/index.tsx | 1 + src/SearchBar/index.tsx | 4 +- src/SideNav/demos/index.tsx | 1 + src/SideNav/index.tsx | 1 + src/Snippet/demos/index.tsx | 1 + src/StroyBook/demos/index.tsx | 1 + src/StroyBook/index.tsx | 1 + src/TabsNav/index.tsx | 1 + src/ThemeProvider/index.tsx | 51 +++++---- src/ThemeSwitch/demos/index.tsx | 1 + src/ThemeSwitch/index.tsx | 3 +- src/Tooltip/demos/index.tsx | 1 + src/Tooltip/index.tsx | 1 + src/hooks/useHighlight.ts | 2 + src/styles/algorithms/generateColorPalette.ts | 1 + .../algorithms/generateCustomStylish.ts | 83 -------------- src/styles/algorithms/generateCustomToken.ts | 29 ++--- src/styles/theme/base.ts | 1 + src/types/customStylish.d.ts | 10 -- src/types/customToken.d.ts | 13 +-- src/utils/colorUtils.ts | 1 + 87 files changed, 341 insertions(+), 210 deletions(-) create mode 100644 packages/dumi-theme-lobehub/src/styles/customStylish.ts create mode 100644 packages/dumi-theme-lobehub/src/styles/customToken.ts diff --git a/.github/ISSUE_TEMPLATE/1_bug_report.yml b/.github/ISSUE_TEMPLATE/1_bug_report.yml index c8aa08e7..d181c387 100644 --- a/.github/ISSUE_TEMPLATE/1_bug_report.yml +++ b/.github/ISSUE_TEMPLATE/1_bug_report.yml @@ -1,11 +1,11 @@ -name: "🐛 反馈缺陷 Bug Report" -description: "反馈一个问题缺陷 | Report an bug" -title: "[Bug] " -labels: "🐛 Bug" +name: '🐛 反馈缺陷 Bug Report' +description: '反馈一个问题缺陷 | Report an bug' +title: '[Bug] ' +labels: '🐛 Bug' body: - type: dropdown attributes: - label: "💻 系统环境 | Operating System" + label: '💻 系统环境 | Operating System' options: - Windows - macOS @@ -16,7 +16,7 @@ body: required: true - type: dropdown attributes: - label: "🌐 浏览器 | Browser" + label: '🌐 浏览器 | Browser' options: - Chrome - Edge @@ -27,19 +27,19 @@ body: required: true - type: textarea attributes: - label: "🐛 问题描述 | Bug Description" + label: '🐛 问题描述 | Bug Description' description: A clear and concise description of the bug. validations: required: true - type: textarea attributes: - label: "🚦 期望结果 | Expected Behavior" + label: '🚦 期望结果 | Expected Behavior' description: A clear and concise description of what you expected to happen. - type: textarea attributes: - label: "📷 复现步骤 | Recurrence Steps" + label: '📷 复现步骤 | Recurrence Steps' description: A clear and concise description of how to recurrence. - type: textarea attributes: - label: "📝 补充信息 | Additional Information" + label: '📝 补充信息 | Additional Information' description: If your problem needs further explanation, or if the issue you're seeing cannot be reproduced in a gist, please add more information here. diff --git a/.github/ISSUE_TEMPLATE/2_feature_request.yml b/.github/ISSUE_TEMPLATE/2_feature_request.yml index b1a9d1e2..edcf7d06 100644 --- a/.github/ISSUE_TEMPLATE/2_feature_request.yml +++ b/.github/ISSUE_TEMPLATE/2_feature_request.yml @@ -1,21 +1,21 @@ -name: "🌠 功能需求 Feature Request" -description: "需求或建议 | Suggest an idea" -title: "[Request] " -labels: "🌠 Feature Request" +name: '🌠 功能需求 Feature Request' +description: '需求或建议 | Suggest an idea' +title: '[Request] ' +labels: '🌠 Feature Request' body: - type: textarea attributes: - label: "🥰 需求描述 | Feature Description" + label: '🥰 需求描述 | Feature Description' description: Please add a clear and concise description of the problem you are seeking to solve with this feature request. validations: required: true - type: textarea attributes: - label: "🧐 解决方案 | Proposed Solution" + label: '🧐 解决方案 | Proposed Solution' description: Describe the solution you'd like in a clear and concise manner. validations: required: true - type: textarea attributes: - label: "📝 补充信息 | Additional Information" + label: '📝 补充信息 | Additional Information' description: Add any other context about the problem here. diff --git a/.github/ISSUE_TEMPLATE/3_question.yml b/.github/ISSUE_TEMPLATE/3_question.yml index 687666d0..f989f7d1 100644 --- a/.github/ISSUE_TEMPLATE/3_question.yml +++ b/.github/ISSUE_TEMPLATE/3_question.yml @@ -1,15 +1,15 @@ -name: "😇 疑问或帮助 Help Wanted" -description: "疑问或需要帮助 | Need help" -title: "[Question] " -labels: "😇 Help Wanted" +name: '😇 疑问或帮助 Help Wanted' +description: '疑问或需要帮助 | Need help' +title: '[Question] ' +labels: '😇 Help Wanted' body: - type: textarea attributes: - label: "🧐 问题描述 | Proposed Solution" + label: '🧐 问题描述 | Proposed Solution' description: A clear and concise description of the proplem. validations: required: true - type: textarea attributes: - label: "📝 补充信息 | Additional Information" + label: '📝 补充信息 | Additional Information' description: Add any other context about the problem here. diff --git a/.github/dependabot.yml b/.github/dependabot.yml index 73470e5f..c7658091 100644 --- a/.github/dependabot.yml +++ b/.github/dependabot.yml @@ -1,17 +1,17 @@ version: 2 updates: - package-ecosystem: npm - directory: "/" + directory: '/' schedule: interval: monthly - time: "19:00" + time: '19:00' timezone: 'Asia/Shanghai' open-pull-requests-limit: 10 versioning-strategy: increase - - package-ecosystem: "github-actions" - directory: "/" + - package-ecosystem: 'github-actions' + directory: '/' schedule: interval: monthly - time: "19:00" + time: '19:00' timezone: 'Asia/Shanghai' diff --git a/.github/workflows/contributor-help.yml b/.github/workflows/contributor-help.yml index 99306066..fd68fec3 100644 --- a/.github/workflows/contributor-help.yml +++ b/.github/workflows/contributor-help.yml @@ -2,7 +2,7 @@ name: Contributor Helper on: # 🌏 Think about the planet! No need to update stats too frequently - schedule: [{cron: "0 18 * * *"}] + schedule: [{ cron: '0 18 * * *' }] # 💡 The following line lets you run workflow manually from the action tab! workflow_dispatch: jobs: diff --git a/.github/workflows/issue-check-inactive.yml b/.github/workflows/issue-check-inactive.yml index 2621364b..d37c4c30 100644 --- a/.github/workflows/issue-check-inactive.yml +++ b/.github/workflows/issue-check-inactive.yml @@ -2,7 +2,7 @@ name: Issue Check Inactive on: schedule: - - cron: "0 0 */15 * *" + - cron: '0 0 */15 * *' permissions: contents: read @@ -10,8 +10,8 @@ permissions: jobs: issue-check-inactive: permissions: - issues: write # for actions-cool/issues-helper to update issues - pull-requests: write # for actions-cool/issues-helper to update PRs + issues: write # for actions-cool/issues-helper to update issues + pull-requests: write # for actions-cool/issues-helper to update PRs runs-on: ubuntu-latest steps: - name: check-inactive @@ -19,4 +19,4 @@ jobs: with: actions: 'check-inactive' inactive-label: 'Inactive' - inactive-day: 30 \ No newline at end of file + inactive-day: 30 diff --git a/.github/workflows/issue-close-require.yml b/.github/workflows/issue-close-require.yml index 1b923979..68d6b6ce 100644 --- a/.github/workflows/issue-close-require.yml +++ b/.github/workflows/issue-close-require.yml @@ -2,7 +2,7 @@ name: Issue Close Require on: schedule: - - cron: "0 0 * * *" + - cron: '0 0 * * *' permissions: contents: read @@ -10,8 +10,8 @@ permissions: jobs: issue-close-require: permissions: - issues: write # for actions-cool/issues-helper to update issues - pull-requests: write # for actions-cool/issues-helper to update PRs + issues: write # for actions-cool/issues-helper to update issues + pull-requests: write # for actions-cool/issues-helper to update PRs runs-on: ubuntu-latest steps: - name: need reproduce diff --git a/.github/workflows/issue-remove-inactive.yml b/.github/workflows/issue-remove-inactive.yml index 3b25e9d0..dbe42ddb 100644 --- a/.github/workflows/issue-remove-inactive.yml +++ b/.github/workflows/issue-remove-inactive.yml @@ -12,8 +12,8 @@ permissions: jobs: issue-remove-inactive: permissions: - issues: write # for actions-cool/issues-helper to update issues - pull-requests: write # for actions-cool/issues-helper to update PRs + issues: write # for actions-cool/issues-helper to update issues + pull-requests: write # for actions-cool/issues-helper to update PRs runs-on: ubuntu-latest steps: - name: remove inactive @@ -22,4 +22,4 @@ jobs: with: actions: 'remove-labels' issue-number: ${{ github.event.issue.number }} - labels: 'Inactive' \ No newline at end of file + labels: 'Inactive' diff --git a/package.json b/package.json index 6964ec87..7cec0c0c 100644 --- a/package.json +++ b/package.json @@ -39,13 +39,13 @@ "doctor": "father doctor", "lint": "eslint \"{src,tests,packages}/**/*.{js,jsx,ts,tsx}\" --fix", "lint:md": "remark . -f -q", + "lint:style": "stylelint \"{src,tests,packages}/**/*.{js,jsx,ts,tsx}\" --fix", "prepare": "husky install && npm run setup", "prepublishOnly": "father doctor && npm run build", "prettier": "prettier -c --write \"**/**\"", "release": "semantic-release", "setup": "dumi setup", "start": "dumi dev", - "stylelint": "stylelint \"{src,tests,packages}/**/*.{js,jsx,ts,tsx}\" --fix", "test": "vitest --passWithNoTests", "test:coverage": "vitest run --coverage --passWithNoTests", "test:update": "vitest -u", @@ -60,14 +60,12 @@ "prettier --write --no-error-on-unmatched-pattern" ], "*.{js,jsx}": [ - "eslint --fix", - "stylelint --fix", - "prettier --write" + "prettier --write", + "eslint --fix" ], "*.{ts,tsx}": [ - "eslint --fix", - "stylelint --fix", - "prettier --parser=typescript --write" + "prettier --parser=typescript --write", + "eslint --fix" ] }, "dependencies": { diff --git a/packages/dumi-theme-lobehub/src/builtins/SourceCode/index.tsx b/packages/dumi-theme-lobehub/src/builtins/SourceCode/index.tsx index d0bb814d..9f1e3c17 100644 --- a/packages/dumi-theme-lobehub/src/builtins/SourceCode/index.tsx +++ b/packages/dumi-theme-lobehub/src/builtins/SourceCode/index.tsx @@ -10,6 +10,7 @@ interface SourceCodeProps { const SourceCode: FC = ({ children, lang }) => { const theme = useTheme(); + return ( {children} diff --git a/packages/dumi-theme-lobehub/src/components/ApiHeader/index.tsx b/packages/dumi-theme-lobehub/src/components/ApiHeader/index.tsx index 633213d8..bacd43ef 100644 --- a/packages/dumi-theme-lobehub/src/components/ApiHeader/index.tsx +++ b/packages/dumi-theme-lobehub/src/components/ApiHeader/index.tsx @@ -2,7 +2,7 @@ import { Icon, Snippet } from '@lobehub/ui'; import { Divider, Space, Typography } from 'antd'; import { useResponsive } from 'antd-style'; import { Edit3, Github } from 'lucide-react'; -import { ReactNode, memo } from 'react'; +import { memo, type ReactNode } from 'react'; import { Flexbox } from 'react-layout-kit'; import { ApiHeaderProps } from '@/index'; diff --git a/packages/dumi-theme-lobehub/src/components/Features/Item.tsx b/packages/dumi-theme-lobehub/src/components/Features/Item.tsx index 6616a5a4..c9357f8a 100644 --- a/packages/dumi-theme-lobehub/src/components/Features/Item.tsx +++ b/packages/dumi-theme-lobehub/src/components/Features/Item.tsx @@ -21,7 +21,7 @@ const Image = memo<{ className?: string; image: string; title: string }>( const FeatureItem = memo( ({ imageType, row, column, hero, description, image, title, link, imageStyle, openExternal }) => { const rowNum = row || 7; - const { styles, theme } = useStyles({ rowNum, hasLink: !!link }); + const { styles, theme } = useStyles({ rowNum, hasLink: Boolean(link) }); return (
(({ items, style }) => { const { styles } = useStyles(); - if (!Boolean(items?.length)) return null; + if (!items?.length) return null; return (
diff --git a/packages/dumi-theme-lobehub/src/components/Hero/HeroButton/index.tsx b/packages/dumi-theme-lobehub/src/components/Hero/HeroButton/index.tsx index 49f2f058..f6b241af 100644 --- a/packages/dumi-theme-lobehub/src/components/Hero/HeroButton/index.tsx +++ b/packages/dumi-theme-lobehub/src/components/Hero/HeroButton/index.tsx @@ -8,6 +8,7 @@ interface HeroButtonProps { } const HeroButton: FC = ({ children }) => { const { styles } = useStyles(); + return (
{scale.map((color, index) => { if (index === 0 || index === 12) return null; + return (
{ const content = `token.${name}${index}${isAlpha ? 'A' : ''} /* ${color} */`; + copy(content); message.success(content); }} diff --git a/src/ColorScales/index.tsx b/src/ColorScales/index.tsx index 1abbd30b..95092b94 100644 --- a/src/ColorScales/index.tsx +++ b/src/ColorScales/index.tsx @@ -14,6 +14,7 @@ export interface ColorScalesProps { const ColorScales = memo(({ name, scale, midHighLight }) => { const { styles } = useStyles(); + return (
@@ -22,9 +23,11 @@ const ColorScales = memo(({ name, scale, midHighLight }) => {
{new Array(scale.light.length).fill('').map((_, index) => { if (index === 0 || index === 12) return null; + const isMidHighlight = midHighLight === index; + return ( -
+
( ({ label, icon, disabled, nested, shortcut, active, selected, ...props }, ref) => { const { styles, cx } = useStyles(); + return (