diff --git a/README.md b/README.md index c1c4cab..436f653 100644 --- a/README.md +++ b/README.md @@ -80,6 +80,27 @@ return [ ]; ``` +# Resource Icons + +You can define custom icons by adding a static icon method to your Nova resource: + +```php +class Article extends Resource +{ + //... + public static function icon(): string + { + return << + + + SVG; + } +} +``` + +![Icons](https://raw.githubusercontent.com/dcasia/collapsible-resource-manager/master/screenshots/menu-icons.png) + # Notes A key difference between `CollapsibleResourceManager` and the default Nova `ResourceManager` is that the later auto scan diff --git a/dist/js/tool.js b/dist/js/tool.js index 7c557a3..1464970 100644 --- a/dist/js/tool.js +++ b/dist/js/tool.js @@ -1 +1 @@ -!function(t){var e={};function n(a){if(e[a])return e[a].exports;var o=e[a]={i:a,l:!1,exports:{}};return t[a].call(o.exports,o,o.exports,n),o.l=!0,o.exports}n.m=t,n.c=e,n.d=function(t,e,a){n.o(t,e)||Object.defineProperty(t,e,{configurable:!1,enumerable:!0,get:a})},n.n=function(t){var e=t&&t.__esModule?function(){return t.default}:function(){return t};return n.d(e,"a",e),e},n.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},n.p="",n(n.s=3)}([function(t,e){t.exports=function(t){var e=[];return e.toString=function(){return this.map(function(e){var n=function(t,e){var n=t[1]||"",a=t[3];if(!a)return n;if(e&&"function"==typeof btoa){var o=(i=a,"/*# sourceMappingURL=data:application/json;charset=utf-8;base64,"+btoa(unescape(encodeURIComponent(JSON.stringify(i))))+" */"),s=a.sources.map(function(t){return"/*# sourceURL="+a.sourceRoot+t+" */"});return[n].concat(s).concat([o]).join("\n")}var i;return[n].join("\n")}(e,t);return e[2]?"@media "+e[2]+"{"+n+"}":n}).join("")},e.i=function(t,n){"string"==typeof t&&(t=[[null,t,""]]);for(var a={},o=0;on.parts.length&&(a.parts.length=n.parts.length)}else{var i=[];for(o=0;on.parts.length&&(a.parts.length=n.parts.length)}else{var i=[];for(o=0;o -
- {{ activeMenu[index] ? '-' : '+' }} +
+ + + + + + + + +
{{ group.title }} @@ -69,12 +81,8 @@ diff --git a/screenshots/menu-icons.png b/screenshots/menu-icons.png new file mode 100644 index 0000000..5211293 Binary files /dev/null and b/screenshots/menu-icons.png differ diff --git a/src/CollapsibleResourceManager.php b/src/CollapsibleResourceManager.php index 446ceb0..92fbca2 100644 --- a/src/CollapsibleResourceManager.php +++ b/src/CollapsibleResourceManager.php @@ -101,6 +101,7 @@ private function resolveResources(array $resources): Collection if ($resource::authorizedToViewAny(request())) { return [ + 'icon' => method_exists($resource, 'icon') ? $resource::icon() : null, 'label' => is_numeric($key) ? $resource::label() : $this->translateKey($key), 'route' => $resource::uriKey() ];