feat: 优化iconfont组件库用户体验
This commit is contained in:
parent
d36518078d
commit
caf7869f15
16
packages/icon/es/Iconfont.d.ts
vendored
16
packages/icon/es/Iconfont.d.ts
vendored
@ -1,16 +0,0 @@
|
||||
import React from 'react';
|
||||
import { ReactNode } from 'react';
|
||||
interface IconFontProps {
|
||||
styles?: React.CSSProperties;
|
||||
icon: string;
|
||||
size?: number;
|
||||
color?: string;
|
||||
title?: string;
|
||||
className?: string;
|
||||
onIconClick?: (e: React.MouseEvent<HTMLElement, MouseEvent>) => void;
|
||||
children?: ReactNode;
|
||||
active?: boolean;
|
||||
disable?: boolean;
|
||||
}
|
||||
declare const IconFont: React.FC<IconFontProps>;
|
||||
export default IconFont;
|
@ -7,7 +7,7 @@ function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e
|
||||
import { createFromIconfontCN } from '@ant-design/icons';
|
||||
import React from 'react';
|
||||
var Icon = createFromIconfontCN({
|
||||
scriptUrl: require("./font_1739270_pqkfa2ldec/iconfont.js")
|
||||
scriptUrl: require("./font/iconfont.js")
|
||||
});
|
||||
var IconFont = function IconFont(props) {
|
||||
var _ref = props || {},
|
||||
|
33
packages/icon/es/demo/demo.js
Normal file
33
packages/icon/es/demo/demo.js
Normal file
@ -0,0 +1,33 @@
|
||||
import React from 'react';
|
||||
var iconJson = require("../font/iconfont.json");
|
||||
import { IconFont } from '@zhst/icon';
|
||||
import "./index.less";
|
||||
import { message } from '@zhst/meta';
|
||||
var demo = function demo() {
|
||||
var iconArr = iconJson['glyphs'];
|
||||
return /*#__PURE__*/React.createElement("div", null, /*#__PURE__*/React.createElement("ul", {
|
||||
className: 'demo-ul'
|
||||
}, iconArr.map(function (item) {
|
||||
var font_class = item.font_class,
|
||||
name = item.name;
|
||||
var fontName = "icon-".concat(font_class);
|
||||
return /*#__PURE__*/React.createElement("li", {
|
||||
className: 'demo-li'
|
||||
}, /*#__PURE__*/React.createElement(IconFont, {
|
||||
styles: {
|
||||
marginBottom: 20
|
||||
},
|
||||
icon: fontName,
|
||||
size: 32,
|
||||
onIconClick: function onIconClick() {
|
||||
navigator.clipboard.writeText(fontName);
|
||||
message.success("\u590D\u5236".concat(fontName, "\u6210\u529F"));
|
||||
}
|
||||
}), /*#__PURE__*/React.createElement("div", {
|
||||
className: "demo-li-name"
|
||||
}, name), /*#__PURE__*/React.createElement("div", {
|
||||
className: "demo-li-name"
|
||||
}, fontName));
|
||||
})));
|
||||
};
|
||||
export default demo;
|
20
packages/icon/es/demo/index.less
Normal file
20
packages/icon/es/demo/index.less
Normal file
@ -0,0 +1,20 @@
|
||||
.demo {
|
||||
&-ul {
|
||||
list-style-type: none;
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
}
|
||||
|
||||
&-li {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
align-items: center;
|
||||
height: 150px;
|
||||
width: 150px;
|
||||
|
||||
&-name {
|
||||
color: #666;
|
||||
font-size: 12px;
|
||||
}
|
||||
}
|
||||
}
|
@ -1,8 +1,8 @@
|
||||
@font-face {
|
||||
font-family: iconfont; /* Project id 1739270 */
|
||||
src: url('iconfont.woff2?t=1711007646448') format('woff2'),
|
||||
url('iconfont.woff?t=1711007646448') format('woff'),
|
||||
url('iconfont.ttf?t=1711007646448') format('truetype');
|
||||
src: url('iconfont.woff2?t=1711094074098') format('woff2'),
|
||||
url('iconfont.woff?t=1711094074098') format('woff'),
|
||||
url('iconfont.ttf?t=1711094074098') format('truetype');
|
||||
}
|
||||
|
||||
.iconfont {
|
Binary file not shown.
Binary file not shown.
BIN
packages/icon/es/font/iconfont.woff2
Normal file
BIN
packages/icon/es/font/iconfont.woff2
Normal file
Binary file not shown.
Binary file not shown.
16
packages/icon/lib/Iconfont.d.ts
vendored
16
packages/icon/lib/Iconfont.d.ts
vendored
@ -1,16 +0,0 @@
|
||||
import React from 'react';
|
||||
import { ReactNode } from 'react';
|
||||
interface IconFontProps {
|
||||
styles?: React.CSSProperties;
|
||||
icon: string;
|
||||
size?: number;
|
||||
color?: string;
|
||||
title?: string;
|
||||
className?: string;
|
||||
onIconClick?: (e: React.MouseEvent<HTMLElement, MouseEvent>) => void;
|
||||
children?: ReactNode;
|
||||
active?: boolean;
|
||||
disable?: boolean;
|
||||
}
|
||||
declare const IconFont: React.FC<IconFontProps>;
|
||||
export default IconFont;
|
@ -35,7 +35,7 @@ module.exports = __toCommonJS(Iconfont_exports);
|
||||
var import_icons = require("@ant-design/icons");
|
||||
var import_react = __toESM(require("react"));
|
||||
var Icon = (0, import_icons.createFromIconfontCN)({
|
||||
scriptUrl: require("./font_1739270_pqkfa2ldec/iconfont.js")
|
||||
scriptUrl: require("./font/iconfont.js")
|
||||
});
|
||||
var IconFont = (props) => {
|
||||
const {
|
||||
|
59
packages/icon/lib/demo/demo.js
Normal file
59
packages/icon/lib/demo/demo.js
Normal file
@ -0,0 +1,59 @@
|
||||
var __create = Object.create;
|
||||
var __defProp = Object.defineProperty;
|
||||
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
||||
var __getOwnPropNames = Object.getOwnPropertyNames;
|
||||
var __getProtoOf = Object.getPrototypeOf;
|
||||
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
||||
var __export = (target, all) => {
|
||||
for (var name in all)
|
||||
__defProp(target, name, { get: all[name], enumerable: true });
|
||||
};
|
||||
var __copyProps = (to, from, except, desc) => {
|
||||
if (from && typeof from === "object" || typeof from === "function") {
|
||||
for (let key of __getOwnPropNames(from))
|
||||
if (!__hasOwnProp.call(to, key) && key !== except)
|
||||
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
||||
}
|
||||
return to;
|
||||
};
|
||||
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
||||
// If the importer is in node compatibility mode or this is not an ESM
|
||||
// file that has been converted to a CommonJS file using a Babel-
|
||||
// compatible transform (i.e. "__esModule" has not been set), then set
|
||||
// "default" to the CommonJS "module.exports" for node compatibility.
|
||||
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
||||
mod
|
||||
));
|
||||
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
||||
|
||||
// src/demo/demo.tsx
|
||||
var demo_exports = {};
|
||||
__export(demo_exports, {
|
||||
default: () => demo_default
|
||||
});
|
||||
module.exports = __toCommonJS(demo_exports);
|
||||
var import_react = __toESM(require("react"));
|
||||
var import_icon = require("@zhst/icon");
|
||||
var import_index = require("./index.less");
|
||||
var import_meta = require("@zhst/meta");
|
||||
var iconJson = require("../font/iconfont.json");
|
||||
var demo = () => {
|
||||
const iconArr = iconJson["glyphs"];
|
||||
return /* @__PURE__ */ import_react.default.createElement("div", null, /* @__PURE__ */ import_react.default.createElement("ul", { className: "demo-ul" }, iconArr.map((item) => {
|
||||
const { font_class, name } = item;
|
||||
const fontName = `icon-${font_class}`;
|
||||
return /* @__PURE__ */ import_react.default.createElement("li", { className: "demo-li" }, /* @__PURE__ */ import_react.default.createElement(
|
||||
import_icon.IconFont,
|
||||
{
|
||||
styles: { marginBottom: 20 },
|
||||
icon: fontName,
|
||||
size: 32,
|
||||
onIconClick: () => {
|
||||
navigator.clipboard.writeText(fontName);
|
||||
import_meta.message.success(`复制${fontName}成功`);
|
||||
}
|
||||
}
|
||||
), /* @__PURE__ */ import_react.default.createElement("div", { className: "demo-li-name" }, name), /* @__PURE__ */ import_react.default.createElement("div", { className: "demo-li-name" }, fontName));
|
||||
})));
|
||||
};
|
||||
var demo_default = demo;
|
20
packages/icon/lib/demo/index.less
Normal file
20
packages/icon/lib/demo/index.less
Normal file
@ -0,0 +1,20 @@
|
||||
.demo {
|
||||
&-ul {
|
||||
list-style-type: none;
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
}
|
||||
|
||||
&-li {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
align-items: center;
|
||||
height: 150px;
|
||||
width: 150px;
|
||||
|
||||
&-name {
|
||||
color: #666;
|
||||
font-size: 12px;
|
||||
}
|
||||
}
|
||||
}
|
@ -1,8 +1,8 @@
|
||||
@font-face {
|
||||
font-family: iconfont; /* Project id 1739270 */
|
||||
src: url('iconfont.woff2?t=1711007646448') format('woff2'),
|
||||
url('iconfont.woff?t=1711007646448') format('woff'),
|
||||
url('iconfont.ttf?t=1711007646448') format('truetype');
|
||||
src: url('iconfont.woff2?t=1711094074098') format('woff2'),
|
||||
url('iconfont.woff?t=1711094074098') format('woff'),
|
||||
url('iconfont.ttf?t=1711094074098') format('truetype');
|
||||
}
|
||||
|
||||
.iconfont {
|
File diff suppressed because one or more lines are too long
Binary file not shown.
Binary file not shown.
BIN
packages/icon/lib/font/iconfont.woff2
Normal file
BIN
packages/icon/lib/font/iconfont.woff2
Normal file
Binary file not shown.
Binary file not shown.
@ -15,7 +15,7 @@ interface IconFontProps {
|
||||
disable?: boolean;
|
||||
}
|
||||
const Icon = createFromIconfontCN({
|
||||
scriptUrl: require('./font_1739270_pqkfa2ldec/iconfont.js'),
|
||||
scriptUrl: require('./font/iconfont.js'),
|
||||
});
|
||||
const IconFont: React.FC<IconFontProps> = (props) => {
|
||||
const {
|
||||
|
31
packages/icon/src/demo/demo.tsx
Normal file
31
packages/icon/src/demo/demo.tsx
Normal file
@ -0,0 +1,31 @@
|
||||
import React from 'react';
|
||||
const iconJson = require('../font/iconfont.json')
|
||||
import { IconFont } from '@zhst/icon';
|
||||
import './index.less';
|
||||
import { message } from '@zhst/meta';
|
||||
const demo = ()=>{
|
||||
const iconArr = iconJson['glyphs']
|
||||
return (
|
||||
<div>
|
||||
<ul className={'demo-ul'}>
|
||||
{iconArr.map((item: any)=>{
|
||||
const {font_class,name}= item;
|
||||
const fontName = `icon-${font_class}`
|
||||
return <li className={'demo-li'} >
|
||||
<IconFont
|
||||
styles={{marginBottom:20}}
|
||||
icon={fontName} size={32}
|
||||
onIconClick={()=>{
|
||||
navigator.clipboard.writeText(fontName)
|
||||
message.success(`复制${fontName}成功`)
|
||||
}}>
|
||||
</IconFont>
|
||||
<div className="demo-li-name">{name}</div>
|
||||
<div className="demo-li-name">{fontName}</div>
|
||||
</li>
|
||||
})}
|
||||
</ul>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
export default demo
|
20
packages/icon/src/demo/index.less
Normal file
20
packages/icon/src/demo/index.less
Normal file
@ -0,0 +1,20 @@
|
||||
.demo {
|
||||
&-ul {
|
||||
list-style-type: none;
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
}
|
||||
|
||||
&-li {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
align-items: center;
|
||||
height: 150px;
|
||||
width: 150px;
|
||||
|
||||
&-name {
|
||||
color: #666;
|
||||
font-size: 12px;
|
||||
}
|
||||
}
|
||||
}
|
@ -1,8 +1,8 @@
|
||||
@font-face {
|
||||
font-family: iconfont; /* Project id 1739270 */
|
||||
src: url('iconfont.woff2?t=1711007646448') format('woff2'),
|
||||
url('iconfont.woff?t=1711007646448') format('woff'),
|
||||
url('iconfont.ttf?t=1711007646448') format('truetype');
|
||||
src: url('iconfont.woff2?t=1711094074098') format('woff2'),
|
||||
url('iconfont.woff?t=1711094074098') format('woff'),
|
||||
url('iconfont.ttf?t=1711094074098') format('truetype');
|
||||
}
|
||||
|
||||
.iconfont {
|
Binary file not shown.
Binary file not shown.
BIN
packages/icon/src/font/iconfont.woff2
Normal file
BIN
packages/icon/src/font/iconfont.woff2
Normal file
Binary file not shown.
Binary file not shown.
@ -9,3 +9,14 @@ title: 快速上手
|
||||
<embed src="../README.md" ></embed>
|
||||
|
||||
<code src="./demo/basic.tsx">基本用法</code>
|
||||
<code src="./demo/demo.tsx">icon列表</code>
|
||||
## API
|
||||
|
||||
| 参数 | 说明 | 类型 | 默认值 | 版本 |
|
||||
| --- | --- | --- | --- | --- |
|
||||
| title | 标题 | string | '' | - |
|
||||
| styles | 样式 | cssProperties | {} | - |
|
||||
| icon | fontClass名 | string | '' | - |
|
||||
| size | fontClass名 | integer | 14 | - |
|
||||
| onIconClick | icon点击事件 | function | ()=>{} | - |
|
||||
| color | 图标颜色 | string | '' | - |
|
@ -1,11 +0,0 @@
|
||||
---
|
||||
nav:
|
||||
title: 其它
|
||||
title: 静态变量库
|
||||
toc: content
|
||||
---
|
||||
|
||||
|
||||
<embed src="../../README.md" ></embed>
|
||||
|
||||
<embed src="../../CHANGELOG.md" ></embed>
|
@ -1 +0,0 @@
|
||||
export default {}
|
Loading…
Reference in New Issue
Block a user