function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
function _iterableToArrayLimit(r, l) { var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (null != t) { var e, n, i, u, a = [], f = !0, o = !1; try { if (i = (t = t.call(r)).next, 0 === l) { if (Object(t) !== t) return; f = !1; } else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0); } catch (r) { o = !0, n = r; } finally { try { if (!f && null != t.return && (u = t.return(), Object(u) !== u)) return; } finally { if (o) throw n; } } return a; } }
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
import React, { useState } from 'react';
import styled from 'styled-components';
import { Display } from '../../../../common/Display';
import { Typography, Box, Button, Flexbox } from '../../../..';
import Badge from '../..';
import { numberWithLimit } from '../../../../common/utils';
export default {
  title: 'Molecules / Badge / Number',
  parameters: {
    component: Badge.Number
  }
};
export var Showcase = {
  render: function render() {
    return React.createElement(Display, {
      items: [{
        title: 'Default Number Badge',
        component: React.createElement(Badge.Number, null, "1")
      }, {
        title: 'Badge with different sizes',
        component: React.createElement("table", null, React.createElement("tr", null, React.createElement("td", {
          width: "30px"
        }, "xs"), React.createElement("td", {
          width: "55px"
        }, "16px"), React.createElement("td", {
          width: "50px"
        }, React.createElement(Badge.Number, {
          badgeSize: "xs"
        }, "1")), React.createElement("td", {
          width: "50px"
        }, React.createElement(Badge.Number, {
          badgeSize: "xs"
        }, "99")), React.createElement("td", {
          width: "50px"
        }, React.createElement(Badge.Number, {
          badgeSize: "xs"
        }, "123"))), React.createElement("tr", null, React.createElement("td", null, "s"), React.createElement("td", null, "20px"), React.createElement("td", null, React.createElement(Badge.Number, {
          badgeSize: "s"
        }, "1")), React.createElement("td", null, React.createElement(Badge.Number, {
          badgeSize: "s"
        }, "99")), React.createElement("td", null, React.createElement(Badge.Number, {
          badgeSize: "s"
        }, "123"))), React.createElement("tr", null, React.createElement("td", null, "m"), React.createElement("td", null, "24px"), React.createElement("td", null, React.createElement(Badge.Number, {
          badgeSize: "m"
        }, "1")), React.createElement("td", null, React.createElement(Badge.Number, {
          badgeSize: "m"
        }, "99")), React.createElement("td", null, React.createElement(Badge.Number, {
          badgeSize: "m"
        }, "123"))), React.createElement("tr", null, React.createElement("td", null, "l"), React.createElement("td", null, "32px"), React.createElement("td", null, React.createElement(Badge.Number, {
          badgeSize: "l"
        }, "1")), React.createElement("td", null, React.createElement(Badge.Number, {
          badgeSize: "l"
        }, "99")), React.createElement("td", null, React.createElement(Badge.Number, {
          badgeSize: "l"
        }, "123"))))
      }, {
        title: 'Custom background colors with children',
        component: React.createElement(React.Fragment, null, React.createElement(Box, {
          mb: 1
        }, React.createElement(Badge.Number, {
          badgeColor: function badgeColor(t) {
            return t.color.badgeBackgroundPositive;
          }
        }, "2")), React.createElement(Box, {
          mb: 1
        }, React.createElement(Badge.Number, {
          badgeColor: function badgeColor(t) {
            return t.color.badgeBackgroundNegative;
          }
        }, "3")), React.createElement(Box, {
          mb: 1
        }, React.createElement(Badge.Number, {
          badgeColor: function badgeColor(t) {
            return t.color.badgeBackgroundWarning;
          }
        }, "4")))
      }, {
        title: 'Custom text color',
        component: React.createElement(Badge.Number, {
          color: function color(t) {
            return t.color.warning;
          }
        }, "5")
      }]
    });
  }
};
export var CommonUseCases = {
  render: function render() {
    return React.createElement(Display, {
      items: [{
        title: 'Number with limit',
        component: React.createElement(Badge.Number, null, numberWithLimit(1234567, 99))
      }, {
        title: 'Text with Badge',
        component: React.createElement(Box, {
          my: 2
        }, React.createElement(Typography, null, "Orders ", React.createElement(Badge.Number, null, "7")))
      }, {
        title: 'Badge with Aria-label',
        component: React.createElement(Box, {
          my: 2
        }, React.createElement(Typography, null, "Orders ", React.createElement(Badge.Number, {
          "aria-label": "7 new orders"
        }, "7")))
      }, {
        title: 'Badge without Aria-label',
        component: React.createElement(Box, {
          my: 2
        }, React.createElement(Typography, null, "Orders ", React.createElement(Badge.Number, null, "7")))
      }]
    });
  },
  name: 'Common use cases'
};
export var SpecializedChildren = {
  render: function render() {
    return React.createElement(Display, {
      items: [{
        title: 'Component as child',
        component: React.createElement(Box, {
          my: 2
        }, React.createElement(Badge.Number, {
          color: function color(t) {
            return t.color.badgeTextColor;
          }
        }, React.createElement(React.Fragment, null, React.createElement(Typography, {
          type: "title3",
          color: function color(t) {
            return t.color.badgeTextColor;
          }
        }, "8"), React.createElement(Typography, {
          type: "tertiary",
          color: function color(t) {
            return t.color.badgeTextColor;
          }
        }, "%"))), React.createElement(Typography, {
          as: "p",
          type: "caption"
        }, "* It's up to developer to set child component font (family, size, etc.)"))
      }, {
        title: 'Function as child',
        component: React.createElement(Box, {
          my: 2
        }, React.createElement(Badge.Number, {
          color: function color(t) {
            return t.color.badgeTextColor;
          }
        }, function () {
          return React.createElement(Typography, {
            type: "tertiary",
            color: function color(t) {
              return t.color.badgeTextColor;
            }
          }, "9%");
        }), React.createElement(Typography, {
          as: "p",
          type: "caption"
        }, "* It's up to developer to set child function font (family, size, etc.)"))
      }]
    });
  },
  name: 'Specialized children'
};
var StyledFlexbox = styled(Flexbox).withConfig({
  displayName: "NumberBadgestories__StyledFlexbox",
  componentId: "sc-idat7m-0"
})(["width:200px;"]);
var BadgeWithAnimationComponent = function BadgeWithAnimationComponent() {
  var _useState = useState(4),
    _useState2 = _slicedToArray(_useState, 2),
    notificationsExampleOne = _useState2[0],
    setNotificationsExampleOne = _useState2[1];
  var _useState3 = useState(4),
    _useState4 = _slicedToArray(_useState3, 2),
    notificationsExampleTwo = _useState4[0],
    setNotificationsExampleTwo = _useState4[1];
  var _useState5 = useState(false),
    _useState6 = _slicedToArray(_useState5, 2),
    isNewNotifications = _useState6[0],
    setIsNewNotifications = _useState6[1];
  return React.createElement(Display, {
    items: [{
      title: 'Badge with animation',
      component: React.createElement(Box, {
        py: 3
      }, React.createElement(StyledFlexbox, {
        container: true,
        justifyContent: "space-between"
      }, React.createElement(Button, {
        variant: "secondary",
        onClick: function onClick() {
          return setNotificationsExampleOne(notificationsExampleOne - 1);
        }
      }, "-"), React.createElement(Badge.Number, {
        key: notificationsExampleOne,
        animateOnChange: true
      }, notificationsExampleOne), React.createElement(Button, {
        variant: "secondary",
        onClick: function onClick() {
          return setNotificationsExampleOne(notificationsExampleOne + 1);
        }
      }, "+")))
    }, {
      title: 'Badge with animation, but without initial animation example',
      component: React.createElement(Box, {
        py: 3
      }, React.createElement(StyledFlexbox, {
        container: true,
        justifyContent: "space-between"
      }, React.createElement(Button, {
        variant: "secondary",
        onClick: function onClick() {
          setNotificationsExampleTwo(notificationsExampleTwo - 1);
          setIsNewNotifications(true);
        }
      }, "-"), React.createElement(Badge.Number, {
        key: notificationsExampleTwo,
        animateOnChange: isNewNotifications
      }, notificationsExampleTwo), React.createElement(Button, {
        variant: "secondary",
        onClick: function onClick() {
          setNotificationsExampleTwo(notificationsExampleTwo + 1);
          setIsNewNotifications(true);
        }
      }, "+")))
    }]
  });
};
export var BadgeWithAnimation = {
  render: function render() {
    return React.createElement(BadgeWithAnimationComponent, null);
  }
};