1 |
|
2 |
|
3 |
|
4 |
|
5 |
|
6 | 'use strict'
|
7 |
|
8 | import React, {PropTypes as types} from 'react'
|
9 | import classnames from 'classnames'
|
10 | import {ApStyle} from 'apeman-react-style'
|
11 |
|
12 |
|
13 | const ApToastStyle = React.createClass({
|
14 | propTypes: {
|
15 | style: types.object,
|
16 | normalColor: types.string,
|
17 | infoColor: types.string,
|
18 | warnColor: types.string,
|
19 | errorColor: types.string
|
20 | },
|
21 | getDefaultProps () {
|
22 | return {
|
23 | style: {},
|
24 | normalColor: ApStyle.NORMAL_COLOR,
|
25 | infoColor: ApStyle.INFO_COLOR,
|
26 | warnColor: ApStyle.WARN_COLOR,
|
27 | errorColor: ApStyle.ERROR_COLOR
|
28 | }
|
29 | },
|
30 | render () {
|
31 | const s = this,
|
32 | { props } = s
|
33 |
|
34 | let {
|
35 | normalColor,
|
36 | infoColor,
|
37 | warnColor,
|
38 | errorColor
|
39 | } = props
|
40 |
|
41 | let data = {
|
42 | '.ap-toast-group': {
|
43 | position: `fixed`,
|
44 | height: 0,
|
45 | top: `initial`,
|
46 | overflow: `visible`,
|
47 | left: 0,
|
48 | bottom: 24,
|
49 | right: 0,
|
50 | textAlign: 'center',
|
51 | padding: 0,
|
52 | zIndex: 49,
|
53 | display: 'flex',
|
54 | flexDirection: `column`,
|
55 | justifyContent: `flex-end`
|
56 | },
|
57 | '.ap-toast': {
|
58 | display: 'block',
|
59 | margin: `0 auto`
|
60 | },
|
61 | '.ap-toast-inner': {
|
62 | margin: `4px auto`,
|
63 | maxWidth: `420px`,
|
64 | display: 'inline-block',
|
65 | textAlign: 'left',
|
66 | padding: `4px`,
|
67 | boxShadow: `2px 2px 4px rgba(0,0,0,0.33)`,
|
68 | backgroundColor: `rgba(255, 255, 255, 0.95)`,
|
69 | color: `${normalColor}`,
|
70 | border: `4px solid ${normalColor}`,
|
71 | fontSize: `14px`,
|
72 | width: `240px`,
|
73 | borderRadius: `2px`
|
74 | },
|
75 | '.ap-toast-item': {
|
76 | display: 'block',
|
77 | padding: `2px 0`
|
78 | },
|
79 | '.ap-toast-item:active': {
|
80 | opacity: 0.8
|
81 | },
|
82 | '.ap-info-toast .ap-toast-inner': {
|
83 | color: `${infoColor}`,
|
84 | borderColor: `${infoColor}`
|
85 | },
|
86 | '.ap-warn-toast .ap-toast-inner': {
|
87 | color: `${warnColor}`,
|
88 | borderColor: `${warnColor}`
|
89 | },
|
90 | '.ap-error-toast .ap-toast-inner': {
|
91 | color: `${errorColor}`,
|
92 | borderColor: `${errorColor}`
|
93 | },
|
94 | '.ap-toast-item-icon': {
|
95 | display: 'inline-block',
|
96 | pointerEvents: 'none'
|
97 | },
|
98 | '.ap-toast-text': {
|
99 | display: 'inline-block',
|
100 | pointerEvents: 'none',
|
101 | margin: `0 2px`,
|
102 | cursor: `default`
|
103 | }
|
104 | }
|
105 | let smallMediaData = {}
|
106 | let mediumMediaData = {}
|
107 | let largeMediaData = {}
|
108 | return (
|
109 | <ApStyle data={ Object.assign(data, props.style) }
|
110 | smallMediaData={ smallMediaData }
|
111 | mediumMediaData={ mediumMediaData }
|
112 | largeMediaData={ largeMediaData }
|
113 | >{ props.children }</ApStyle>
|
114 | )
|
115 | }
|
116 | })
|
117 |
|
118 | export default ApToastStyle
|