jorenvh / laravel-share

Optional package for Laravel to generate social share links.
MIT License
529 stars 88 forks source link

Add FontAwesome 5 Compatibility #16

Closed charlielangridge closed 6 years ago

charlielangridge commented 6 years ago

Adding an extra value in to the config file, font awesome 5 can be used

jorenvh commented 6 years ago

Hi Charlie

Thanks for the PR, I think we can call this a new mayor release so no need to keep it backward compatible.

This way we can get rid of the if else state in the buildLink method, something like this:


/**
     * Build a single link
     *
     * @param $provider
     * @param $url
     */
    protected function buildLink($provider, $url)
    {
        $fontAwesomeVersion = config('laravel-share.fontAwesomeVersion', 4);

        $this->html .= trans("laravel-share::laravel-share-fa$fontAwesomeVersion.$provider", [
            'url' => $url,
            'class' => key_exists('class', $this->options) ? $this->options['class'] : '',
            'id' => key_exists('id', $this->options) ? $this->options['id'] : '',
        ]);

    }

We then only need to make sure we rename the original language file.

And could you also create some tests to make sure this functionality is working as expected, now they fail since fa-facebook is changed to fab-facebook

When I got some time tonight I will work a bit on it as well.

Joren

jorenvh commented 6 years ago

@charlielangridge I cleaned things up a bit. Laravel share now supports Font Awesome 5, I wasn't able to commit my changes to this PR so I pushed them directly to the repo. Thanks for contributing!

Joren