ew-solid-press-theme-minimal 0.0.0-stage → 0.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +76 -2
- package/package.json +34 -3
- package/src/ComponentPage.tsx +132 -0
- package/src/DocPage.tsx +79 -0
- package/src/Home.tsx +77 -0
- package/src/Layout.tsx +125 -0
- package/src/Search.tsx +106 -0
- package/src/index.ts +10 -0
- package/src/styles.css +652 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 eveningwater
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
CHANGED
|
@@ -1,3 +1,77 @@
|
|
|
1
|
-
#
|
|
1
|
+
# ew-solid-press-theme-minimal
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
`ew-solid-press` 的极简主题:系统字体、单一强调色、原生元素,除框架本身与 `minisearch` 外不依赖任何
|
|
4
|
+
组件库。它同时是自建主题包时的参考实现。
|
|
5
|
+
|
|
6
|
+
## 安装
|
|
7
|
+
|
|
8
|
+
```bash
|
|
9
|
+
pnpm add -D ew-solid-press-theme-minimal
|
|
10
|
+
```
|
|
11
|
+
|
|
12
|
+
## 使用
|
|
13
|
+
|
|
14
|
+
把 `theme` 指向包名即可,框架会从项目根解析它的 `package.json`:
|
|
15
|
+
|
|
16
|
+
```ts
|
|
17
|
+
import { defineDocsConfig } from 'ew-solid-press'
|
|
18
|
+
|
|
19
|
+
export default defineDocsConfig({
|
|
20
|
+
title: '我的文档',
|
|
21
|
+
theme: 'ew-solid-press-theme-minimal',
|
|
22
|
+
})
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
主题入口已经引入自己的样式表(`src/styles.css`),不需要再手动引入 CSS。
|
|
26
|
+
|
|
27
|
+
## 包含什么
|
|
28
|
+
|
|
29
|
+
- 完整外壳:顶部导航、侧栏、大纲、页脚与搜索(`minisearch`),支持 `themeConfig` 与多语言前缀;
|
|
30
|
+
- 页面:`Layout`、`Home`、`DocPage` / `PageLayout`、`ComponentPage`、`NotFound`;
|
|
31
|
+
- 明暗两套令牌,`[data-theme='dark']` 下自动切换,与 `themeConfig.darkTheme` 一致。
|
|
32
|
+
|
|
33
|
+
## 自定义
|
|
34
|
+
|
|
35
|
+
主题的配色与排版都通过 CSS 变量控制,在自己的样式里覆盖即可:
|
|
36
|
+
|
|
37
|
+
```css
|
|
38
|
+
:root {
|
|
39
|
+
--ewp-bg: #ffffff;
|
|
40
|
+
--ewp-surface: #f6f7f9;
|
|
41
|
+
--ewp-text: #1f2328;
|
|
42
|
+
--ewp-muted: #656d76;
|
|
43
|
+
--ewp-border: #d8dee4;
|
|
44
|
+
--ewp-accent: #2563eb;
|
|
45
|
+
--ewp-radius: 8px;
|
|
46
|
+
--ewp-content: 760px;
|
|
47
|
+
--ewp-font: ui-sans-serif, system-ui, sans-serif;
|
|
48
|
+
--ewp-mono: ui-monospace, SFMono-Regular, monospace;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
[data-theme='dark'] {
|
|
52
|
+
--ewp-bg: #0d1117;
|
|
53
|
+
--ewp-accent: #6ea8fe;
|
|
54
|
+
}
|
|
55
|
+
```
|
|
56
|
+
|
|
57
|
+
## 自己写一个主题
|
|
58
|
+
|
|
59
|
+
`ew-solid-press` 的主题就是一组组件,`theme` 也可以直接指向本地入口:
|
|
60
|
+
|
|
61
|
+
```ts
|
|
62
|
+
theme: { entry: './theme/index.ts', css: './theme/styles.css' }
|
|
63
|
+
```
|
|
64
|
+
|
|
65
|
+
本包的源码可以当作最小示例:`Layout.tsx` 负责外壳,`DocPage.tsx` 负责文章与 404,`Home.tsx` 与
|
|
66
|
+
`ComponentPage.tsx` 分别对应首页和组件文档页,`styles.css` 只有一份令牌与基础排版。
|
|
67
|
+
|
|
68
|
+
## English
|
|
69
|
+
|
|
70
|
+
Dependency-free minimal theme for `ew-solid-press`: system fonts, a single accent color and native
|
|
71
|
+
elements. Install it and set `theme: 'ew-solid-press-theme-minimal'`; styles ship with the entry.
|
|
72
|
+
Colors and spacing are CSS variables (`--ewp-*`), light and dark tokens are both included. The source
|
|
73
|
+
doubles as a reference implementation for writing your own theme package.
|
|
74
|
+
|
|
75
|
+
## License
|
|
76
|
+
|
|
77
|
+
MIT
|
package/package.json
CHANGED
|
@@ -1,6 +1,37 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "ew-solid-press-theme-minimal",
|
|
3
|
-
"version": "0.0.
|
|
4
|
-
"
|
|
5
|
-
"
|
|
3
|
+
"version": "0.0.1",
|
|
4
|
+
"description": "Dependency-free minimal theme for ew-solid-press, and a reference implementation for writing your own theme package",
|
|
5
|
+
"keywords": [
|
|
6
|
+
"ew-solid-press",
|
|
7
|
+
"theme",
|
|
8
|
+
"minimal",
|
|
9
|
+
"documentation"
|
|
10
|
+
],
|
|
11
|
+
"type": "module",
|
|
12
|
+
"license": "MIT",
|
|
13
|
+
"author": "eveningwater",
|
|
14
|
+
"files": [
|
|
15
|
+
"src"
|
|
16
|
+
],
|
|
17
|
+
"exports": {
|
|
18
|
+
".": "./src/index.ts",
|
|
19
|
+
"./theme.css": "./src/styles.css",
|
|
20
|
+
"./package.json": "./package.json"
|
|
21
|
+
},
|
|
22
|
+
"dependencies": {
|
|
23
|
+
"minisearch": "^7.1.2"
|
|
24
|
+
},
|
|
25
|
+
"peerDependencies": {
|
|
26
|
+
"ew-solid-press": ">=0.0.1 <0.1.0",
|
|
27
|
+
"solid-js": "^1.9.0"
|
|
28
|
+
},
|
|
29
|
+
"devDependencies": {
|
|
30
|
+
"solid-js": "^1.9.5",
|
|
31
|
+
"typescript": "~5.7.2",
|
|
32
|
+
"ew-solid-press": "0.0.4"
|
|
33
|
+
},
|
|
34
|
+
"scripts": {
|
|
35
|
+
"typecheck": "tsc --noEmit"
|
|
36
|
+
}
|
|
6
37
|
}
|
|
@@ -0,0 +1,132 @@
|
|
|
1
|
+
import { For, Show, createMemo } from 'solid-js'
|
|
2
|
+
import { Dynamic } from 'solid-js/web'
|
|
3
|
+
import type { DocDemo, DocEntry, Localized, RouteRecord } from 'ew-solid-press/runtime'
|
|
4
|
+
import { PageMeta, isZh, useDocs } from 'ew-solid-press/runtime'
|
|
5
|
+
import type { PageModule } from './DocPage'
|
|
6
|
+
|
|
7
|
+
const pick = (value: Localized | string | undefined, zh: boolean): string => {
|
|
8
|
+
if (!value) return ''
|
|
9
|
+
return typeof value === 'string' ? value : zh ? value.zh : value.en
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* 组件文档页:消费 DocEntry[],渲染标题、示例、源码与 API 表。
|
|
14
|
+
* Component docs page: renders entries (demos, source, props) from DocEntry[].
|
|
15
|
+
*/
|
|
16
|
+
export const ComponentPage = (props: { route: RouteRecord; mod: PageModule }) => {
|
|
17
|
+
const docs = useDocs()
|
|
18
|
+
const zh = () => isZh(docs.lang)
|
|
19
|
+
const entries = () => (props.mod.default as unknown as DocEntry[]) ?? []
|
|
20
|
+
const entry = createMemo(() => entries().find(item => item.id === props.route.id))
|
|
21
|
+
const label = (zhText: string, enText: string): string => (zh() ? zhText : enText)
|
|
22
|
+
|
|
23
|
+
const demos = createMemo<DocDemo[]>(() => {
|
|
24
|
+
const current = entry()
|
|
25
|
+
if (!current) return []
|
|
26
|
+
return [
|
|
27
|
+
...(current.demo
|
|
28
|
+
? [{ title: { zh: '基础用法', en: 'Basic usage' }, demo: current.demo, code: current.code ?? '' }]
|
|
29
|
+
: []),
|
|
30
|
+
...(current.demos ?? []),
|
|
31
|
+
]
|
|
32
|
+
})
|
|
33
|
+
|
|
34
|
+
return (
|
|
35
|
+
<article class="ewp-page">
|
|
36
|
+
<PageMeta
|
|
37
|
+
title={entry() ? `${pick(entry()!.name, zh())} · ${docs.config.title}` : docs.config.title}
|
|
38
|
+
description={pick(entry()?.desc, zh()) || docs.config.description}
|
|
39
|
+
/>
|
|
40
|
+
<Show
|
|
41
|
+
when={entry()}
|
|
42
|
+
fallback={
|
|
43
|
+
<p class="ewp-missing">
|
|
44
|
+
Component "{props.route.id}" is not exported from {props.route.file}.
|
|
45
|
+
</p>
|
|
46
|
+
}
|
|
47
|
+
>
|
|
48
|
+
{current => (
|
|
49
|
+
<>
|
|
50
|
+
<h1 class="ewp-page__title">{pick(current().name, zh())}</h1>
|
|
51
|
+
<Show when={pick(current().desc, zh())}>
|
|
52
|
+
<p class="ewp-lead">{pick(current().desc, zh())}</p>
|
|
53
|
+
</Show>
|
|
54
|
+
|
|
55
|
+
<For each={demos()}>
|
|
56
|
+
{demo => (
|
|
57
|
+
<section class="ewp-demo">
|
|
58
|
+
<header class="ewp-demo__head">
|
|
59
|
+
<h3>{pick(demo.title, zh())}</h3>
|
|
60
|
+
<Show when={docs.config.componentDocs.versionBadge && demo.since}>
|
|
61
|
+
<span class="ewp-badge">
|
|
62
|
+
{docs.t('version')} {demo.since}
|
|
63
|
+
</span>
|
|
64
|
+
</Show>
|
|
65
|
+
</header>
|
|
66
|
+
<Show when={pick(demo.desc, zh())}>
|
|
67
|
+
<p class="ewp-demo__desc">{pick(demo.desc, zh())}</p>
|
|
68
|
+
</Show>
|
|
69
|
+
<div class="ewp-demo__preview">
|
|
70
|
+
<Dynamic component={demo.demo} />
|
|
71
|
+
</div>
|
|
72
|
+
<Show when={demo.code}>
|
|
73
|
+
<details class="ewp-demo__source">
|
|
74
|
+
<summary>{label('查看代码', 'View code')}</summary>
|
|
75
|
+
<pre>
|
|
76
|
+
<code>{demo.code}</code>
|
|
77
|
+
</pre>
|
|
78
|
+
</details>
|
|
79
|
+
</Show>
|
|
80
|
+
</section>
|
|
81
|
+
)}
|
|
82
|
+
</For>
|
|
83
|
+
|
|
84
|
+
<Show when={docs.config.componentDocs.propsTable && current().props?.length}>
|
|
85
|
+
<section class="ewp-props">
|
|
86
|
+
<h2>API</h2>
|
|
87
|
+
<div class="ewp-table">
|
|
88
|
+
<table>
|
|
89
|
+
<thead>
|
|
90
|
+
<tr>
|
|
91
|
+
<th>{label('属性', 'Prop')}</th>
|
|
92
|
+
<th>{label('类型', 'Type')}</th>
|
|
93
|
+
<th>{label('默认值', 'Default')}</th>
|
|
94
|
+
<th>{label('说明', 'Description')}</th>
|
|
95
|
+
</tr>
|
|
96
|
+
</thead>
|
|
97
|
+
<tbody>
|
|
98
|
+
<For each={current().props}>
|
|
99
|
+
{prop => (
|
|
100
|
+
<tr>
|
|
101
|
+
<td>
|
|
102
|
+
<code>{prop.name}</code>
|
|
103
|
+
</td>
|
|
104
|
+
<td>
|
|
105
|
+
<code>{prop.type}</code>
|
|
106
|
+
</td>
|
|
107
|
+
<td>{prop.default ?? '—'}</td>
|
|
108
|
+
<td>{pick(prop.desc, zh())}</td>
|
|
109
|
+
</tr>
|
|
110
|
+
)}
|
|
111
|
+
</For>
|
|
112
|
+
</tbody>
|
|
113
|
+
</table>
|
|
114
|
+
</div>
|
|
115
|
+
</section>
|
|
116
|
+
</Show>
|
|
117
|
+
|
|
118
|
+
<Show when={current().more}>
|
|
119
|
+
{more => (
|
|
120
|
+
<p class="ewp-page__more">
|
|
121
|
+
<a href={more().href} target="_blank" rel="noreferrer">
|
|
122
|
+
{pick(more().label, zh()) || more().href}
|
|
123
|
+
</a>
|
|
124
|
+
</p>
|
|
125
|
+
)}
|
|
126
|
+
</Show>
|
|
127
|
+
</>
|
|
128
|
+
)}
|
|
129
|
+
</Show>
|
|
130
|
+
</article>
|
|
131
|
+
)
|
|
132
|
+
}
|
package/src/DocPage.tsx
ADDED
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
import { Show, createMemo } from 'solid-js'
|
|
2
|
+
import { Dynamic } from 'solid-js/web'
|
|
3
|
+
import type { DocBlock, DocsPageModule, RouteRecord } from 'ew-solid-press/runtime'
|
|
4
|
+
import { DocContent, PageMeta, localeLink, resolvePrevNext, useDocs, withBase } from 'ew-solid-press/runtime'
|
|
5
|
+
|
|
6
|
+
export type PageModule = DocsPageModule
|
|
7
|
+
|
|
8
|
+
export const DocPage = (props: { route: RouteRecord; mod: PageModule }) => {
|
|
9
|
+
const docs = useDocs()
|
|
10
|
+
const links = createMemo(() =>
|
|
11
|
+
resolvePrevNext(docs.themeConfig, docs.routes, props.route, docs.localeBase),
|
|
12
|
+
)
|
|
13
|
+
const description = () =>
|
|
14
|
+
(props.route.meta?.description as string | undefined) ?? docs.config.description
|
|
15
|
+
|
|
16
|
+
return (
|
|
17
|
+
<article class="ewp-page">
|
|
18
|
+
<PageMeta
|
|
19
|
+
title={props.route.title ? `${props.route.title} · ${docs.config.title}` : docs.config.title}
|
|
20
|
+
description={description()}
|
|
21
|
+
/>
|
|
22
|
+
<Show when={props.route.title}>
|
|
23
|
+
<h1 class="ewp-page__title">{props.route.title}</h1>
|
|
24
|
+
</Show>
|
|
25
|
+
<Show when={props.mod.blocks} fallback={<Dynamic component={props.mod.default} />}>
|
|
26
|
+
<DocContent blocks={props.mod.blocks as DocBlock[]} />
|
|
27
|
+
</Show>
|
|
28
|
+
<nav class="ewp-prevnext">
|
|
29
|
+
<Show when={links().prev}>
|
|
30
|
+
{item => (
|
|
31
|
+
<a class="ewp-prevnext__link" href={withBase(docs.config.base, item().path)}>
|
|
32
|
+
<span class="ewp-prevnext__label">{docs.t('previous')}</span>
|
|
33
|
+
<span>{item().title}</span>
|
|
34
|
+
</a>
|
|
35
|
+
)}
|
|
36
|
+
</Show>
|
|
37
|
+
<Show when={links().next}>
|
|
38
|
+
{item => (
|
|
39
|
+
<a class="ewp-prevnext__link ewp-prevnext__link--next" href={withBase(docs.config.base, item().path)}>
|
|
40
|
+
<span class="ewp-prevnext__label">{docs.t('next')}</span>
|
|
41
|
+
<span>{item().title}</span>
|
|
42
|
+
</a>
|
|
43
|
+
)}
|
|
44
|
+
</Show>
|
|
45
|
+
</nav>
|
|
46
|
+
</article>
|
|
47
|
+
)
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
/** 自定义页面:直接渲染页面模块的默认导出 */
|
|
51
|
+
export const PageLayout = (props: { route: RouteRecord; mod: PageModule }) => {
|
|
52
|
+
const docs = useDocs()
|
|
53
|
+
return (
|
|
54
|
+
<div class="ewp-page">
|
|
55
|
+
<PageMeta
|
|
56
|
+
title={props.route.title ? `${props.route.title} · ${docs.config.title}` : docs.config.title}
|
|
57
|
+
/>
|
|
58
|
+
<Dynamic component={props.mod.default} />
|
|
59
|
+
</div>
|
|
60
|
+
)
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
export const NotFound = () => {
|
|
64
|
+
const docs = useDocs()
|
|
65
|
+
return (
|
|
66
|
+
<div class="ewp-notfound">
|
|
67
|
+
<PageMeta title={`404 · ${docs.config.title}`} />
|
|
68
|
+
<p class="ewp-notfound__code">404</p>
|
|
69
|
+
<h1>{docs.t('notFoundTitle')}</h1>
|
|
70
|
+
<p>{docs.t('notFoundText')}</p>
|
|
71
|
+
<a
|
|
72
|
+
class="ewp-button"
|
|
73
|
+
href={withBase(docs.config.base, localeLink('/', docs.localeBase))}
|
|
74
|
+
>
|
|
75
|
+
{docs.t('backHome')}
|
|
76
|
+
</a>
|
|
77
|
+
</div>
|
|
78
|
+
)
|
|
79
|
+
}
|
package/src/Home.tsx
ADDED
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
import { For, Show } from 'solid-js'
|
|
2
|
+
import { Dynamic } from 'solid-js/web'
|
|
3
|
+
import type { DocBlock, RouteRecord } from 'ew-solid-press/runtime'
|
|
4
|
+
import { DocContent, PageMeta, localeLink, useDocs, withBase } from 'ew-solid-press/runtime'
|
|
5
|
+
import type { PageModule } from './DocPage'
|
|
6
|
+
|
|
7
|
+
interface HeroAction {
|
|
8
|
+
text: string
|
|
9
|
+
link: string
|
|
10
|
+
theme?: 'primary' | 'secondary' | 'ghost'
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
interface Hero {
|
|
14
|
+
name?: string
|
|
15
|
+
text?: string
|
|
16
|
+
tagline?: string
|
|
17
|
+
actions?: HeroAction[]
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
interface Feature {
|
|
21
|
+
title: string
|
|
22
|
+
details: string
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
export const Home = (props: { route: RouteRecord; mod: PageModule }) => {
|
|
26
|
+
const docs = useDocs()
|
|
27
|
+
const hero = () => (props.route.meta?.hero as Hero | undefined) ?? {}
|
|
28
|
+
const features = () => (props.route.meta?.features as Feature[] | undefined) ?? []
|
|
29
|
+
|
|
30
|
+
const href = (link: string): string =>
|
|
31
|
+
link.startsWith('http')
|
|
32
|
+
? link
|
|
33
|
+
: withBase(docs.config.base, localeLink(link, docs.localeBase, docs.config.locales))
|
|
34
|
+
|
|
35
|
+
return (
|
|
36
|
+
<div class="ewp-home">
|
|
37
|
+
<PageMeta title={docs.config.title} description={docs.config.description} />
|
|
38
|
+
<section class="ewp-hero">
|
|
39
|
+
<Show when={hero().tagline}>
|
|
40
|
+
<p class="ewp-hero__tagline">{hero().tagline}</p>
|
|
41
|
+
</Show>
|
|
42
|
+
<h1 class="ewp-hero__name">{hero().name ?? docs.config.title}</h1>
|
|
43
|
+
<Show when={hero().text ?? docs.config.description}>
|
|
44
|
+
<p class="ewp-hero__text">{hero().text ?? docs.config.description}</p>
|
|
45
|
+
</Show>
|
|
46
|
+
<Show when={hero().actions?.length}>
|
|
47
|
+
<p class="ewp-hero__actions">
|
|
48
|
+
<For each={hero().actions}>
|
|
49
|
+
{action => (
|
|
50
|
+
<a class={`ewp-button ewp-button--${action.theme ?? 'primary'}`} href={href(action.link)}>
|
|
51
|
+
{action.text}
|
|
52
|
+
</a>
|
|
53
|
+
)}
|
|
54
|
+
</For>
|
|
55
|
+
</p>
|
|
56
|
+
</Show>
|
|
57
|
+
</section>
|
|
58
|
+
<Show when={features().length}>
|
|
59
|
+
<section class="ewp-features">
|
|
60
|
+
<For each={features()}>
|
|
61
|
+
{feature => (
|
|
62
|
+
<div class="ewp-feature">
|
|
63
|
+
<h2>{feature.title}</h2>
|
|
64
|
+
<p>{feature.details}</p>
|
|
65
|
+
</div>
|
|
66
|
+
)}
|
|
67
|
+
</For>
|
|
68
|
+
</section>
|
|
69
|
+
</Show>
|
|
70
|
+
<section class="ewp-home__content">
|
|
71
|
+
<Show when={props.mod.blocks} fallback={<Dynamic component={props.mod.default} />}>
|
|
72
|
+
<DocContent blocks={props.mod.blocks as DocBlock[]} />
|
|
73
|
+
</Show>
|
|
74
|
+
</section>
|
|
75
|
+
</div>
|
|
76
|
+
)
|
|
77
|
+
}
|
package/src/Layout.tsx
ADDED
|
@@ -0,0 +1,125 @@
|
|
|
1
|
+
import { For, Show, createSignal } from 'solid-js'
|
|
2
|
+
import type { DocsLayoutProps } from 'ew-solid-press/runtime'
|
|
3
|
+
import { alternateLocalePath, isZh, localeLink, useDocs, withBase } from 'ew-solid-press/runtime'
|
|
4
|
+
import { Search } from './Search'
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* 极简主题骨架:顶部导航 + 正文 + 可选大纲。
|
|
8
|
+
* 没有侧栏、没有组件库依赖,所有样式都在 styles.css。
|
|
9
|
+
* Minimal shell: header, content and an optional outline. No sidebar, no UI library.
|
|
10
|
+
*/
|
|
11
|
+
export const Layout = (props: DocsLayoutProps) => {
|
|
12
|
+
const docs = useDocs()
|
|
13
|
+
const [menuOpen, setMenuOpen] = createSignal(false)
|
|
14
|
+
const hasAside = (): boolean => props.showAside !== false && Boolean(props.toc?.length)
|
|
15
|
+
const nav = () => docs.themeConfig.nav ?? []
|
|
16
|
+
const outlineLabel = () => {
|
|
17
|
+
const outline = docs.themeConfig.outline
|
|
18
|
+
if (outline) return outline.label ?? (isZh(docs.lang) ? '本页目录' : 'On this page')
|
|
19
|
+
return isZh(docs.lang) ? '本页目录' : 'On this page'
|
|
20
|
+
}
|
|
21
|
+
// 当前语言:有路由时取路由语言,404 时按 localeBase 推断
|
|
22
|
+
const currentLocaleKey = () =>
|
|
23
|
+
docs.route?.locale ??
|
|
24
|
+
docs.config.locales.find(locale => locale.base === docs.localeBase)?.key
|
|
25
|
+
// 当前语言之外的语言,渲染成切换链接
|
|
26
|
+
const otherLocales = () => docs.config.locales.filter(locale => locale.key !== currentLocaleKey())
|
|
27
|
+
|
|
28
|
+
return (
|
|
29
|
+
<div class="ewp-shell">
|
|
30
|
+
<header class="ewp-header">
|
|
31
|
+
<a class="ewp-brand" href={withBase(docs.config.base, localeLink('/', docs.localeBase))}>
|
|
32
|
+
{docs.config.title}
|
|
33
|
+
</a>
|
|
34
|
+
<button
|
|
35
|
+
type="button"
|
|
36
|
+
class="ewp-menu"
|
|
37
|
+
aria-label="Menu"
|
|
38
|
+
aria-expanded={menuOpen()}
|
|
39
|
+
onClick={() => setMenuOpen(value => !value)}
|
|
40
|
+
>
|
|
41
|
+
☰
|
|
42
|
+
</button>
|
|
43
|
+
<nav class="ewp-nav" classList={{ 'is-open': menuOpen() }} onClick={() => setMenuOpen(false)}>
|
|
44
|
+
<For each={nav()}>
|
|
45
|
+
{item => (
|
|
46
|
+
<a
|
|
47
|
+
class="ewp-nav__link"
|
|
48
|
+
href={withBase(
|
|
49
|
+
docs.config.base,
|
|
50
|
+
localeLink(item.link, docs.localeBase, docs.config.locales),
|
|
51
|
+
)}
|
|
52
|
+
>
|
|
53
|
+
{item.text}
|
|
54
|
+
</a>
|
|
55
|
+
)}
|
|
56
|
+
</For>
|
|
57
|
+
<Show when={otherLocales().length}>
|
|
58
|
+
<For each={otherLocales()}>
|
|
59
|
+
{locale => (
|
|
60
|
+
<a
|
|
61
|
+
class="ewp-nav__locale"
|
|
62
|
+
href={withBase(
|
|
63
|
+
docs.config.base,
|
|
64
|
+
// 404 等无路由页面回退到目标语言首页
|
|
65
|
+
docs.route
|
|
66
|
+
? alternateLocalePath(docs.routes, docs.route, locale.base, docs.localeBase)
|
|
67
|
+
: localeLink('/', locale.base, docs.config.locales),
|
|
68
|
+
)}
|
|
69
|
+
>
|
|
70
|
+
{locale.label}
|
|
71
|
+
</a>
|
|
72
|
+
)}
|
|
73
|
+
</For>
|
|
74
|
+
</Show>
|
|
75
|
+
</nav>
|
|
76
|
+
<Show when={docs.themeConfig.search !== false}>
|
|
77
|
+
<button type="button" class="ewp-search" onClick={props.onOpenSearch}>
|
|
78
|
+
{docs.t('search')}
|
|
79
|
+
<kbd class="ewp-kbd">⌘K</kbd>
|
|
80
|
+
</button>
|
|
81
|
+
</Show>
|
|
82
|
+
</header>
|
|
83
|
+
|
|
84
|
+
<div class="ewp-body" classList={{ 'no-aside': !hasAside() }}>
|
|
85
|
+
<main class="ewp-main">{props.children}</main>
|
|
86
|
+
<Show when={hasAside()}>
|
|
87
|
+
<aside class="ewp-aside">
|
|
88
|
+
<p class="ewp-aside__label">{outlineLabel()}</p>
|
|
89
|
+
<ul class="ewp-aside__list">
|
|
90
|
+
<For each={props.toc}>
|
|
91
|
+
{item => (
|
|
92
|
+
<li class={`ewp-aside__item ewp-aside__item--${item.level}`}>
|
|
93
|
+
<a href={`#${item.id}`}>{item.text}</a>
|
|
94
|
+
</li>
|
|
95
|
+
)}
|
|
96
|
+
</For>
|
|
97
|
+
</ul>
|
|
98
|
+
</aside>
|
|
99
|
+
</Show>
|
|
100
|
+
</div>
|
|
101
|
+
|
|
102
|
+
<footer class="ewp-footer">
|
|
103
|
+
<Show when={docs.themeConfig.footer?.message}>
|
|
104
|
+
<p>{docs.themeConfig.footer?.message}</p>
|
|
105
|
+
</Show>
|
|
106
|
+
<Show when={docs.themeConfig.footer?.copyright}>
|
|
107
|
+
<p>{docs.themeConfig.footer?.copyright}</p>
|
|
108
|
+
</Show>
|
|
109
|
+
<Show when={docs.themeConfig.footer?.links?.length}>
|
|
110
|
+
<p class="ewp-footer__links">
|
|
111
|
+
<For each={docs.themeConfig.footer?.links}>
|
|
112
|
+
{link => (
|
|
113
|
+
<a href={link.link} target="_blank" rel="noreferrer">
|
|
114
|
+
{link.text}
|
|
115
|
+
</a>
|
|
116
|
+
)}
|
|
117
|
+
</For>
|
|
118
|
+
</p>
|
|
119
|
+
</Show>
|
|
120
|
+
</footer>
|
|
121
|
+
|
|
122
|
+
<Search open={props.searchOpen} onClose={props.onCloseSearch} />
|
|
123
|
+
</div>
|
|
124
|
+
)
|
|
125
|
+
}
|
package/src/Search.tsx
ADDED
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
import { For, Show, createEffect, createMemo, createSignal } from 'solid-js'
|
|
2
|
+
import type MiniSearch from 'minisearch'
|
|
3
|
+
import { normalizePath, useDocs, withBase, type SearchDoc } from 'ew-solid-press/runtime'
|
|
4
|
+
import { createSearchEngine, createSnippet } from 'ew-solid-press/runtime/search'
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* 本地搜索浮层:索引在构建期生成,打开时按需加载。
|
|
8
|
+
* 只用原生元素实现,方便用户直接改成自己的样式或交互。
|
|
9
|
+
* Local search overlay built from native elements only.
|
|
10
|
+
*/
|
|
11
|
+
export const Search = (props: { open: boolean; onClose: () => void }) => {
|
|
12
|
+
const docs = useDocs()
|
|
13
|
+
const [query, setQuery] = createSignal('')
|
|
14
|
+
const [items, setItems] = createSignal<SearchDoc[]>([])
|
|
15
|
+
const [engine, setEngine] = createSignal<MiniSearch<SearchDoc> | null>(null)
|
|
16
|
+
let input: HTMLInputElement | undefined
|
|
17
|
+
|
|
18
|
+
const maxResults = () => {
|
|
19
|
+
const search = docs.themeConfig.search
|
|
20
|
+
return (search ? search.maxResults : undefined) ?? 10
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
const load = async (): Promise<void> => {
|
|
24
|
+
if (engine()) return
|
|
25
|
+
const response = await fetch(withBase(docs.config.base, 'search-index.json'))
|
|
26
|
+
const list = (await response.json()) as SearchDoc[]
|
|
27
|
+
setItems(list)
|
|
28
|
+
setEngine(createSearchEngine(list))
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
createEffect(() => {
|
|
32
|
+
if (!props.open) return
|
|
33
|
+
void load()
|
|
34
|
+
queueMicrotask(() => input?.focus())
|
|
35
|
+
})
|
|
36
|
+
|
|
37
|
+
const results = createMemo<SearchDoc[]>(() => {
|
|
38
|
+
const value = query().trim()
|
|
39
|
+
if (!value) return []
|
|
40
|
+
const current = engine()
|
|
41
|
+
if (!current) return []
|
|
42
|
+
return current
|
|
43
|
+
.search(value)
|
|
44
|
+
.slice(0, maxResults())
|
|
45
|
+
.map(hit => items().find(item => item.id === hit.id))
|
|
46
|
+
.filter((item): item is SearchDoc => Boolean(item))
|
|
47
|
+
})
|
|
48
|
+
|
|
49
|
+
const go = (doc: SearchDoc): void => {
|
|
50
|
+
props.onClose()
|
|
51
|
+
setQuery('')
|
|
52
|
+
// navigate 内部会处理 #锚点,这里补上 base 让浏览器地址栏保持站点前缀
|
|
53
|
+
docs.navigate(withBase(docs.config.base, normalizePath(doc.path)))
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
return (
|
|
57
|
+
<Show when={props.open}>
|
|
58
|
+
<div class="ewp-mask" onClick={props.onClose}>
|
|
59
|
+
<div
|
|
60
|
+
class="ewp-dialog"
|
|
61
|
+
role="dialog"
|
|
62
|
+
aria-modal="true"
|
|
63
|
+
aria-label={docs.t('search')}
|
|
64
|
+
onClick={event => event.stopPropagation()}
|
|
65
|
+
>
|
|
66
|
+
<input
|
|
67
|
+
ref={input}
|
|
68
|
+
class="ewp-dialog__input"
|
|
69
|
+
type="search"
|
|
70
|
+
placeholder={docs.t('searchPlaceholder')}
|
|
71
|
+
value={query()}
|
|
72
|
+
onInput={event => setQuery(event.currentTarget.value)}
|
|
73
|
+
onKeyDown={event => {
|
|
74
|
+
if (event.key === 'Escape') props.onClose()
|
|
75
|
+
if (event.key === 'Enter') {
|
|
76
|
+
const first = results()[0]
|
|
77
|
+
if (first) go(first)
|
|
78
|
+
}
|
|
79
|
+
}}
|
|
80
|
+
/>
|
|
81
|
+
<ul class="ewp-dialog__list">
|
|
82
|
+
<For
|
|
83
|
+
each={results()}
|
|
84
|
+
fallback={
|
|
85
|
+
<li class="ewp-dialog__empty">
|
|
86
|
+
{query().trim() && items().length ? docs.t('searchEmpty') : ''}
|
|
87
|
+
</li>
|
|
88
|
+
}
|
|
89
|
+
>
|
|
90
|
+
{doc => (
|
|
91
|
+
<li>
|
|
92
|
+
<button type="button" class="ewp-dialog__item" onClick={() => go(doc)}>
|
|
93
|
+
<span class="ewp-dialog__title">{doc.titles ?? doc.title}</span>
|
|
94
|
+
<Show when={createSnippet(doc.text, query())}>
|
|
95
|
+
{snippet => <span class="ewp-dialog__snippet">{snippet()}</span>}
|
|
96
|
+
</Show>
|
|
97
|
+
</button>
|
|
98
|
+
</li>
|
|
99
|
+
)}
|
|
100
|
+
</For>
|
|
101
|
+
</ul>
|
|
102
|
+
</div>
|
|
103
|
+
</div>
|
|
104
|
+
</Show>
|
|
105
|
+
)
|
|
106
|
+
}
|
package/src/index.ts
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
// 极简主题不依赖任何组件库,样式随入口一起引入,
|
|
2
|
+
// 站点只需配置 theme: 'ew-solid-press-theme-minimal'。
|
|
3
|
+
// The theme has no UI-library dependency and ships its styles with the entry, so
|
|
4
|
+
// a site only needs theme: 'ew-solid-press-theme-minimal'.
|
|
5
|
+
import './styles.css'
|
|
6
|
+
|
|
7
|
+
export { Layout } from './Layout'
|
|
8
|
+
export { DocPage, PageLayout, NotFound } from './DocPage'
|
|
9
|
+
export { Home } from './Home'
|
|
10
|
+
export { ComponentPage } from './ComponentPage'
|
package/src/styles.css
ADDED
|
@@ -0,0 +1,652 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* ew-solid-press-theme-minimal
|
|
3
|
+
* 极简主题:系统字体、单一强调色、没有额外装饰,也不依赖任何组件库。
|
|
4
|
+
* Minimal theme: system fonts, one accent color, no UI-library dependency.
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
:root {
|
|
8
|
+
--ewp-bg: #ffffff;
|
|
9
|
+
--ewp-surface: #f6f7f9;
|
|
10
|
+
--ewp-text: #1f2328;
|
|
11
|
+
--ewp-muted: #656d76;
|
|
12
|
+
--ewp-border: #d8dee4;
|
|
13
|
+
--ewp-accent: #2563eb;
|
|
14
|
+
--ewp-radius: 8px;
|
|
15
|
+
--ewp-content: 760px;
|
|
16
|
+
--ewp-font:
|
|
17
|
+
ui-sans-serif, system-ui, -apple-system, 'Segoe UI', 'PingFang SC', 'Hiragino Sans GB',
|
|
18
|
+
'Microsoft YaHei', sans-serif;
|
|
19
|
+
--ewp-mono: ui-monospace, SFMono-Regular, Menlo, Consolas, 'Liberation Mono', monospace;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
[data-theme='dark'] {
|
|
23
|
+
--ewp-bg: #0d1117;
|
|
24
|
+
--ewp-surface: #161b22;
|
|
25
|
+
--ewp-text: #e6edf3;
|
|
26
|
+
--ewp-muted: #8b949e;
|
|
27
|
+
--ewp-border: #30363d;
|
|
28
|
+
--ewp-accent: #6ea8fe;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
* {
|
|
32
|
+
box-sizing: border-box;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
html {
|
|
36
|
+
scroll-behavior: smooth;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
body {
|
|
40
|
+
margin: 0;
|
|
41
|
+
background: var(--ewp-bg);
|
|
42
|
+
color: var(--ewp-text);
|
|
43
|
+
font-family: var(--ewp-font);
|
|
44
|
+
line-height: 1.7;
|
|
45
|
+
-webkit-font-smoothing: antialiased;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
a {
|
|
49
|
+
color: var(--ewp-accent);
|
|
50
|
+
text-decoration: none;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
a:hover {
|
|
54
|
+
text-decoration: underline;
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
.ewp-shell {
|
|
58
|
+
display: flex;
|
|
59
|
+
flex-direction: column;
|
|
60
|
+
min-height: 100vh;
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
/* 顶部导航 */
|
|
64
|
+
.ewp-header {
|
|
65
|
+
position: sticky;
|
|
66
|
+
top: 0;
|
|
67
|
+
z-index: 20;
|
|
68
|
+
display: flex;
|
|
69
|
+
align-items: center;
|
|
70
|
+
gap: 20px;
|
|
71
|
+
height: 56px;
|
|
72
|
+
padding: 0 24px;
|
|
73
|
+
border-bottom: 1px solid var(--ewp-border);
|
|
74
|
+
background: var(--ewp-bg);
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
.ewp-brand {
|
|
78
|
+
color: var(--ewp-text);
|
|
79
|
+
font-size: 15px;
|
|
80
|
+
font-weight: 600;
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
.ewp-brand:hover {
|
|
84
|
+
text-decoration: none;
|
|
85
|
+
color: var(--ewp-accent);
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
.ewp-menu {
|
|
89
|
+
display: none;
|
|
90
|
+
margin-left: auto;
|
|
91
|
+
padding: 2px 8px;
|
|
92
|
+
border: 1px solid var(--ewp-border);
|
|
93
|
+
border-radius: 6px;
|
|
94
|
+
background: var(--ewp-surface);
|
|
95
|
+
color: var(--ewp-text);
|
|
96
|
+
font: inherit;
|
|
97
|
+
cursor: pointer;
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
.ewp-nav {
|
|
101
|
+
display: flex;
|
|
102
|
+
align-items: center;
|
|
103
|
+
gap: 18px;
|
|
104
|
+
font-size: 14px;
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
.ewp-nav__link {
|
|
108
|
+
color: var(--ewp-muted);
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
.ewp-nav__link:hover {
|
|
112
|
+
color: var(--ewp-text);
|
|
113
|
+
text-decoration: none;
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
.ewp-nav__locale {
|
|
117
|
+
padding-left: 18px;
|
|
118
|
+
border-left: 1px solid var(--ewp-border);
|
|
119
|
+
color: var(--ewp-muted);
|
|
120
|
+
font-size: 13px;
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
.ewp-search {
|
|
124
|
+
display: inline-flex;
|
|
125
|
+
align-items: center;
|
|
126
|
+
gap: 8px;
|
|
127
|
+
margin-left: auto;
|
|
128
|
+
padding: 5px 10px;
|
|
129
|
+
border: 1px solid var(--ewp-border);
|
|
130
|
+
border-radius: 6px;
|
|
131
|
+
background: var(--ewp-surface);
|
|
132
|
+
color: var(--ewp-muted);
|
|
133
|
+
font: inherit;
|
|
134
|
+
font-size: 13px;
|
|
135
|
+
cursor: pointer;
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
.ewp-search:hover {
|
|
139
|
+
color: var(--ewp-text);
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
.ewp-kbd {
|
|
143
|
+
font-family: var(--ewp-mono);
|
|
144
|
+
font-size: 11px;
|
|
145
|
+
opacity: 0.7;
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
/* 正文与大纲 */
|
|
149
|
+
.ewp-body {
|
|
150
|
+
display: grid;
|
|
151
|
+
grid-template-columns: minmax(0, 1fr) 200px;
|
|
152
|
+
gap: 56px;
|
|
153
|
+
width: 100%;
|
|
154
|
+
max-width: 1120px;
|
|
155
|
+
margin: 0 auto;
|
|
156
|
+
padding: 40px 24px 72px;
|
|
157
|
+
flex: 1;
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
.ewp-body.no-aside {
|
|
161
|
+
grid-template-columns: minmax(0, 1fr);
|
|
162
|
+
max-width: calc(var(--ewp-content) + 48px);
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
.ewp-main {
|
|
166
|
+
min-width: 0;
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
.ewp-aside {
|
|
170
|
+
position: sticky;
|
|
171
|
+
top: 88px;
|
|
172
|
+
align-self: start;
|
|
173
|
+
max-height: calc(100vh - 120px);
|
|
174
|
+
overflow: auto;
|
|
175
|
+
font-size: 13px;
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
.ewp-aside__label {
|
|
179
|
+
margin: 0 0 10px;
|
|
180
|
+
color: var(--ewp-text);
|
|
181
|
+
font-weight: 600;
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
.ewp-aside__list {
|
|
185
|
+
margin: 0;
|
|
186
|
+
padding: 0;
|
|
187
|
+
list-style: none;
|
|
188
|
+
border-left: 1px solid var(--ewp-border);
|
|
189
|
+
}
|
|
190
|
+
|
|
191
|
+
.ewp-aside__item a {
|
|
192
|
+
display: block;
|
|
193
|
+
padding: 4px 0 4px 12px;
|
|
194
|
+
color: var(--ewp-muted);
|
|
195
|
+
}
|
|
196
|
+
|
|
197
|
+
.ewp-aside__item a:hover {
|
|
198
|
+
color: var(--ewp-accent);
|
|
199
|
+
text-decoration: none;
|
|
200
|
+
}
|
|
201
|
+
|
|
202
|
+
.ewp-aside__item--3 a {
|
|
203
|
+
padding-left: 24px;
|
|
204
|
+
}
|
|
205
|
+
|
|
206
|
+
.ewp-aside__item--4 a {
|
|
207
|
+
padding-left: 36px;
|
|
208
|
+
}
|
|
209
|
+
|
|
210
|
+
/* 内容排版 */
|
|
211
|
+
.ewp-page__title,
|
|
212
|
+
.ewp-hero__name {
|
|
213
|
+
margin: 0 0 16px;
|
|
214
|
+
font-size: 30px;
|
|
215
|
+
line-height: 1.3;
|
|
216
|
+
letter-spacing: -0.02em;
|
|
217
|
+
}
|
|
218
|
+
|
|
219
|
+
.ewp-main h2 {
|
|
220
|
+
margin: 40px 0 12px;
|
|
221
|
+
font-size: 21px;
|
|
222
|
+
line-height: 1.4;
|
|
223
|
+
}
|
|
224
|
+
|
|
225
|
+
.ewp-main h3 {
|
|
226
|
+
margin: 28px 0 10px;
|
|
227
|
+
font-size: 17px;
|
|
228
|
+
}
|
|
229
|
+
|
|
230
|
+
.ewp-main p,
|
|
231
|
+
.ewp-main li {
|
|
232
|
+
font-size: 15px;
|
|
233
|
+
}
|
|
234
|
+
|
|
235
|
+
.ewp-main ul,
|
|
236
|
+
.ewp-main ol {
|
|
237
|
+
padding-left: 22px;
|
|
238
|
+
}
|
|
239
|
+
|
|
240
|
+
.ewp-main img {
|
|
241
|
+
max-width: 100%;
|
|
242
|
+
}
|
|
243
|
+
|
|
244
|
+
.ewp-main hr {
|
|
245
|
+
border: none;
|
|
246
|
+
border-top: 1px solid var(--ewp-border);
|
|
247
|
+
margin: 32px 0;
|
|
248
|
+
}
|
|
249
|
+
|
|
250
|
+
.ewp-main :not(pre) > code {
|
|
251
|
+
padding: 2px 5px;
|
|
252
|
+
border-radius: 4px;
|
|
253
|
+
background: var(--ewp-surface);
|
|
254
|
+
font-family: var(--ewp-mono);
|
|
255
|
+
font-size: 0.9em;
|
|
256
|
+
}
|
|
257
|
+
|
|
258
|
+
.ew-doc-code pre,
|
|
259
|
+
.ewp-demo__source pre {
|
|
260
|
+
margin: 16px 0;
|
|
261
|
+
padding: 14px 16px;
|
|
262
|
+
overflow: auto;
|
|
263
|
+
border: 1px solid var(--ewp-border);
|
|
264
|
+
border-radius: var(--ewp-radius);
|
|
265
|
+
background: var(--ewp-surface);
|
|
266
|
+
font-family: var(--ewp-mono);
|
|
267
|
+
font-size: 13px;
|
|
268
|
+
line-height: 1.6;
|
|
269
|
+
}
|
|
270
|
+
|
|
271
|
+
.ew-doc-code pre code,
|
|
272
|
+
.ewp-demo__source pre code {
|
|
273
|
+
font-family: inherit;
|
|
274
|
+
}
|
|
275
|
+
|
|
276
|
+
/* 语法高亮:shiki 只输出 --shiki-light / --shiki-dark 变量,主题要负责映射成实际颜色 */
|
|
277
|
+
.shiki {
|
|
278
|
+
background: var(--shiki-light-bg, var(--ewp-surface)) !important;
|
|
279
|
+
}
|
|
280
|
+
|
|
281
|
+
.shiki span {
|
|
282
|
+
color: var(--shiki-light, inherit);
|
|
283
|
+
}
|
|
284
|
+
|
|
285
|
+
[data-theme='dark'] .shiki {
|
|
286
|
+
background: var(--shiki-dark-bg, var(--ewp-surface)) !important;
|
|
287
|
+
}
|
|
288
|
+
|
|
289
|
+
[data-theme='dark'] .shiki span {
|
|
290
|
+
color: var(--shiki-dark, inherit);
|
|
291
|
+
}
|
|
292
|
+
|
|
293
|
+
.ewp-main table {
|
|
294
|
+
width: 100%;
|
|
295
|
+
margin: 16px 0;
|
|
296
|
+
border-collapse: collapse;
|
|
297
|
+
font-size: 14px;
|
|
298
|
+
}
|
|
299
|
+
|
|
300
|
+
.ewp-main th,
|
|
301
|
+
.ewp-main td {
|
|
302
|
+
padding: 8px 12px;
|
|
303
|
+
border: 1px solid var(--ewp-border);
|
|
304
|
+
text-align: left;
|
|
305
|
+
vertical-align: top;
|
|
306
|
+
}
|
|
307
|
+
|
|
308
|
+
.ewp-main th {
|
|
309
|
+
background: var(--ewp-surface);
|
|
310
|
+
font-weight: 600;
|
|
311
|
+
}
|
|
312
|
+
|
|
313
|
+
.ew-doc-table-wrap {
|
|
314
|
+
overflow-x: auto;
|
|
315
|
+
}
|
|
316
|
+
|
|
317
|
+
/* 按钮 */
|
|
318
|
+
.ewp-button {
|
|
319
|
+
display: inline-block;
|
|
320
|
+
padding: 8px 18px;
|
|
321
|
+
border-radius: 6px;
|
|
322
|
+
border: 1px solid transparent;
|
|
323
|
+
font-size: 14px;
|
|
324
|
+
font-weight: 500;
|
|
325
|
+
}
|
|
326
|
+
|
|
327
|
+
.ewp-button:hover {
|
|
328
|
+
text-decoration: none;
|
|
329
|
+
}
|
|
330
|
+
|
|
331
|
+
.ewp-button--primary {
|
|
332
|
+
background: var(--ewp-accent);
|
|
333
|
+
color: #fff;
|
|
334
|
+
}
|
|
335
|
+
|
|
336
|
+
.ewp-button--secondary {
|
|
337
|
+
border-color: var(--ewp-border);
|
|
338
|
+
background: var(--ewp-surface);
|
|
339
|
+
color: var(--ewp-text);
|
|
340
|
+
}
|
|
341
|
+
|
|
342
|
+
.ewp-button--ghost {
|
|
343
|
+
color: var(--ewp-accent);
|
|
344
|
+
}
|
|
345
|
+
|
|
346
|
+
/* 首页 */
|
|
347
|
+
.ewp-hero {
|
|
348
|
+
padding: 24px 0 8px;
|
|
349
|
+
}
|
|
350
|
+
|
|
351
|
+
.ewp-hero__tagline {
|
|
352
|
+
margin: 0 0 8px;
|
|
353
|
+
color: var(--ewp-accent);
|
|
354
|
+
font-size: 13px;
|
|
355
|
+
letter-spacing: 0.06em;
|
|
356
|
+
text-transform: uppercase;
|
|
357
|
+
}
|
|
358
|
+
|
|
359
|
+
.ewp-hero__text {
|
|
360
|
+
max-width: 620px;
|
|
361
|
+
margin: 0 0 20px;
|
|
362
|
+
color: var(--ewp-muted);
|
|
363
|
+
font-size: 16px;
|
|
364
|
+
}
|
|
365
|
+
|
|
366
|
+
.ewp-hero__actions {
|
|
367
|
+
display: flex;
|
|
368
|
+
flex-wrap: wrap;
|
|
369
|
+
gap: 12px;
|
|
370
|
+
margin: 0;
|
|
371
|
+
}
|
|
372
|
+
|
|
373
|
+
.ewp-features {
|
|
374
|
+
display: grid;
|
|
375
|
+
grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
|
|
376
|
+
gap: 16px;
|
|
377
|
+
margin: 32px 0;
|
|
378
|
+
}
|
|
379
|
+
|
|
380
|
+
.ewp-feature {
|
|
381
|
+
padding: 16px 18px;
|
|
382
|
+
border: 1px solid var(--ewp-border);
|
|
383
|
+
border-radius: var(--ewp-radius);
|
|
384
|
+
background: var(--ewp-surface);
|
|
385
|
+
}
|
|
386
|
+
|
|
387
|
+
.ewp-feature h2 {
|
|
388
|
+
margin: 0 0 6px;
|
|
389
|
+
font-size: 15px;
|
|
390
|
+
}
|
|
391
|
+
|
|
392
|
+
.ewp-feature p {
|
|
393
|
+
margin: 0;
|
|
394
|
+
color: var(--ewp-muted);
|
|
395
|
+
font-size: 14px;
|
|
396
|
+
}
|
|
397
|
+
|
|
398
|
+
/* 上一页 / 下一页 */
|
|
399
|
+
.ewp-prevnext {
|
|
400
|
+
display: flex;
|
|
401
|
+
gap: 16px;
|
|
402
|
+
margin-top: 56px;
|
|
403
|
+
padding-top: 20px;
|
|
404
|
+
border-top: 1px solid var(--ewp-border);
|
|
405
|
+
}
|
|
406
|
+
|
|
407
|
+
.ewp-prevnext__link {
|
|
408
|
+
display: flex;
|
|
409
|
+
flex-direction: column;
|
|
410
|
+
gap: 2px;
|
|
411
|
+
font-size: 14px;
|
|
412
|
+
}
|
|
413
|
+
|
|
414
|
+
.ewp-prevnext__link--next {
|
|
415
|
+
margin-left: auto;
|
|
416
|
+
text-align: right;
|
|
417
|
+
}
|
|
418
|
+
|
|
419
|
+
.ewp-prevnext__label {
|
|
420
|
+
color: var(--ewp-muted);
|
|
421
|
+
font-size: 12px;
|
|
422
|
+
}
|
|
423
|
+
|
|
424
|
+
/* 组件文档页 */
|
|
425
|
+
.ewp-lead {
|
|
426
|
+
margin: 0 0 24px;
|
|
427
|
+
color: var(--ewp-muted);
|
|
428
|
+
font-size: 16px;
|
|
429
|
+
}
|
|
430
|
+
|
|
431
|
+
.ewp-badge {
|
|
432
|
+
padding: 1px 8px;
|
|
433
|
+
border-radius: 999px;
|
|
434
|
+
background: var(--ewp-surface);
|
|
435
|
+
border: 1px solid var(--ewp-border);
|
|
436
|
+
color: var(--ewp-muted);
|
|
437
|
+
font-size: 12px;
|
|
438
|
+
}
|
|
439
|
+
|
|
440
|
+
.ew-doc-demo {
|
|
441
|
+
margin: 20px 0;
|
|
442
|
+
border: 1px solid var(--ewp-border);
|
|
443
|
+
border-radius: var(--ewp-radius);
|
|
444
|
+
overflow: hidden;
|
|
445
|
+
}
|
|
446
|
+
|
|
447
|
+
.ew-doc-demo__head {
|
|
448
|
+
display: flex;
|
|
449
|
+
align-items: center;
|
|
450
|
+
justify-content: space-between;
|
|
451
|
+
gap: 12px;
|
|
452
|
+
padding: 10px 16px;
|
|
453
|
+
border-bottom: 1px solid var(--ewp-border);
|
|
454
|
+
background: var(--ewp-surface);
|
|
455
|
+
}
|
|
456
|
+
|
|
457
|
+
.ew-doc-demo__head h3,
|
|
458
|
+
.ew-doc-demo__head h4 {
|
|
459
|
+
margin: 0;
|
|
460
|
+
font-size: 14px;
|
|
461
|
+
}
|
|
462
|
+
|
|
463
|
+
.ew-doc-demo__preview {
|
|
464
|
+
padding: 20px;
|
|
465
|
+
}
|
|
466
|
+
|
|
467
|
+
.ew-doc-demo__toolbar {
|
|
468
|
+
padding: 6px 16px;
|
|
469
|
+
border-top: 1px solid var(--ewp-border);
|
|
470
|
+
background: var(--ewp-surface);
|
|
471
|
+
}
|
|
472
|
+
|
|
473
|
+
.ew-doc-textbtn {
|
|
474
|
+
padding: 0;
|
|
475
|
+
border: none;
|
|
476
|
+
background: none;
|
|
477
|
+
color: var(--ewp-muted);
|
|
478
|
+
font: inherit;
|
|
479
|
+
font-size: 13px;
|
|
480
|
+
cursor: pointer;
|
|
481
|
+
}
|
|
482
|
+
|
|
483
|
+
.ew-doc-textbtn:hover {
|
|
484
|
+
color: var(--ewp-accent);
|
|
485
|
+
}
|
|
486
|
+
|
|
487
|
+
.ew-doc-demo__code {
|
|
488
|
+
margin: 0;
|
|
489
|
+
padding: 14px 16px;
|
|
490
|
+
overflow: auto;
|
|
491
|
+
border-top: 1px solid var(--ewp-border);
|
|
492
|
+
font-family: var(--ewp-mono);
|
|
493
|
+
font-size: 13px;
|
|
494
|
+
}
|
|
495
|
+
|
|
496
|
+
/* 搜索浮层 */
|
|
497
|
+
.ewp-mask {
|
|
498
|
+
position: fixed;
|
|
499
|
+
inset: 0;
|
|
500
|
+
z-index: 50;
|
|
501
|
+
display: flex;
|
|
502
|
+
justify-content: center;
|
|
503
|
+
padding-top: 12vh;
|
|
504
|
+
background: rgb(0 0 0 / 40%);
|
|
505
|
+
}
|
|
506
|
+
|
|
507
|
+
.ewp-dialog {
|
|
508
|
+
width: min(560px, calc(100vw - 32px));
|
|
509
|
+
max-height: 60vh;
|
|
510
|
+
display: flex;
|
|
511
|
+
flex-direction: column;
|
|
512
|
+
border: 1px solid var(--ewp-border);
|
|
513
|
+
border-radius: var(--ewp-radius);
|
|
514
|
+
background: var(--ewp-bg);
|
|
515
|
+
box-shadow: 0 16px 48px rgb(0 0 0 / 18%);
|
|
516
|
+
overflow: hidden;
|
|
517
|
+
}
|
|
518
|
+
|
|
519
|
+
.ewp-dialog__input {
|
|
520
|
+
width: 100%;
|
|
521
|
+
padding: 14px 16px;
|
|
522
|
+
border: none;
|
|
523
|
+
border-bottom: 1px solid var(--ewp-border);
|
|
524
|
+
background: transparent;
|
|
525
|
+
color: var(--ewp-text);
|
|
526
|
+
font: inherit;
|
|
527
|
+
font-size: 15px;
|
|
528
|
+
outline: none;
|
|
529
|
+
}
|
|
530
|
+
|
|
531
|
+
.ewp-dialog__list {
|
|
532
|
+
margin: 0;
|
|
533
|
+
padding: 6px;
|
|
534
|
+
list-style: none;
|
|
535
|
+
overflow: auto;
|
|
536
|
+
}
|
|
537
|
+
|
|
538
|
+
.ewp-dialog__item {
|
|
539
|
+
display: flex;
|
|
540
|
+
flex-direction: column;
|
|
541
|
+
gap: 2px;
|
|
542
|
+
width: 100%;
|
|
543
|
+
padding: 8px 10px;
|
|
544
|
+
border: none;
|
|
545
|
+
border-radius: 6px;
|
|
546
|
+
background: transparent;
|
|
547
|
+
color: inherit;
|
|
548
|
+
font: inherit;
|
|
549
|
+
text-align: left;
|
|
550
|
+
cursor: pointer;
|
|
551
|
+
}
|
|
552
|
+
|
|
553
|
+
.ewp-dialog__item:hover {
|
|
554
|
+
background: var(--ewp-surface);
|
|
555
|
+
}
|
|
556
|
+
|
|
557
|
+
.ewp-dialog__title {
|
|
558
|
+
font-size: 14px;
|
|
559
|
+
}
|
|
560
|
+
|
|
561
|
+
.ewp-dialog__snippet {
|
|
562
|
+
display: -webkit-box;
|
|
563
|
+
-webkit-line-clamp: 2;
|
|
564
|
+
-webkit-box-orient: vertical;
|
|
565
|
+
overflow: hidden;
|
|
566
|
+
color: var(--ewp-muted);
|
|
567
|
+
font-size: 12px;
|
|
568
|
+
line-height: 1.5;
|
|
569
|
+
}
|
|
570
|
+
|
|
571
|
+
.ewp-dialog__empty {
|
|
572
|
+
padding: 14px 10px;
|
|
573
|
+
color: var(--ewp-muted);
|
|
574
|
+
font-size: 13px;
|
|
575
|
+
}
|
|
576
|
+
|
|
577
|
+
/* 页脚与 404 */
|
|
578
|
+
.ewp-footer {
|
|
579
|
+
padding: 24px;
|
|
580
|
+
border-top: 1px solid var(--ewp-border);
|
|
581
|
+
color: var(--ewp-muted);
|
|
582
|
+
font-size: 13px;
|
|
583
|
+
text-align: center;
|
|
584
|
+
}
|
|
585
|
+
|
|
586
|
+
.ewp-footer p {
|
|
587
|
+
margin: 4px 0;
|
|
588
|
+
}
|
|
589
|
+
|
|
590
|
+
.ewp-footer__links {
|
|
591
|
+
display: flex;
|
|
592
|
+
justify-content: center;
|
|
593
|
+
gap: 16px;
|
|
594
|
+
}
|
|
595
|
+
|
|
596
|
+
.ewp-notfound {
|
|
597
|
+
padding: 80px 0;
|
|
598
|
+
text-align: center;
|
|
599
|
+
}
|
|
600
|
+
|
|
601
|
+
.ewp-notfound__code {
|
|
602
|
+
margin: 0;
|
|
603
|
+
color: var(--ewp-border);
|
|
604
|
+
font-size: 64px;
|
|
605
|
+
font-weight: 700;
|
|
606
|
+
line-height: 1;
|
|
607
|
+
}
|
|
608
|
+
|
|
609
|
+
/* 窄屏:收起导航,去掉大纲 */
|
|
610
|
+
@media (max-width: 860px) {
|
|
611
|
+
.ewp-menu {
|
|
612
|
+
display: block;
|
|
613
|
+
}
|
|
614
|
+
|
|
615
|
+
.ewp-nav {
|
|
616
|
+
display: none;
|
|
617
|
+
position: absolute;
|
|
618
|
+
top: 56px;
|
|
619
|
+
left: 0;
|
|
620
|
+
right: 0;
|
|
621
|
+
flex-direction: column;
|
|
622
|
+
align-items: flex-start;
|
|
623
|
+
gap: 12px;
|
|
624
|
+
padding: 14px 24px;
|
|
625
|
+
border-bottom: 1px solid var(--ewp-border);
|
|
626
|
+
background: var(--ewp-bg);
|
|
627
|
+
}
|
|
628
|
+
|
|
629
|
+
.ewp-nav.is-open {
|
|
630
|
+
display: flex;
|
|
631
|
+
}
|
|
632
|
+
|
|
633
|
+
.ewp-nav__locale {
|
|
634
|
+
padding-left: 0;
|
|
635
|
+
border-left: none;
|
|
636
|
+
}
|
|
637
|
+
|
|
638
|
+
.ewp-search {
|
|
639
|
+
margin-left: 0;
|
|
640
|
+
}
|
|
641
|
+
|
|
642
|
+
.ewp-body,
|
|
643
|
+
.ewp-body.no-aside {
|
|
644
|
+
grid-template-columns: minmax(0, 1fr);
|
|
645
|
+
gap: 0;
|
|
646
|
+
padding: 28px 20px 56px;
|
|
647
|
+
}
|
|
648
|
+
|
|
649
|
+
.ewp-aside {
|
|
650
|
+
display: none;
|
|
651
|
+
}
|
|
652
|
+
}
|