title: React gradient slider (rating component) with rounded corners
body: <p>I'm quite new in CSS and React.
  My task is to make a component like on the image below.</p>
  
  <p><a href="https://i.stack.imgur.com/slFen.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/slFen.png" alt="enter image description here"></a></p>
  
  <p>This is what I have made by covering gradient div with white color and opacity like 0.2. Color doesn't matter.</p>
  
  <p><a href="https://i.stack.imgur.com/Jgy2n.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/Jgy2n.png" alt="enter image description here"></a></p>
  
  <p>Can you help me to make a rounded border inside a slider like on a first image?</p>
  
  <p><a href="https://i.stack.imgur.com/1r1LN.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/1r1LN.png" alt="enter image description here"></a></p>
  
  <p>Adding missing code. 
  I've modified Benjamin's Reid example.</p>
  
  <p>Here's my code:</p>
  
  <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="true">
  <div class="snippet-code">
  <pre class="snippet-code-js lang-js prettyprint-override"><code>class MySlider extends React.Component {
    constructor(props) {
      super(props);
      this.state = {
        rating: this.props.rating || null,
        tempRating: null
      };
    }
  
    rate = (rating) =&gt; {
      this.setState({
        rating,
        tempRating: rating
      });
    };
  
    starOver = (rating) =&gt; {
      this.setState({
        rating,
        tempRating: this.state.rating
      });
    };
  
    starOut = () =&gt; {
      this.setState({
        rating: this.state.tempRating
      });
    };
  
    render() {
      const elements = [];
  
      for (let i = 0; i &lt; 5; i++) {
        let cssSelectorClass = 'my-slider__item';
  
        if (this.state.rating !== null &amp;&amp; this.state.rating &gt;= i) {
          cssSelectorClass += ' --selected';
        }
  
        elements.push(
          &lt;div
            className={cssSelectorClass}
            onClick={this.rate.bind(this, i)}
            onMouseOver={this.starOver.bind(this, i)}
            onMouseOut={this.starOut} /&gt;
        );
      }
  
      return (
        &lt;div&gt;
          &lt;div className="back" /&gt;
          &lt;div className="my-slider"&gt;
            {elements}
          &lt;/div&gt;
        &lt;/div&gt;
      );
    }
  }
  
  class App extends React.Component {
      render() {
          return &lt;MySlider value={2} /&gt;
      }
  }
  
  ReactDOM.render(&lt;App /&gt;, document.getElementById('root'));</code></pre>
  <pre class="snippet-code-css lang-css prettyprint-override"><code>.my-slider {
    display: flex;
    position: relative;
    z-index: 1;
  }
  .my-slider__item {
      height: 30px;
      width: 30px;
      background-color: white;
      opacity: 0.8;
  }
  
  .my-slider__item:hover {
        cursor: pointer;
      }
  
  .--selected {
        opacity: 0;
  }
  
  .back {
    opacity: 0.5;
    background-image: linear-gradient(to right, blue, red);
    position: absolute;
    z-index: 0;
    width: 150px;
    height: 30px;
    background-color: #00ccff;
    border-radius: 0 20px 20px 0;
  }</code></pre>
  <pre class="snippet-code-html lang-html prettyprint-override"><code>&lt;script src="https://cdnjs.cloudflare.com/ajax/libs/react/16.6.3/umd/react.production.min.js"&gt;&lt;/script&gt;
  &lt;script src="https://cdnjs.cloudflare.com/ajax/libs/react-dom/16.6.3/umd/react-dom.production.min.js"&gt;&lt;/script&gt;
  
  &lt;div id='root'&gt;&lt;/div&gt;</code></pre>
  </div>
  </div>
  </p>
  
  <p>en/vNVwPW</p>