UNPKG

2.03 kBJSXView Raw
1/**
2 * Style for ApCheckbox.
3 * @class ApCheckboxStyle
4 */
5
6'use strict'
7
8import React, {Component, PropTypes as types} from 'react'
9import {ApStyle} from 'apeman-react-style'
10
11/** @lends ApCheckboxStyle */
12class ApCheckboxStyle extends Component {
13 render () {
14 const s = this
15 let { props } = s
16
17 let { all, small, medium, large } = ApCheckboxStyle.styleData(props)
18
19 return (
20 <ApStyle data={ Object.assign(all, props.style) }
21 smallMediaData={ small }
22 mediumMediaData={ medium }
23 largeMediaData={ large }
24 >{ props.children }</ApStyle>
25 )
26 }
27}
28
29Object.assign(ApCheckboxStyle, {
30 propTypes: {
31 style: types.object,
32 highlightColor: types.string
33 },
34
35 defaultProps: {
36 style: {},
37 highlightColor: '#38E'
38 },
39 styleData (config) {
40 let {
41 highlightColor
42 } = config
43
44 return {
45 all: {
46 '.ap-checkbox': {
47 display: 'inline-block',
48 padding: '0 4px',
49 cursor: 'pointer',
50 position: 'relative'
51 },
52 '.ap-checkbox:hover': {
53 opacity: 0.9
54 },
55 '.ap-checkbox:active': {
56 opacity: 0.75
57 },
58 '.ap-checkbox-input': {
59 display: 'inline-block',
60 padding: '0 2px',
61 position: 'relative',
62 top: '-2px',
63 opacity: 0,
64 zIndex: 8
65 },
66 '.ap-checkbox-title': {},
67 '.ap-checkbox-icon': {
68 position: 'absolute',
69 left: 2,
70 top: 0,
71 bottom: 0,
72 display: 'inline-flex',
73 justifyContent: 'center',
74 alignItems: 'center'
75 },
76 '.ap-checkbox:hover .ap-checkbox-icon': {
77 color: `${highlightColor}`
78 },
79 '.ap-checkbox:active .ap-checkbox-icon': {
80 opacity: 0.5
81 },
82 '.ap-checkbox-icon-checked': {
83 color: `${highlightColor}`
84 }
85 },
86 small: {},
87 medium: {},
88 large: {}
89 }
90 }
91})
92
93export default ApCheckboxStyle