import React, {Component} from 'react'
|
import PropTypes from 'prop-types'
|
import { is, fromJS } from 'immutable'
|
import { Collapse, Form, Col, InputNumber, Input, Select, Radio, Drawer, Button } from 'antd'
|
import {
|
ColumnHeightOutlined,
|
FontSizeOutlined,
|
BoldOutlined,
|
LineHeightOutlined,
|
ColumnWidthOutlined,
|
FontColorsOutlined,
|
ItalicOutlined,
|
AlignLeftOutlined,
|
AlignCenterOutlined,
|
AlignRightOutlined,
|
UnderlineOutlined,
|
StrikethroughOutlined,
|
BgColorsOutlined,
|
PictureOutlined,
|
BorderOutlined,
|
BorderOuterOutlined,
|
BorderLeftOutlined,
|
BorderRightOutlined,
|
BorderTopOutlined,
|
BorderBottomOutlined,
|
RadiusSettingOutlined,
|
ArrowUpOutlined,
|
ArrowDownOutlined,
|
ArrowLeftOutlined,
|
ArrowRightOutlined,
|
SwapOutlined,
|
EnterOutlined,
|
} from '@ant-design/icons'
|
|
import MKEmitter from '@/utils/events.js'
|
import asyncComponent from '@/utils/asyncComponent'
|
import StyleInput from './styleInput'
|
import MainLogo from '@/assets/img/main-logo.png'
|
import './index.scss'
|
|
const { Panel } = Collapse
|
const { Option } = Select
|
const ColorSketch = asyncComponent(() => import('@/mob/colorsketch'))
|
const SourceComponent = asyncComponent(() => import('@/menu/components/share/sourcecomponent'))
|
|
class MobController extends Component {
|
static propTpyes = {
|
editElem: PropTypes.any,
|
updateStyle: PropTypes.func,
|
}
|
|
state = {
|
card: null,
|
fonts: null,
|
backgroundImage: '',
|
options: [],
|
borposition: 'outer'
|
}
|
|
callback = null
|
|
shouldComponentUpdate (nextProps, nextState) {
|
return !is(fromJS(this.state), fromJS(nextState))
|
}
|
|
componentDidMount () {
|
MKEmitter.addListener('changeStyle', this.initStyle)
|
}
|
|
/**
|
* @description 组件销毁,清除state更新,清除快捷键设置
|
*/
|
componentWillUnmount () {
|
this.setState = () => {
|
return
|
}
|
MKEmitter.removeListener('changeStyle', this.initStyle)
|
}
|
|
initStyle = (options, style = {}, callback) => {
|
let backgroundImage = ''
|
if (style.backgroundImage && /^url/ig.test(style.backgroundImage)) {
|
backgroundImage = style.backgroundImage.replace(/^url\(/ig, '').replace(/\)$/ig, '')
|
}
|
let fonts = null
|
if (options.includes('font')) {
|
fonts = ['fontSize', 'fontWeight', 'lineHeight', 'letterSpacing', 'color', 'fontStyle', 'textAlign', 'textDecoration']
|
} else if (options.includes('font1')) {
|
fonts = ['fontSize', 'fontWeight', 'color']
|
if (options[0] === 'font1') {
|
options[0] = 'font'
|
}
|
} else if (options.includes('font2')) {
|
fonts = ['fontSize', 'fontWeight', 'lineHeight', 'letterSpacing', 'color', 'fontStyle', 'textAlign', 'textDecoration', 'textIndent', 'wordBreak']
|
if (options[0] === 'font2') {
|
options[0] = 'font'
|
}
|
}
|
|
this.callback = callback
|
let card = fromJS(style).toJS()
|
let borposition = 'outer'
|
|
if (!card.borderWidth) {
|
if (card.borderLeftWidth) {
|
borposition = 'left'
|
} else if (card.borderRightWidth) {
|
borposition = 'right'
|
} else if (card.borderTopWidth) {
|
borposition = 'top'
|
} else if (card.borderBottomWidth) {
|
borposition = 'bottom'
|
}
|
}
|
|
this.setState({
|
visible: true,
|
fonts: fonts,
|
card: card,
|
options: options,
|
borposition: borposition,
|
backgroundImage
|
})
|
window.GLOB.styling = true
|
}
|
|
onCloseDrawer = () => {
|
let card = fromJS(this.state.card).toJS()
|
|
let check = false
|
if (card.borderWidth === '0px') {
|
delete card.borderWidth
|
delete card.borderColor
|
check = true
|
} else if (card.borderLeftWidth === '0px') {
|
delete card.borderLeftWidth
|
delete card.borderLeftColor
|
check = true
|
} else if (card.borderRightWidth === '0px') {
|
delete card.borderRightWidth
|
delete card.borderRightColor
|
check = true
|
} else if (card.borderTopWidth === '0px') {
|
delete card.borderTopWidth
|
delete card.borderTopColor
|
check = true
|
} else if (card.borderBottomWidth === '0px') {
|
delete card.borderBottomWidth
|
delete card.borderBottomColor
|
check = true
|
}
|
|
if (check) {
|
this.callback && this.callback(card)
|
}
|
|
this.setState({
|
visible: false,
|
card: null,
|
options: [],
|
backgroundImage: ''
|
})
|
window.GLOB.styling = false
|
this.callback = null
|
}
|
|
updateStyle = (style) => {
|
const { card } = this.state
|
|
let _style = {
|
...card,
|
...style
|
}
|
|
this.setState({
|
card: _style,
|
})
|
|
this.callback && this.callback(_style)
|
}
|
|
/**
|
* @description 字体大小切换,超出范围忽略
|
*/
|
changeFontSize = (val) => {
|
let value = parseInt(val)
|
|
if (isNaN(value)) return
|
|
if (value < 12) {
|
value = 12
|
} else if (value > 300) {
|
value = 300
|
}
|
|
this.updateStyle({fontSize: `${value}px`})
|
}
|
|
/**
|
* @description 修改行间距,超出范围忽略
|
*/
|
changeLineHeight = (val) => {
|
let value = parseFloat(val)
|
|
if (isNaN(value) || value < 1 || value > 10) return
|
|
this.updateStyle({lineHeight: value})
|
}
|
|
/**
|
* @description 字体间距修改,超出范围忽略
|
*/
|
changeLetterSpacing = (val) => {
|
let value = parseFloat(val)
|
|
if (isNaN(value) || value < 0 || value > 100) return
|
|
this.updateStyle({letterSpacing: `${value}px`})
|
}
|
|
/**
|
* @description 首行缩进
|
*/
|
changeTextIndent = (val) => {
|
let value = parseFloat(val)
|
|
if (isNaN(value) || value < 0 || value > 100) return
|
|
this.updateStyle({textIndent: `${value}px`})
|
}
|
|
/**
|
* @description 修改字体粗细
|
*/
|
boldChange = (val) => {
|
this.updateStyle({fontWeight: val})
|
}
|
|
/**
|
* @description 自动换行
|
*/
|
wordBreakChange = (val) => {
|
this.updateStyle({wordBreak: val})
|
}
|
|
/**
|
* @description 修改字体颜色 ,颜色控件
|
*/
|
changeFontColor = (val) => {
|
this.updateStyle({color: val})
|
}
|
|
/**
|
* @description 字体对齐
|
*/
|
changeTextAlign = (e) => {
|
this.updateStyle({textAlign: e.target.value})
|
}
|
|
/**
|
* @description 字体样式,倾斜
|
*/
|
changeFontStyle = (e) => {
|
this.updateStyle({fontStyle: e.target.value})
|
}
|
|
/**
|
* @description 字体装饰,下划线、贯穿线、上划线
|
*/
|
changeTextDecoration = (e) => {
|
this.updateStyle({textDecoration: e.target.value})
|
}
|
|
/**
|
* @description 修改背景颜色 ,颜色控件
|
*/
|
changeBackgroundColor = (val) => {
|
this.updateStyle({backgroundColor: val})
|
}
|
|
changeBackground = (val) => {
|
const { card } = this.state
|
|
let _style = { ...card }
|
|
_style.background = val
|
|
delete _style.backgroundColor
|
delete _style.backgroundImage
|
|
if (!val) {
|
delete _style.background
|
}
|
|
this.setState({
|
card: _style,
|
})
|
|
if (!val || /(^linear-gradient|^radial-gradient)\(.*\)$/.test(val)) {
|
this.callback && this.callback(_style)
|
}
|
}
|
|
/**
|
* @description 修改背景大小
|
*/
|
changeBackgroundSize = (val) => {
|
this.updateStyle({backgroundSize: val})
|
}
|
|
/**
|
* @description 修改背景位置
|
*/
|
changeBackgroundPositon= (val) => {
|
this.updateStyle({backgroundPosition: val})
|
}
|
|
/**
|
* @description 修改背景重复设置
|
*/
|
changeBackgroundRepeat = (val) => {
|
this.updateStyle({backgroundRepeat: val})
|
}
|
|
/**
|
* @description 修改阴影颜色 ,颜色控件
|
*/
|
changeShadowColor = (val) => {
|
const { card } = this.state
|
|
let boxShadow = `${card.hShadow || '0px'} ${card.vShadow || '0px'} ${card.shadowBlur || '0px'} ${val}`
|
|
this.updateStyle({shadowColor: val, boxShadow})
|
}
|
|
/**
|
* @description 修改阴影颜色 ,颜色控件
|
*/
|
changeShadowBlur = (val) => {
|
const { card } = this.state
|
|
let boxShadow = `${card.hShadow || '0px'} ${card.vShadow || '0px'} ${val || '0px'} ${card.shadowColor || 'transparent'}`
|
|
this.updateStyle({shadowBlur: val, boxShadow})
|
}
|
|
/**
|
* @description 修改阴影颜色 ,颜色控件
|
*/
|
changeHShadow = (val) => {
|
const { card } = this.state
|
|
let boxShadow = `${val || '0px'} ${card.vShadow || '0px'} ${card.shadowBlur || '0px'} ${card.shadowColor || 'transparent'}`
|
|
this.updateStyle({hShadow: val, boxShadow})
|
}
|
|
/**
|
* @description 修改阴影颜色 ,颜色控件
|
*/
|
changeVShadow = (val) => {
|
const { card } = this.state
|
|
let boxShadow = `${card.hShadow || '0px'} ${val || '0px'} ${card.shadowBlur || '0px'} ${card.shadowColor || 'transparent'}`
|
|
this.updateStyle({vShadow: val, boxShadow})
|
}
|
|
imgChange = (val) => {
|
this.setState({
|
backgroundImage: val
|
})
|
if (val) {
|
this.updateStyle({backgroundImage: `url(${val})`})
|
} else {
|
this.updateStyle({backgroundImage: ''})
|
}
|
}
|
|
changeBorderStyle = (val) => {
|
const { borposition } = this.state
|
let _style = {}
|
|
if (borposition === 'outer') {
|
_style.borderStyle = val
|
} else if (borposition === 'left') {
|
_style.borderLeftStyle = val
|
} else if (borposition === 'right') {
|
_style.borderRightStyle = val
|
} else if (borposition === 'top') {
|
_style.borderTopStyle = val
|
} else if (borposition === 'bottom') {
|
_style.borderBottomStyle = val
|
}
|
|
this.updateStyle(_style)
|
}
|
|
changeBorderWidth = (val) => {
|
const { borposition } = this.state
|
let _style = {}
|
|
if (borposition === 'outer') {
|
_style.borderWidth = val
|
} else if (borposition === 'left') {
|
_style.borderLeftWidth = val
|
} else if (borposition === 'right') {
|
_style.borderRightWidth = val
|
} else if (borposition === 'top') {
|
_style.borderTopWidth = val
|
} else if (borposition === 'bottom') {
|
_style.borderBottomWidth = val
|
}
|
|
this.updateStyle(_style)
|
}
|
|
changeBorderColor = (val) => {
|
const { borposition } = this.state
|
let _style = {}
|
|
if (borposition === 'outer') {
|
_style.borderColor = val
|
} else if (borposition === 'left') {
|
_style.borderLeftColor = val
|
} else if (borposition === 'right') {
|
_style.borderRightColor = val
|
} else if (borposition === 'top') {
|
_style.borderTopColor = val
|
} else if (borposition === 'bottom') {
|
_style.borderBottomColor = val
|
}
|
|
this.updateStyle(_style)
|
}
|
|
changeWidth = (val) => {
|
const { card } = this.state
|
let _style = {...card}
|
|
if (val === '0px') {
|
delete _style.width
|
} else {
|
_style.width = val
|
}
|
|
this.setState({
|
card: _style
|
})
|
|
this.callback && this.callback(_style)
|
}
|
|
changeHeight = (val) => {
|
let _val = val
|
if (_val === '0px') {
|
_val = 'auto'
|
}
|
|
this.updateStyle({height: _val})
|
}
|
|
changeNormalStyle = (val, type) => {
|
this.updateStyle({[type]: val})
|
}
|
|
render () {
|
const { card, options, backgroundImage, borposition, fonts } = this.state
|
const formItemLayout = {
|
labelCol: {
|
xs: { span: 24 },
|
sm: { span: 8 }
|
},
|
wrapperCol: {
|
xs: { span: 24 },
|
sm: { span: 16 }
|
}
|
}
|
|
return (
|
<Drawer
|
title={
|
<div className="header-logo">
|
<img src={MainLogo} alt=""/>
|
</div>
|
}
|
placement="left"
|
width="300"
|
className="menu-style-drawer"
|
closable={true}
|
maskClosable={false}
|
onClose={this.onCloseDrawer}
|
maskStyle={{opacity: 0.1}}
|
visible={this.state.visible}
|
>
|
<div className="menu-style-controller">
|
<Form {...formItemLayout}>
|
{card ? <Collapse expandIconPosition="right" destroyInactivePanel={true} defaultActiveKey={options[0]}>
|
{options.includes('width') ? <Panel header="宽度" key="width">
|
<Col span={24}>
|
<Form.Item
|
colon={false}
|
label={<ColumnWidthOutlined title="宽度"/>}
|
labelCol={{xs: { span: 24 }, sm: { span: 4 }}} wrapperCol={ {xs: { span: 24 }, sm: { span: 20 }} }
|
>
|
<StyleInput defaultValue={card.width || ''} options={['px', 'vh', 'vw', '%', 'auto']} onChange={this.changeWidth}/>
|
</Form.Item>
|
</Col>
|
</Panel> : null}
|
{options.includes('height') ? <Panel header="高度" key="height">
|
<Col span={24}>
|
<Form.Item
|
colon={false}
|
label={<ColumnHeightOutlined title="高度"/>}
|
labelCol={{xs: { span: 24 }, sm: { span: 4 }}} wrapperCol={ {xs: { span: 24 }, sm: { span: 20 }} }
|
>
|
<StyleInput defaultValue={card.height || ''} options={['px', 'vh', 'vw']} onChange={this.changeHeight}/>
|
</Form.Item>
|
</Col>
|
</Panel> : null}
|
{fonts ? <Panel header="字体" key="font">
|
{fonts.includes('fontSize') ? <Col span={12}>
|
<Form.Item colon={false} label={<FontSizeOutlined title="字体大小"/>}>
|
<InputNumber defaultValue={card.fontSize || 14} min={12} max={300} precision={0} onChange={this.changeFontSize} />
|
</Form.Item>
|
</Col> : null}
|
{fonts.includes('fontWeight') ? <Col span={12}>
|
<Form.Item colon={false} label={<BoldOutlined title="字体粗细"/>}>
|
<Select defaultValue={card.fontWeight || 'normal'} onChange={this.boldChange}>
|
<Option value="normal">normal</Option>
|
<Option value="bold">bold</Option>
|
<Option value="bolder">bolder</Option>
|
<Option value="lighter">lighter</Option>
|
<Option value="100">100</Option>
|
<Option value="200">200</Option>
|
<Option value="300">300</Option>
|
<Option value="400">400</Option>
|
<Option value="500">500</Option>
|
<Option value="600">600</Option>
|
<Option value="700">700</Option>
|
<Option value="800">800</Option>
|
<Option value="900">900</Option>
|
</Select>
|
</Form.Item>
|
</Col> : null}
|
{fonts.includes('lineHeight') ? <Col span={12}>
|
<Form.Item colon={false} label={<LineHeightOutlined title="行高"/>}>
|
<InputNumber defaultValue={card.lineHeight || 1.5} min={1} max={10} precision={1} onChange={this.changeLineHeight} />
|
</Form.Item>
|
</Col> : null}
|
{fonts.includes('letterSpacing') ? <Col span={12}>
|
<Form.Item colon={false} label={<ColumnWidthOutlined title="字间距"/>}>
|
<InputNumber defaultValue={card.letterSpacing || 0} min={0} max={100} precision={0} onChange={this.changeLetterSpacing}/>
|
</Form.Item>
|
</Col> : null}
|
{fonts.includes('textIndent') ? <Col span={12}>
|
<Form.Item colon={false} label={<AlignRightOutlined title="首行缩进"/>}>
|
<InputNumber defaultValue={card.textIndent || 0} min={0} max={100} precision={0} onChange={this.changeTextIndent}/>
|
</Form.Item>
|
</Col> : null}
|
{fonts.includes('wordBreak') ? <Col span={12}>
|
<Form.Item colon={false} label={<EnterOutlined title="自动换行"/>}>
|
<Select defaultValue={card.wordBreak || 'normal'} onChange={this.wordBreakChange}>
|
<Option value="normal">normal</Option>
|
<Option value="break-all">break-all</Option>
|
</Select>
|
</Form.Item>
|
</Col> : null}
|
{fonts.includes('color') ? <Col span={24}>
|
<Form.Item
|
colon={false}
|
label={<FontColorsOutlined title="字体颜色"/>}
|
labelCol={{xs: { span: 24 }, sm: { span: 4 }}} wrapperCol={ {xs: { span: 24 }, sm: { span: 20 }} }
|
>
|
<ColorSketch value={card.color || 'rgba(0, 0, 0, 0.85)'} onChange={this.changeFontColor} />
|
</Form.Item>
|
</Col> : null}
|
{fonts.includes('fontStyle') ? <Col span={24}>
|
<Form.Item
|
colon={false}
|
label={' '}
|
labelCol={{xs: { span: 24 }, sm: { span: 4 }}} wrapperCol={ {xs: { span: 24 }, sm: { span: 20 }} }
|
>
|
<Radio.Group defaultValue={card.fontStyle || 'normal'} onChange={this.changeFontStyle}>
|
<Radio.Button value="normal"><span title="标准">N</span></Radio.Button>
|
<Radio.Button value="italic"><ItalicOutlined title="斜体"/></Radio.Button>
|
<Radio.Button value="oblique" style={{fontStyle: 'oblique'}}><span title="倾斜">B</span></Radio.Button>
|
</Radio.Group>
|
</Form.Item>
|
</Col> : null}
|
{fonts.includes('textAlign') ? <Col span={24}>
|
<Form.Item
|
colon={false}
|
label={' '}
|
labelCol={{xs: { span: 24 }, sm: { span: 4 }}} wrapperCol={ {xs: { span: 24 }, sm: { span: 20 }} }
|
>
|
<Radio.Group className="text-align" defaultValue={card.textAlign || 'left'} onChange={this.changeTextAlign}>
|
<Radio.Button value="left"><AlignLeftOutlined title="左对齐"/></Radio.Button>
|
<Radio.Button value="center"><AlignCenterOutlined title="居中对齐"/></Radio.Button>
|
<Radio.Button value="right"><AlignRightOutlined title="右对齐"/></Radio.Button>
|
</Radio.Group>
|
</Form.Item>
|
</Col> : null}
|
{fonts.includes('textDecoration') ? <Col span={24}>
|
<Form.Item
|
colon={false}
|
label={' '}
|
labelCol={{xs: { span: 24 }, sm: { span: 4 }}} wrapperCol={ {xs: { span: 24 }, sm: { span: 20 }} }
|
>
|
<Radio.Group className="text-decoration" defaultValue={card.textDecoration || 'none'} onChange={this.changeTextDecoration}>
|
<Radio.Button value="none"><span title="标准">N</span></Radio.Button>
|
<Radio.Button value="underline"><UnderlineOutlined title="下划线"/></Radio.Button>
|
<Radio.Button value="line-through"><StrikethroughOutlined title="中划线"/></Radio.Button>
|
<Radio.Button value="overline" style={{textDecoration: 'overline'}}><span title="上划线">O</span></Radio.Button>
|
</Radio.Group>
|
</Form.Item>
|
</Col> : null}
|
</Panel> : null}
|
{options.includes('background') || options.includes('backgroundColor') ? <Panel header="背景" key="background">
|
<Col span={24}>
|
<Form.Item
|
colon={false}
|
label={<BgColorsOutlined title="背景颜色"/>}
|
labelCol={{xs: { span: 24 }, sm: { span: 4 }}} wrapperCol={ {xs: { span: 24 }, sm: { span: 20 }} }
|
>
|
<ColorSketch value={card.backgroundColor || '#ffffff'} onChange={this.changeBackgroundColor} />
|
</Form.Item>
|
</Col>
|
{window.develop === true ? <Col span={24}>
|
<Form.Item
|
colon={false}
|
label={<BgColorsOutlined title="背景颜色"/>}
|
labelCol={{xs: { span: 24 }, sm: { span: 4 }}} wrapperCol={ {xs: { span: 24 }, sm: { span: 20 }} }
|
>
|
<Input value={card.background || ''} onChange={(e) => this.changeBackground(e.target.value)} />
|
</Form.Item>
|
</Col> : null}
|
{!options.includes('backgroundColor') ? <Col span={24}>
|
<Form.Item
|
colon={false}
|
label={<PictureOutlined title="背景图片"/>}
|
labelCol={{xs: { span: 24 }, sm: { span: 4 }}} wrapperCol={ {xs: { span: 24 }, sm: { span: 20 }} }
|
>
|
<SourceComponent value={backgroundImage} type="" placement="right" onChange={this.imgChange}/>
|
</Form.Item>
|
</Col> : null}
|
{!options.includes('backgroundColor') ? <Col span={24}>
|
<Form.Item
|
colon={false}
|
label="比例"
|
labelCol={{xs: { span: 24 }, sm: { span: 4 }}} wrapperCol={ {xs: { span: 24 }, sm: { span: 20 }} }
|
>
|
<Select defaultValue={card.backgroundSize || 'cover'} onChange={this.changeBackgroundSize}>
|
<Option value="100%">100%</Option>
|
<Option value="100% 100%">100% 100%</Option>
|
<Option value="auto 100%">auto 100%</Option>
|
<Option value="100% auto">100% auto</Option>
|
<Option value="auto">auto</Option>
|
<Option value="contain">contain</Option>
|
<Option value="cover">cover</Option>
|
</Select>
|
</Form.Item>
|
</Col> : null}
|
{!options.includes('backgroundColor') ? <Col span={24}>
|
<Form.Item
|
colon={false}
|
label="重复"
|
labelCol={{xs: { span: 24 }, sm: { span: 4 }}} wrapperCol={ {xs: { span: 24 }, sm: { span: 20 }} }
|
>
|
<Select defaultValue={card.backgroundRepeat || 'no-repeat'} onChange={this.changeBackgroundRepeat}>
|
<Option value="repeat">repeat</Option>
|
<Option value="no-repeat">no-repeat</Option>
|
<Option value="repeat-x">repeat-x</Option>
|
<Option value="repeat-y">repeat-y</Option>
|
</Select>
|
</Form.Item>
|
</Col> : null}
|
{!options.includes('backgroundColor') ? <Col span={24}>
|
<Form.Item
|
colon={false}
|
label="位置"
|
labelCol={{xs: { span: 24 }, sm: { span: 4 }}} wrapperCol={ {xs: { span: 24 }, sm: { span: 20 }} }
|
>
|
<Select defaultValue={card.backgroundPosition || 'center'} onChange={this.changeBackgroundPositon}>
|
<Option value="center">center</Option>
|
<Option value="center top">center top</Option>
|
<Option value="center bottom">center bottom</Option>
|
<Option value="left top">left top</Option>
|
<Option value="left center">left center</Option>
|
<Option value="left bottom">left bottom</Option>
|
<Option value="right top">right top</Option>
|
<Option value="right center">right center</Option>
|
<Option value="right bottom">right bottom</Option>
|
</Select>
|
</Form.Item>
|
</Col> : null}
|
</Panel> : null}
|
{options.includes('border') ? <Panel header="边框" key="border">
|
<Col span={24}>
|
<Form.Item
|
colon={false}
|
label={<BorderOutlined title="边框位置"/>}
|
labelCol={{xs: { span: 24 }, sm: { span: 4 }}} wrapperCol={ {xs: { span: 24 }, sm: { span: 20 }} }
|
>
|
<Radio.Group className="border-position" defaultValue={borposition} onChange={(e) => this.setState({borposition: e.target.value})}>
|
<Radio value="outer"><BorderOuterOutlined title="外边框"/></Radio>
|
<Radio value="left"><BorderLeftOutlined title="左边框"/></Radio>
|
<Radio value="right"><BorderRightOutlined title="右边框"/></Radio>
|
<Radio value="top"><BorderTopOutlined title="上边框"/></Radio>
|
<Radio value="bottom"><BorderBottomOutlined title="下边框"/></Radio>
|
</Radio.Group>
|
</Form.Item>
|
</Col>
|
<Col span={24}>
|
<Form.Item
|
colon={false}
|
label={<BorderOuterOutlined title="边框样式"/>}
|
labelCol={{xs: { span: 24 }, sm: { span: 4 }}} wrapperCol={ {xs: { span: 24 }, sm: { span: 20 }} }
|
>
|
{borposition === 'outer' ? <Select defaultValue={card.borderStyle || 'solid'} onChange={this.changeBorderStyle}>
|
<Option value="solid">实线</Option>
|
<Option value="dotted">点划线</Option>
|
<Option value="dashed">虚线</Option>
|
<Option value="double">双线</Option>
|
</Select> : null}
|
{borposition === 'left' ? <Select defaultValue={card.borderLeftStyle || 'solid'} onChange={this.changeBorderStyle}>
|
<Option value="solid">实线</Option>
|
<Option value="dotted">点划线</Option>
|
<Option value="dashed">虚线</Option>
|
<Option value="double">双线</Option>
|
</Select> : null}
|
{borposition === 'right' ? <Select defaultValue={card.borderRightStyle || 'solid'} onChange={this.changeBorderStyle}>
|
<Option value="solid">实线</Option>
|
<Option value="dotted">点划线</Option>
|
<Option value="dashed">虚线</Option>
|
<Option value="double">双线</Option>
|
</Select> : null}
|
{borposition === 'top' ? <Select defaultValue={card.borderTopStyle || 'solid'} onChange={this.changeBorderStyle}>
|
<Option value="solid">实线</Option>
|
<Option value="dotted">点划线</Option>
|
<Option value="dashed">虚线</Option>
|
<Option value="double">双线</Option>
|
</Select> : null}
|
{borposition === 'bottom' ? <Select defaultValue={card.borderBottomStyle || 'solid'} onChange={this.changeBorderStyle}>
|
<Option value="solid">实线</Option>
|
<Option value="dotted">点划线</Option>
|
<Option value="dashed">虚线</Option>
|
<Option value="double">双线</Option>
|
</Select> : null}
|
</Form.Item>
|
</Col>
|
<Col span={24}>
|
<Form.Item
|
colon={false}
|
label={<ColumnWidthOutlined title="边框宽度"/>}
|
labelCol={{xs: { span: 24 }, sm: { span: 4 }}} wrapperCol={ {xs: { span: 24 }, sm: { span: 20 }} }
|
>
|
{borposition === 'outer' ? <StyleInput defaultValue={card.borderWidth || '0px'} options={['px']} onChange={this.changeBorderWidth}/> : null}
|
{borposition === 'left' ? <StyleInput defaultValue={card.borderLeftWidth || '0px'} options={['px']} onChange={this.changeBorderWidth}/> : null}
|
{borposition === 'right' ? <StyleInput defaultValue={card.borderRightWidth || '0px'} options={['px']} onChange={this.changeBorderWidth}/> : null}
|
{borposition === 'top' ? <StyleInput defaultValue={card.borderTopWidth || '0px'} options={['px']} onChange={this.changeBorderWidth}/> : null}
|
{borposition === 'bottom' ? <StyleInput defaultValue={card.borderBottomWidth || '0px'} options={['px']} onChange={this.changeBorderWidth}/> : null}
|
</Form.Item>
|
</Col>
|
<Col span={24}>
|
<Form.Item
|
colon={false}
|
label={<BgColorsOutlined title="边框颜色"/>}
|
labelCol={{xs: { span: 24 }, sm: { span: 4 }}} wrapperCol={ {xs: { span: 24 }, sm: { span: 20 }} }
|
>
|
{borposition === 'outer' ? <ColorSketch defaultValue={card.borderColor || 'transparent'} onChange={this.changeBorderColor} /> : null}
|
{borposition === 'left' ? <ColorSketch defaultValue={card.borderLeftColor || 'transparent'} onChange={this.changeBorderColor} /> : null}
|
{borposition === 'right' ? <ColorSketch defaultValue={card.borderRightColor || 'transparent'} onChange={this.changeBorderColor} /> : null}
|
{borposition === 'top' ? <ColorSketch defaultValue={card.borderTopColor || 'transparent'} onChange={this.changeBorderColor} /> : null}
|
{borposition === 'bottom' ? <ColorSketch defaultValue={card.borderBottomColor || 'transparent'} onChange={this.changeBorderColor} /> : null}
|
</Form.Item>
|
</Col>
|
<Col span={24}>
|
<Form.Item
|
colon={false}
|
label={<RadiusSettingOutlined title="圆角"/>}
|
labelCol={{xs: { span: 24 }, sm: { span: 4 }}} wrapperCol={ {xs: { span: 24 }, sm: { span: 20 }} }
|
>
|
<StyleInput defaultValue={card.borderRadius || '0px'} options={['px', '%']} onChange={(val) => this.changeNormalStyle(val, 'borderRadius')}/>
|
</Form.Item>
|
</Col>
|
</Panel> : null}
|
{options.includes('shadow') ? <Panel header="阴影" key="shadow">
|
<Col span={24}>
|
<Form.Item
|
colon={false}
|
label={<BgColorsOutlined title="阴影颜色"/>}
|
labelCol={{xs: { span: 24 }, sm: { span: 4 }}} wrapperCol={ {xs: { span: 24 }, sm: { span: 20 }} }
|
>
|
<ColorSketch value={card.shadowColor || 'transparent'} onChange={this.changeShadowColor} />
|
</Form.Item>
|
</Col>
|
<Col span={24}>
|
<Form.Item
|
colon={false}
|
label={<ColumnWidthOutlined title="模糊距离"/>}
|
labelCol={{xs: { span: 24 }, sm: { span: 4 }}} wrapperCol={ {xs: { span: 24 }, sm: { span: 20 }} }
|
>
|
<StyleInput defaultValue={card.shadowBlur || '0px'} options={['px']} onChange={this.changeShadowBlur}/>
|
</Form.Item>
|
</Col>
|
<Col span={24}>
|
<Form.Item
|
colon={false}
|
label={<ArrowRightOutlined title="水平位置"/>}
|
labelCol={{xs: { span: 24 }, sm: { span: 4 }}} wrapperCol={ {xs: { span: 24 }, sm: { span: 20 }} }
|
>
|
<StyleInput defaultValue={card.hShadow || '0px'} options={['px']} onChange={this.changeHShadow}/>
|
</Form.Item>
|
</Col>
|
<Col span={24}>
|
<Form.Item
|
colon={false}
|
label={<ArrowDownOutlined title="垂直位置"/>}
|
labelCol={{xs: { span: 24 }, sm: { span: 4 }}} wrapperCol={ {xs: { span: 24 }, sm: { span: 20 }} }
|
>
|
<StyleInput defaultValue={card.vShadow || '0px'} options={['px']} onChange={this.changeVShadow}/>
|
</Form.Item>
|
</Col>
|
</Panel> : null}
|
{options.includes('margin') ? <Panel header="外边距" key="margin">
|
<Col span={24}>
|
<Form.Item
|
colon={false}
|
label={<ArrowUpOutlined title="上边距"/>}
|
labelCol={{xs: { span: 24 }, sm: { span: 4 }}} wrapperCol={ {xs: { span: 24 }, sm: { span: 20 }} }
|
>
|
<StyleInput defaultValue={card.marginTop || '0px'} options={['px', 'vh', 'vw', '%']} onChange={(val) => this.changeNormalStyle(val, 'marginTop')}/>
|
</Form.Item>
|
</Col>
|
<Col span={24}>
|
<Form.Item
|
colon={false}
|
label={<ArrowDownOutlined title="下边距"/>}
|
labelCol={{xs: { span: 24 }, sm: { span: 4 }}} wrapperCol={ {xs: { span: 24 }, sm: { span: 20 }} }
|
>
|
<StyleInput defaultValue={card.marginBottom || '0px'} options={['px', 'vh', 'vw', '%']} onChange={(val) => this.changeNormalStyle(val, 'marginBottom')}/>
|
</Form.Item>
|
</Col>
|
<Col span={24}>
|
<Form.Item
|
colon={false}
|
label={<ArrowLeftOutlined title="左边距"/>}
|
labelCol={{xs: { span: 24 }, sm: { span: 4 }}} wrapperCol={ {xs: { span: 24 }, sm: { span: 20 }} }
|
>
|
<StyleInput defaultValue={card.marginLeft || '0px'} options={['px', 'vh', 'vw', '%']} onChange={(val) => this.changeNormalStyle(val, 'marginLeft')}/>
|
</Form.Item>
|
</Col>
|
<Col span={24}>
|
<Form.Item
|
colon={false}
|
label={<ArrowRightOutlined title="右边距"/>}
|
labelCol={{xs: { span: 24 }, sm: { span: 4 }}} wrapperCol={ {xs: { span: 24 }, sm: { span: 20 }} }
|
>
|
<StyleInput defaultValue={card.marginRight || '0px'} options={['px', 'vh', 'vw', '%']} onChange={(val) => this.changeNormalStyle(val, 'marginRight')}/>
|
</Form.Item>
|
</Col>
|
</Panel> : null}
|
{options.includes('padding') ? <Panel header="内边距" key="padding">
|
<Col span={24}>
|
<Form.Item
|
colon={false}
|
label={<ArrowUpOutlined title="上边距"/>}
|
labelCol={{xs: { span: 24 }, sm: { span: 4 }}} wrapperCol={ {xs: { span: 24 }, sm: { span: 20 }} }
|
>
|
<StyleInput defaultValue={card.paddingTop || '0px'} options={['px', 'vh', 'vw', '%']} onChange={(val) => this.changeNormalStyle(val, 'paddingTop')}/>
|
</Form.Item>
|
</Col>
|
<Col span={24}>
|
<Form.Item
|
colon={false}
|
label={<ArrowDownOutlined title="下边距"/>}
|
labelCol={{xs: { span: 24 }, sm: { span: 4 }}} wrapperCol={ {xs: { span: 24 }, sm: { span: 20 }} }
|
>
|
<StyleInput defaultValue={card.paddingBottom || '0px'} options={['px', 'vh', 'vw', '%']} onChange={(val) => this.changeNormalStyle(val, 'paddingBottom')}/>
|
</Form.Item>
|
</Col>
|
<Col span={24}>
|
<Form.Item
|
colon={false}
|
label={<ArrowLeftOutlined title="左边距"/>}
|
labelCol={{xs: { span: 24 }, sm: { span: 4 }}} wrapperCol={ {xs: { span: 24 }, sm: { span: 20 }} }
|
>
|
<StyleInput defaultValue={card.paddingLeft || '0px'} options={['px', 'vh', 'vw', '%']} onChange={(val) => this.changeNormalStyle(val, 'paddingLeft')}/>
|
</Form.Item>
|
</Col>
|
<Col span={24}>
|
<Form.Item
|
colon={false}
|
label={<ArrowRightOutlined title="右边距"/>}
|
labelCol={{xs: { span: 24 }, sm: { span: 4 }}} wrapperCol={ {xs: { span: 24 }, sm: { span: 20 }} }
|
>
|
<StyleInput defaultValue={card.paddingRight || '0px'} options={['px', 'vh', 'vw', '%']} onChange={(val) => this.changeNormalStyle(val, 'paddingRight')}/>
|
</Form.Item>
|
</Col>
|
</Panel> : null}
|
{options.includes('float') ? <Panel header="对齐方式" key="float">
|
<Col span={24}>
|
<Form.Item
|
colon={false}
|
label={<SwapOutlined title="对齐"/>}
|
labelCol={{xs: { span: 24 }, sm: { span: 4 }}} wrapperCol={ {xs: { span: 24 }, sm: { span: 20 }} }
|
>
|
<Radio.Group style={{whiteSpace: 'nowrap'}} defaultValue={card.float || 'left'} onChange={(e) => this.changeNormalStyle(e.target.value, 'float')}>
|
<Radio value="left">左</Radio>
|
<Radio value="center">居中</Radio>
|
<Radio value="right">右</Radio>
|
</Radio.Group>
|
</Form.Item>
|
</Col>
|
</Panel> : null}
|
{options.includes('minHeight') ? <Panel header="最小高度" key="minHeight">
|
<Col span={24}>
|
<Form.Item
|
colon={false}
|
label={<ColumnHeightOutlined title="最小高度"/>}
|
labelCol={{xs: { span: 24 }, sm: { span: 4 }}} wrapperCol={ {xs: { span: 24 }, sm: { span: 20 }} }
|
>
|
<StyleInput defaultValue={card.minHeight || ''} options={['px', 'vh', 'vw']} onChange={(val) => this.changeNormalStyle(val, 'minHeight')}/>
|
</Form.Item>
|
</Col>
|
</Panel> : null}
|
{options.includes('clear') ? <Panel header="浮动" key="clear">
|
<Col span={24}>
|
<Form.Item
|
colon={false}
|
label={<SwapOutlined title="浮动"/>}
|
labelCol={{xs: { span: 24 }, sm: { span: 4 }}} wrapperCol={ {xs: { span: 24 }, sm: { span: 20 }} }
|
>
|
<Radio.Group style={{whiteSpace: 'nowrap'}} defaultValue={card.clear || 'none'} onChange={(e) => this.changeNormalStyle(e.target.value, 'clear')}>
|
<Radio value="none">左浮动</Radio>
|
<Radio value="left">不浮动</Radio>
|
</Radio.Group>
|
</Form.Item>
|
</Col>
|
</Panel> : null}
|
{options.includes('display') ? <Panel header="显示" key="display">
|
<Col span={24}>
|
<Form.Item
|
colon={false}
|
label={<SwapOutlined title="浮动"/>}
|
labelCol={{xs: { span: 24 }, sm: { span: 4 }}} wrapperCol={ {xs: { span: 24 }, sm: { span: 20 }} }
|
>
|
<Radio.Group style={{whiteSpace: 'nowrap'}} defaultValue={card.display || 'block'} onChange={(e) => this.changeNormalStyle(e.target.value, 'display')}>
|
<Radio value="block">块级元素</Radio>
|
<Radio value="inline-block">行内块元素</Radio>
|
</Radio.Group>
|
</Form.Item>
|
</Col>
|
</Panel> : null}
|
</Collapse> : null}
|
</Form>
|
<div style={{textAlign: 'right'}}>
|
<Button style={{margin: '30px 10px 30px 0px'}} onClick={this.onCloseDrawer}>关闭</Button>
|
</div>
|
</div>
|
</Drawer>
|
)
|
}
|
}
|
|
export default MobController
|