From 6c34b9dbbe7a59e8592c1ce9571ddca5f577906e Mon Sep 17 00:00:00 2001 From: mantou132 <709922234@qq.com> Date: Tue, 26 Dec 2023 17:56:18 +0800 Subject: [PATCH] [gem-book] Improve mobile --- .../duoyun-ui/docs/zh/02-elements/README.md | 2 +- packages/duoyun-ui/package.json | 4 +- packages/gem-book/src/element/elements/404.ts | 3 +- .../gem-book/src/element/elements/icons.ts | 17 +++ .../gem-book/src/element/elements/main.ts | 3 +- .../gem-book/src/element/elements/nav-logo.ts | 14 ++- packages/gem-book/src/element/elements/nav.ts | 78 +++++++------ packages/gem-book/src/element/elements/pre.ts | 1 - .../gem-book/src/element/elements/sidebar.ts | 104 ++++++++++++++---- packages/gem-book/src/element/elements/toc.ts | 2 + packages/gem-book/src/element/index.ts | 22 ++-- packages/gem-book/src/plugins/code-group.ts | 3 +- packages/gem-book/src/plugins/docsearch.ts | 8 +- packages/gem-book/src/plugins/raw.ts | 1 + packages/gem-book/src/plugins/sandpack.ts | 8 +- packages/gem-examples/package.json | 2 +- .../docs/en/001-guide/002-advance/005-i18n.md | 2 +- packages/gem/docs/en/README.md | 7 ++ .../docs/zh/001-guide/002-advance/005-i18n.md | 2 +- packages/gem/docs/zh/README.md | 7 ++ packages/gem/src/elements/base/title.ts | 30 +++-- packages/gem/src/lib/history.ts | 4 +- 22 files changed, 231 insertions(+), 93 deletions(-) diff --git a/packages/duoyun-ui/docs/zh/02-elements/README.md b/packages/duoyun-ui/docs/zh/02-elements/README.md index 682adee5..bab55df5 100644 --- a/packages/duoyun-ui/docs/zh/02-elements/README.md +++ b/packages/duoyun-ui/docs/zh/02-elements/README.md @@ -2,7 +2,7 @@ diff --git a/packages/duoyun-ui/package.json b/packages/duoyun-ui/package.json index af249097..2371999a 100644 --- a/packages/duoyun-ui/package.json +++ b/packages/duoyun-ui/package.json @@ -1,6 +1,6 @@ { "name": "duoyun-ui", - "version": "1.1.6", + "version": "1.1.7", "description": "A lightweight desktop UI component library, implemented using Gem", "keywords": [ "frontend", @@ -48,7 +48,7 @@ "elkjs": "^0.7.1" }, "peerDependencies": { - "@mantou/gem": "^1.7.2" + "@mantou/gem": "^1.7.6" }, "devDependencies": { "@esm-bundle/chai": "^4.3.4-fix.0", diff --git a/packages/gem-book/src/element/elements/404.ts b/packages/gem-book/src/element/elements/404.ts index 9a971d45..edfe6d23 100644 --- a/packages/gem-book/src/element/elements/404.ts +++ b/packages/gem-book/src/element/elements/404.ts @@ -7,6 +7,7 @@ import { selfI18n } from '../helper/i18n'; import { icons } from './icons'; import '@mantou/gem/elements/reflect'; +import '@mantou/gem/elements/title'; @customElement('gem-book-404') @connectStore(selfI18n.store) @@ -53,7 +54,7 @@ export class Meta extends GemElement { margin-right: 10px; } -

404 - Not found

+

Not Found

${noGithub ? '' : html` diff --git a/packages/gem-book/src/element/elements/icons.ts b/packages/gem-book/src/element/elements/icons.ts index de7a415a..d0ece9f9 100644 --- a/packages/gem-book/src/element/elements/icons.ts +++ b/packages/gem-book/src/element/elements/icons.ts @@ -1,6 +1,23 @@ import { raw } from '@mantou/gem'; export const icons = { + github: raw` + + + + `, + menu: raw` + + `, + close: raw` + + `, i18n: raw` ` : null} ${title} + ${icon ? html`` : null} + ${title} `; }; diff --git a/packages/gem-book/src/element/elements/nav.ts b/packages/gem-book/src/element/elements/nav.ts index dee9c51a..23d722f9 100644 --- a/packages/gem-book/src/element/elements/nav.ts +++ b/packages/gem-book/src/element/elements/nav.ts @@ -7,6 +7,7 @@ import { globalemitter, connectStore, boolattribute, + classMap, } from '@mantou/gem'; import { mediaQuery } from '@mantou/gem/helper/mediaquery'; @@ -16,6 +17,7 @@ import { capitalize, isSameOrigin } from '../lib/utils'; import { bookStore } from '../store'; import { icons } from './icons'; +import { sidebarStore, toggleSidebar } from './sidebar'; import '@mantou/gem/elements/link'; import '@mantou/gem/elements/use'; @@ -28,6 +30,7 @@ import './nav-logo'; */ @customElement('gem-book-nav') @connectStore(bookStore) +@connectStore(sidebarStore) export class Nav extends GemElement { @boolattribute logo: boolean; @@ -38,10 +41,8 @@ export class Nav extends GemElement { renderI18nSelect = () => { const { langList = [], lang } = bookStore; if (lang) { - const name = langList.find(({ code }) => code === lang)?.name; return html` -
- ${mediaQuery.isPhone ? '' : name || lang} +
this.i18nRef.element?.click()} .element=${icons.i18n}>