@kawapress/plugin-code-group 0.0.1-beta.1 → 0.1.0

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/README.md CHANGED
@@ -16,7 +16,7 @@
16
16
  </p>
17
17
 
18
18
  <p align="center">
19
- <a href="https://www.npmjs.com/package/kawapress"><img src="https://img.shields.io/npm/v/kawapress/beta?label=npm%20beta&color=42b883" alt="npm beta version"></a>
19
+ <a href="https://www.npmjs.com/package/kawapress"><img src="https://img.shields.io/npm/v/kawapress?label=npm&color=42b883" alt="npm version"></a>
20
20
  <a href="https://github.com/ShenQingchuan/kawapress/actions/workflows/deploy-pages.yml"><img src="https://github.com/ShenQingchuan/kawapress/actions/workflows/deploy-pages.yml/badge.svg" alt="documentation build"></a>
21
21
  <a href="https://github.com/ShenQingchuan/kawapress/blob/main/LICENSE"><img src="https://img.shields.io/github/license/ShenQingchuan/kawapress" alt="MIT license"></a>
22
22
  <img src="https://img.shields.io/badge/Node.js-%E2%89%A522.12-339933?logo=nodedotjs&logoColor=white" alt="Node.js 22.12 or newer">
@@ -28,8 +28,7 @@
28
28
  <a href="https://github.com/ShenQingchuan/kawapress/blob/main/README.zh-CN.md">简体中文</a>
29
29
  </p>
30
30
 
31
- > [!IMPORTANT]
32
- > KawaPress is in beta. It is ready for testing and early projects, but APIs may change before 0.1.0. Please pin the version when adopting it today.
31
+ If you run into any problems while using KawaPress, please [open an issue](https://github.com/ShenQingchuan/kawapress/issues). Your feedback helps shape the project during its early development.
33
32
 
34
33
  ## Why KawaPress?
35
34
 
@@ -47,6 +46,18 @@ KawaPress is an independent project. It is not a VitePress fork or a drop-in rep
47
46
 
48
47
  You need [Node.js](https://nodejs.org/) 22.12 or newer.
49
48
 
49
+ Create a new site with the scaffolder:
50
+
51
+ ```sh
52
+ npm create kawapress@latest my-kawapress-site
53
+ cd my-kawapress-site
54
+ npm run dev
55
+ ```
56
+
57
+ `pnpm create kawapress my-kawapress-site` and `yarn create kawapress my-kawapress-site` do the same thing. The scaffolder asks for a site title and a default language, and can install dependencies for you.
58
+
59
+ If you would rather see every file from the start, set the site up by hand:
60
+
50
61
  ```sh
51
62
  mkdir my-kawapress-site
52
63
  cd my-kawapress-site
package/README.zh-CN.md CHANGED
@@ -16,7 +16,7 @@
16
16
  </p>
17
17
 
18
18
  <p align="center">
19
- <a href="https://www.npmjs.com/package/kawapress"><img src="https://img.shields.io/npm/v/kawapress/beta?label=npm%20beta&color=42b883" alt="npm beta 版本"></a>
19
+ <a href="https://www.npmjs.com/package/kawapress"><img src="https://img.shields.io/npm/v/kawapress?label=npm&color=42b883" alt="npm 版本"></a>
20
20
  <a href="https://github.com/ShenQingchuan/kawapress/actions/workflows/deploy-pages.yml"><img src="https://github.com/ShenQingchuan/kawapress/actions/workflows/deploy-pages.yml/badge.svg" alt="文档构建状态"></a>
21
21
  <a href="https://github.com/ShenQingchuan/kawapress/blob/main/LICENSE"><img src="https://img.shields.io/github/license/ShenQingchuan/kawapress" alt="MIT 许可"></a>
22
22
  <img src="https://img.shields.io/badge/Node.js-%E2%89%A522.12-339933?logo=nodedotjs&logoColor=white" alt="Node.js 22.12 或更高版本">
@@ -28,8 +28,7 @@
28
28
  <a href="https://github.com/ShenQingchuan/kawapress/blob/main/README.md">English</a>
29
29
  </p>
30
30
 
31
- > [!IMPORTANT]
32
- > KawaPress 目前处于 beta 阶段,适合试用和早期项目。0.1.0 之前,公开 API 仍可能调整;现阶段使用时请固定具体版本。
31
+ 使用 KawaPress 时遇到任何问题,欢迎到 [提交 Issue](https://github.com/ShenQingchuan/kawapress/issues) 反馈,一起参与本项目的早期建设。
33
32
 
34
33
  ## 为什么选择 KawaPress?
35
34
 
@@ -47,6 +46,18 @@ KawaPress 是一个独立项目,不是 VitePress 的分支或配置兼容层
47
46
 
48
47
  请先准备 [Node.js](https://nodejs.org/) 22.12 或更高版本。
49
48
 
49
+ 用脚手架创建新站点:
50
+
51
+ ```sh
52
+ npm create kawapress@latest my-kawapress-site
53
+ cd my-kawapress-site
54
+ npm run dev
55
+ ```
56
+
57
+ `pnpm create kawapress my-kawapress-site` 和 `yarn create kawapress my-kawapress-site` 的作用完全一样。脚手架会询问站点标题和默认语言,也可以顺便帮你安装依赖。
58
+
59
+ 如果你更想从零看清每个文件,可以手动创建:
60
+
50
61
  ```sh
51
62
  mkdir my-kawapress-site
52
63
  cd my-kawapress-site
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@kawapress/plugin-code-group",
3
3
  "type": "module",
4
- "version": "0.0.1-beta.1",
4
+ "version": "0.1.0",
5
5
  "description": "Accessible code group tabs for KawaPress",
6
6
  "license": "MIT",
7
7
  "homepage": "https://shenqingchuan.github.io/kawapress/",
@@ -27,7 +27,7 @@
27
27
  "./package.json": "./package.json"
28
28
  },
29
29
  "files": [
30
- "src"
30
+ "src/**/!(*.test.*)"
31
31
  ],
32
32
  "engines": {
33
33
  "node": ">=22.12.0"
@@ -38,7 +38,7 @@
38
38
  },
39
39
  "peerDependencies": {
40
40
  "vue": "^3.5.41",
41
- "kawapress": "0.0.1-beta.1"
41
+ "kawapress": "0.1.0"
42
42
  },
43
43
  "dependencies": {
44
44
  "@mdit/plugin-container": "^1.0.2"
@@ -0,0 +1,90 @@
1
+ @layer kawa.plugin {
2
+ .kawa-code-group {
3
+ margin: 1rem 0;
4
+ overflow: hidden;
5
+ background: var(--kawa-c-bg-soft);
6
+ border: 1px solid var(--kawa-c-divider);
7
+ border-radius: var(--kawa-radius);
8
+ }
9
+
10
+ .kawa-code-group__tabs {
11
+ display: flex;
12
+ gap: 1rem;
13
+ padding: 0 1rem;
14
+ overflow-x: auto;
15
+ overflow-y: hidden;
16
+ border-bottom: 1px solid var(--kawa-c-divider);
17
+ overscroll-behavior-inline: contain;
18
+ /* The tab strip scrolls by touch or trackpad; a native bar would double the border. */
19
+ scrollbar-width: none;
20
+ }
21
+
22
+ .kawa-code-group__tabs::-webkit-scrollbar {
23
+ display: none;
24
+ }
25
+
26
+ .kawa-code-group__tab {
27
+ position: relative;
28
+ flex: none;
29
+ padding: 0.75rem 0.25rem 0.625rem;
30
+ color: var(--kawa-c-text-2);
31
+ font-size: 0.8125rem;
32
+ font-weight: 500;
33
+ line-height: 1.5;
34
+ transition: color 180ms cubic-bezier(0.22, 1, 0.36, 1);
35
+ }
36
+
37
+ .kawa-code-group__tab::after {
38
+ position: absolute;
39
+ right: 0;
40
+ bottom: 0;
41
+ left: 0;
42
+ height: 2px;
43
+ background: var(--kawa-c-brand);
44
+ content: '';
45
+ opacity: 0;
46
+ transform: scaleX(0.6);
47
+ transition:
48
+ opacity 180ms cubic-bezier(0.22, 1, 0.36, 1),
49
+ transform 180ms cubic-bezier(0.22, 1, 0.36, 1);
50
+ }
51
+
52
+ .kawa-code-group__tab:hover,
53
+ .kawa-code-group__tab[aria-selected='true'] {
54
+ color: var(--kawa-c-text-1);
55
+ }
56
+
57
+ .kawa-code-group__tab[aria-selected='true']::after {
58
+ opacity: 1;
59
+ transform: scaleX(1);
60
+ }
61
+
62
+ .kawa-code-group__tab:focus-visible {
63
+ outline: 2px solid var(--kawa-c-brand);
64
+ outline-offset: -2px;
65
+ }
66
+
67
+ .kawa-code-group__panel[hidden] {
68
+ display: none;
69
+ }
70
+
71
+ /* The group already draws the frame, so the code block inside drops its own. */
72
+ .kawa-code-group__panel > .kawa-code-block {
73
+ width: 100%;
74
+ margin: 0;
75
+ border: 0;
76
+ border-radius: 0;
77
+ }
78
+
79
+ /* The tab strip already names the language. */
80
+ .kawa-code-group__panel .kawa-code-block__language {
81
+ display: none;
82
+ }
83
+
84
+ @media (prefers-reduced-motion: reduce) {
85
+ .kawa-code-group__tab,
86
+ .kawa-code-group__tab::after {
87
+ transition: none;
88
+ }
89
+ }
90
+ }
@@ -1,5 +1,6 @@
1
1
  import { defineRuntimePlugin } from 'kawapress'
2
2
  import CodeGroup from './CodeGroup.vue'
3
+ import './code-group.css'
3
4
 
4
5
  export default defineRuntimePlugin({
5
6
  name: '@kawapress/plugin-code-group',