Socket
Socket
Sign inDemoInstall

@khanacademy/wonder-blocks-icon

Package Overview
Dependencies
Maintainers
1
Versions
179
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@khanacademy/wonder-blocks-icon - npm Package Compare versions

Comparing version 1.0.9 to 1.0.10

168

dist/es/index.js

@@ -5,2 +5,24 @@ import React from 'react';

function _classCallCheck(instance, Constructor) {
if (!(instance instanceof Constructor)) {
throw new TypeError("Cannot call a class as a 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);
}
}
function _createClass(Constructor, protoProps, staticProps) {
if (protoProps) _defineProperties(Constructor.prototype, protoProps);
if (staticProps) _defineProperties(Constructor, staticProps);
return Constructor;
}
function _defineProperty(obj, key, value) {

@@ -21,2 +43,49 @@ if (key in obj) {

function _inherits(subClass, superClass) {
if (typeof superClass !== "function" && superClass !== null) {
throw new TypeError("Super expression must either be null or a function");
}
subClass.prototype = Object.create(superClass && superClass.prototype, {
constructor: {
value: subClass,
writable: true,
configurable: true
}
});
if (superClass) _setPrototypeOf(subClass, superClass);
}
function _getPrototypeOf(o) {
_getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) {
return o.__proto__ || Object.getPrototypeOf(o);
};
return _getPrototypeOf(o);
}
function _setPrototypeOf(o, p) {
_setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) {
o.__proto__ = p;
return o;
};
return _setPrototypeOf(o, p);
}
function _assertThisInitialized(self) {
if (self === void 0) {
throw new ReferenceError("this hasn't been initialised - super() hasn't been called");
}
return self;
}
function _possibleConstructorReturn(self, call) {
if (call && (typeof call === "object" || typeof call === "function")) {
return call;
}
return _assertThisInitialized(self);
}
/**

@@ -26,8 +95,10 @@ * A simple function that tells us how many viewport pixels each icon size

*/
const viewportPixelsForSize = size => ({
small: 16,
medium: 24,
large: 48,
xlarge: 96
})[size];
var viewportPixelsForSize = function viewportPixelsForSize(size) {
return {
small: 16,
medium: 24,
large: 48,
xlarge: 96
}[size];
};
/**

@@ -45,3 +116,3 @@ * A utility to find the right asset from an IconAsset to display in an icon

const getPathForIcon = (icon, size) => {
var getPathForIcon = function getPathForIcon(icon, size) {
if (icon[size]) {

@@ -57,13 +128,15 @@ // Great, we have the IconSize we actually requested

// using a larger icon and shrinking it such that detail may be lost.
const desiredPixelSize = viewportPixelsForSize(size);
const availableSizes = Object.keys(icon);
var desiredPixelSize = viewportPixelsForSize(size);
var availableSizes = Object.keys(icon);
const sortFn = availableSize => {
const availablePixelSize = viewportPixelsForSize(availableSize);
const tooLargeByPixels = availablePixelSize - desiredPixelSize;
var sortFn = function sortFn(availableSize) {
var availablePixelSize = viewportPixelsForSize(availableSize);
var tooLargeByPixels = availablePixelSize - desiredPixelSize;
return tooLargeByPixels > 0 ? Number.POSITIVE_INFINITY : Math.abs(tooLargeByPixels);
};
const assetSizes = availableSizes.sort((a, b) => sortFn(a) - sortFn(b));
const bestAssetSize = assetSizes[0];
var assetSizes = availableSizes.sort(function (a, b) {
return sortFn(a) - sortFn(b);
});
var bestAssetSize = assetSizes[0];

@@ -81,3 +154,3 @@ if (bestAssetSize && icon[bestAssetSize]) {

const StyledSVG = addStyle("svg");
var StyledSVG = addStyle("svg");
/**

@@ -119,11 +192,23 @@ * An Icon displays a small informational or decorative image as an SVG.

class Icon extends React.PureComponent {
render() {
// There is a weird thing where Flow will only recognize a string-quoted
// prop name if it's in single quotes, but our tooling normalizes it to
// double-quotes on commit. So the aria-label prop isn't included in
// props validation.
// eslint-disable-next-line react/prop-types
const ariaLabel = this.props["aria-label"];
const _this$props = this.props,
var Icon =
/*#__PURE__*/
function (_React$PureComponent) {
_inherits(Icon, _React$PureComponent);
function Icon() {
_classCallCheck(this, Icon);
return _possibleConstructorReturn(this, _getPrototypeOf(Icon).apply(this, arguments));
}
_createClass(Icon, [{
key: "render",
value: function render() {
// There is a weird thing where Flow will only recognize a string-quoted
// prop name if it's in single quotes, but our tooling normalizes it to
// double-quotes on commit. So the aria-label prop isn't included in
// props validation.
// eslint-disable-next-line react/prop-types
var ariaLabel = this.props["aria-label"];
var _this$props = this.props,
color = _this$props.color,

@@ -134,21 +219,23 @@ icon = _this$props.icon,

const _getPathForIcon = getPathForIcon(icon, size),
var _getPathForIcon = getPathForIcon(icon, size),
assetSize = _getPathForIcon.assetSize,
path = _getPathForIcon.path;
const pixelSize = viewportPixelsForSize(size);
const viewboxPixelSize = viewportPixelsForSize(assetSize);
return React.createElement(StyledSVG, {
style: [styles.svg, style],
width: pixelSize,
height: pixelSize,
"aria-label": ariaLabel,
viewBox: `0 0 ${viewboxPixelSize} ${viewboxPixelSize}`
}, React.createElement("path", {
fill: color,
d: path
}));
}
var pixelSize = viewportPixelsForSize(size);
var viewboxPixelSize = viewportPixelsForSize(assetSize);
return React.createElement(StyledSVG, {
style: [styles.svg, style],
width: pixelSize,
height: pixelSize,
"aria-label": ariaLabel,
viewBox: "0 0 ".concat(viewboxPixelSize, " ").concat(viewboxPixelSize)
}, React.createElement("path", {
fill: color,
d: path
}));
}
}]);
}
return Icon;
}(React.PureComponent);

@@ -159,4 +246,3 @@ _defineProperty(Icon, "defaultProps", {

});
const styles = StyleSheet.create({
var styles = StyleSheet.create({
svg: {

@@ -163,0 +249,0 @@ display: "inline-block",

@@ -128,8 +128,10 @@ module.exports =

*/
const viewportPixelsForSize = size => ({
small: 16,
medium: 24,
large: 48,
xlarge: 96
})[size];
var viewportPixelsForSize = function viewportPixelsForSize(size) {
return {
small: 16,
medium: 24,
large: 48,
xlarge: 96
}[size];
};
/**

@@ -147,3 +149,3 @@ * A utility to find the right asset from an IconAsset to display in an icon

const getPathForIcon = (icon, size) => {
var getPathForIcon = function getPathForIcon(icon, size) {
if (icon[size]) {

@@ -159,13 +161,15 @@ // Great, we have the IconSize we actually requested

// using a larger icon and shrinking it such that detail may be lost.
const desiredPixelSize = viewportPixelsForSize(size);
const availableSizes = Object.keys(icon);
var desiredPixelSize = viewportPixelsForSize(size);
var availableSizes = Object.keys(icon);
const sortFn = availableSize => {
const availablePixelSize = viewportPixelsForSize(availableSize);
const tooLargeByPixels = availablePixelSize - desiredPixelSize;
var sortFn = function sortFn(availableSize) {
var availablePixelSize = viewportPixelsForSize(availableSize);
var tooLargeByPixels = availablePixelSize - desiredPixelSize;
return tooLargeByPixels > 0 ? Number.POSITIVE_INFINITY : Math.abs(tooLargeByPixels);
};
const assetSizes = availableSizes.sort((a, b) => sortFn(a) - sortFn(b));
const bestAssetSize = assetSizes[0];
var assetSizes = availableSizes.sort(function (a, b) {
return sortFn(a) - sortFn(b);
});
var bestAssetSize = assetSizes[0];

@@ -183,2 +187,20 @@ if (bestAssetSize && icon[bestAssetSize]) {

// CONCATENATED MODULE: ./packages/wonder-blocks-icon/components/icon.js
function _typeof(obj) { if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a 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); } }
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); }
function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); }
function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }

@@ -190,3 +212,3 @@

const StyledSVG = Object(wonder_blocks_core_["addStyle"])("svg");
var StyledSVG = Object(wonder_blocks_core_["addStyle"])("svg");
/**

@@ -228,11 +250,23 @@ * An Icon displays a small informational or decorative image as an SVG.

class icon_Icon extends external_react_default.a.PureComponent {
render() {
// There is a weird thing where Flow will only recognize a string-quoted
// prop name if it's in single quotes, but our tooling normalizes it to
// double-quotes on commit. So the aria-label prop isn't included in
// props validation.
// eslint-disable-next-line react/prop-types
const ariaLabel = this.props["aria-label"];
const _this$props = this.props,
var icon_Icon =
/*#__PURE__*/
function (_React$PureComponent) {
_inherits(Icon, _React$PureComponent);
function Icon() {
_classCallCheck(this, Icon);
return _possibleConstructorReturn(this, _getPrototypeOf(Icon).apply(this, arguments));
}
_createClass(Icon, [{
key: "render",
value: function render() {
// There is a weird thing where Flow will only recognize a string-quoted
// prop name if it's in single quotes, but our tooling normalizes it to
// double-quotes on commit. So the aria-label prop isn't included in
// props validation.
// eslint-disable-next-line react/prop-types
var ariaLabel = this.props["aria-label"];
var _this$props = this.props,
color = _this$props.color,

@@ -243,21 +277,23 @@ icon = _this$props.icon,

const _getPathForIcon = getPathForIcon(icon, size),
var _getPathForIcon = getPathForIcon(icon, size),
assetSize = _getPathForIcon.assetSize,
path = _getPathForIcon.path;
const pixelSize = viewportPixelsForSize(size);
const viewboxPixelSize = viewportPixelsForSize(assetSize);
return external_react_default.a.createElement(StyledSVG, {
style: [styles.svg, style],
width: pixelSize,
height: pixelSize,
"aria-label": ariaLabel,
viewBox: `0 0 ${viewboxPixelSize} ${viewboxPixelSize}`
}, external_react_default.a.createElement("path", {
fill: color,
d: path
}));
}
var pixelSize = viewportPixelsForSize(size);
var viewboxPixelSize = viewportPixelsForSize(assetSize);
return external_react_default.a.createElement(StyledSVG, {
style: [styles.svg, style],
width: pixelSize,
height: pixelSize,
"aria-label": ariaLabel,
viewBox: "0 0 ".concat(viewboxPixelSize, " ").concat(viewboxPixelSize)
}, external_react_default.a.createElement("path", {
fill: color,
d: path
}));
}
}]);
}
return Icon;
}(external_react_default.a.PureComponent);

@@ -269,3 +305,4 @@ _defineProperty(icon_Icon, "defaultProps", {

const styles = external_aphrodite_["StyleSheet"].create({
var styles = external_aphrodite_["StyleSheet"].create({
svg: {

@@ -272,0 +309,0 @@ display: "inline-block",

{
"name": "@khanacademy/wonder-blocks-icon",
"version": "1.0.9",
"version": "1.0.10",
"design": "v1",

@@ -18,6 +18,7 @@ "publishConfig": {

"dependencies": {
"@khanacademy/wonder-blocks-core": "^1.2.5"
"@khanacademy/wonder-blocks-core": "^1.2.6"
},
"devDependencies": {
"@khanacademy/wonder-blocks-color": "^1.0.12"
"@khanacademy/wonder-blocks-color": "^1.0.13",
"wb-dev-build-settings": "^0.0.2"
},

@@ -24,0 +25,0 @@ "peerDependencies": {

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc