buoy-breadcrumbs
Advanced tools
Comparing version 6.3.0-alpha.2 to 7.0.0
@@ -6,7 +6,4 @@ "use strict"; | ||
}); | ||
exports["default"] = undefined; | ||
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; }; }(); | ||
var _templateObject = _taggedTemplateLiteral(["\n color: ", ";\n ", ";\n font-weight: 500;\n"], ["\n color: ", ";\n ", ";\n font-weight: 500;\n"]); | ||
var _react = require("react"); | ||
@@ -28,45 +25,63 @@ | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; } | ||
function _typeof(obj) { "@babel/helpers - typeof"; 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 _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 _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 _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; } | ||
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; } | ||
function _taggedTemplateLiteral(strings, raw) { return Object.freeze(Object.defineProperties(strings, { raw: { value: Object.freeze(raw) } })); } | ||
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 _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; } | ||
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 _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Date.prototype.toString.call(Reflect.construct(Date, [], function () {})); return true; } catch (e) { return false; } } | ||
function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); } | ||
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; } | ||
// Styles | ||
var SpanParagraph = _buoyText.Paragraph.withComponent("span"); | ||
var ActiveItem = (0, _styledComponents2.default)(SpanParagraph).withConfig({ | ||
var InlineParagraph = (0, _styledComponents2["default"])(_buoyText.Paragraph).withConfig({ | ||
displayName: "breadcrumbItem__InlineParagraph", | ||
componentId: "sc-142s8fr-0" | ||
})(["display:inline;"]); | ||
var ActiveItem = (0, _styledComponents2["default"])(InlineParagraph).withConfig({ | ||
displayName: "breadcrumbItem__ActiveItem", | ||
componentId: "sc-142s8fr-0" | ||
})(_templateObject, _buoyTheme.colors.primary, (0, _buoyTheme.fontSize)("label")); | ||
var DeactivatedLink = (0, _styledComponents2.default)(SpanParagraph).withConfig({ | ||
componentId: "sc-142s8fr-1" | ||
})(["color:", ";", ";font-weight:500;"], _buoyTheme.colors.primary, (0, _buoyTheme.fontSize)("label")); | ||
var DeactivatedLink = (0, _styledComponents2["default"])(InlineParagraph).withConfig({ | ||
displayName: "breadcrumbItem__DeactivatedLink", | ||
componentId: "sc-142s8fr-1" | ||
})(_templateObject, _buoyTheme.colors.neutral, (0, _buoyTheme.fontSize)("label")); | ||
var StyledLink = (0, _styledComponents2.default)(_buoyText.Link).withConfig({ | ||
componentId: "sc-142s8fr-2" | ||
})(["color:", ";", ";font-weight:500;"], _buoyTheme.colors.neutral, (0, _buoyTheme.fontSize)("label")); | ||
var StyledLink = (0, _styledComponents2["default"])(_buoyText.Link).withConfig({ | ||
displayName: "breadcrumbItem__StyledLink", | ||
componentId: "sc-142s8fr-2" | ||
})(_templateObject, _buoyTheme.colors.neutral, (0, _buoyTheme.fontSize)("label")); | ||
componentId: "sc-142s8fr-3" | ||
})(["color:", ";", ";font-weight:500;"], _buoyTheme.colors.neutral, (0, _buoyTheme.fontSize)("label")); | ||
var BreadcrumbItem = function (_Component) { | ||
var BreadcrumbItem = /*#__PURE__*/function (_Component) { | ||
_inherits(BreadcrumbItem, _Component); | ||
var _super = _createSuper(BreadcrumbItem); | ||
function BreadcrumbItem() { | ||
var _ref; | ||
var _this; | ||
var _temp, _this, _ret; | ||
_classCallCheck(this, BreadcrumbItem); | ||
for (var _len = arguments.length, args = Array(_len), _key = 0; _key < _len; _key++) { | ||
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) { | ||
args[_key] = arguments[_key]; | ||
} | ||
return _ret = (_temp = (_this = _possibleConstructorReturn(this, (_ref = BreadcrumbItem.__proto__ || Object.getPrototypeOf(BreadcrumbItem)).call.apply(_ref, [this].concat(args))), _this), _this.computeElementType = function () { | ||
_this = _super.call.apply(_super, [this].concat(args)); | ||
_defineProperty(_assertThisInitialized(_this), "computeElementType", function () { | ||
var _this$props = _this.props, | ||
@@ -80,29 +95,24 @@ href = _this$props.href, | ||
} | ||
return href || onClick ? StyledLink : DeactivatedLink; | ||
}, _temp), _possibleConstructorReturn(_this, _ret); | ||
}); | ||
return _this; | ||
} | ||
// Returns correct element depending on props passed | ||
_createClass(BreadcrumbItem, [{ | ||
key: "render", | ||
value: function render() { | ||
var _props = this.props, | ||
children = _props.children, | ||
href = _props.href, | ||
onClick = _props.onClick, | ||
content = _props.content; | ||
var _this$props2 = this.props, | ||
children = _this$props2.children, | ||
href = _this$props2.href, | ||
onClick = _this$props2.onClick, | ||
content = _this$props2.content; | ||
var ElementType = this.computeElementType(); | ||
return _react2.default.createElement( | ||
"li", | ||
null, | ||
_react2.default.createElement( | ||
ElementType, | ||
{ underline: false, small: true, href: href, onClick: onClick }, | ||
children ? children.toLocaleUpperCase() : content.toLocaleUpperCase() | ||
) | ||
); | ||
return /*#__PURE__*/_react2["default"].createElement("li", null, /*#__PURE__*/_react2["default"].createElement(ElementType, { | ||
underline: false, | ||
small: true, | ||
href: href, | ||
onClick: onClick | ||
}, children ? children.toLocaleUpperCase() : content.toLocaleUpperCase())); | ||
} | ||
@@ -114,21 +124,18 @@ }]); | ||
exports.default = BreadcrumbItem; | ||
exports["default"] = BreadcrumbItem; | ||
BreadcrumbItem.defaultProps = { | ||
content: "" | ||
}; | ||
BreadcrumbItem.propTypes = { | ||
/** Style as the currently active section. */ | ||
active: _propTypes2.default.bool, | ||
active: _propTypes2["default"].bool, | ||
/** Primary content. */ | ||
children: _propTypes2.default.node, | ||
children: _propTypes2["default"].node, | ||
/** Shorthand for primary content. */ | ||
content: _propTypes2.default.string, | ||
content: _propTypes2["default"].string, | ||
/** Render as an `a` tag instead of a `span` and adds the href attribute. */ | ||
href: _propTypes2.default.string, | ||
href: _propTypes2["default"].string, | ||
@@ -139,3 +146,3 @@ /** | ||
*/ | ||
onClick: _propTypes2.default.func | ||
onClick: _propTypes2["default"].func | ||
}; |
@@ -6,8 +6,4 @@ "use strict"; | ||
}); | ||
exports["default"] = Breadcrumbs; | ||
var _templateObject = _taggedTemplateLiteral(["\n margin: 0 12px 0 12px;\n ", ";\n color: ", ";\n"], ["\n margin: 0 12px 0 12px;\n ", ";\n color: ", ";\n"]), | ||
_templateObject2 = _taggedTemplateLiteral(["\n list-style: none;\n overflow: hidden;\n ", ";\n padding: 0;\n > * {\n display: inline;\n }\n"], ["\n list-style: none;\n overflow: hidden;\n ", ";\n padding: 0;\n > * {\n display: inline;\n }\n"]); | ||
exports.default = Breadcrumbs; | ||
var _react = require("react"); | ||
@@ -27,39 +23,32 @@ | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; } | ||
function _taggedTemplateLiteral(strings, raw) { return Object.freeze(Object.defineProperties(strings, { raw: { value: Object.freeze(raw) } })); } | ||
// Styles | ||
var DividerContainer = _styledComponents2.default.div.withConfig({ | ||
var DividerContainer = _styledComponents2["default"].div.withConfig({ | ||
displayName: "breadcrumbs__DividerContainer", | ||
componentId: "sc-1ykl7fx-0" | ||
})(_templateObject, (0, _buoyTheme.fontSize)("label"), _buoyTheme.colors.neutral); | ||
})(["margin:0 12px 0 12px;", ";color:", ";"], (0, _buoyTheme.fontSize)("label"), _buoyTheme.colors.neutral); // adding margin prop allows default margin to be overridden | ||
// adding margin prop allows default margin to be overridden | ||
var StyledList = _styledComponents2.default.ul.withConfig({ | ||
var StyledList = _styledComponents2["default"].ul.withConfig({ | ||
displayName: "breadcrumbs__StyledList", | ||
componentId: "sc-1ykl7fx-1" | ||
})(_templateObject2, function (props) { | ||
})(["list-style:none;overflow:hidden;", ";padding:0;> *{display:inline;}"], function (props) { | ||
return props.margin && props.margin; | ||
}); | ||
}); // Arrow Divider component | ||
// Arrow Divider component | ||
var Arrow = function Arrow() { | ||
return _react2.default.createElement( | ||
"svg", | ||
{ | ||
xmlns: "http://www.w3.org/2000/svg", | ||
width: "6", | ||
height: "8", | ||
viewBox: "0 0 6 8" | ||
}, | ||
_react2.default.createElement("path", { | ||
fill: "none", | ||
fillRule: "evenodd", | ||
stroke: "#B9B9B9", | ||
d: "M1 8l3.636-4.023L1 0" | ||
}) | ||
); | ||
return /*#__PURE__*/_react2["default"].createElement("svg", { | ||
xmlns: "http://www.w3.org/2000/svg", | ||
width: "6", | ||
height: "8", | ||
viewBox: "0 0 6 8" | ||
}, /*#__PURE__*/_react2["default"].createElement("path", { | ||
fill: "none", | ||
fillRule: "evenodd", | ||
stroke: "#B9B9B9", | ||
d: "M1 8l3.636-4.023L1 0" | ||
})); | ||
}; | ||
/** | ||
@@ -69,2 +58,4 @@ * @prop {(string|Object)} divider - Accepts either a string or an image/element | ||
*/ | ||
function Breadcrumbs(_ref) { | ||
@@ -77,36 +68,31 @@ var children = _ref.children, | ||
if (divider === true) { | ||
divider = _react2.default.createElement(Arrow, null); | ||
divider = /*#__PURE__*/_react2["default"].createElement(Arrow, null); | ||
} | ||
var childElements = []; | ||
// Arranges and adds divider to the breadcrumbs | ||
var childElements = []; // Arranges and adds divider to the breadcrumbs | ||
children.forEach(function (section, i) { | ||
childElements.push(section); | ||
if (i < children.length - 1) { | ||
childElements.push(_react2.default.createElement( | ||
DividerContainer, | ||
{ key: i }, | ||
divider | ||
)); | ||
childElements.push( /*#__PURE__*/_react2["default"].createElement(DividerContainer, { | ||
key: i | ||
}, divider)); | ||
} | ||
}); | ||
return /*#__PURE__*/_react2["default"].createElement(StyledList, { | ||
margin: margin | ||
}, childElements); | ||
} | ||
return _react2.default.createElement( | ||
StyledList, | ||
{ margin: margin }, | ||
childElements | ||
); | ||
} | ||
Breadcrumbs.defaultProps = { | ||
divider: _react2.default.createElement(Arrow, null) | ||
divider: /*#__PURE__*/_react2["default"].createElement(Arrow, null) | ||
}; | ||
Breadcrumbs.propTypes = { | ||
/** Primary content. */ | ||
children: _propTypes2.default.node, | ||
children: _propTypes2["default"].node, | ||
/** Shorthand for primary content of the Breadcrumb.Divider. */ | ||
divider: _propTypes2.default.oneOfType([_propTypes2.default.string, _propTypes2.default.element, _propTypes2.default.bool]), | ||
margin: _propTypes2.default.any | ||
divider: _propTypes2["default"].oneOfType([_propTypes2["default"].string, _propTypes2["default"].element, _propTypes2["default"].bool]), | ||
margin: _propTypes2["default"].any | ||
}; |
@@ -16,5 +16,5 @@ "use strict"; | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; } | ||
exports.Breadcrumbs = _breadcrumbs2.default; | ||
exports.BreadcrumbItem = _breadcrumbItem2.default; | ||
exports.Breadcrumbs = _breadcrumbs2["default"]; | ||
exports.BreadcrumbItem = _breadcrumbItem2["default"]; |
{ | ||
"name": "buoy-breadcrumbs", | ||
"version": "6.3.0-alpha.2", | ||
"version": "7.0.0", | ||
"description": "Breadcrumb component for Buoy Health", | ||
@@ -19,6 +19,6 @@ "main": "dist/index.js", | ||
"dependencies": { | ||
"buoy-text": "^6.3.0-alpha.2", | ||
"buoy-theme": "^6.3.0-alpha.0" | ||
"buoy-text": "7.0.0", | ||
"buoy-theme": "7.0.0" | ||
}, | ||
"gitHead": "524113d4766642d9b61679ed070f3afe6a8d63a4" | ||
"gitHead": "fc44b2e626b12848f4c7dca32bd14fc0c6b1065c" | ||
} |
@@ -8,5 +8,7 @@ import React, { Component } from "react" | ||
// Styles | ||
const SpanParagraph = Paragraph.withComponent("span") | ||
const InlineParagraph = styled(Paragraph)` | ||
display: inline; | ||
` | ||
const ActiveItem = styled(SpanParagraph)` | ||
const ActiveItem = styled(InlineParagraph)` | ||
color: ${colors.primary}; | ||
@@ -17,3 +19,3 @@ ${fontSize("label")}; | ||
const DeactivatedLink = styled(SpanParagraph)` | ||
const DeactivatedLink = styled(InlineParagraph)` | ||
color: ${colors.neutral}; | ||
@@ -58,3 +60,3 @@ ${fontSize("label")}; | ||
BreadcrumbItem.defaultProps = { | ||
content: "" | ||
content: "", | ||
} | ||
@@ -79,3 +81,3 @@ | ||
*/ | ||
onClick: PropTypes.func | ||
onClick: PropTypes.func, | ||
} |
@@ -60,3 +60,3 @@ import React from "react" | ||
return <StyledList margin={margin} >{childElements}</StyledList> | ||
return <StyledList margin={margin}>{childElements}</StyledList> | ||
} | ||
@@ -75,6 +75,6 @@ Breadcrumbs.defaultProps = { | ||
PropTypes.element, | ||
PropTypes.bool | ||
PropTypes.bool, | ||
]), | ||
margin: PropTypes.any | ||
margin: PropTypes.any, | ||
} |
import React from "react" | ||
import { storiesOf } from "@storybook/react" | ||
import { text, array, number } from "@storybook/addon-knobs" | ||
import { Breadcrumbs, BreadcrumbItem } from "./src" | ||
import { text, array, number } from "@storybook/addon-knobs" | ||
storiesOf("Navigation", module).add( | ||
"Breadcrumbs", | ||
() => { | ||
const items = array("Items", ["Home", "Current", "Next"]) | ||
const active = number("Active", items.length, { | ||
range: true, | ||
min: 1, | ||
max: items.length, | ||
step: 1, | ||
}) | ||
const links = array("Links", ["https://buoyhealth.com"]) | ||
return ( | ||
<div> | ||
<Breadcrumbs divider={text("Divider", "") || undefined}> | ||
{items.map((item, i) => ( | ||
<BreadcrumbItem active={i + 1 === active} href={links[i]}> | ||
{item} | ||
</BreadcrumbItem> | ||
))} | ||
</Breadcrumbs> | ||
</div> | ||
) | ||
} | ||
) | ||
storiesOf("Navigation", module).add("Breadcrumbs", () => { | ||
const items = array("Items", ["Home", "Current", "Next"]) | ||
const active = number("Active", items.length, { | ||
range: true, | ||
min: 1, | ||
max: items.length, | ||
step: 1, | ||
}) | ||
const links = array("Links", ["https://buoyhealth.com"]) | ||
return ( | ||
<div> | ||
<Breadcrumbs divider={text("Divider", "") || undefined}> | ||
{items.map((item, i) => ( | ||
<BreadcrumbItem key={item} active={i + 1 === active} href={links[i]}> | ||
{item} | ||
</BreadcrumbItem> | ||
))} | ||
</Breadcrumbs> | ||
</div> | ||
) | ||
}) |
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
Found 1 instance in 1 package
15473
2
351
+ Addedbuoy-text@7.0.0(transitive)
+ Addedbuoy-theme@7.0.0(transitive)
- Removedbuoy-text@6.3.0-alpha.2(transitive)
- Removedbuoy-theme@6.3.0-alpha.0(transitive)
Updatedbuoy-text@7.0.0
Updatedbuoy-theme@7.0.0