Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@vx/pattern

Package Overview
Dependencies
Maintainers
3
Versions
38
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@vx/pattern - npm Package Compare versions

Comparing version 0.0.192 to 0.0.193-alpha.0

lib/constants/index.d.ts

2

esm/constants/index.js

@@ -1,2 +0,2 @@

export default {
export var PatternOrientation = {
horizontal: 'horizontal',

@@ -3,0 +3,0 @@ vertical: 'vertical',

@@ -7,2 +7,2 @@ export { default as Pattern } from './patterns/Pattern';

export { default as PatternPath } from './patterns/Path';
export { default as PatternOrientation } from './constants';
export { PatternOrientation } from './constants';

@@ -0,14 +1,11 @@

import _pt from "prop-types";
import React from 'react';
import PropTypes from 'prop-types';
import cxx from 'classnames';
import cx from 'classnames';
import Pattern from './Pattern';
/**
* Creates an array of cirlces for a list of corners
* in the format [[cornerX, cornerY], ...]
*/
export function createCircles(_ref) {
var corners = _ref.corners,
id = _ref.id,
radius = _ref.radius,
export default function PatternCircles(_ref) {
var id = _ref.id,
width = _ref.width,
height = _ref.height,
_ref$radius = _ref.radius,
radius = _ref$radius === void 0 ? 2 : _ref$radius,
fill = _ref.fill,

@@ -18,46 +15,6 @@ stroke = _ref.stroke,

strokeDasharray = _ref.strokeDasharray,
background = _ref.background,
_ref$complement = _ref.complement,
complement = _ref$complement === void 0 ? false : _ref$complement,
className = _ref.className;
return corners.map(function (_ref2) {
var cornerX = _ref2[0],
cornerY = _ref2[1];
return React.createElement("circle", {
key: id + "-complement-" + cornerX + "-" + cornerY,
className: cxx('vx-pattern-circle vx-pattern-circle-complement', className),
cx: cornerX,
cy: cornerY,
r: radius,
fill: fill,
stroke: stroke,
strokeWidth: strokeWidth,
strokeDasharray: strokeDasharray
});
});
}
PatternCircles.propTypes = {
id: PropTypes.string.isRequired,
width: PropTypes.number.isRequired,
height: PropTypes.number.isRequired,
radius: PropTypes.number,
fill: PropTypes.string,
className: PropTypes.string,
stroke: PropTypes.string,
strokeWidth: PropTypes.number,
strokeDasharray: PropTypes.string,
complement: PropTypes.bool,
background: PropTypes.string
};
export default function PatternCircles(_ref3) {
var id = _ref3.id,
width = _ref3.width,
height = _ref3.height,
_ref3$radius = _ref3.radius,
radius = _ref3$radius === void 0 ? 2 : _ref3$radius,
fill = _ref3.fill,
stroke = _ref3.stroke,
strokeWidth = _ref3.strokeWidth,
strokeDasharray = _ref3.strokeDasharray,
background = _ref3.background,
_ref3$complement = _ref3.complement,
complement = _ref3$complement === void 0 ? false : _ref3$complement,
className = _ref3.className;
var corners;

@@ -78,3 +35,3 @@

}), React.createElement("circle", {
className: cxx('vx-pattern-circle', className),
className: cx('vx-pattern-circle', className),
cx: width / 2,

@@ -87,11 +44,30 @@ cy: height / 2,

strokeDasharray: strokeDasharray
}), complement && createCircles({
corners: corners,
id: id,
radius: radius,
fill: fill,
stroke: stroke,
strokeWidth: strokeWidth,
strokeDasharray: strokeDasharray
}), corners && corners.map(function (_ref2) {
var cornerX = _ref2[0],
cornerY = _ref2[1];
return React.createElement("circle", {
key: id + "-complement-" + cornerX + "-" + cornerY,
className: cx('vx-pattern-circle vx-pattern-circle-complement', className),
cx: cornerX,
cy: cornerY,
r: radius,
fill: fill,
stroke: stroke,
strokeWidth: strokeWidth,
strokeDasharray: strokeDasharray
});
}));
}
}
PatternCircles.propTypes = {
id: _pt.string.isRequired,
width: _pt.number.isRequired,
height: _pt.number.isRequired,
radius: _pt.number,
fill: _pt.string,
className: _pt.string,
stroke: _pt.string,
strokeWidth: _pt.oneOfType([_pt.number, _pt.string]),
strokeDasharray: _pt.oneOfType([_pt.number, _pt.string]),
complement: _pt.bool,
background: _pt.string
};

@@ -0,18 +1,5 @@

import _pt from "prop-types";
import React from 'react';
import PropTypes from 'prop-types';
import cx from 'classnames';
import Path from './Path';
PatternHexagons.propTypes = {
id: PropTypes.string.isRequired,
height: PropTypes.number.isRequired,
size: PropTypes.number,
fill: PropTypes.string,
className: PropTypes.string,
background: PropTypes.string,
stroke: PropTypes.string,
strokeWidth: PropTypes.number,
strokeDasharray: PropTypes.string,
strokeLinecap: PropTypes.string,
shapeRendering: PropTypes.string
};
export default function PatternHexagons(_ref) {

@@ -46,2 +33,15 @@ var id = _ref.id,

});
}
}
PatternHexagons.propTypes = {
id: _pt.string.isRequired,
height: _pt.number.isRequired,
size: _pt.number,
fill: _pt.string,
className: _pt.string,
background: _pt.string,
stroke: _pt.string,
strokeWidth: _pt.oneOfType([_pt.number, _pt.string]),
strokeDasharray: _pt.oneOfType([_pt.string, _pt.number]),
strokeLinecap: _pt.oneOf(['square', 'butt', 'round', 'inherit']),
shapeRendering: _pt.oneOfType([_pt.string, _pt.number])
};

@@ -0,6 +1,6 @@

import _pt from "prop-types";
import React from 'react';
import PropTypes from 'prop-types';
import cx from 'classnames';
import Pattern from './Pattern';
import Orientation from '../constants';
import { PatternOrientation } from '../constants';

@@ -10,22 +10,16 @@ function pathForOrientation(_ref) {

orientation = _ref.orientation;
var path;
switch (orientation) {
case Orientation.vertical:
path = "M " + height / 2 + ", 0 l 0, " + height;
break;
case PatternOrientation.vertical:
return "M " + height / 2 + ", 0 l 0, " + height;
case Orientation.horizontal:
path = "M 0," + height / 2 + " l " + height + ",0";
break;
case PatternOrientation.horizontal:
return "M 0," + height / 2 + " l " + height + ",0";
case Orientation.diagonal:
path = "M 0," + height + " l " + height + "," + -height + " M " + -height / 4 + "," + height / 4 + " l " + height / 2 + "," + -height / 2 + "\n M " + 3 / 4 * height + "," + 5 / 4 * height + " l " + height / 2 + "," + -height / 2;
break;
case PatternOrientation.diagonal:
return "M 0," + height + " l " + height + "," + -height + " M " + -height / 4 + "," + height / 4 + " l " + height / 2 + "," + -height / 2 + "\n M " + 3 / 4 * height + "," + 5 / 4 * height + " l " + height / 2 + "," + -height / 2;
default:
path = "M " + height / 2 + ", 0 l 0, " + height;
return "M " + height / 2 + ", 0 l 0, " + height;
}
return path;
}

@@ -75,13 +69,13 @@

PatternLines.propTypes = {
id: PropTypes.string.isRequired,
width: PropTypes.number.isRequired,
height: PropTypes.number.isRequired,
background: PropTypes.string,
stroke: PropTypes.string.isRequired,
strokeWidth: PropTypes.number.isRequired,
strokeDasharray: PropTypes.string,
className: PropTypes.string,
strokeLinecap: PropTypes.string,
shapeRendering: PropTypes.string,
orientation: PropTypes.array
id: _pt.string.isRequired,
width: _pt.number.isRequired,
height: _pt.number.isRequired,
className: _pt.string,
background: _pt.string,
stroke: _pt.string,
strokeWidth: _pt.oneOfType([_pt.number, _pt.string]),
strokeDasharray: _pt.oneOfType([_pt.string, _pt.number]),
strokeLinecap: _pt.oneOf(['square', 'butt', 'round', 'inherit']),
shapeRendering: _pt.oneOfType([_pt.string, _pt.number]),
orientation: _pt.arrayOf(_pt.any)
};

@@ -0,3 +1,3 @@

import _pt from "prop-types";
import React from 'react';
import PropTypes from 'prop-types';
import cx from 'classnames';

@@ -41,14 +41,14 @@ import Pattern from './Pattern';

PatternPath.propTypes = {
id: PropTypes.string.isRequired,
width: PropTypes.number.isRequired,
height: PropTypes.number.isRequired,
path: PropTypes.string,
fill: PropTypes.string,
className: PropTypes.string,
background: PropTypes.string,
stroke: PropTypes.string,
strokeWidth: PropTypes.number,
strokeDasharray: PropTypes.string,
strokeLinecap: PropTypes.string,
shapeRendering: PropTypes.string
id: _pt.string.isRequired,
width: _pt.number.isRequired,
height: _pt.number.isRequired,
path: _pt.string,
fill: _pt.string,
className: _pt.string,
background: _pt.string,
stroke: _pt.string,
strokeWidth: _pt.oneOfType([_pt.number, _pt.string]),
strokeDasharray: _pt.oneOfType([_pt.string, _pt.number]),
strokeLinecap: _pt.oneOf(['square', 'butt', 'round', 'inherit']),
shapeRendering: _pt.oneOfType([_pt.string, _pt.number])
};

@@ -0,3 +1,3 @@

import _pt from "prop-types";
import React from 'react';
import PropTypes from 'prop-types';
export default function Pattern(_ref) {

@@ -16,6 +16,6 @@ var id = _ref.id,

Pattern.propTypes = {
id: PropTypes.string.isRequired,
width: PropTypes.number.isRequired,
height: PropTypes.number.isRequired,
children: PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.node), PropTypes.node]).isRequired
id: _pt.string.isRequired,
width: _pt.number.isRequired,
height: _pt.number.isRequired,
children: _pt.node.isRequired
};

@@ -0,3 +1,3 @@

import _pt from "prop-types";
import React from 'react';
import PropTypes from 'prop-types';
import cx from 'classnames';

@@ -33,13 +33,13 @@ import Path from './Path';

PatternWaves.propTypes = {
id: PropTypes.string.isRequired,
width: PropTypes.number.isRequired,
height: PropTypes.number.isRequired,
fill: PropTypes.string,
className: PropTypes.string,
background: PropTypes.string,
stroke: PropTypes.string,
strokeWidth: PropTypes.number,
strokeDasharray: PropTypes.string,
strokeLinecap: PropTypes.string,
shapeRendering: PropTypes.string
id: _pt.string.isRequired,
width: _pt.number.isRequired,
height: _pt.number.isRequired,
fill: _pt.string,
className: _pt.string,
background: _pt.string,
stroke: _pt.string,
strokeWidth: _pt.oneOfType([_pt.number, _pt.string]),
strokeDasharray: _pt.oneOfType([_pt.string, _pt.number]),
strokeLinecap: _pt.oneOf(['square', 'butt', 'round', 'inherit']),
shapeRendering: _pt.oneOfType([_pt.string, _pt.number])
};
"use strict";
exports.__esModule = true;
exports.default = void 0;
var _default = {
exports.PatternOrientation = void 0;
var PatternOrientation = {
horizontal: 'horizontal',

@@ -10,2 +10,2 @@ vertical: 'vertical',

};
exports.default = _default;
exports.PatternOrientation = PatternOrientation;

@@ -30,6 +30,6 @@ "use strict";

var _constants = _interopRequireDefault(require("./constants"));
var _constants = require("./constants");
exports.PatternOrientation = _constants.default;
exports.PatternOrientation = _constants.PatternOrientation;
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
"use strict";
exports.__esModule = true;
exports.createCircles = createCircles;
exports.default = PatternCircles;
var _propTypes = _interopRequireDefault(require("prop-types"));
var _react = _interopRequireDefault(require("react"));
var _propTypes = _interopRequireDefault(require("prop-types"));
var _classnames = _interopRequireDefault(require("classnames"));

@@ -17,10 +16,8 @@

/**
* Creates an array of cirlces for a list of corners
* in the format [[cornerX, cornerY], ...]
*/
function createCircles(_ref) {
var corners = _ref.corners,
id = _ref.id,
radius = _ref.radius,
function PatternCircles(_ref) {
var id = _ref.id,
width = _ref.width,
height = _ref.height,
_ref$radius = _ref.radius,
radius = _ref$radius === void 0 ? 2 : _ref$radius,
fill = _ref.fill,

@@ -30,4 +27,30 @@ stroke = _ref.stroke,

strokeDasharray = _ref.strokeDasharray,
background = _ref.background,
_ref$complement = _ref.complement,
complement = _ref$complement === void 0 ? false : _ref$complement,
className = _ref.className;
return corners.map(function (_ref2) {
var corners;
if (complement) {
corners = [[0, 0], [0, height], [width, 0], [width, height]];
}
return _react.default.createElement(_Pattern.default, {
id: id,
width: width,
height: height
}, !!background && _react.default.createElement("rect", {
width: width,
height: height,
fill: background
}), _react.default.createElement("circle", {
className: (0, _classnames.default)('vx-pattern-circle', className),
cx: width / 2,
cy: height / 2,
r: radius,
fill: fill,
stroke: stroke,
strokeWidth: strokeWidth,
strokeDasharray: strokeDasharray
}), corners && corners.map(function (_ref2) {
var cornerX = _ref2[0],

@@ -46,3 +69,3 @@ cornerY = _ref2[1];

});
});
}));
}

@@ -58,54 +81,6 @@

stroke: _propTypes.default.string,
strokeWidth: _propTypes.default.number,
strokeDasharray: _propTypes.default.string,
strokeWidth: _propTypes.default.oneOfType([_propTypes.default.number, _propTypes.default.string]),
strokeDasharray: _propTypes.default.oneOfType([_propTypes.default.number, _propTypes.default.string]),
complement: _propTypes.default.bool,
background: _propTypes.default.string
};
function PatternCircles(_ref3) {
var id = _ref3.id,
width = _ref3.width,
height = _ref3.height,
_ref3$radius = _ref3.radius,
radius = _ref3$radius === void 0 ? 2 : _ref3$radius,
fill = _ref3.fill,
stroke = _ref3.stroke,
strokeWidth = _ref3.strokeWidth,
strokeDasharray = _ref3.strokeDasharray,
background = _ref3.background,
_ref3$complement = _ref3.complement,
complement = _ref3$complement === void 0 ? false : _ref3$complement,
className = _ref3.className;
var corners;
if (complement) {
corners = [[0, 0], [0, height], [width, 0], [width, height]];
}
return _react.default.createElement(_Pattern.default, {
id: id,
width: width,
height: height
}, !!background && _react.default.createElement("rect", {
width: width,
height: height,
fill: background
}), _react.default.createElement("circle", {
className: (0, _classnames.default)('vx-pattern-circle', className),
cx: width / 2,
cy: height / 2,
r: radius,
fill: fill,
stroke: stroke,
strokeWidth: strokeWidth,
strokeDasharray: strokeDasharray
}), complement && createCircles({
corners: corners,
id: id,
radius: radius,
fill: fill,
stroke: stroke,
strokeWidth: strokeWidth,
strokeDasharray: strokeDasharray
}));
}
};

@@ -6,6 +6,6 @@ "use strict";

var _propTypes = _interopRequireDefault(require("prop-types"));
var _react = _interopRequireDefault(require("react"));
var _propTypes = _interopRequireDefault(require("prop-types"));
var _classnames = _interopRequireDefault(require("classnames"));

@@ -17,16 +17,2 @@

PatternHexagons.propTypes = {
id: _propTypes.default.string.isRequired,
height: _propTypes.default.number.isRequired,
size: _propTypes.default.number,
fill: _propTypes.default.string,
className: _propTypes.default.string,
background: _propTypes.default.string,
stroke: _propTypes.default.string,
strokeWidth: _propTypes.default.number,
strokeDasharray: _propTypes.default.string,
strokeLinecap: _propTypes.default.string,
shapeRendering: _propTypes.default.string
};
function PatternHexagons(_ref) {

@@ -60,2 +46,16 @@ var id = _ref.id,

});
}
}
PatternHexagons.propTypes = {
id: _propTypes.default.string.isRequired,
height: _propTypes.default.number.isRequired,
size: _propTypes.default.number,
fill: _propTypes.default.string,
className: _propTypes.default.string,
background: _propTypes.default.string,
stroke: _propTypes.default.string,
strokeWidth: _propTypes.default.oneOfType([_propTypes.default.number, _propTypes.default.string]),
strokeDasharray: _propTypes.default.oneOfType([_propTypes.default.string, _propTypes.default.number]),
strokeLinecap: _propTypes.default.oneOf(['square', 'butt', 'round', 'inherit']),
shapeRendering: _propTypes.default.oneOfType([_propTypes.default.string, _propTypes.default.number])
};

@@ -6,6 +6,6 @@ "use strict";

var _propTypes = _interopRequireDefault(require("prop-types"));
var _react = _interopRequireDefault(require("react"));
var _propTypes = _interopRequireDefault(require("prop-types"));
var _classnames = _interopRequireDefault(require("classnames"));

@@ -15,3 +15,3 @@

var _constants = _interopRequireDefault(require("../constants"));
var _constants = require("../constants");

@@ -23,22 +23,16 @@ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }

orientation = _ref.orientation;
var path;
switch (orientation) {
case _constants.default.vertical:
path = "M " + height / 2 + ", 0 l 0, " + height;
break;
case _constants.PatternOrientation.vertical:
return "M " + height / 2 + ", 0 l 0, " + height;
case _constants.default.horizontal:
path = "M 0," + height / 2 + " l " + height + ",0";
break;
case _constants.PatternOrientation.horizontal:
return "M 0," + height / 2 + " l " + height + ",0";
case _constants.default.diagonal:
path = "M 0," + height + " l " + height + "," + -height + " M " + -height / 4 + "," + height / 4 + " l " + height / 2 + "," + -height / 2 + "\n M " + 3 / 4 * height + "," + 5 / 4 * height + " l " + height / 2 + "," + -height / 2;
break;
case _constants.PatternOrientation.diagonal:
return "M 0," + height + " l " + height + "," + -height + " M " + -height / 4 + "," + height / 4 + " l " + height / 2 + "," + -height / 2 + "\n M " + 3 / 4 * height + "," + 5 / 4 * height + " l " + height / 2 + "," + -height / 2;
default:
path = "M " + height / 2 + ", 0 l 0, " + height;
return "M " + height / 2 + ", 0 l 0, " + height;
}
return path;
}

@@ -92,10 +86,10 @@

height: _propTypes.default.number.isRequired,
className: _propTypes.default.string,
background: _propTypes.default.string,
stroke: _propTypes.default.string.isRequired,
strokeWidth: _propTypes.default.number.isRequired,
strokeDasharray: _propTypes.default.string,
className: _propTypes.default.string,
strokeLinecap: _propTypes.default.string,
shapeRendering: _propTypes.default.string,
orientation: _propTypes.default.array
stroke: _propTypes.default.string,
strokeWidth: _propTypes.default.oneOfType([_propTypes.default.number, _propTypes.default.string]),
strokeDasharray: _propTypes.default.oneOfType([_propTypes.default.string, _propTypes.default.number]),
strokeLinecap: _propTypes.default.oneOf(['square', 'butt', 'round', 'inherit']),
shapeRendering: _propTypes.default.oneOfType([_propTypes.default.string, _propTypes.default.number]),
orientation: _propTypes.default.arrayOf(_propTypes.default.any)
};

@@ -6,6 +6,6 @@ "use strict";

var _propTypes = _interopRequireDefault(require("prop-types"));
var _react = _interopRequireDefault(require("react"));
var _propTypes = _interopRequireDefault(require("prop-types"));
var _classnames = _interopRequireDefault(require("classnames"));

@@ -62,6 +62,6 @@

stroke: _propTypes.default.string,
strokeWidth: _propTypes.default.number,
strokeDasharray: _propTypes.default.string,
strokeLinecap: _propTypes.default.string,
shapeRendering: _propTypes.default.string
strokeWidth: _propTypes.default.oneOfType([_propTypes.default.number, _propTypes.default.string]),
strokeDasharray: _propTypes.default.oneOfType([_propTypes.default.string, _propTypes.default.number]),
strokeLinecap: _propTypes.default.oneOf(['square', 'butt', 'round', 'inherit']),
shapeRendering: _propTypes.default.oneOfType([_propTypes.default.string, _propTypes.default.number])
};

@@ -6,6 +6,6 @@ "use strict";

var _propTypes = _interopRequireDefault(require("prop-types"));
var _react = _interopRequireDefault(require("react"));
var _propTypes = _interopRequireDefault(require("prop-types"));
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }

@@ -30,3 +30,3 @@

height: _propTypes.default.number.isRequired,
children: _propTypes.default.oneOfType([_propTypes.default.arrayOf(_propTypes.default.node), _propTypes.default.node]).isRequired
children: _propTypes.default.node.isRequired
};

@@ -6,6 +6,6 @@ "use strict";

var _propTypes = _interopRequireDefault(require("prop-types"));
var _react = _interopRequireDefault(require("react"));
var _propTypes = _interopRequireDefault(require("prop-types"));
var _classnames = _interopRequireDefault(require("classnames"));

@@ -53,6 +53,6 @@

stroke: _propTypes.default.string,
strokeWidth: _propTypes.default.number,
strokeDasharray: _propTypes.default.string,
strokeLinecap: _propTypes.default.string,
shapeRendering: _propTypes.default.string
strokeWidth: _propTypes.default.oneOfType([_propTypes.default.number, _propTypes.default.string]),
strokeDasharray: _propTypes.default.oneOfType([_propTypes.default.string, _propTypes.default.number]),
strokeLinecap: _propTypes.default.oneOf(['square', 'butt', 'round', 'inherit']),
shapeRendering: _propTypes.default.oneOfType([_propTypes.default.string, _propTypes.default.number])
};
{
"name": "@vx/pattern",
"version": "0.0.192",
"version": "0.0.193-alpha.0",
"description": "vx pattern",

@@ -8,2 +8,3 @@ "sideEffects": false,

"module": "esm/index.js",
"types": "lib/index.d.ts",
"files": [

@@ -34,2 +35,4 @@ "lib",

"dependencies": {
"@types/classnames": "^2.2.9",
"@types/react": "*",
"classnames": "^2.2.5",

@@ -44,3 +47,3 @@ "prop-types": "^15.5.10"

},
"gitHead": "101db6e89d7e8a4966dfafba5a782297110f7844"
"gitHead": "8fb99e77e64fa9c319c0addc2a3fbf61e64885cc"
}
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