UNPKG

@cainiaofe/cn-ui-m

Version:
40 lines (39 loc) 2.09 kB
import React from 'react'; import { CnBox, CnDemoBlock, CnDemoPage, CnEllipsis, CnIcon, } from "../../.."; export var 全部icon = function () { var _a = React.useState([{ id: 1, font_class: 'case' }]), data = _a[0], setData = _a[1]; React.useEffect(function () { fetch('//at.alicdn.com/t/c/font_3267196_jnb7oe820r.json') .then(function (res) { return res.json(); }) .then(function (res) { setData(res.glyphs); }); }, []); var copyToClipboard = function (text) { window.prompt('复制到剪切板: 输入 Ctrl/Cmd +C ,然后按 Enter', text); }; return (React.createElement(CnDemoPage, { title: "\u5168\u90E8icon" }, React.createElement(CnDemoBlock, { title: "\u5168\u90E8icon" }, React.createElement(CnBox, { direction: "row", wrap: true }, data.map(function (iconItem) { if (iconItem.font_class.toLowerCase() !== iconItem.font_class) { console.log('有大写', iconItem.font_class); } if (iconItem.font_class.includes('_')) { console.log('有下划线', iconItem.font_class); } if (iconItem.font_class.includes(' ')) { console.log('有空格', iconItem.font_class); } return (React.createElement(CnBox, { direction: "row", align: "center", style: { width: '40vw', marginTop: 12 }, onClick: function () { return copyToClipboard("<CnIcon type=\"".concat(iconItem.font_class, "\" size=\"medium\" />")); } }, React.createElement(CnIcon, { key: iconItem.id, type: iconItem.font_class, size: "xl" }), React.createElement(CnEllipsis, { style: { width: '30vw', marginLeft: '4px', color: '#666', fontSize: 12, } }, iconItem.font_class))); }))))); }; export default { title: 'demo/CnIcon' };