UNPKG

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