import React, {Component} from 'react'
|
import PropTypes from 'prop-types'
|
import { is, fromJS } from 'immutable'
|
import { Form, Col, Icon } from 'antd'
|
|
import zhCN from '@/locales/zh-CN/mob.js'
|
import enUS from '@/locales/en-US/mob.js'
|
import StyleInput from '../stylecontroller/styleInput'
|
import './index.scss'
|
|
class MobController extends Component {
|
static propTpyes = {
|
config: PropTypes.any,
|
updateConfig: PropTypes.func,
|
}
|
|
state = {
|
dict: localStorage.getItem('lang') !== 'en-US' ? zhCN : enUS,
|
paddingTop: '',
|
paddingBottom: '',
|
paddingLeft: '',
|
paddingRight: ''
|
}
|
|
UNSAFE_componentWillMount () {
|
|
}
|
|
shouldComponentUpdate (nextProps, nextState) {
|
return !is(fromJS(this.state), fromJS(nextState))
|
}
|
|
/**
|
* @description 修改背景颜色 ,颜色控件
|
*/
|
changePadding = (val, type) => {
|
let config = fromJS(this.props.config).toJS()
|
|
config.style[type] = val
|
this.props.updateConfig(config)
|
}
|
|
render () {
|
const { config } = this.props
|
const formItemLayout = {
|
labelCol: {
|
xs: { span: 24 },
|
sm: { span: 4 }
|
},
|
wrapperCol: {
|
xs: { span: 24 },
|
sm: { span: 20 }
|
}
|
}
|
|
return (
|
<div className="menu-padding-controller">
|
<Form {...formItemLayout}>
|
<Col span={24}>
|
<Form.Item
|
colon={false}
|
label={<Icon title="上边距" type="arrow-up"/>}
|
>
|
<StyleInput defaultValue={config.style.paddingTop || '0px'} options={['px', 'vh', 'vw']} onChange={(val) => this.changePadding(val, 'paddingTop')}/>
|
</Form.Item>
|
</Col>
|
<Col span={24}>
|
<Form.Item
|
colon={false}
|
label={<Icon title="下边距" type="arrow-down"/>}
|
>
|
<StyleInput defaultValue={config.style.paddingBottom || '0px'} options={['px', 'vh', 'vw']} onChange={(val) => this.changePadding(val, 'paddingBottom')}/>
|
</Form.Item>
|
</Col>
|
<Col span={24}>
|
<Form.Item
|
colon={false}
|
label={<Icon title="左边距" type="arrow-left"/>}
|
>
|
<StyleInput defaultValue={config.style.paddingLeft || '0px'} options={['px', 'vh', 'vw']} onChange={(val) => this.changePadding(val, 'paddingLeft')}/>
|
</Form.Item>
|
</Col>
|
<Col span={24}>
|
<Form.Item
|
colon={false}
|
label={<Icon title="右边距" type="arrow-right"/>}
|
>
|
<StyleInput defaultValue={config.style.paddingRight || '0px'} options={['px', 'vh', 'vw']} onChange={(val) => this.changePadding(val, 'paddingRight')}/>
|
</Form.Item>
|
</Col>
|
</Form>
|
</div>
|
)
|
}
|
}
|
|
export default MobController
|