UNPKG

4.28 kBJSXView Raw
1/**
2 * Style for ApDialog.
3 * @class ApDialogStyle
4 */
5
6'use strict'
7
8import React, {PropTypes as types} from 'react'
9import {ApStyle} from 'apeman-react-style'
10
11/** @lends ApDialogStyle */
12const ApDialogStyle = React.createClass({
13 propTypes: {
14
15 style: types.object,
16 headerHeight: types.number
17 },
18 getDefaultProps () {
19 return {
20 style: {},
21 headerHeight: 44
22 }
23 },
24 statics: {
25 styleData (config) {
26 let {
27 headerHeight,
28 backgroundColor
29 } = config
30
31 return {
32 all: {
33 '.ap-dialog': {
34 display: 'none',
35 backgroundColor: 'transparent',
36 position: 'fixed',
37 left: 0,
38 right: 0,
39 bottom: 0,
40 top: 0,
41 zIndex: 99
42 },
43 '.ap-dialog-back': {
44 backgroundColor: 'rgba(0,0,0,0.1)',
45 position: 'absolute',
46 left: 0,
47 right: 0,
48 bottom: 0,
49 top: 0,
50 zIndex: 1
51 },
52 '.ap-dialog-back-inner': {
53 width: '100%',
54 height: '100%',
55 boxSizing: 'border-box',
56 display: 'block'
57 },
58 '.ap-dialog-present': {
59 display: 'block'
60 },
61 '.ap-dialog-inner': {
62 height: '100%',
63 width: '100%',
64 boxSizing: 'border-box',
65 position: 'relative',
66 padding: '36px 24px',
67 zIndex: 4,
68 justifyContent: 'center',
69 flexDirection: 'column'
70 },
71 '.ap-dialog-content': {
72 overflow: 'auto',
73 zIndex: 8,
74 margin: '0 auto',
75 height: 'auto',
76 backgroundColor: '#FFF',
77 border: '1px solid #E0E0E0',
78 borderRadius: '8px',
79 minHeight: '240px',
80 maxWidth: '640px',
81 width: '100%',
82 boxSizing: 'border-box',
83 position: 'relative'
84 },
85 '.ap-dialog-title': {
86 lineHeight: `${headerHeight}px`,
87 margin: 0,
88 padding: 0,
89 fontWeight: 'normal'
90 },
91 '.ap-dialog-close-button': {
92 position: 'absolute',
93 top: 0,
94 right: 0,
95 padding: '0 16px',
96 fontSize: '16px',
97 lineHeight: `${headerHeight}px`,
98 display: 'inline-block',
99 cursor: 'pointer',
100 zIndex: 44
101 },
102 '.ap-dialog-close-button:hover': {
103 opacity: 0.9
104 },
105 '.ap-dialog-close-button:active': {
106 opacity: 0.6
107 },
108 '.ap-dialog-close-button-icon': {
109 lineHeight: `${headerHeight}px`
110 },
111 '.ap-dialog-header': {
112 display: 'block',
113 position: 'absolute',
114 zIndex: 2,
115 textAlign: 'center',
116 top: 0,
117 left: 0,
118 right: 0,
119 height: `${headerHeight}px`,
120 lineHeight: `${headerHeight}px`,
121 boxSizing: 'border-box',
122 borderBottom: '1px solid #F5F5F5',
123 backgroundColor: 'rgba(255,255,255,0.9)'
124 },
125 '.ap-dialog-body': {
126 padding: `${headerHeight + 8}px 16px 8px`,
127 boxSizing: 'border-box',
128 maxHeight: '100%',
129 height: 'auto',
130 width: '100%',
131 overflow: 'auto'
132 },
133 '.ap-dialog-fix': {
134 overflow: 'hidden !important'
135 },
136 '.ap-dialog-spinner': {
137 position: 'absolute',
138 background: `${ApStyle.COVER_BACKGROUND}`,
139 left: 0,
140 top: 0,
141 right: 0,
142 bottom: 0,
143 zIndex: 99
144 }
145 },
146 small: {},
147 medium: {},
148 large: {}
149 }
150 }
151 },
152 render () {
153 const s = this
154 let { props } = s
155
156 let { all, small, medium, large } = ApDialogStyle.styleData(props)
157
158 return (
159 <ApStyle data={ Object.assign(all, props.style) }
160 smallMediaData={ small }
161 mediumMediaData={ medium }
162 largeMediaData={ large }
163 >{ props.children }</ApStyle>
164 )
165 }
166})
167
168export default ApDialogStyle