All files / UI_Component/common Image.js

100% Statements 7/7
100% Branches 0/0
100% Functions 6/6
100% Lines 7/7
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86                                                            358x                   241x   241x                     241x         241x               6x                   6x                  
/**
 * @author Haipeng Zhang(hp.zhang@samsung.com)
 * @fileoverview This module manages image item.
 * @date    2017/06/13 (last modified date)
 *
 * Copyright 2017 by Samsung Electronics, Inc.,
 *
 * This software is the confidential and proprietary information
 * of Samsung Electronics, Inc. ("Confidential Information").  You
 * shall not disclose such Confidential Information and shall use
 * it only in accordance with the terms of the license agreement
 * you entered into with Samsung.
 */
import React, { Component } from 'react';
import PropTypes from 'prop-types';
import { is, Map, fromJS } from 'immutable';
 
export default class Image extends Component {
 
  // constructor(props) {
    // super(props);
  // }
 
    componentDidMount() {
    }
 
    componentWillReceiveProps(nextProps) {
    }
 
    shouldComponentUpdate(nextProps, nextState) {
        return (JSON.stringify(nextProps) !== JSON.stringify(this.props));
    }
 
    componentDidUpdate(prevProps, prevState) {
    }
 
    componentWillUnmount() {
    }
 
    render() {
        const { OSD } = this.props;
 
        const borderStyle = {
            position: 'absolute',
            top: OSD.t,
            left: OSD.l,
            width: OSD.w,
            height: OSD.h,
            borderRadius: '3px',
            overflow: 'hidden',
            backgroundColor: 'rgba(0,0,0,0.0)',
        };
 
        const imageStyle = {
            height: OSD.h,
            width: OSD.w,
        };
 
        return (
          <div style={borderStyle}>
            <img style={imageStyle} src={OSD.url} alt='X' />
          </div>
        );
    }
}
 
Image.defaultProps = {
    OSD: {
        t: 0,
        l: 0,
        w: 285,
        h: 285,
        url: '',
    },
};
 
Image.propTypes = {
    OSD: PropTypes.shape({        // thumbnail position
        t: PropTypes.number,         // thumbnail top
        l: PropTypes.number,        // thumbnail left
        w: PropTypes.number,           // thumbnail width
        h: PropTypes.number,           // thumbnail height
        url: PropTypes.string,
    }),
};