-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
20 changed files
with
13,228 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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' |
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | ||
} | ||
} |
Oops, something went wrong.