From e13e630cd6e4fc0b1ff92098a28a770794c7bb9a Mon Sep 17 00:00:00 2001
From: gabrhr <73925454+gabrhr@users.noreply.github.com>
Date: Wed, 20 Apr 2022 10:19:29 -0500
Subject: =?UTF-8?q?A=C3=B1adir=20plantilla?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Base para front
---
front/odiparpack/app/components/Rating/Rating.js | 144 +++++++++++++++++++++++
1 file changed, 144 insertions(+)
create mode 100644 front/odiparpack/app/components/Rating/Rating.js
(limited to 'front/odiparpack/app/components/Rating/Rating.js')
diff --git a/front/odiparpack/app/components/Rating/Rating.js b/front/odiparpack/app/components/Rating/Rating.js
new file mode 100644
index 0000000..6f65d06
--- /dev/null
+++ b/front/odiparpack/app/components/Rating/Rating.js
@@ -0,0 +1,144 @@
+import React, { Component } from 'react';
+import PropTypes from 'prop-types';
+import ToggleStar from '@material-ui/icons/Star';
+import ToggleStarBorder from '@material-ui/icons/StarBorder';
+import { orange, grey } from '@material-ui/core/colors';
+
+import { IconButton } from '@material-ui/core';
+
+const styles = {
+ disabled: {
+ pointerEvents: 'none'
+ }
+};
+
+class Rating extends Component {
+ constructor(props) {
+ super(props);
+ this.state = {
+ hoverValue: props.value
+ };
+ }
+
+ renderIcon(i) {
+ const filled = i <= this.props.value;
+ const hovered = i <= this.state.hoverValue;
+
+ if ((hovered && !filled) || (!hovered && filled)) {
+ return this.props.iconHoveredRenderer ? this.props.iconHoveredRenderer({
+ ...this.props,
+ index: i
+ }) : this.props.iconHovered;
+ } if (filled) {
+ return this.props.iconFilledRenderer ? this.props.iconFilledRenderer({
+ ...this.props,
+ index: i
+ }) : this.props.iconFilled;
+ }
+ return this.props.iconNormalRenderer ? this.props.iconNormalRenderer({
+ ...this.props,
+ index: i
+ }) : this.props.iconNormal;
+ }
+
+ render() {
+ const {
+ disabled,
+ iconFilled,
+ iconHovered,
+ iconNormal,
+ tooltip,
+ tooltipRenderer,
+ tooltipPosition,
+ tooltipStyles,
+ iconFilledRenderer,
+ iconHoveredRenderer,
+ iconNormalRenderer,
+ itemStyle,
+ itemClassName,
+ itemIconStyle,
+ max,
+ onChange,
+ readOnly,
+ style,
+ value,
+ ...other
+ } = this.props;
+
+ const rating = [];
+
+ for (let i = 1; i <= max; i += 1) {
+ rating.push(
+