Skip to content

Commit

Permalink
Add flags lib
Browse files Browse the repository at this point in the history
  • Loading branch information
Joao Nascimento committed Jun 19, 2024
1 parent 4cb78a0 commit 9c06774
Show file tree
Hide file tree
Showing 4 changed files with 74 additions and 69 deletions.
9 changes: 8 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,14 @@ Optionally, you can publish the translations using
php artisan vendor:publish --tag="filament-world-clock-translations"
```

This is the contents of the published config file:
You can publish the flags

>[!NOTE]
> to publish the flags is necessary to run the command below:
```bash
php artisan vendor:publish --tag=blade-flags --force
```

## Usage

Expand Down
3 changes: 2 additions & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
"require": {
"php": "^8.1",
"filament/filament": "^3.0",
"outhebox/blade-flags": "^1.5",
"spatie/laravel-package-tools": "^1.15.0"
},
"require-dev": {
Expand Down Expand Up @@ -68,4 +69,4 @@
},
"minimum-stability": "dev",
"prefer-stable": true
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,8 @@
<div class="grid grid-cols-1 gap-2 md:grid-cols-{{$quantityPerRow}}"> <!-- md:grid-cols-2 -->
@foreach ($cities as $city)
<div class="flex items-center justify-between bg-gray-100 dark:bg-gray-700 p-2 rounded-md shadow-sm">
<span class="text-sm font-medium text-gray-800 dark:text-white">{{ $city['flag'] }} {{ $city['name'] }}</span>
<span class="flex text-sm font-medium text-gray-800 dark:text-white">
<img src="{{ $city['flag'] }}" width="16" height="16" style="margin-right: 10px;"/> {{ $city['name'] }}</span>
<span class="flex items-center text-xs text-gray-500 dark:text-gray-300">
{{ $city['time'] }}
@if($city['night'])
Expand Down
128 changes: 62 additions & 66 deletions src/Helpers/FlagsHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,72 +7,68 @@ class FlagsHelper
public static function get(string $timezone): string
{
$timezones = [
'Europe/London' => '🇬🇧', // London
'Europe/Paris' => '🇫🇷', // Paris
'Europe/Berlin' => '🇩🇪', // Berlin
'Europe/Madrid' => '🇪🇸', // Madrid
'Europe/Rome' => '🇮🇹', // Rome
'Europe/Amsterdam' => '🇳🇱', // Amsterdam
'Europe/Brussels' => '🇧🇪', // Brussels
'Europe/Vienna' => '🇦🇹', // Vienna
'Europe/Stockholm' => '🇸🇪', // Stockholm
'Europe/Athens' => '🇬🇷', // Athens
'Europe/Warsaw' => '🇵🇱', // Warsaw
'Europe/Zurich' => '🇨🇭', // Zurich
'Europe/Prague' => '🇨🇿', // Prague
'Europe/Oslo' => '🇳🇴', // Oslo
'Europe/Copenhagen' => '🇩🇰', // Copenhagen
'Europe/Helsinki' => '🇫🇮', // Helsinki
'Europe/Istanbul' => '🇹🇷', // Istanbul
'Europe/Lisbon' => '🇵🇹', // Lisbon
'Europe/Budapest' => '🇭🇺', // Budapest
'Europe/Bucharest' => '🇷🇴', // Bucharest
'Europe/Dublin' => '🇮🇪', // Dublin
'Europe/Ljubljana' => '🇸🇮', // Ljubljana
'Europe/Luxembourg' => '🇱🇺', // Luxembourg
'Europe/Minsk' => '🇧🇾', // Minsk
'Europe/Monaco' => '🇲🇨', // Monaco
'Europe/Riga' => '🇱🇻', // Riga
'Europe/San_Marino' => '🇸🇲', // San Marino
'Europe/Sarajevo' => '🇧🇦', // Sarajevo
'Europe/Skopje' => '🇲🇰', // Skopje
'Europe/Sofia' => '🇧🇬', // Sofia
'Europe/Tallinn' => '🇪🇪', // Tallinn
'Europe/Vaduz' => '🇱🇮', // Vaduz
'Europe/Vatican' => '🇻🇦', // Vatican
'Europe/Vilnius' => '🇱🇹', // Vilnius
'Europe/Zagreb' => '🇭🇷', // Zagreb
'America/New_York' => '🇺🇸', // New York
'America/Los_Angeles' => '🇺🇸', // Los Angeles
'America/Chicago' => '🇺🇸', // Chicago
'America/Toronto' => '🇨🇦', // Toronto
'America/Mexico_City' => '🇲🇽', // Mexico City
'America/Buenos_Aires' => '🇦🇷', // Buenos Aires
'America/Sao_Paulo' => '🇧🇷', // São Paulo
'America/Bogota' => '🇨🇴', // Bogotá
'America/Lima' => '🇵🇪', // Lima
'America/Caracas' => '🇻🇪', // Caracas
'America/Santiago' => '🇨🇱', // Santiago
'America/Halifax' => '🇨🇦', // Halifax
'America/Phoenix' => '🇺🇸', // Phoenix
'America/Anchorage' => '🇺🇸', // Anchorage
'America/Honolulu' => '🇺🇸', // Honolulu
'America/Montevideo' => '🇺🇾', // Montevideo
'Asia/Dhaka' => '🇧🇩', // Dhaka
'Asia/Jakarta' => '🇮🇩', // Jakarta
'Asia/Singapore' => '🇸🇬', // Singapore
'Asia/Tokyo' => '🇯🇵', // Tokyo
'Asia/Seoul' => '🇰🇷', // Seoul
'Asia/Beijing' => '🇨🇳', // Beijing
'Asia/Taipei' => '🇹🇼', // Taipei
'Asia/Kuala_Lumpur' => '🇲🇾', // Kuala Lumpur
'Asia/Bangkok' => '🇹🇭', // Bangkok
'Asia/Dubai' => '🇦🇪', // Dubai
'Asia/Kolkata' => '🇮🇳', // Mumbai (Standard Time for India)
'Asia/Hong_Kong' => '🇭🇰', // Hong Kong
'Australia/Sydney' => '🇦🇺', // Sydney
'Pacific/Auckland' => '🇳🇿', // Auckland
'Etc/UTC' => '🕒', // Default flag (UTC)
'Europe/London' => asset('vendor/blade-flags/country-uk.svg'), // London
'Europe/Paris' => asset('vendor/blade-flags/country-fr.svg'), // Paris
'Europe/Berlin' => asset('vendor/blade-flags/country-de.svg'), // Berlin
'Europe/Madrid' => asset('vendor/blade-flags/country-es.svg'), // Madrid
'Europe/Rome' => asset('vendor/blade-flags/country-it.svg'), // Rome
'Europe/Amsterdam' => asset('vendor/blade-flags/country-nl.svg'), // Amsterdam
'Europe/Brussels' => asset('vendor/blade-flags/country-be.svg'), // Brussels
'Europe/Vienna' => asset('vendor/blade-flags/country-at.svg'), // Vienna
'Europe/Stockholm' => asset('vendor/blade-flags/country-se.svg'), // Stockholm
'Europe/Athens' => asset('vendor/blade-flags/country-gr.svg'), // Athens
'Europe/Warsaw' => asset('vendor/blade-flags/country-pl.svg'), // Warsaw
'Europe/Zurich' => asset('vendor/blade-flags/country-ch.svg'), // Zurich
'Europe/Prague' => asset('vendor/blade-flags/country-cz.svg'), // Prague
'Europe/Oslo' => asset('vendor/blade-flags/country-no.svg'), // Oslo
'Europe/Copenhagen' => asset('vendor/blade-flags/country-dk.svg'), // Copenhagen
'Europe/Helsinki' => asset('vendor/blade-flags/country-fi.svg'), // Helsinki
'Europe/Istanbul' => asset('vendor/blade-flags/country-tr.svg'), // Istanbul
'Europe/Lisbon' => asset('vendor/blade-flags/country-pt.svg'), // Lisbon
'Europe/Budapest' => asset('vendor/blade-flags/country-hu.svg'), // Budapest
'Europe/Bucharest' => asset('vendor/blade-flags/country-ro.svg'), // Bucharest
'Europe/Dublin' => asset('vendor/blade-flags/country-ie.svg'), // Dublin
'Europe/Ljubljana' => asset('vendor/blade-flags/country-si.svg'), // Ljubljana
'Europe/Luxembourg' => asset('vendor/blade-flags/country-lu.svg'), // Luxembourg
'Europe/Minsk' => asset('vendor/blade-flags/country-by.svg'), // Minsk
'Europe/Monaco' => asset('vendor/blade-flags/country-mc.svg'), // Monaco
'Europe/Riga' => asset('vendor/blade-flags/country-lv.svg'), // Riga
'Europe/San_Marino' => asset('vendor/blade-flags/country-sm.svg'), // San Marino
'Europe/Sarajevo' => asset('vendor/blade-flags/country-ba.svg'), // Sarajevo
'Europe/Sofia' => asset('vendor/blade-flags/country-bg.svg'), // Sofia
'Europe/Tallinn' => asset('vendor/blade-flags/country-ee.svg'), // Tallinn
'Europe/Vatican' => asset('vendor/blade-flags/country-va.svg'), // Vatican
'Europe/Zagreb' => asset('vendor/blade-flags/country-hr.svg'), // Zagreb
'America/New_York' => asset('vendor/blade-flags/country-us.svg'), // New York
'America/Los_Angeles' => asset('vendor/blade-flags/country-us.svg'), // Los Angeles
'America/Chicago' => asset('vendor/blade-flags/country-us.svg'), // Chicago
'America/Toronto' => asset('vendor/blade-flags/country-ca.svg'), // Toronto
'America/Mexico_City' => asset('vendor/blade-flags/country-mx.svg'), // Mexico City
'America/Buenos_Aires' => asset('vendor/blade-flags/country-ar.svg'), // Buenos Aires
'America/Sao_Paulo' => asset('vendor/blade-flags/country-br.svg'), // São Paulo
'America/Bogota' => asset('vendor/blade-flags/country-co.svg'), // Bogotá
'America/Lima' => asset('vendor/blade-flags/country-pe.svg'), // Lima
'America/Caracas' => asset('vendor/blade-flags/country-ve.svg'), // Caracas
'America/Santiago' => asset('vendor/blade-flags/country-cl.svg'), // Santiago
'America/Halifax' => asset('vendor/blade-flags/country-ca.svg'), // Halifax
'America/Phoenix' => asset('vendor/blade-flags/country-us.svg'), // Phoenix
'America/Anchorage' => asset('vendor/blade-flags/country-us.svg'), // Anchorage
'America/Honolulu' => asset('vendor/blade-flags/country-us.svg'), // Honolulu
'America/Montevideo' => asset('vendor/blade-flags/country-uy.svg'), // Montevideo
'Asia/Jakarta' => asset('vendor/blade-flags/country-id.svg'), // Jakarta
'Asia/Singapore' => asset('vendor/blade-flags/country-sg.svg'), // Singapore
'Asia/Tokyo' => asset('vendor/blade-flags/country-jp.svg'), // Tokyo
'Asia/Seoul' => asset('vendor/blade-flags/country-kr.svg'), // Seoul
'Asia/Beijing' => asset('vendor/blade-flags/country-cn.svg'), // Beijing
'Asia/Taipei' => asset('vendor/blade-flags/country-tw.svg'), // Taipei
'Asia/Kuala_Lumpur' => asset('vendor/blade-flags/country-my.svg'), // Kuala Lumpur
'Asia/Bangkok' => asset('vendor/blade-flags/country-th.svg'), // Bangkok
'Asia/Dubai' => asset('vendor/blade-flags/country-ae.svg'), // Dubai
'Asia/Kolkata' => asset('vendor/blade-flags/country-in.svg'), // Mumbai (Standard Time for India)
'Asia/Hong_Kong' => asset('vendor/blade-flags/country-hk.svg'), // Hong Kong
'Australia/Sydney' => asset('vendor/blade-flags/country-au.svg'), // Sydney
'Pacific/Auckland' => asset('vendor/blade-flags/country-nz.svg'), // Auckland
'Etc/UTC' => asset('vendor/blade-flags/country-xx.svg'), // Default flag (UTC)
];

return $timezones[$timezone] ?? '🕒';
Expand Down

0 comments on commit 9c06774

Please sign in to comment.