From 7d23cff04e2147ab49c0a20dadd4c402fda104d0 Mon Sep 17 00:00:00 2001 From: Dylan Seago Date: Wed, 10 Jan 2018 12:07:42 -0500 Subject: [PATCH 1/3] Improve accessibility of rendered canvas --- src/main.jsx | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/main.jsx b/src/main.jsx index ff91a67..534545a 100644 --- a/src/main.jsx +++ b/src/main.jsx @@ -152,6 +152,8 @@ export default class Identicon extends Component { { this.identicon = identicon; }} className="identicon" + aria-label="Identicon" + role="img" /> ); } From f86a1aae969165681dc7d80c47e576d083b4a6a6 Mon Sep 17 00:00:00 2001 From: Dylan Seago Date: Wed, 10 Jan 2018 12:14:42 -0500 Subject: [PATCH 2/3] Allow extra props to be passed to canvas element --- src/main.jsx | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/main.jsx b/src/main.jsx index 534545a..cdeb077 100644 --- a/src/main.jsx +++ b/src/main.jsx @@ -148,12 +148,14 @@ export default class Identicon extends Component { } render() { + const { seed, size, scale, color, bgColor, spotColor, ...extraProps } = this.props return ( { this.identicon = identicon; }} className="identicon" aria-label="Identicon" role="img" + {...extraProps} /> ); } From ebfa254a330bec405832dc39ddec44595324b9a9 Mon Sep 17 00:00:00 2001 From: Dylan Seago Date: Wed, 10 Jan 2018 13:08:10 -0500 Subject: [PATCH 3/3] Rebuild --- dist/main.js | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/dist/main.js b/dist/main.js index dae33b8..5e30708 100644 --- a/dist/main.js +++ b/dist/main.js @@ -18,6 +18,8 @@ var _propTypes2 = _interopRequireDefault(_propTypes); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } +function _objectWithoutProperties(obj, keys) { var target = {}; for (var i in obj) { if (keys.indexOf(i) >= 0) continue; if (!Object.prototype.hasOwnProperty.call(obj, i)) continue; target[i] = obj[i]; } return target; } + 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; } @@ -184,12 +186,23 @@ var Identicon = function (_Component) { value: function render() { var _this2 = this; - return _react2.default.createElement('canvas', { + var _props = this.props, + seed = _props.seed, + size = _props.size, + scale = _props.scale, + color = _props.color, + bgColor = _props.bgColor, + spotColor = _props.spotColor, + extraProps = _objectWithoutProperties(_props, ['seed', 'size', 'scale', 'color', 'bgColor', 'spotColor']); + + return _react2.default.createElement('canvas', _extends({ ref: function ref(identicon) { _this2.identicon = identicon; }, - className: 'identicon' - }); + className: 'identicon', + 'aria-label': 'Identicon', + role: 'img' + }, extraProps)); } }]);