GithubHelp home page GithubHelp logo

Comments (7)

rhukster avatar rhukster commented on July 17, 2024 1

merged

from grav-plugin-shortcode-core.

speedbomb avatar speedbomb commented on July 17, 2024

I'm not very familiar with pull requests, so i'll attach some code that allows to use the new v5 font family classes fab, fal, fas and far:

            if($icon) {
                $fa_class = 'fa';
                $extras = explode(',', $sc->getParameter('extras', ''));

                foreach($extras as $extra) {
                    if(!empty($extra)) {
                        if(in_array($extra, array('fab', 'fal', 'fas', 'far'))) {
                            $fa_class = $extra;
                            continue;
                        }
                        if(!Utils::startsWith($extra, 'fa-')) {
                            $extra = 'fa-' . $extra;
                        }
                        $icon .= ' ' . $extra;
                    }
                }

                $output = '<i class="' . $fa_class . ' ' . $icon . '">' . $str . '</i>';

                return $output;
            }

Replace this into File shortcodes/FontAwesomeShortcode.php at line 25.

For testing purposes i have added the CDN version of Font Awesome:

<link rel="stylesheet" href="https://use.fontawesome.com/releases/v5.3.1/css/all.css" integrity="sha384-mzrmE5qonljUremFsqc01SB46JvROS7bZs3IO2EmfFsd15uHvIt+Y8vEf7N7fWAU" crossorigin="anonymous">

This allows e.g. a spinning Grav icon with the Shortcode [fa icon=fa-grav extras=fab,fa-spin /]

from grav-plugin-shortcode-core.

rhukster avatar rhukster commented on July 17, 2024

I would maybe make your own, because i've found FA5 to not be 100% compatible with FA4

from grav-plugin-shortcode-core.

speedbomb avatar speedbomb commented on July 17, 2024

Great! Thank You! :D

from grav-plugin-shortcode-core.

rhukster avatar rhukster commented on July 17, 2024

I just realized that with the latest 4.0 version of shortcode-core, it probably won't work on Grav 1.5, but it will with 1.6-RC.4. As it depends on the new 'deferred' block functionality for adding assets to work.

I am going to add the deferred extension to 1.5, but it does require a minor fix in the theme to take advantage of it.

{% block assets deferred %}
    {{ assets.css()|raw }}
    {{ assets.js()|raw }}
{% endblock %}

from grav-plugin-shortcode-core.

onetrev avatar onetrev commented on July 17, 2024

So if you enable FA5, you then have to manually update the "Fontawesome URL" setting to something like so: //use.fontawesome.com/releases/v5.8.0/css/all.css?

Just thinking this may cause confusion for some users if that's the case. But not sure if there is an easy fix?

from grav-plugin-shortcode-core.

rhukster avatar rhukster commented on July 17, 2024

it's a bit complicated, the logic i had before to get the assets and add them before the twig rendered, was actually breaking a number of plugins, and also modular forms.

I have a better way to do it using the deferred block capability, and ive added this to Grav 1.5 and i will release this very soon, but will require a change in the theme as outlined above.

from grav-plugin-shortcode-core.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.