A Pen by Ara Asryan

Thumbnail
This awesome code was written by 025pro, you can see more from this user in the personal repository.
You can find the original code on Codepen.io
Copyright 025pro ©

Technologies

  • HTML
  • JavaScript
<!DOCTYPE html>
<html lang="en" >

<head>
  <meta charset="UTF-8">
  <title>A Pen by  Ara Asryan</title>
  
  
  
  
  
</head>

<body>

  <div id="root"></div>
  <script src='https://cdnjs.cloudflare.com/ajax/libs/react/15.4.2/react.min.js'></script>
<script src='https://cdnjs.cloudflare.com/ajax/libs/react/15.4.2/react-dom.min.js'></script>

  

    <script  src="js/index.js"></script>




</body>

</html>

/*Downloaded from https://www.codeseek.co/025pro/a-pen-by-ara-asryan-PmrmOX */
var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();

function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }

function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }

function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }

var P = function (_React$Component) {
  _inherits(P, _React$Component);

  function P(props) {
    _classCallCheck(this, P);

    var _this = _possibleConstructorReturn(this, (P.__proto__ || Object.getPrototypeOf(P)).call(this, props));

    _this.direction = props.direction || "ltr";
    _this.gradient = props.gradient || 'normal';
    _this.width = props.width === undefined ? 60 : props.width;
    _this.height = props.height === undefined ? 3 : props.height;
    _this.radius = props.radius || 4;
    _this.value = props.value || 0;
    return _this;
  }

  _createClass(P, [{
    key: "getClipPoints",
    value: function getClipPoints() {
      if (this.direction == "ltr") {
        return "0 " + this.height + ", " + this.value * this.width + " " + this.height + ", " + this.value * this.width + " 0, 0 0";
      }
      return this.width + " " + this.height + ", " + (this.width - this.value * this.width) + " " + this.height + ", " + (this.width - this.value * this.width) + " 0, " + this.width + " 0";
    }
  }, {
    key: "render",
    value: function render() {
      return React.createElement(
        "svg",
        { height: "80", width: "800" },
        React.createElement(
          "defs",
          null,
          React.createElement(
            "linearGradient",
            { id: "danger-ltr", x1: "100%", y1: "0%", x2: "0%", y2: "0%" },
            React.createElement("stop", { offset: "0%", style: { 'stopColor': '#EE8C4B', 'stopOpacity': 1 } }),
            React.createElement("stop", { offset: "100%", style: { 'stopColor': '#F36062', 'stopOpacity': 1 } })
          ),
          React.createElement(
            "linearGradient",
            { id: "danger-rtl", x1: "0%", y1: "0%", x2: "100%", y2: "0%" },
            React.createElement("stop", { offset: "0%", style: { 'stopColor': '#EE8C4B', 'stopOpacity': 1 } }),
            React.createElement("stop", { offset: "100%", style: { 'stopColor': '#F36062', 'stopOpacity': 1 } })
          ),
          React.createElement(
            "linearGradient",
            { id: "success-ltr", x1: "100%", y1: "0%", x2: "0%", y2: "0%" },
            React.createElement("stop", { offset: "0%", style: { 'stopColor': '#B4DE85', 'stopOpacity': 1 } }),
            React.createElement("stop", { offset: "100%", style: { 'stopColor': '#14B474', 'stopOpacity': 1 } })
          ),
          React.createElement(
            "linearGradient",
            { id: "success-rtl", x1: "100%", y1: "0%", x2: "0%", y2: "0%" },
            React.createElement("stop", { offset: "0%", style: { 'stopColor': '#14B474', 'stopOpacity': 1 } }),
            React.createElement("stop", { offset: "100%", style: { 'stopColor': '#B4DE85', 'stopOpacity': 1 } })
          ),
          React.createElement(
            "linearGradient",
            { id: "normal-ltr", x1: "100%", y1: "0%", x2: "0%", y2: "0%" },
            React.createElement("stop", { offset: "0%", style: { 'stopColor': '#FFE8A8', 'stopOpacity': 1 } }),
            React.createElement("stop", { offset: "100%", style: { 'stopColor': '#D4AF51', 'stopOpacity': 1 } })
          ),
          React.createElement(
            "linearGradient",
            { id: "normal-rtl", x1: "100%", y1: "0%", x2: "0%", y2: "0%" },
            React.createElement("stop", { offset: "0%", style: { 'stopColor': '#D4AF51', 'stopOpacity': 1 } }),
            React.createElement("stop", { offset: "100%", style: { 'stopColor': '#FFE8A8', 'stopOpacity': 1 } })
          ),
          React.createElement(
            "clipPath",
            { id: "clipping" },
            React.createElement("polygon", { points: this.getClipPoints() })
          )
        ),
        React.createElement("rect", { x: "0", y: "0", rx: this.radius / 2, ry: this.radius / 2, width: this.width, height: this.height, fill: "#33394A" }),
        React.createElement("rect", { x: "0", y: "0", rx: this.radius / 2, ry: this.radius / 2, clipPath: "url(#clipping)", width: this.width, height: this.height, fill: "url(#" + this.gradient + "-" + this.direction + ")" })
      );
    }
  }]);

  return P;
}(React.Component);

ReactDOM.render(React.createElement(
  "div",
  null,
  React.createElement(P, { value: 0.8, direction: "rtl", gradient: "success", width: 60, height: 3 }),
  React.createElement(P, { value: 0.9, direction: "ltr", gradient: "danger", width: 120, height: 20 }),
  React.createElement(P, { value: 0.8, direction: "rtl", gradient: "success", width: 60, height: 3 }),
  React.createElement(P, { value: 0.2, direction: "ltr", gradient: "danger", width: 120, height: 20 })
), document.getElementById('root'));

Comments