@keyblade/svg-icons 1.0.0-alpha.0 → 1.0.0-alpha.2
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 +54 -1
- package/es/components/svg-icon/use-svg-attrs.js +1 -1
- package/es/index.d.ts +3 -0
- package/es/index.js +4 -3
- package/package.json +2 -1
package/README.md
CHANGED
|
@@ -1,4 +1,57 @@
|
|
|
1
1
|
# @keyblade/svg-icons
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
SVG 图标库
|
|
4
4
|
|
|
5
|
+
## 使用示例
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
$ pnpm i @keyblade/svg-icons
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
```ts
|
|
12
|
+
// main.ts
|
|
13
|
+
import SvgIcons from '@keyblade/svg-icons'
|
|
14
|
+
|
|
15
|
+
app.use(SvgIcons)
|
|
16
|
+
```
|
|
17
|
+
|
|
18
|
+
通过 `name` 属性指定图标,`name` 同 svg 的文件名
|
|
19
|
+
|
|
20
|
+
```html
|
|
21
|
+
<kb-svg-icon name="icon-name" />
|
|
22
|
+
```
|
|
23
|
+
|
|
24
|
+
## 图标扩展
|
|
25
|
+
|
|
26
|
+
可以在项目中扩展内置的图标库,需要配置如下加载器,加载器通过 `Promise` 返回 svg 的内容
|
|
27
|
+
|
|
28
|
+
```ts
|
|
29
|
+
// main.ts
|
|
30
|
+
import SvgIcons from '@keyblade/svg-icons'
|
|
31
|
+
|
|
32
|
+
app.use(SvgIcons, {
|
|
33
|
+
async loader(name: string) {
|
|
34
|
+
const svgUrl = new URL(`@/assets/svg/${name}.svg`, import.meta.url).href
|
|
35
|
+
const res = await fetch(svgUrl)
|
|
36
|
+
if(res.ok) {
|
|
37
|
+
return res.text()
|
|
38
|
+
}
|
|
39
|
+
return Promise.reject(res.statusText)
|
|
40
|
+
},
|
|
41
|
+
})
|
|
42
|
+
```
|
|
43
|
+
|
|
44
|
+
然后通过 `custom` 属性标明为自定义图标,如:
|
|
45
|
+
|
|
46
|
+
```html
|
|
47
|
+
<kb-svg-icon custom name="icon-name" />
|
|
48
|
+
```
|
|
49
|
+
|
|
50
|
+
## Props
|
|
51
|
+
|
|
52
|
+
名称|描述|类型|默认值|是否必须|
|
|
53
|
+
--|--|--|--|--
|
|
54
|
+
name|图标名称,对应 svg 文件名|`string`|-|是
|
|
55
|
+
size|尺寸,默认跟文本一致|`nuber`\|`string`|-|否
|
|
56
|
+
color|颜色,默认跟文本一致|`string`|-|否
|
|
57
|
+
custom|是否为自定义图标|`boolean`|`false`|否
|
|
@@ -18,7 +18,7 @@ import d from "../../_virtual/dynamic-import-helper.js";
|
|
|
18
18
|
import { isRef as u, toRef as h, inject as f, ref as w, watch as y } from "vue";
|
|
19
19
|
import { provideKey as b } from "../../config.js";
|
|
20
20
|
function l(t) {
|
|
21
|
-
const r = t.match(/width="([^"]+)"/), i = t.match(/height="([^"]+)"/), g = t.match(/viewBox="([^"]+)"/);
|
|
21
|
+
const r = t.match(/width=["']([^"']+)["']/), i = t.match(/height=["']([^"']+)["']/), g = t.match(/viewBox=["']([^"']+)["']/);
|
|
22
22
|
let s = "0", o = "0", e = "";
|
|
23
23
|
if (r && i && (s = r[1], o = i[1]), g) {
|
|
24
24
|
const [, m, x, n, p] = g[1].split(/\s+|,/);
|
package/es/index.d.ts
CHANGED
|
@@ -1,6 +1,9 @@
|
|
|
1
1
|
import { App } from 'vue';
|
|
2
2
|
import { SvgIconOptions } from './types';
|
|
3
|
+
import { default as SvgIcon } from './components/svg-icon/index.vue';
|
|
4
|
+
export * from './types';
|
|
3
5
|
export * from './utils';
|
|
6
|
+
export { SvgIcon, };
|
|
4
7
|
declare const _default: {
|
|
5
8
|
install(app: App, options?: SvgIconOptions): void;
|
|
6
9
|
};
|
package/es/index.js
CHANGED
|
@@ -2,13 +2,14 @@ import './style.css';
|
|
|
2
2
|
import r from "./components/svg-icon/index.vue.js";
|
|
3
3
|
/* empty css */
|
|
4
4
|
import { provideKey as t } from "./config.js";
|
|
5
|
-
import { getAllNames as
|
|
5
|
+
import { getAllNames as c } from "./utils.js";
|
|
6
6
|
const p = {
|
|
7
7
|
install(o, e) {
|
|
8
|
-
o.component("KbSvgIcon", r), o.provide(t, e);
|
|
8
|
+
o.component("KbSvgIcon", r), o.provide(t, e || {});
|
|
9
9
|
}
|
|
10
10
|
};
|
|
11
11
|
export {
|
|
12
|
+
r as SvgIcon,
|
|
12
13
|
p as default,
|
|
13
|
-
|
|
14
|
+
c as getAllNames
|
|
14
15
|
};
|
package/package.json
CHANGED
|
@@ -2,11 +2,12 @@
|
|
|
2
2
|
"name": "@keyblade/svg-icons",
|
|
3
3
|
"description": "KeyBlade SVG Icons",
|
|
4
4
|
"author": "yangshuai <704807396@qq.com>",
|
|
5
|
-
"version": "1.0.0-alpha.
|
|
5
|
+
"version": "1.0.0-alpha.2",
|
|
6
6
|
"private": false,
|
|
7
7
|
"type": "module",
|
|
8
8
|
"main": "es/index.js",
|
|
9
9
|
"module": "es/index.js",
|
|
10
|
+
"homepage": "https://keyblade-docs.gcongo.com.cn/component-library/keyblade/keyblade/svg-icons/start.html",
|
|
10
11
|
"files": [
|
|
11
12
|
"es",
|
|
12
13
|
"package.json",
|