UNPKG

1.58 kBJSXView Raw
1/**
2 * @class ApPaperPhoto
3 */
4
5'use strict'
6
7import React, {PropTypes as types} from 'react'
8import classnames from 'classnames'
9import ApPhoto from './ap_photo'
10import {ApPureMixin} from 'apeman-react-mixins'
11
12/** @lends ApPaperPhoto */
13const ApPaperPhoto = React.createClass({
14
15 // --------------------
16 // Specs
17 // --------------------
18
19 propTypes: {
20 /** Image source URL */
21 imgSrc: types.string.isRequired,
22 /** Image width */
23 imgWidth: types.number,
24 /** Image height */
25 imgHeight: types.number,
26 /** Image scale policy */
27 imgScale: types.string,
28 /** Handler for tap event */
29 onTap: types.func
30 },
31
32 mixins: [
33 ApPureMixin
34 ],
35
36 statics: {},
37
38 getInitialState () {
39 return {}
40 },
41
42 getDefaultProps () {
43 return {
44 imgSrc: null,
45 imgWidth: 256,
46 imgHeight: 192,
47 imgScale: 'fill',
48 onTap: null
49 }
50 },
51
52 render () {
53 const s = this
54 let { props } = s
55
56 let { imgWidth, imgHeight } = props
57
58 return (
59 <ApPhoto className={ classnames('ap-paper-photo', props.className)}
60 imgSrc={ props.imgSrc }
61 imgWidth={ imgWidth }
62 imgHeight={ imgHeight }
63 imgScale={ props.imgScale }
64 onTap={ props.onTap }>
65 <div className="ap-paper-photo-shadow ap-paper-photo-shadow-left"/>
66 <div className="ap-paper-photo-shadow ap-paper-photo-shadow-right"/>
67 <div className="ap-paper-photo-text">
68 { props.children }
69 </div>
70 </ApPhoto>
71 )
72 }
73})
74
75export default ApPaperPhoto