Skip to content

Commit

Permalink
fix: bug
Browse files Browse the repository at this point in the history
  • Loading branch information
lhlyu committed Apr 3, 2023
1 parent 556228b commit 056654d
Show file tree
Hide file tree
Showing 20 changed files with 13,228 additions and 4 deletions.
8 changes: 4 additions & 4 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -19,24 +19,24 @@ source/db-fixed.csv
source/icons-config.json
source/icons.json

packages/svg/src
packages/svg/src/icons
packages/svg/es
packages/svg/lib
packages/svg/icons.json

packages/react/src
packages/react/src/icons
packages/react/es
packages/react/lib
packages/react/styles
packages/react/icons.json

packages/vue/src
packages/vue/src/icons
packages/vue/es
packages/vue/lib
packages/vue/styles
packages/vue/icons.json

packages/vue-next/src
packages/vue-next/src/icons
packages/vue-next/es
packages/vue-next/lib
packages/vue-next/styles
Expand Down
45 changes: 45 additions & 0 deletions packages/react/src/all.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
/**
* @file react all.ts
* @author Auto Generated by IconSpace
*/

import * as IconMap from './map'
import { IIconProps } from './runtime'
import React from 'react'

export type IconType = keyof typeof IconMap

/**
* 获取对象的属性名数组
*
* @param obj 要获取的对象
*/
function getKeys<T extends {}>(obj: T): Array<keyof T> {
return Object.keys(obj) as Array<keyof T>
}

export const ALL_ICON_KEYS = getKeys(IconMap)

export interface IIconAllProps extends IIconProps {
// FIXME just use string to prevent type error.
type: IconType | string
}

function toPascalCase(val: string): string {
return val.replace(/(^\w|-\w)/g, c => c.slice(-1).toUpperCase())
}

export default function Icon(props: IIconAllProps) {
const { type, ...extra } = props

const realType = toPascalCase(type)

if (!(realType in IconMap)) {
console.error(`${type} is not a valid icon type name`)
return
}

return React.createElement(IconMap[realType as IconType], extra)
}

export * from './runtime'
8 changes: 8 additions & 0 deletions packages/react/src/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
/**
* @file react index.ts
* @author Auto Generated by IconSpace
*/

export * from './map'

export { IconProvider, DEFAULT_ICON_CONFIGS } from './runtime'
2,690 changes: 2,690 additions & 0 deletions packages/react/src/map.ts

Large diffs are not rendered by default.

35 changes: 35 additions & 0 deletions packages/react/src/runtime/index.less
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
/**
* @file index 样式文件
* @author Auto Generated by IconSpace
*/

.i-icon {
display: inline-block;
color: inherit;
font-style: normal;
line-height: 0;
text-align: center;
text-transform: none;
vertical-align: -0.125em;
text-rendering: optimizeLegibility;
-webkit-font-smoothing: antialiased;
-moz-osx-font-smoothing: grayscale;

&-spin svg {
animation: i-icon-spin 1s infinite linear;
}
}

@keyframes i-icon-spin {
100% {
-webkit-transform: rotate(360deg);
transform: rotate(360deg);
}
}

@-webkit-keyframes i-icon-spin {
100% {
-webkit-transform: rotate(360deg);
transform: rotate(360deg);
}
}
Loading

0 comments on commit 056654d

Please sign in to comment.