Advertisement
Guest User

Untitled

a guest
Nov 22nd, 2019
103
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.11 KB | None | 0 0
  1. import React, { Component } from 'react';
  2. import PropTypes from 'prop-types';
  3.  
  4. export default class GreenSurfaceArea extends Component {
  5. constructor() {
  6. super();
  7. this.state = {
  8. measures: 0,
  9. };
  10. }
  11.  
  12. componentDidMount() {
  13. const gsaCard = document.getElementById('greensurfacearea');
  14. let measures = 0;
  15. if (gsaCard != null) {
  16. measures = gsaCard.clientHeight;
  17. }
  18.  
  19. this.setState({
  20. measures,
  21. });
  22. }
  23.  
  24. getBackgroundStyle = () => ({
  25. position: 'relative',
  26. width: '100%',
  27. height: '100%',
  28. background: '#676363', // "#87CEFA" não fica muito bem a cor ativa, ponderar mudar depois,
  29. });
  30.  
  31. styleTitle = () => ({
  32. position: 'absolute',
  33. width: '580px',
  34. height: '88px',
  35. left: '32px',
  36. top: '16px',
  37.  
  38. fontFamily: 'ibm-plex-sans',
  39. fontStyle: 'normal',
  40. fontWeight: 'normal',
  41. fontSize: '64px',
  42. lineHeight: '88px',
  43. textAlign: 'left',
  44. color: '#ffffff',
  45. zIndex: '5',
  46. });
  47.  
  48. styleDescription = () => ({
  49. position: 'absolute',
  50. width: '556px',
  51. height: '32px',
  52. left: '56px',
  53. top: '92px',
  54.  
  55. fontFamily: 'ibm-plex-sans',
  56. fontStyle: 'normal',
  57. fontWeight: 'normal',
  58. fontSize: '22px',
  59. lineHeight: '32px',
  60. textAlign: 'left',
  61. color: '#ffffff',
  62. zIndex: '5',
  63. });
  64.  
  65. stylePath = (x, y, value) => {
  66. const GSAProps = this.props;
  67. const { unifiedMeasure } = GSAProps.metric;
  68. const { measures } = this.state;
  69. const stringX = `${x}%`;
  70. const stringY = `${y}%`;
  71. const measure = `${(unifiedMeasure / 100) * measures * value}px`;
  72. return ({
  73. position: 'absolute',
  74. width: measure,
  75. height: measure,
  76. left: stringX,
  77. top: stringY,
  78. zIndex: 1,
  79. background: '#4CD60E',
  80. borderRadius: '50%',
  81. });
  82. };
  83.  
  84. render() {
  85. const GSAProps = this.props;
  86.  
  87. const surfaces = (
  88. <div>
  89. <div className="surface" style={this.stylePath(5, 40, 1)} />
  90. <div className="surface" style={this.stylePath(75, 40, 0.3)} />
  91. <div className="surface" style={this.stylePath(50, 15, 0.5)} />
  92. <div className="surface" style={this.stylePath(50, 70, 0.45)} />
  93. </div>
  94. );
  95.  
  96. return (
  97. <div id="greensurfacearea" className="GreenSurfaceAreaCard" style={this.getBackgroundStyle()}>
  98. <div className="title">
  99. <h1 style={this.styleTitle()}>
  100. {GSAProps.metric.measure + GSAProps.metric.title}
  101. </h1>
  102. </div>
  103.  
  104. <div className="description">
  105. <h2 style={this.styleDescription()}>
  106. <i
  107. className="fas fa-level-up-alt fa-rotate-90 fa-xs"
  108. style={{ marginRight: 10 }}
  109. />
  110. {GSAProps.metric.description}
  111. </h2>
  112. </div>
  113. {surfaces}
  114. </div>
  115. );
  116. }
  117. }
  118.  
  119. GreenSurfaceArea.propTypes = {
  120. metric: PropTypes.shape({
  121. metricName: PropTypes.string,
  122. title: PropTypes.string,
  123. description: PropTypes.string,
  124. measure: PropTypes.number,
  125. unifiedMeasure: PropTypes.number,
  126. }).isRequired,
  127. };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement