Skip to content

Commit

Permalink
Theme "none" + version 1.2.2.
Browse files Browse the repository at this point in the history
  • Loading branch information
evoluteur committed Jan 2, 2023
1 parent 5776f0b commit 91f8316
Show file tree
Hide file tree
Showing 7 changed files with 22 additions and 39 deletions.
2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
MIT License

Copyright (c) 2022 Olivier Giulieri
Copyright (c) 2023 Olivier Giulieri

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ Themes: light, dark.

![Screenshot](screenshots/hover.gif)

To disable the icon hover effect, set theme = "none".
To disable the icon hover effect, set theme = "none". It will only render the SVG without CSS classes.

### 6 Sizes

Expand Down Expand Up @@ -82,7 +82,7 @@ Notes:

## License

Copyright (c) 2022 [Olivier Giulieri](https://evoluteur.github.io/).
Copyright (c) 2023 [Olivier Giulieri](https://evoluteur.github.io/).

React-CRUD-Icons is Open Source wih [MIT license](http://github.com/evoluteur/react-crud-icons/blob/master/LICENSE).

Expand Down
2 changes: 1 addition & 1 deletion dist/css/react-crud-icons.css
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/*
React-CRUD-Icons
https://github.com/evoluteur/react-crud-icons
(c) 2022 Olivier Giulieri
(c) 2023 Olivier Giulieri
*/
.crud-icon {
position: relative;
Expand Down
40 changes: 12 additions & 28 deletions dist/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,9 @@ Object.defineProperty(exports, "__esModule", {
});
exports["default"] = Icon;
exports.keys = void 0;

var _react = _interopRequireDefault(require("react"));

var _propTypes = _interopRequireDefault(require("prop-types"));

function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }

/*
___ _
| _ \___ __ _ __| |_
Expand All @@ -28,12 +24,15 @@ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "d
Set of SVG icons for CRUD apps, packaged as a React component for Web UI.
https://github.com/evoluteur/react-crud-icons
(c) 2022 Olivier Giulieri
(c) 2023 Olivier Giulieri
*/

//import './Icon.scss'

// The SVG icons are hand-picked among thousands from https://materialdesignicons.com/
// The code is partially based on https://medium.com/recraftrelic/building-a-react-component-as-a-npm-module-18308d4ccde9

var svgPaths = {
"arrow-left": "M2,12A10,10 0 0,1 12,2A10,10 0 0,1 22,12A10,10 0 0,1 12,22A10,10 0 0,1 2,12M18,11H10L13.5,7.5L12.08,6.08L6.16,12L12.08,17.92L13.5,16.5L10,13H18V11Z",
"arrow-right": "M22,12A10,10 0 0,1 12,22A10,10 0 0,1 2,12A10,10 0 0,1 12,2A10,10 0 0,1 22,12M6,13H14L10.5,16.5L11.92,17.92L17.84,12L11.92,6.08L10.5,7.5L14,11H6V13Z",
Expand Down Expand Up @@ -106,7 +105,6 @@ var svgPaths = {
};
var keys = Object.keys(svgPaths).sort();
exports.keys = keys;

var svgCmp = function svgCmp(path, onClick, css) {
return /*#__PURE__*/_react["default"].createElement("svg", {
className: css,
Expand All @@ -119,68 +117,54 @@ var svgCmp = function svgCmp(path, onClick, css) {
d: path
}));
};

function Icon(_ref) {
var id = _ref.id,
name = _ref.name,
size = _ref.size,
theme = _ref.theme,
tooltip = _ref.tooltip,
disabled = _ref.disabled,
onClick = _ref.onClick,
className = _ref.className;
name = _ref.name,
size = _ref.size,
theme = _ref.theme,
tooltip = _ref.tooltip,
disabled = _ref.disabled,
onClick = _ref.onClick,
className = _ref.className;
var path = svgPaths[name] || null;

if (!path) {
console.error('Invalid icon name "' + name + '".');
}

if (theme === "none") {
return svgCmp(path, onClick, className);
} else {
var props = {
className: "crud-icon " + size + " " + className + " " + theme + (!!disabled ? " disabled" : ""),
"data-id": id || name
};

if (id) {
props.id = id;
}

if (onClick && !disabled) {
props.tabIndex = 0;
props.onClick = onClick;

props.onKeyUp = function (evt) {
if (evt.keyCode === 13) {
onClick(evt);
}
};
}

return /*#__PURE__*/_react["default"].createElement("i", props, svgCmp(path), tooltip ? /*#__PURE__*/_react["default"].createElement("div", null, tooltip) : null);
}
}

Icon.propTypes = {
/** Name of the icon (i.e. "home") */
name: _propTypes["default"].oneOf(keys).isRequired,

/** Icon size (i.e. "medium") */
size: _propTypes["default"].oneOf(["tiny", "small", "medium", "large", "big", "huge"]),

/** Light or dark theme */
theme: _propTypes["default"].oneOf(["light", "dark"]),

theme: _propTypes["default"].oneOf(["light", "dark", "none"]),
/** Tooltip on hover */
tooltip: _propTypes["default"].string,

/** Disable click event (icon in grey) */
disabled: _propTypes["default"].bool,

/** Callback function triggered when icon is clicked */
onClick: _propTypes["default"].func,

/** Extra CSS class */
className: _propTypes["default"].string
};
Expand Down
7 changes: 3 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
{
"name": "react-crud-icons",
"version": "1.2.1",
"version": "1.2.2",
"description": "Set of SVG icons for CRUD applications packaged as a React component",
"repository": {
"type": "git",
"url": "git://github.com/evoluteur/react-crud-icons.git"
},
"copyright": "(c) 2022 Olivier Giulieri",
"copyright": "(c) 2023 Olivier Giulieri",
"homepage": "https://evoluteur.github.io/react-crud-icons",
"author": "Olivier Giulieri (https://evoluteur.github.io/)",
"license": "MIT",
Expand Down Expand Up @@ -39,7 +39,6 @@
"component",
"ui",
"toolbar",
"material",
"web"
"material"
]
}
4 changes: 2 additions & 2 deletions src/Icon.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
Set of SVG icons for CRUD apps, packaged as a React component for Web UI.
https://github.com/evoluteur/react-crud-icons
(c) 2022 Olivier Giulieri
(c) 2023 Olivier Giulieri
*/

Expand Down Expand Up @@ -208,7 +208,7 @@ Icon.propTypes = {
/** Icon size (i.e. "medium") */
size: PropTypes.oneOf(["tiny", "small", "medium", "large", "big", "huge"]),
/** Light or dark theme */
theme: PropTypes.oneOf(["light", "dark"]),
theme: PropTypes.oneOf(["light", "dark", "none"]),
/** Tooltip on hover */
tooltip: PropTypes.string,
/** Disable click event (icon in grey) */
Expand Down
2 changes: 1 addition & 1 deletion src/Icon.scss
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/*
React-CRUD-Icons
https://github.com/evoluteur/react-crud-icons
(c) 2022 Olivier Giulieri
(c) 2023 Olivier Giulieri
*/

.crud-icon {
Expand Down

0 comments on commit 91f8316

Please sign in to comment.