@tnotesjs/ui 0.4.3 → 0.4.4
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/dist/alerts/icons.d.ts +8 -0
- package/dist/alerts/icons.js +29 -0
- package/package.json +8 -3
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/** GitHub Alerts 风格的容器图标。`currentColor`,颜色由侧边色条同一变量决定。 */
|
|
2
|
+
declare const ALERT_TYPES: readonly ["tip", "info", "warning", "danger", "details"];
|
|
3
|
+
type AlertType = (typeof ALERT_TYPES)[number];
|
|
4
|
+
declare function isAlertType(name: string): name is AlertType;
|
|
5
|
+
declare function alertIcon(name: string): string;
|
|
6
|
+
declare const ALERT_LABELS: Record<AlertType, string>;
|
|
7
|
+
|
|
8
|
+
export { ALERT_LABELS, ALERT_TYPES, type AlertType, alertIcon, isAlertType };
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
// src/alerts/icons.ts
|
|
2
|
+
var ALERT_TYPES = ["tip", "info", "warning", "danger", "details"];
|
|
3
|
+
var PATHS = {
|
|
4
|
+
tip: '<path fill="currentColor" d="M8 1.5a4.5 4.5 0 0 0-2.6 8.17c.3.22.5.5.55.84l.2 1.24h3.7l.2-1.24c.05-.34.25-.62.55-.84A4.5 4.5 0 0 0 8 1.5Zm1.9 11.25H6.1l.15.9c.05.3.3.5.6.5h1.5c.3 0 .55-.2.6-.5l.15-.9ZM8 0a6 6 0 0 1 3.5 10.87l-.35 2.1A2.1 2.1 0 0 1 9.1 15H6.9a2.1 2.1 0 0 1-2.05-1.53l-.35-2.1A6 6 0 0 1 8 0Z"/>',
|
|
5
|
+
info: '<path fill="currentColor" d="M8 1.5a6.5 6.5 0 1 0 0 13 6.5 6.5 0 0 0 0-13ZM0 8a8 8 0 1 1 16 0A8 8 0 0 1 0 8Zm8-3.25a.75.75 0 0 1 .75.75v.01a.75.75 0 0 1-1.5 0V5.5A.75.75 0 0 1 8 4.75ZM7.25 7.5a.75.75 0 0 1 1.5 0v4a.75.75 0 0 1-1.5 0v-4Z"/>',
|
|
6
|
+
warning: '<path fill="currentColor" d="M6.46 1.96a1.8 1.8 0 0 1 3.08 0l5.9 9.92A1.8 1.8 0 0 1 13.9 14.5H2.1a1.8 1.8 0 0 1-1.54-2.62l5.9-9.92ZM8 3.15 2.1 13h11.8L8 3.15Zm-.75 3.6a.75.75 0 0 1 1.5 0v2.5a.75.75 0 0 1-1.5 0V6.75Zm.75 5.5a.9.9 0 1 1 0-1.8.9.9 0 0 1 0 1.8Z"/>',
|
|
7
|
+
danger: '<path fill="currentColor" d="M8 0 15.5 4.3v7.4L8 16 0.5 11.7V4.3L8 0Zm0 1.7L1.9 5.1v5.8L8 14.3l6.1-3.4V5.1L8 1.7ZM7.25 4.75a.75.75 0 0 1 1.5 0v3.5a.75.75 0 0 1-1.5 0v-3.5Zm.75 6.5a.9.9 0 1 1 0-1.8.9.9 0 0 1 0 1.8Z"/>',
|
|
8
|
+
details: '<path fill="currentColor" d="M2 3.75A.75.75 0 0 1 2.75 3h10.5a.75.75 0 0 1 0 1.5H2.75A.75.75 0 0 1 2 3.75ZM2 8a.75.75 0 0 1 .75-.75h10.5a.75.75 0 0 1 0 1.5H2.75A.75.75 0 0 1 2 8Zm.75 3.5h6.5a.75.75 0 0 1 0 1.5h-6.5a.75.75 0 0 1 0-1.5Z"/>'
|
|
9
|
+
};
|
|
10
|
+
function isAlertType(name) {
|
|
11
|
+
return ALERT_TYPES.includes(name);
|
|
12
|
+
}
|
|
13
|
+
function alertIcon(name) {
|
|
14
|
+
const type = isAlertType(name) ? name : "info";
|
|
15
|
+
return `<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 16 16" width="16" height="16" aria-hidden="true">${PATHS[type]}</svg>`;
|
|
16
|
+
}
|
|
17
|
+
var ALERT_LABELS = {
|
|
18
|
+
tip: "\u63D0\u793A",
|
|
19
|
+
info: "\u4FE1\u606F",
|
|
20
|
+
warning: "\u8B66\u544A",
|
|
21
|
+
danger: "\u9519\u8BEF",
|
|
22
|
+
details: "\u8BE6\u60C5"
|
|
23
|
+
};
|
|
24
|
+
export {
|
|
25
|
+
ALERT_LABELS,
|
|
26
|
+
ALERT_TYPES,
|
|
27
|
+
alertIcon,
|
|
28
|
+
isAlertType
|
|
29
|
+
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tnotesjs/ui",
|
|
3
|
-
"version": "0.4.
|
|
3
|
+
"version": "0.4.4",
|
|
4
4
|
"description": "Shared Vue UI for TNotes built-in blocks — consumed by the TNotes SSG and Desk.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"exports": {
|
|
@@ -50,7 +50,12 @@
|
|
|
50
50
|
},
|
|
51
51
|
"./code-block": "./src/components/CodeBlock/CodeBlock.vue",
|
|
52
52
|
"./code-group": "./src/components/CodeGroup/CodeGroup.vue",
|
|
53
|
-
"./alerts":
|
|
53
|
+
"./alerts": {
|
|
54
|
+
"types": "./src/alerts/icons.ts",
|
|
55
|
+
"node": "./dist/alerts/icons.js",
|
|
56
|
+
"import": "./src/alerts/icons.ts",
|
|
57
|
+
"default": "./src/alerts/icons.ts"
|
|
58
|
+
},
|
|
54
59
|
"./badge": "./src/components/Badge/Badge.vue",
|
|
55
60
|
"./image-preview": "./src/components/ImagePreview/ImagePreview.vue",
|
|
56
61
|
"./bilibili-video": "./src/entries/bilibili-video.ts",
|
|
@@ -134,7 +139,7 @@
|
|
|
134
139
|
],
|
|
135
140
|
"license": "MIT",
|
|
136
141
|
"scripts": {
|
|
137
|
-
"build": "tsup src/code/highlight.ts src/components/Footprints/parse.ts src/components/Mindmap/markdown.ts src/markdown/image.ts src/markdown/lineBreaks.ts src/swiper/hydrate.ts --format esm --dts --out-dir dist --clean",
|
|
142
|
+
"build": "tsup src/alerts/icons.ts src/code/highlight.ts src/components/Footprints/parse.ts src/components/Mindmap/markdown.ts src/markdown/image.ts src/markdown/lineBreaks.ts src/swiper/hydrate.ts --format esm --dts --out-dir dist --clean",
|
|
138
143
|
"typecheck": "tsc --noEmit -p tsconfig.json",
|
|
139
144
|
"test": "vitest run",
|
|
140
145
|
"lint": "eslint . --max-warnings=0",
|