Skip to content

Commit

Permalink
Keep onClick even if theme is "none".
Browse files Browse the repository at this point in the history
  • Loading branch information
evoluteur committed Dec 16, 2019
1 parent f114fd7 commit 99a7777
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 5 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ class Example extends React.Component {
tooltip = "Edit"
theme = "light"
size = "medium"
onClick = { doSomething }
/>
);
}
Expand Down
7 changes: 4 additions & 3 deletions dist/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -84,12 +84,13 @@ var svgPaths = {
var keys = Object.keys(svgPaths);
exports.keys = keys;

var svgCmp = function svgCmp(path) {
var svgCmp = function svgCmp(path, onClick) {
return _react["default"].createElement("svg", {
focusable: "false",
viewBox: "0 0 24 24",
"aria-hidden": "true",
role: "presentation"
role: "presentation",
onClick: onClick ? onClick : null
}, _react["default"].createElement("path", {
d: path
}));
Expand All @@ -110,7 +111,7 @@ function Icon(args) {
}

if (theme === 'none') {
return svgCmp(path);
return svgCmp(path, onClick);
} else {
var css = "crud-icon " + size + ' ' + args.className + ' ' + theme + (!!disabled ? ' disabled' : '');
return _react["default"].createElement("i", {
Expand Down
5 changes: 3 additions & 2 deletions src/Icon.js
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,8 @@ const svgPaths = {

export const keys = Object.keys(svgPaths)

const svgCmp = path => <svg focusable="false" viewBox="0 0 24 24" aria-hidden="true" role="presentation">
const svgCmp = (path, onClick) => <svg focusable="false" viewBox="0 0 24 24" aria-hidden="true" role="presentation"
onClick={onClick ? onClick : null}>
<path d={ path }></path>
</svg>

Expand All @@ -98,7 +99,7 @@ export default function Icon(args) {
console.error('Invalid icon name "'+name+'".')
}
if(theme==='none'){
return svgCmp(path)
return svgCmp(path, onClick)
}else{
const css = "crud-icon "+size+' '+args.className+' '+theme+(!!disabled ? ' disabled' : '')
return <i data-id={ id || name } className={css} onClick={onClick ? onClick : null}>
Expand Down

0 comments on commit 99a7777

Please sign in to comment.