Skip to content

Latest commit

 

History

History
105 lines (73 loc) · 3.61 KB

README.md

File metadata and controls

105 lines (73 loc) · 3.61 KB

Laflamoji — Use Country Flags, and Emoji's in your Laravel Projects

A package to easily make use of country flags in your Laravel Blade views.

This package is using SVG flags provided by flag-icon-css. All credits go to this project and all of its creators.

Flags

Country flags in SVG format for your Laravel application. Uses lipis/flag-icons icons under the hood.

Requirements

  • PHP 8.0 or higher
  • Laravel 8.0 or higher

Installation

composer require simtabi/laflamoji

Usage

While Blade Country Flags uses Blade Icons. Please refer to the Blade Icons readme for additional functionality. We also recommend to enable icon caching with this library. Flags can be used as self-closing Blade components which will be compiled to SVG flags:

Directive

// Render flag using default ratio:
@laflag('us')

// Tell what ratio to use, which classes, and attributes to add to the svg element:
@laflag('us:1x1', 'w-64', ['id' => 'flag-us'])

// Render emoji
@lamoji('us')

Helper

// Render flag using default ratio:
{{ laflamoji()->flag('us') }}

// Tell what ratio to use, which classes, and attributes to add to the svg element:
{{ laflamoji()->flag('us:1x1', 'w-64', ['id' => 'flag-us']) }}

// Render emoji
{{ laflamoji()->emoji('us') }}

Configuration

Laflag also offers the ability to use features from Blade Icons like default classes, default attributes, etc. If you'd like to configure these, publish the laflamoji.php config file. You may configure the default ratio to use, and default css classes to add:

# publish config files
php artisan vendor:publish --tag=laflamoji:config

# publish raw SVG files
php artisan vendor:publish --tag=laflamoji:assets

# publish view files
php artisan vendor:publish --tag=laflamoji:views

After publishing the raw SVG files, you can then use them in your views like:

<img src="{{ asset('vendor/laflamoji/flags/4x3/be.svg') }}" width="10"/>
<img src="{{ asset('vendor/laflamoji/twemoji/svg/1f1e6.svg) }}" width="10"/>

Changelog

Check out the CHANGELOG in this repository for all the recent changes.

Credits

License

Laflamoji is open-sourced software licensed under the MIT license.