Giter Club home page Giter Club logo

blade-country-flags's Introduction

Blade Country Flags

Tests Code Style Latest Stable Version Total Downloads

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 it's creators.

Requirements

  • PHP 7.4 or higher
  • Laravel 8.0 or higher

Installation

composer require stijnvanouplines/blade-country-flags

Blade Icons

Blade Country Flags uses Blade Icons under the hood. Please refer to the Blade Icons readme for additional functionality. We also recommend to enable icon caching with this library.

Configuration

Blade Country Flags 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 blade-country-flags.php config file:

php artisan vendor:publish --tag=blade-country-flags-config

Usage

Flags can be used as self-closing Blade components which will be compiled to SVG flags:

<x-flag-4x3-be/>

You can also pass classes to your flag components:

<x-flag-4x3-be class="w-6"/>

And even use inline styles:

<x-flag-4x3-be style="width: 1.5rem"/>

A square flag can be referenced like this:

<x-flag-1x1-be/>

Raw SVG Flags

If you want to use the raw SVG flags as assets, you can publish them using:

php artisan vendor:publish --tag=blade-country-flags --force

Then use them in your views like:

<img src="{{ asset('vendor/blade-country-flags/4x3-be.svg') }}" width="10"/>

Changelog

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

Credits

License

Blade Country Flags is open-sourced software licensed under the MIT license.

blade-country-flags's People

Contributors

andrefilsantos avatar laravel-shift avatar paulohenriquesg avatar rubenvanerk avatar stijnvanouplines avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

blade-country-flags's Issues

List of all flags

Do you have a list/array of all the flags useful for admin selection?

cn.svg is missing stars

it seems that CN is pretty out of date with upstream.
Could it be updated, please?

This repo:
https://raw.githubusercontent.com/stijnvanouplines/blade-country-flags/main/resources/svg/4x3-cn.svg

Upstream:
https://raw.githubusercontent.com/lipis/flag-icons/main/flags/4x3/cn.svg

Installation failed

Installation in conjunction with previously installed Filament PLugin "Filament Language Switch" fails:

Problem 1
    - stijnvanouplines/blade-country-flags[1.0.0, ..., 1.0.1] require illuminate/support ^8.0 -> found illuminate/support[v8.0.0, ..., v8.83.27] but these were not loaded, likely because it conflicts with another require.
    - stijnvanouplines/blade-country-flags 1.0.2 requires illuminate/support ^8.0|^9.0 -> found illuminate/support[v8.0.0, ..., v8.83.27, v9.0.0, ..., v9.52.4] but these were not loaded, likely because it conflicts with another require.
    - Root composer.json requires stijnvanouplines/blade-country-flags * -> satisfiable by stijnvanouplines/blade-country-flags[1.0.0, 1.0.1, 1.0.2].

You can also try re-running composer require with an explicit version constraint, e.g. "composer require stijnvanouplines/blade-country-flags:*" to figure out if any version is installable, or "composer require stijnvanouplines/blade-country-flags:^2.1" if you know which you need.

Laravel Version: 10.3.3
Filament Version: 2.17.16
Filament Language Switch (bezhansalleh/filament-language-switch) Version: 1.0.6
PHP Version: 8.2.3
OS: WSL2 (Ubuntu 22.04.2 LTS) on Windows 11

maybe it's a stupid question but...

Maybe the question is something stupid,
but how can i do such a thing?

<x-flag-4x3-{{ $country->code }} class="w-6" />

That is, to add a variable

edit
my solution

{!! svg('flag-4x3-' . $val->country->code, ['class' => 'w-5'])->toHtml() !!}

Albania flag broken

Hello there,
first of all thank you very much for this very helpful package ๐Ÿซถ

But I've discovered that the albania flag is somehow cut in the middle
image

I'm using it like this: <x-icon name="flag-4x3-al" class="inline-block h-4 w-4 rounded-md shadow-md" />

Could you please help me out ๐Ÿ™

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.