{"id":14827,"date":"2022-08-03T14:43:43","date_gmt":"2022-08-03T12:43:43","guid":{"rendered":"https:\/\/hesmid.nl\/test\/?p=14827"},"modified":"2022-08-22T11:00:57","modified_gmt":"2022-08-22T09:00:57","slug":"blade-icons","status":"publish","type":"post","link":"https:\/\/hesmid.nl\/test\/blade-icons\/","title":{"rendered":"Blade Icons"},"content":{"rendered":"\n<h4 class=\"wp-block-heading\">Blade Icons<\/h4>\n\n\n\n<p>A package to easily make use of SVG icons in your Laravel Blade views. Originally &#8220;Blade SVG&#8221; by <a href=\"https:\/\/twitter.com\/adamwathan\">Adam Wathan<\/a>.<\/p>\n\n\n\n<p>Turn&#8230;<\/p>\n\n\n\n<pre class=\"wp-block-code has-small-font-size\"><code>&lt;!-- camera.svg --&gt;\n&lt;svg fill=\"none\" viewBox=\"0 0 24 24\" stroke=\"currentColor\" class=\"w-6 h-6\"&gt;\n  &lt;path stroke-linecap=\"round\" stroke-linejoin=\"round\" stroke-width=\"2\" d=\"M3 9a2 2 0 012-2h.93a2 2 0 001.664-.89l.812-1.22A2 2 0 0110.07 4h3.86a2 2 0 011.664.89l.812 1.22A2 2 0 0018.07 7H19a2 2 0 012 2v9a2 2 0 01-2 2H5a2 2 0 01-2-2V9z\"\/&gt;\n  &lt;path stroke-linecap=\"round\" stroke-linejoin=\"round\" stroke-width=\"2\" d=\"M15 13a3 3 0 11-6 0 3 3 0 016 0z\"\/&gt;\n&lt;\/svg&gt;<\/code><\/pre>\n\n\n\n<p>Into&#8230;<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">&lt;x-icon-camera class=\"w-6 h-6\" \/&gt;<\/pre>\n\n\n\n<p>Or into&#8230;<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">@svg('camera', 'w-6 h-6')<\/pre>\n\n\n\n<p><strong>Search<\/strong> all 84,305 Blade Icons:<\/p>\n\n\n\n<p><a href=\"https:\/\/blade-ui-kit.com\/blade-icons#search\">https:\/\/blade-ui-kit.com\/blade-icons#search<\/a><\/p>\n\n\n\n<p>But for a better overview you may want to go to the homepages of the icons set instead. For example:<\/p>\n\n\n\n<p><a href=\"https:\/\/heroicons.com\/\">https:\/\/heroicons.com\/<\/a><\/p>\n\n\n\n<!--more-->\n\n\n\n<h4 class=\"wp-block-heading\">Sage Blade Icons<\/h4>\n\n\n\n<p>Sage Blade Icons is a simple Composer package \/ wrapper to use <a href=\"https:\/\/github.com\/blade-ui-kit\/blade-icons\">Blade Icons<\/a> with <a href=\"https:\/\/github.com\/roots\/sage\">Sage 10<\/a>.<\/p>\n\n\n\n<p><a href=\"https:\/\/github.com\/zirkeldesign\/sage-blade-icons\">https:\/\/github.com\/zirkeldesign\/sage-blade-icons<\/a><\/p>\n\n\n\n<p>(I didn&#8217;t use this. because I got errors)<\/p>\n\n\n\n<p>Install via package Composer:<\/p>\n\n\n\n<pre class=\"wp-block-preformatted has-small-font-size\">composer require zirkeldesign\/sage-blade-icons<\/pre>\n\n\n\n<p>This package comes with a build-in dependency for the base package <a href=\"https:\/\/github.com\/blade-ui-kit\/blade-icons\">Blade Icons<\/a>. To use a specific <a href=\"https:\/\/github.com\/blade-ui-kit\/blade-icons#icon-packages\">icon package<\/a> (i.e. <a href=\"https:\/\/github.com\/blade-ui-kit\/blade-heroicons\">Blade Heroicons<\/a>), you&#8217;ll need to require the package via Composer:<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">composer require blade-ui-kit\/blade-heroicons<\/pre>\n\n\n\n<p>After this you should be able to use a package-depended <a href=\"https:\/\/laravel.com\/docs\/8.x\/blade#components\">Blade component<\/a> to include your icon in the Blade views. I.e.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted has-small-font-size\">&lt;x-heroicon-o-adjustments class=\"w-6 h-6 text-gray-500\"\/&gt;\n<\/pre>\n\n\n\n<h4 class=\"wp-block-heading\">Roots Documentation:<\/h4>\n\n\n\n<p><a href=\"https:\/\/docs.roots.io\/sage\/10.x\/guides\/use-blade-icons\/#installation\">How to use blade-icons-blade-icons<\/a><\/p>\n\n\n\n<p>Note: I prefer to install the blade icons in the theme folder, so I should try this:<\/p>\n\n\n\n<p>(<a href=\"https:\/\/discourse.roots.io\/u\/zupa\">https:\/\/discourse.roots.io\/u\/zupa<\/a>)<\/p>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<p><strong>Zupa: <\/strong>I had some problems to installing <code>blade-ui-kit\/blade-icons<\/code> package and got the same error.<\/p>\n\n\n\n<p>Fixed by:<\/p>\n\n\n\n<ol><li>Install with <code>composer require blade-ui-kit\/blade-icons<\/code> in sage theme root folder, not bedrock root folder.<\/li><li>Create folder called <code>config<\/code> in theme root folder<\/li><li>Run <code>wp acorn package:discover<\/code> or else package config might not be detected\/able to publish config-file<\/li><li>Run <code>wp acorn vendor:publish --tag=blade-icons<\/code> to publish config file to config folder.<\/li><li>In config -file, uncomment everything and let path be <code>resources\/svg<\/code> and create that folder in resources (or change if you want).<\/li><li>In <code>bud.config.mjs<\/code> add svg to assets array like this <code>.assets([\"images\",\"svg\"])<\/code> (if you chose to create the svg -folder)<\/li><li>Run <code>wp acorn config:clear<\/code> in theme root folder.<\/li><li>Add your icons\/svg -files to <code>resources\/svg<\/code><\/li><li>Run <code>yarn build<\/code> and <code>yarn dev<\/code><\/li><li>Run <code>wp acorn optimize<\/code><\/li><li>Run <code>wp acorn icons:cache<\/code><\/li><li>Use <code>&lt;x-icon-name_of_svg_file \/&gt;<\/code> to display the icon.<\/li><\/ol>\n\n\n\n<p>Don\u2019t know if all this is necessary but it worked for me.<br>And instead of installing an entire icon library now you can download individual icons from those packages and just put them in your svg-folder and save some loading time. Or if you want a entire package you could still try above steps except with that package. But first remove the <code>blade-ui-kit\/blade-icons<\/code> package as it is already included in the other packages I believe.<\/p>\n\n\n\n<p>To get Blade Icons to work I did this:<\/p>\n\n\n\n<p><strong>note: <\/strong> I did not use the wrapper from zirkeldesign, because it gives errors<\/p>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<p><strong>But following the guide on roots.io I did this:<\/strong><\/p>\n\n\n\n<p><strong>In the bedrock(!) folder<\/strong>:<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"bash\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">lando composer require blade-ui-kit\/blade-icons\nlando wp acorn package:discover\n\nDiscovered Package: blade-ui-kit\/blade-icons\nDiscovered Package: nesbot\/carbon\nDiscovered Package: log1x\/acf-composer\nDiscovered Package: log1x\/sage-svg\nDiscovered Package: roots\/sage\n\nlando wp acorn vendor:publish --tag=blade-icons\n\nCopied File [\/app\/vendor\/blade-ui-kit\/blade-icons\/config\/blade-icons.php] To [\/config\/blade-icons.php]\nPublishing complete.\n<\/pre>\n\n\n\n<p>Then edit the created <code>config\/blade-icons.php<\/code>:<\/p>\n\n\n\n<p>Roots docs: From the published <code>config\/blade-icons.php<\/code> file, we recommend setting the default set to point to your theme directory:<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"php\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">&lt;?php\n\nreturn [\n    'sets' => [\n        'default' => [\n            'path' => 'web\/app\/themes\/MYTHEME\/resources\/images\/icons', # Relative path to the new directory\n            'prefix' => 'icon',\n        ],\n    ],\n];\n<\/pre>\n\n\n\n<p>Add a new directory inside <code>resources\/images\/<\/code> named <code>icons\/<\/code> and place your SVG icons in this directory.<\/p>\n\n\n\n<h4 class=\"wp-block-heading\">Adding icon sets<\/h4>\n\n\n\n<p>To add aditional icon sets, require them as Composer dependencies the same as you did for the <code>blade-icons<\/code> package. In this example, we&#8217;ll add the <code>blade-heroicons<\/code> package:<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"bash\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">lando composer require blade-ui-kit\/blade-heroicons\n\n# again I need to discover and publish, even if I don't really need the config for heroicons\nlando wp acorn package:discover\n\n# maybe discover was enough? Anyway I also published\nlando wp acorn vendor:publish --tag=blade-heroicons-config <\/pre>\n\n\n\n<p>I can now add icons to my blade views:<\/p>\n\n\n\n<p class=\"has-small-font-size\"><code>&lt;x-heroicon-o-adjustments class=\"w-20 h-20 text-blue-300\"\/&gt;<\/code><\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"81\" height=\"80\" src=\"https:\/\/hesmid.nl\/test\/wp-content\/uploads\/2022\/08\/image-2.png\" alt=\"\" class=\"wp-image-14832\" srcset=\"https:\/\/hesmid.nl\/test\/wp-content\/uploads\/2022\/08\/image-2.png 81w, https:\/\/hesmid.nl\/test\/wp-content\/uploads\/2022\/08\/image-2-60x60.png 60w\" sizes=\"(max-width: 81px) 100vw, 81px\" \/><\/figure>\n\n\n\n<p>The @svg directive does not work, probably because I have also installed the svg-sage package (?)<\/p>\n\n\n\n<p><\/p>\n\n\n\n<p><strong>And then there is also this:<\/strong><\/p>\n\n\n\n<p><a class=\"\" href=\"https:\/\/discourse.roots.io\/u\/ben\">ben<\/a> roots dev <a href=\"https:\/\/discourse.roots.io\/t\/cpu-on-server-maxes-out-on-almost-every-request\/22462\/18?u=cim\">Mar 27<\/a><\/p>\n\n\n\n<p>In our case, we\u2019re using the <code>blade-icons<\/code> package with a couple different icon sets. We needed to run <code>wp acorn icons:cache<\/code> and the performance issues were solved <img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/discourse.roots.io\/images\/emoji\/twitter\/tada.png?v=12\" alt=\":tada:\" width=\"20\" height=\"20\"><\/p>\n\n\n\n<p><a href=\"https:\/\/discourse.roots.io\/u\/twansparant\">@Twansparant<\/a> <a href=\"https:\/\/discourse.roots.io\/u\/monokai\">@monokai<\/a> have y\u2019all had any luck digging deeper into the source of your issue?<\/p>\n\n\n\n<p>If you aren\u2019t using blade-icons, are you using another package that might have registered a command that would allow things to be cached? You can check by running <code>wp acorn<\/code> and looking at the list of commands<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Blade Icons A package to easily make use of SVG icons in your Laravel Blade views. Originally &#8220;Blade SVG&#8221; by Adam Wathan. Turn&#8230; Into&#8230; &lt;x-icon-camera class=&#8221;w-6 h-6&#8243; \/&gt; Or into&#8230; @svg(&#8216;camera&#8217;, &#8216;w-6 h-6&#8217;) Search all 84,305 Blade Icons: https:\/\/blade-ui-kit.com\/blade-icons#search But for a better overview you may want to go to the homepages of the icons [&hellip;]<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[45,17],"tags":[297,704,735],"acf":[],"_links":{"self":[{"href":"https:\/\/hesmid.nl\/test\/wp-json\/wp\/v2\/posts\/14827"}],"collection":[{"href":"https:\/\/hesmid.nl\/test\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/hesmid.nl\/test\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/hesmid.nl\/test\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/hesmid.nl\/test\/wp-json\/wp\/v2\/comments?post=14827"}],"version-history":[{"count":5,"href":"https:\/\/hesmid.nl\/test\/wp-json\/wp\/v2\/posts\/14827\/revisions"}],"predecessor-version":[{"id":14878,"href":"https:\/\/hesmid.nl\/test\/wp-json\/wp\/v2\/posts\/14827\/revisions\/14878"}],"wp:attachment":[{"href":"https:\/\/hesmid.nl\/test\/wp-json\/wp\/v2\/media?parent=14827"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/hesmid.nl\/test\/wp-json\/wp\/v2\/categories?post=14827"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/hesmid.nl\/test\/wp-json\/wp\/v2\/tags?post=14827"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}