[Feature Request] icons
xiaohuoni opened this issue · 0 comments
xiaohuoni commented
0.0.1
createReactComponent 用来创建组件的基础方法
export const AlertIcon = /*@__PURE__*/ createReactComponent<HTMLImageElement>(type,'alert');
以上代码可以通过脚本生成
const ionicIcons = ['alert]
g(ionicIcons) --> component/IonicIcons
验收测试
import React from 'react';
import { render } from '@alita/test';
import { dashToPascalCase } from './createReactComponent';
import * as Components from './';
import images from './images.json';
const getHtml = (type: string) =>
`https://cdn.jsdelivr.net/gh/ionic-team/ionic-docs@latest/static/icons/component-${type}-icon.png`;
describe('icons', () => {
images.forEach((image) => {
it(image, () => {
const Dom = Components[dashToPascalCase(image)];
const { getByRole } = render(<Dom />);
const img = getByRole('img') as HTMLImageElement;
expect(img?.src).toBe(getHtml(image));
});
});
});