Add: component <Icon>

Improve: use SFC
This commit is contained in:
Jason 2018-09-18 01:35:16 +08:00
parent c5fcba3444
commit 2982026060
9 changed files with 78 additions and 20 deletions

View File

@ -1,6 +1,7 @@
{
"extends": "stylelint-config-standard",
"rules": {
"indentation": 4
"indentation": 4,
"font-family-no-missing-generic-family-keyword": null
}
}

View File

@ -8,13 +8,11 @@ interface HeaderProps extends BaseComponentProps {
title: string
}
export class Header extends React.Component<HeaderProps, {}> {
render () {
const { title, children, className, style } = this.props
export const Header: React.SFC<HeaderProps> = props => {
const { title, children, className, style } = props
return <header className={classnames('header', className)} style={style}>
<h1>{title}</h1>
<div className="operations">{children}</div>
</header>
}
return <header className={classnames('header', className)} style={style}>
<h1>{title}</h1>
<div className="operations">{children}</div>
</header>
}

View File

@ -9,7 +9,7 @@
> h1 {
flex-shrink: 0;
font-size: 30px;
font-size: 24px;
color: $color-primary-dark;
font-weight: 500;
text-shadow: 0 2px 6px rgba($color: $color-primary-dark, $alpha: 0.4);

View File

@ -0,0 +1,20 @@
import * as React from 'react'
import { BaseComponentProps } from '@models/BaseProps'
import classnames from 'classnames'
interface IconProps extends BaseComponentProps {
// icon type
type: string
// icon size
size?: number
}
export const Icon: React.SFC<IconProps> = props => {
const { type, size = 14, className: cn, style: s } = props
const className = classnames('clash-iconfont', `icon-${type}`, cn)
const style: React.CSSProperties = { fontSize: size, ...s }
const iconProps = { ...props, className, style }
return <i {...iconProps} />
}

View File

@ -1 +1,2 @@
export * from './Header'
export * from './Icon'

View File

@ -1,11 +1,11 @@
import * as React from 'react'
import { Header } from '@components'
import { Header, Icon } from '@components'
export default class Proxies extends React.Component<{}, {}> {
render () {
return <div className="container">
<Header title="代理" >
<Icon type="plus" size={20} style={{ fontWeight: 'bold' }} />
</Header>
</div>
}

View File

@ -1,4 +1,5 @@
@import 'variables';
@import 'iconfont';
// styles initial
html {

37
src/styles/iconfont.scss Normal file
View File

@ -0,0 +1,37 @@
/**
* Clash Dashboard Iconfont
* generated by iconfont.cn
*/
@import 'variables';
@font-face {
font-family: "clash-iconfont";
src: url('//at.alicdn.com/t/font_841708_2viqaiy9h37.ttf') format('truetype');
}
.clash-iconfont {
font-family: "clash-iconfont" !important;
font-size: 14px;
font-style: normal;
-webkit-font-smoothing: antialiased;
-moz-osx-font-smoothing: grayscale;
color: $color-primary-dark;
}
.icon-close::before { content: "\e602"; }
.icon-info::before { content: "\e603"; }
.icon-drag::before { content: "\e604"; }
.icon-down-arrow-o::before { content: "\e605"; }
.icon-check::before { content: "\e606"; }
.icon-plus::before { content: "\e607"; }
.icon-triangle-up::before { content: "\e608"; }
.icon-triangle-down::before { content: "\e609"; }
.icon-up-arrow-o::before { content: "\e60a"; }

View File

@ -4,11 +4,11 @@ import * as React from 'react'
import ProxiesContainer from '@containers/Proxies'
import ProxyGroupContainer from '@containers/ProxyGroup'
export default class Proxies extends React.Component<{}, {}> {
render () {
return <div className="page">
<ProxiesContainer />
<ProxyGroupContainer />
</div>
}
}
const Proxies: React.SFC = () => (
<div className="page">
<ProxiesContainer />
<ProxyGroupContainer />
</div>
)
export default Proxies