Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: init guidelines #198

Merged
merged 69 commits into from
Aug 22, 2024
Merged
Show file tree
Hide file tree
Changes from 65 commits
Commits
Show all changes
69 commits
Select commit Hold shift + click to select a range
d15d29b
feat: init guidelines
Mister-Hope Jun 5, 2024
51ba154
chore: update some colors
Mister-Hope Jun 5, 2024
451cd0c
chore: tweaks
Mister-Hope Jun 5, 2024
8a7477a
feat: add colors
Mister-Hope Jun 6, 2024
5674da8
chore: tweaks
Mister-Hope Jun 6, 2024
83958ef
feat: make styles built-in for highlighter
Mister-Hope Jul 18, 2024
d8448ab
fix: fix shiki style
Mister-Hope Jul 18, 2024
29e7d51
fix: fix styles for shiki
Mister-Hope Jul 18, 2024
3178682
feat(plugin-prismjs): remove language class from pre
Mister-Hope Jul 18, 2024
972f128
chore: remove unneeded import
Mister-Hope Jul 18, 2024
d24e1ac
chore: tweaks
Mister-Hope Jul 18, 2024
feb4100
Merge branch 'highlighter-style' into guidelines
Mister-Hope Jul 19, 2024
2e1de36
fix(theme-default): fix darkmode
Mister-Hope Jul 19, 2024
e2254ee
fix(plugin-prismjs): fix dual theme
Mister-Hope Jul 19, 2024
5754ca9
Merge branch 'highlighter-style' into guidelines
Mister-Hope Jul 19, 2024
c7e798c
feat: update styles
Mister-Hope Jul 19, 2024
30976d5
Merge branch 'main' into guidelines
Mister-Hope Jul 19, 2024
8ae82d9
chore: tweaks
Mister-Hope Jul 19, 2024
e03c5c8
chore: tweaks
Mister-Hope Jul 19, 2024
1983be5
Merge branch 'main' into guidelines
Mister-Hope Jul 19, 2024
11873a0
chore: tweaks
Mister-Hope Jul 19, 2024
e09545f
chore: tweaks
Mister-Hope Jul 19, 2024
3ae8778
chore: tweaks
Mister-Hope Jul 19, 2024
a7b22ba
chore: tweaks
Mister-Hope Jul 19, 2024
88eab22
chore: tweaks
Mister-Hope Jul 19, 2024
d90c915
chore: tweaks
Mister-Hope Jul 19, 2024
d4e08ca
chore: tweaks
Mister-Hope Jul 19, 2024
ec2e004
chore: tweaks
Mister-Hope Jul 19, 2024
8b630d9
chore: tweaks
Mister-Hope Jul 19, 2024
687095c
fix: revert
Mister-Hope Jul 19, 2024
d6a488a
chore: tweaks
Mister-Hope Jul 19, 2024
2c378d0
chore: tweaks
Mister-Hope Jul 19, 2024
e5675d8
chore: tweaks
Mister-Hope Jul 19, 2024
c4e7f02
fix: fix copy code css variables
Mister-Hope Jul 19, 2024
34b6c89
chore: tweaks
Mister-Hope Jul 19, 2024
c564150
chore: tweaks
Mister-Hope Jul 19, 2024
f86bede
chore: tweaks
Mister-Hope Jul 19, 2024
a444a94
chore: tweaks
Mister-Hope Jul 19, 2024
5bfbec3
chore: tweaks
Mister-Hope Jul 19, 2024
d90631e
chore: tweaks
Mister-Hope Jul 19, 2024
0e10b23
chore: tweaks
Mister-Hope Jul 19, 2024
bcbb3d6
chore: tweaks
Mister-Hope Jul 19, 2024
0600188
chore: tweaks
Mister-Hope Jul 19, 2024
1663b0a
chore: tweaks
Mister-Hope Jul 19, 2024
843af94
chore: tweaks
Mister-Hope Jul 19, 2024
df9382f
chore: tweaks
Mister-Hope Jul 19, 2024
b256538
chore: tweaks
Mister-Hope Jul 19, 2024
239ba22
chore: tweaks
Mister-Hope Jul 19, 2024
8c19451
chore: tweaks
Mister-Hope Jul 19, 2024
0b36066
chore: tweaks
Mister-Hope Jul 19, 2024
c65f599
chore: tweaks
Mister-Hope Jul 19, 2024
b18c4f0
chore: tweaks
Mister-Hope Jul 19, 2024
8ab89f9
Merge branch 'main' into guidelines
Mister-Hope Jul 20, 2024
bd78c9f
chore: tweaks
Mister-Hope Jul 20, 2024
e963f1f
chore: tweaks
Mister-Hope Jul 20, 2024
0d7b075
chore: tweaks
Mister-Hope Jul 20, 2024
1880f7b
chore: tweaks
Mister-Hope Jul 20, 2024
19460a3
chore: tweaks
Mister-Hope Jul 20, 2024
b90f15f
Merge branch 'main' into guidelines
Mister-Hope Aug 20, 2024
f843698
chore: tweaks
Mister-Hope Aug 20, 2024
0fcb9ce
chore: tweaks
Mister-Hope Aug 20, 2024
fb2ae47
chore: tweaks
Mister-Hope Aug 20, 2024
fc0cdc3
chore: update colors
Mister-Hope Aug 20, 2024
9296f38
chore: tweaks
Mister-Hope Aug 20, 2024
7f48564
chore: tweaks
Mister-Hope Aug 20, 2024
c95d3e4
chore: update docs
Mister-Hope Aug 21, 2024
8a9c52e
chore: fix copy icon
Mister-Hope Aug 21, 2024
9bcfbc1
chore: fix text mute
Mister-Hope Aug 22, 2024
8070b0f
chore: shrink icon size
Mister-Hope Aug 22, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions docs/plugins/development/sass-palette/guide.md
Original file line number Diff line number Diff line change
Expand Up @@ -103,9 +103,9 @@ If the Scss file is not imported directly, but is imported through `@use` or `@i

::: tip

- If you are developing a plugin, you may set `$dark-selector: html.dark !default;` in default config files, as `@vuepress/theme-default` is doing that.
- If you are developing a plugin, you may set `$dark-selector: [data-theme="dark"] !default;` in default config files, as our guideline is asking this.

Your plugin will work with default theme, and users are allowed to change this selector in config file if they are using a third-party theme with different dark selector.
Your plugin will work with most of theme, and users are still allowed to change this selector in config file if they are using a third-party theme with different dark selector.

- If you are developing a theme, you may set `$dark-selector` in default config files with your darkmode selector without `!default`, to insure users cannot override it.

Expand Down Expand Up @@ -180,15 +180,15 @@ $bg-color: (
) !default;
```

Then if `$dark-selector` has a value `"html.dark"` in config file, you will get:
Then if `$dark-selector` has a value `"[data-theme="dark"]"` in config file, you will get:

```scss
:root {
--text-color: #222;
--bg-color: #fff;
}

html.dark {
[data-theme='dark'] {
--text-color: #999;
--bg-color: #1e1e1e;
}
Expand Down
4 changes: 2 additions & 2 deletions docs/plugins/features/copy-code.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ export default {
### selector

- Type: `string | string[]`
- Default: `'.theme-default-content div[class*="language-"] pre'`
- Default: `'[vp-content] div[class*="language-"] pre'`
- Details:

Code block selector
Expand Down Expand Up @@ -187,4 +187,4 @@ export default {

You can customize the icon of the _copy button_ via CSS variables:

@[code{1-6} css](@vuepress/plugin-copy-code/src/client/styles/copy-code.css)
@[code{1-6} css](@vuepress/plugin-copy-code/src/client/styles/vars.css)
2 changes: 1 addition & 1 deletion docs/plugins/features/medium-zoom.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ export default {

- Type: `string`

- Default: `':not(a) > img'`
- Default: `'[vp-content] > img, [vp-content] :not(a) > img'`

- Details:

Expand Down
2 changes: 1 addition & 1 deletion docs/plugins/features/photo-swipe.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ In preview mode, you can:
### selector

- Type: `string | string[]`
- Default: `".theme-default-content :not(a) > img:not([no-view])"`
- Default: `"[vp-content] :not(a) > img:not([no-view])"`
- Details: Image selector

### download
Expand Down
4 changes: 2 additions & 2 deletions docs/plugins/markdown/markdown-image.md
Original file line number Diff line number Diff line change
Expand Up @@ -150,13 +150,13 @@ If the image is standalone in a line, wrapped or not wrapped by link, it will be
### lightmodeSelector

- Type: `string`
- Default: `'html:not(.dark)'`
- Default: `'[data-theme="light"]'`
- Details: The selector to detect light mode.

### darkmodeSelector

- Type: `string`
- Default: `'html.dark'`
- Default: `'[data-theme="dark"]'`
- Details: The selector to detect dark mode.

<script setup>
Expand Down
14 changes: 7 additions & 7 deletions docs/plugins/search/docsearch.md
Original file line number Diff line number Diff line change
Expand Up @@ -77,13 +77,13 @@ new Crawler({
selectors: '.vp-sidebar-heading.active',
defaultValue: 'Documentation',
},
lvl1: '.theme-default-content h1',
lvl2: '.theme-default-content h2',
lvl3: '.theme-default-content h3',
lvl4: '.theme-default-content h4',
lvl5: '.theme-default-content h5',
lvl6: '.theme-default-content h6',
content: '.theme-default-content p, .theme-default-content li',
lvl1: '[vp-content] h1',
lvl2: '[vp-content] h2',
lvl3: '[vp-content] h3',
lvl4: '[vp-content] h4',
lvl5: '[vp-content] h5',
lvl6: '[vp-content] h6',
content: '[vp-content] p, [vp-content] li',
},
indexHeadings: true,
})
Expand Down
2 changes: 1 addition & 1 deletion docs/themes/default/frontmatter.md
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ pageClass: custom-page-class
Then you can customize styles of this page in `.vuepress/styles/index.scss` file:

```scss
.theme-container.custom-page-class {
[vp-container].custom-page-class {
/* page styles */
}
```
Expand Down
76 changes: 76 additions & 0 deletions docs/themes/guidelines.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
# Theme Guidelines

To avoid theme developers and users setting unneeded options, we have a set of guidelines that should be followed when creating a theme.

## DOM Structure

A theme must implement the following DOM structure:

- Container: An element which contains the entire theme. This element should have an attribute `vp-container`.
- Content: An element which holds markdown render results. This element should have an attribute `vp-content`.

A theme may have the following optional elements:

- Navbar: Navbar of the site. This element should have an attribute `vp-navbar`.
- Sidebar: Sidebar of the site. This element should have an attribute `vp-sidebar`.
- Outline: Headings or outline of the main content. This element should have an attribute `vp-outline`.
- Comment: Comment service (comment box and comment list). This element should have an attribute `vp-comment`.
- Footer: Footer of the site. This element should have an attribute `vp-footer`.

A theme must:

- Set `data-theme` to `dark` on html in darkmode.
- Set `data-theme` to `light` on html in lightmode.

If it only have one color scheme, it still needs to set `data-theme` to `light` or `dark` to indicate the default color scheme.

## Color Variables

A theme must implement the following color variables:

### Text

- `--vp-c-text`: Default text color.
- `--vp-c-text-mute`: Colors for muted texts, such as "inactive menu" or "info texts".
- `--vp-c-text-subtle`: Color for subtle text, such as as "placeholders" or "caret icon".

### Background

- `--vp-c-bg`: The bg color used for main screen.
- `--vp-c-bg-alt`: The alternative bg color used in places such as "sidebar", or "code block".
- `--vp-c-bg-elv`: The elevated bg color. This is used at parts where it "floats", such as "dialog".

### Shadow

- `--vp-c-shadow`: The normal shadow color
- `--vp-c-shadow-hard`: The shadow color used for hard shadow, such as "dialog".

### Accent

Accent color and brand colors which used for interactive components.

- `--vp-c-accent`: The most solid color used mainly for colored text. It must satisfy the contrast ratio against when used on top of `--vp-c-accent-soft`.
- `--vp-c-accent-hover`: Color used for hover state.
- `--vp-c-accent-bg`: Color used for solid background. It must satisfy the contrast ratio with `--vp-c-accent-text` on top of it.
- `--vp-c-accent-text`: Color used for text with `--vp-c-accent-bg` background. It must satisfy the contrast ratio with `--vp-c-accent-bg`.
- `--vp-c-accent-soft`: The color used for subtle background such as custom container or badges. It must satisfy the contrast ratio when putting `--vp-c-accent` colors on top of it.

The soft color must be semi transparent alpha channel. This is crucial because it allows adding multiple "soft" colors on top of each other to create a accent, such as when having inline code block inside custom containers.

### Borders

- `--vp-c-border`: Border color for interactive components. For example this should be used for a button outline.
- `--vp-c-border-hard`: Darker border colors, which is used for "hard" borders closed to text, such as table and kbd.
- `--vp-c-divider`: Color for separators, used to divide sections within the same components, such as having separator on "h2" heading.

### Controls

- `--vp-c-control`: Background color for interactive controls, such as buttons or checkboxes.
- `--vp-c-control-hover`: Background color for hover state of interactive controls.
- `--vp-c-control-active`: Background color for active or focus state of interactive controls.
- `--vp-c-control-disabled`: Color for disabled state of interactive controls.

## Transition timing

- `--vp-t-color`: Color transition timing.
- `--vp-t-transform`: Transform transition timing.
4 changes: 2 additions & 2 deletions docs/tools/helper/client.md
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ export interface GetHeadersOptions {
* It will be passed as an argument to `document.querySelectorAll(selector)`,
* so you should pass a `CSS Selector` string.
*
* @default '#vp-content h1, #vp-content h2, #vp-content h3, #vp-content h4, #vp-content h5, #vp-content h6'
* @default '[vp-content] h1, [vp-content] h2, [vp-content] h3, [vp-content] h4, [vp-content] h5, [vp-content] h6'
*/
selector?: string
/**
Expand Down Expand Up @@ -148,7 +148,7 @@ export type MenuItem = Omit<Header, 'children' | 'slug'> & {
```ts
onMounted(() => {
const headers = getHeaders({
selector: '#vp-content :where(h1,h2,h3,h4,h5,h6)',
selector: '[vp-content] :where(h1,h2,h3,h4,h5,h6)',
levels: [2, 3], // only h2 and h3
ignore: ['.badge'], // ignore the <Badge /> within the header
})
Expand Down
8 changes: 4 additions & 4 deletions docs/zh/plugins/development/sass-palette/guide.md
Original file line number Diff line number Diff line change
Expand Up @@ -101,9 +101,9 @@ $sidebar-width: 18rem !default;

::: tip

- 如果你正在开发插件,你可以在默认配置文件中设置 `$dark-selector: html.dark !default;`,因为这是 `@vuepress/theme-default` 的默认行为
- 如果你正在开发插件,你可以在默认配置文件中设置 `$dark-selector: [data-theme="dark"] !default;`,因为这是社区对主题的推荐要求

你的插件将在默认主题正常工作,如果用户使用具有不同深色模式选择器的第三方主题,则用户可以在配置文件中更改此选择器。
你的插件将在绝大多主题中正常工作,如果用户使用具有不同深色模式选择器的第三方主题,则用户可以在配置文件中更改此选择器。

- 如果你在开发主题,你可以在默认配置文件中设置 `$dark-selector` 为你的深色模式选择器同时不包含 `!default`,确保用户不能覆盖它。

Expand Down Expand Up @@ -178,15 +178,15 @@ $bg-color: (
) !default;
```

然后,如果在配置文件中 `$dark-selector` 的值为 `"html.dark"`,你会得到:
然后,如果在配置文件中 `$dark-selector` 的值为 `"[data-theme="dark"]"`,你会得到:

```scss
:root {
--text-color: #222;
--bg-color: #fff;
}

html.dark {
[data-theme='dark'] {
--text-color: #999;
--bg-color: #1e1e1e;
}
Expand Down
4 changes: 2 additions & 2 deletions docs/zh/plugins/features/copy-code.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ export default {
### selector

- 类型:`string | string[]`
- 默认值:`'.theme-default-content div[class*="language-"] pre'`
- 默认值:`'[vp-content] div[class*="language-"] pre'`
- 详情:

代码块选择器
Expand Down Expand Up @@ -185,4 +185,4 @@ export default {

你可以通过 CSS 变量来自定义*复制按钮*的样式:

@[code{1-6} css](@vuepress/plugin-copy-code/src/client/styles/copy-code.css)
@[code{1-6} css](@vuepress/plugin-copy-code/src/client/styles/vars.css)
2 changes: 1 addition & 1 deletion docs/zh/plugins/features/medium-zoom.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ export default {

- 类型: `string`

- 默认值: `':not(a) > img'`
- 默认值: `'[vp-content] > img, [vp-content] :not(a) > img'`

- 详情:

Expand Down
2 changes: 1 addition & 1 deletion docs/zh/plugins/features/photo-swipe.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ export default {
### selector

- 类型:`string | string[]`
- 默认值:`".theme-default-content :not(a) > img:not([no-view])"`
- 默认值:`"[vp-content] :not(a) > img:not([no-view])"`
- 详情:图片选择器

### download
Expand Down
4 changes: 2 additions & 2 deletions docs/zh/plugins/markdown/markdown-image.md
Original file line number Diff line number Diff line change
Expand Up @@ -149,13 +149,13 @@ interface ImageMarkOptions {
### lightmodeSelector

- 类型:`string`
- 默认值:`'html:not(.dark)'`
- 默认值:`'[data-theme="light"]'`
- 详情:日间模式的选择器。

### darkmodeSelector

- 类型:`string`
- 默认值:`'html.dark'`
- 默认值:`'[data-theme="dark"]'`
- 详情:夜间模式的选择器。

<script setup>
Expand Down
14 changes: 7 additions & 7 deletions docs/zh/plugins/search/docsearch.md
Original file line number Diff line number Diff line change
Expand Up @@ -76,13 +76,13 @@ new Crawler({
selectors: '.vp-sidebar-heading.active',
defaultValue: 'Documentation',
},
lvl1: '.theme-default-content h1',
lvl2: '.theme-default-content h2',
lvl3: '.theme-default-content h3',
lvl4: '.theme-default-content h4',
lvl5: '.theme-default-content h5',
lvl6: '.theme-default-content h6',
content: '.theme-default-content p, .theme-default-content li',
lvl1: '[vp-content] h1',
lvl2: '[vp-content] h2',
lvl3: '[vp-content] h3',
lvl4: '[vp-content] h4',
lvl5: '[vp-content] h5',
lvl6: '[vp-content] h6',
content: '[vp-content] p, [vp-content] li',
},
indexHeadings: true,
})
Expand Down
2 changes: 1 addition & 1 deletion docs/zh/themes/default/frontmatter.md
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ pageClass: custom-page-class
然后你可以在 `.vuepress/styles/index.scss` 文件中为这个页面添加自定义样式:

```scss
.theme-container.custom-page-class {
[vp-container].custom-page-class {
/* 页面样式 */
}
```
Expand Down
78 changes: 78 additions & 0 deletions docs/zh/themes/guidelines.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
# 主题指南

为了避免主题开发者和用户设置不必要的选项,我们制定了一套主题创建时应遵循的指南。

## DOM 结构

A theme must implement the following DOM structure:
Mister-Hope marked this conversation as resolved.
Show resolved Hide resolved

一个主题必须实现以下 DOM 结构:

- 容器:一个包含整个主题的元素。此元素应该有一个 `vp-container` 属性。
- 内容:一个包含 markdown 渲染结果的元素。此元素应该有一个 `vp-content` 属性。

一个主题可以有以下可选元素:

- 导航栏:站点的导航栏。此元素应该有一个 `vp-navbar` 属性。
- 侧边栏:站点的侧边栏。此元素应该有一个 `vp-sidebar` 属性。
- 大纲:主要内容的标题或大纲。此元素应该有一个 `vp-outline` 属性。
- 评论:评论服务(评论框和评论列表)。此元素应该有一个 `vp-comment` 属性。
- 页脚:站点的页脚。此元素应该有一个 `vp-footer` 属性。

一个主题必须:

- 在暗色模式下,将 html 元素的 `data-theme` 设置为 `dark`。
- 在亮色模式下,将 html 元素的 `data-theme` 设置为 `light`。

如果主题只有一种颜色方案,主题仍然需要将 `data-theme` 设置为 `light` 或 `dark`,以指示默认颜色方案。

## 颜色变量

一个主题必须实现以下颜色变量:

### 文字

- `--vp-c-text`:默认文本颜色。
- `--vp-c-text-mute`:用于静音文本的颜色,例如“非活动菜单”或“信息文本”。
- `--vp-c-text-subtle`:用于细微文本的颜色,例如“占位符”或“插入符号”。

### 背景

- `--vp-c-bg`:用于主屏幕的背景颜色。
- `--vp-c-bg-alt`:用于“侧边栏”或“代码块”等地方的备用背景颜色。
- `--vp-c-bg-elv`:用于“浮动”部分的提升背景颜色,例如“对话框”。

### 阴影

- `--vp-c-shadow`:正常阴影颜色
- `--vp-c-shadow-hard`:用于硬阴影的阴影颜色,例如“对话框”。

### 强调

用于交互组件的强调颜色和品牌颜色。

- `--vp-c-accent`:主要用于彩色文本的最实色。它必须满足与放在 `--vp-c-accent-soft` 顶部时的对比度。
- `--vp-c-accent-hover`:用于悬停状态的颜色。
- `--vp-c-accent-bg`:用于实色背景的颜色。它必须满足与放在其顶部的 `--vp-c-accent-text` 的对比度。
- `--vp-c-accent-text`:用于 `--vp-c-accent-bg` 背景的文本颜色。它必须满足与 `--vp-c-accent-bg` 的对比度。
- `--vp-c-accent-soft`:用于自定义容器或徽章等细微背景的颜色。当将 `--vp-c-accent` 颜色放在其顶部时,它必须满足对比度。

软色必须是半透明的 alpha 通道。这是至关重要的,因为它允许将多个“软”颜色叠加在一起以创建强调,例如在自定义容器内部有内联代码块时。

### 边框

- `--vp-c-border`:交互组件的边框颜色。例如,这应该用于按钮轮廓。
- `--vp-c-border-hard`:较暗的边框颜色,用于紧贴文本的“硬”边框,例如表格和 kbd。
- `--vp-c-divider`:分隔符的颜色,用于在同一组件内分隔部分,例如在“h2”标题上放置分隔符。

### 控件

- `--vp-c-control`:用于交互控件(例如按钮或复选框)的背景颜色。
- `--vp-c-control-hover`:用于交互控件悬停状态的背景颜色。
- `--vp-c-control-active`:用于交互控件的活动或焦点状态的背景颜色。
- `--vp-c-control-disabled`:用于交互控件禁用状态的颜色。

## 过渡时间

- `--vp-t-color`:颜色过渡时间。
- `--vp-t-transform`:变换过渡时间。
Loading
Loading