1 |
|
2 |
|
3 |
|
4 |
|
5 |
|
6 | 'use strict'
|
7 |
|
8 | import React, {PropTypes as types} from 'react'
|
9 | import {ApStyle} from 'apeman-react-style'
|
10 |
|
11 |
|
12 | const ApDropdownStyle = React.createClass({
|
13 | propTypes: {
|
14 | style: types.object,
|
15 | highlightColor: types.string
|
16 | },
|
17 | getDefaultProps () {
|
18 | return {
|
19 | style: {},
|
20 | highlightColor: ApStyle.DEFAULT_HIGHLIGHT_COLOR,
|
21 | backgroundColor: ApStyle.DEFAULT_BACKGROUND_COLOR
|
22 | }
|
23 | },
|
24 | render () {
|
25 | const s = this
|
26 | let { props } = s
|
27 |
|
28 | let { highlightColor, backgroundColor } = props
|
29 |
|
30 | let duration = '400ms'
|
31 | let buttonHeight = 44
|
32 |
|
33 | let data = {
|
34 | '.ap-dropdown': {
|
35 | position: 'relative',
|
36 | boxSizing: 'border-box',
|
37 | display: 'inline-block'
|
38 | },
|
39 | '.ap-dropdown-content': {
|
40 | position: 'absolute',
|
41 | boxSizing: 'border-box',
|
42 | overflow: 'hidden',
|
43 | transition: `width ${duration}, height ${duration}`,
|
44 | top: `${buttonHeight}px`,
|
45 | left: 0,
|
46 | background: 'rgba(255,255,255,0.95)',
|
47 | width: '100%',
|
48 | maxWidth: ApStyle.CONTENT_WIDTH,
|
49 | border: '1px solid #EEE',
|
50 | zIndex: 99
|
51 | },
|
52 | '.ap-dropdown-content-inner': {
|
53 | minWidth: '192px',
|
54 | minHeight: '40px'
|
55 | },
|
56 | '.ap-dropdown-open .ap-dropdown-content': {},
|
57 | '.ap-dropdown-closed .ap-dropdown-content': {
|
58 | height: '0 !important',
|
59 | border: 'none'
|
60 | },
|
61 |
|
62 | '.ap-dropdown-button-wrap': {
|
63 | position: 'relative'
|
64 | },
|
65 | '.ap-dropdown-button': {
|
66 | margin: 0,
|
67 | padding: '0 8px',
|
68 | boxSizing: 'border-box',
|
69 | verticalAlign: 'middle',
|
70 | border: 'none',
|
71 | display: 'block',
|
72 | color: 'inherit',
|
73 | lineHeight: `${buttonHeight}px`,
|
74 | backgroundColor: 'transparent'
|
75 | },
|
76 | '.ap-dropdown-button-aligner': {
|
77 | height: '100%',
|
78 | width: '1px',
|
79 | verticalAlign: 'middle'
|
80 | },
|
81 | '.ap-dropdown-item': {
|
82 | display: 'block',
|
83 | boxSizing: 'border-box',
|
84 | textDecoration: 'none',
|
85 | padding: '4px 8px',
|
86 | lineHeight: '36px',
|
87 | borderBottom: '1px solid #F0F0F0'
|
88 | },
|
89 | '.ap-dropdown-item:hover': {
|
90 | cursor: 'pointer',
|
91 | background: '#FAFAFA'
|
92 | },
|
93 | '.ap-dropdown-item:active': {
|
94 | background: '#F0F0F0'
|
95 | },
|
96 | '.ap-dropdown-icon': {
|
97 | display: 'inline-block',
|
98 | margin: '0 8px',
|
99 | fontSize: '12px'
|
100 | },
|
101 | '.ap-dropdown-spinner-cover': {
|
102 | position: 'absolute',
|
103 | left: 0,
|
104 | top: 0,
|
105 | right: 0,
|
106 | bottom: 0,
|
107 | textAlign: 'center',
|
108 | boxSizing: 'border-box',
|
109 | padding: '16px 32px',
|
110 | background: 'rgba(255, 255, 255, 0.75)',
|
111 | border: '1px solid rgba(255, 255, 255, 0.9)',
|
112 | zIndex: 101,
|
113 | color: '#888'
|
114 | }
|
115 | }
|
116 | let smallMediaData = {}
|
117 | let mediumMediaData = {}
|
118 | let largeMediaData = {}
|
119 | return (
|
120 | <ApStyle data={ Object.assign(data, props.style) }
|
121 | smallMediaData={ smallMediaData }
|
122 | mediumMediaData={ mediumMediaData }
|
123 | largeMediaData={ largeMediaData }
|
124 | >{ props.children }</ApStyle>
|
125 | )
|
126 | }
|
127 | })
|
128 |
|
129 | export default ApDropdownStyle
|