Skip to content

Commit

Permalink
feat(atui): 提交按钮和icon
Browse files Browse the repository at this point in the history
  • Loading branch information
cos2004 committed Jul 19, 2018
1 parent 3066193 commit 1756135
Show file tree
Hide file tree
Showing 10 changed files with 236 additions and 6 deletions.
2 changes: 2 additions & 0 deletions src/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ class App extends Component {
'pages/action/progress/index',
'pages/action/action-sheet/index',
'pages/action/activity-indicator/index',
'pages/view/icon/index',
'pages/view/button/index',
],
window: {
backgroundTextStyle: 'light',
Expand Down
47 changes: 45 additions & 2 deletions src/components/button/index.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,51 @@
import Taro from "@tarojs/taro"
import { Button } from "@tarojs/components"
import { View } from "@tarojs/components"

import './index.scss'

const SIZE_CLASS = {
normal: 'normal',
large: 'large',
small: 'small',
}

const TYPE_CLASS = {
primary: 'primary',
}


export default class AtButton extends Taro.Component {
constructor() {
super(...arguments)
this.state = {

}
}

onClick() {
console.log('ddasddas')
}

render(){
return <Button className='at_button'>AtButton</Button>
let {
size = 'normal',
type = 'primary',
icon = '',
loading = false,
disabled = false,
} = this.props
let rootClassName = ['at-button']
let sizeClass = SIZE_CLASS[size] || ''
let disabledClass = disabled? 'at-button--disabled': ''
let typeClass = TYPE_CLASS[type]? `at-button--${type}`: ''

rootClassName.push(`at-button--${sizeClass}`, disabledClass, typeClass)
rootClassName = rootClassName.filter(str => str != '')
console.log(this.props, this.state)
return (
<View className={rootClassName} onClick={this.onClick}>
测试按钮
</View>
)
}
}
27 changes: 27 additions & 0 deletions src/components/button/index.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@

.at-button {
width: 710px;
height: 92px;
line-height: 92px;
text-align: center;
border-radius: 8px;
font-size: 32px;
margin: 0 auto;

border: 2px solid #6190E8;
background-color: #fff;
color: #6190E8;
box-sizing: border-box;
&--active {
opacity: .8;
}
&--disabled {
opacity: .5;
}
&--primary {
background-color: rgba(92, 137, 228, 1);
color: #fff;
border: none;

}
}
27 changes: 27 additions & 0 deletions src/components/icon/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
import Taro from '@tarojs/taro'
import { View } from '@tarojs/components'

import './index.scss'

export default class AtIcon extends Taro.Component {
constructor() {
super(...arguments)
}

render() {
let { value, size = 24, color = '#000'} = this.props

const rootStyle = {
// width: `${+size}px`,
// height: `${+size}px`,
fontSize: `${size}px`,
color,
}

let rootClassName = ['at-icon', `at-icon-${value}`]

return (
<View className={rootClassName} style={rootStyle}></View>
)
}
}
31 changes: 31 additions & 0 deletions src/components/icon/index.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@


@font-face {
font-family: 'fontello';
src: url('https://wq.360buyimg.com/data/ppms/others/fontello.ttf') format('truetype');
font-weight: normal;
font-style: normal;
}
.at-icon {
display: inline-block;
font-size: 24px;
color: #000;
&::after {
font-family: fontello;
color: currentColor;
text-transform: none;
}
}

.at-icon-arrow-left {
&::after {
content: '\e801';
}
}

.at-icon-arrow-down-left {
&::after {
content: '\e800';
}
}

5 changes: 1 addition & 4 deletions src/pages/index/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -195,10 +195,7 @@ export default class Index extends Taro.Component {
return (
<View
key={index}
onClick={this.goToComponent.bind(this, {
id: item.id,
name: child.name
})}

className='list-component'>
<View className='list-component-info'>
{child.name.split('-').join('')} {child.title}
Expand Down
45 changes: 45 additions & 0 deletions src/pages/view/button/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
import Taro from '@tarojs/taro'
import { View, Text } from '@tarojs/components'

import AtButton from '../../../components/button/index'

import './index.scss'

export default class ButtonPage extends Taro.Component {
config = {
navigationBarTitleText: 'Button Page'
}

constructor() {
super(...arguments)
this.state = {
// icons: [
// 'arrow-left',
// 'arrow-down-left',
// ]
}
}

render() {
// let {icons} = this.state
return (
<View className='page'>
<View className='example'>
<AtButton>测试按钮</AtButton>
</View>
<View className='example'>
<AtButton>测试按钮</AtButton>
</View>
<View className='example'>
<AtButton disabled>测试按钮</AtButton>
</View>
<View className='example'>
<AtButton type="secondary">测试按钮</AtButton>
</View>
<View className='example'>
<AtButton type="secondary" disabled>测试按钮</AtButton>
</View>
</View>
)
}
}
10 changes: 10 additions & 0 deletions src/pages/view/button/index.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
@import "../../../style/variables";

.page {
background-color: #fff;
}


.example {
margin-bottom: 15px;
}
39 changes: 39 additions & 0 deletions src/pages/view/icon/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
import Taro from '@tarojs/taro'
import { View, Text } from '@tarojs/components'

import AtIcon from '../../../components/icon/index'

import './index.scss'

export default class IconPage extends Taro.Component {
config = {
navigationBarTitleText: 'Icon Page'
}

constructor() {
super(...arguments)
this.state = {
icons: [
'arrow-left',
'arrow-down-left',
]
}
}

render() {
let {icons} = this.state
return (
<View className='page'>
<View className='example'>
{icons.map((icon) => {
return (
<AtIcon value={icon} color='#f00' size={30}>
</AtIcon>
)
})}

</View>
</View>
)
}
}
9 changes: 9 additions & 0 deletions src/pages/view/icon/index.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
@import "../../../style/variables";

.page {
background-color: #fff;
}

.at-icon {
margin: 0 10px;
}

0 comments on commit 1756135

Please sign in to comment.