Skip to content

Commit aa5bf5b

Browse files
committed
flag order
1 parent d6d3664 commit aa5bf5b

File tree

2 files changed

+27
-25
lines changed

2 files changed

+27
-25
lines changed
Lines changed: 23 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
@php
2-
$flags = $getState(); // Example: More than 4 flags
2+
$flags = $getState();
33
$visibleFlags = [];
44
$remainingFlags = 0;
55
$currentLang = $this->lang ?? request()->get('lang', app()->getLocale());
@@ -9,9 +9,11 @@
99
$currentLangFlag = null;
1010
$otherFlags = [];
1111
12-
foreach ($flags as $flag) {
13-
$flagLang = str_replace('flag-', '', str_replace(' trashed', '', $flag));
14-
if ($flagLang === $currentLang) {
12+
foreach ($flags as $flagData) {
13+
$flag = $flagData['flag'];
14+
$locale = $flagData['locale'];
15+
16+
if ($locale === $currentLang) {
1517
$currentLangFlag = $flag;
1618
} else {
1719
$otherFlags[] = $flag;
@@ -23,7 +25,7 @@
2325
$otherVisibleFlags = array_slice($otherFlags, 0, 2);
2426
$visibleFlags = array_merge($visibleFlags, $otherVisibleFlags);
2527
} else {
26-
$visibleFlags = array_slice($flags, 0, 3);
28+
$visibleFlags = array_slice(array_column($flags, 'flag'), 0, 3);
2729
}
2830
2931
$remainingFlags = max(0, count($flags) - count($visibleFlags));
@@ -32,30 +34,27 @@
3234
$visibleFlags = [];
3335
$remainingFlags = 0;
3436
}
35-
$visibleFlags = array_reverse($visibleFlags);
3637
@endphp
3738
<x-filament-forms::field-wrapper>
3839
<div style="padding-left: 30%; position: relative; height: 28px; min-width: 66px;">
3940
<div style="position: relative; height: 28px; min-width: 66px;">
40-
@foreach($visibleFlags as $revIndex => $flag)
41-
@php
42-
$index = count($visibleFlags) - 1 - $revIndex;
43-
$isTrashed = str_contains($flag, 'trashed');
44-
$flagComponent = str_replace(' trashed', '', $flag);
45-
@endphp
46-
<span style="position: absolute; left: {{ $index * 18 }}px; z-index: {{ 10 + $index }};">
47-
<x-dynamic-component :component="$flagComponent"
48-
style="width: 24px; height: 24px; border-radius: 50%; background: #fff;" />
49-
</span>
41+
@foreach($visibleFlags as $index => $flag)
42+
@php
43+
$isTrashed = str_contains($flag, 'trashed');
44+
$flagComponent = str_replace(' trashed', '', $flag);
45+
@endphp
46+
<span style="position: absolute; left: {{ $index * 18 }}px; z-index: {{ 10 + $index }};">
47+
<x-dynamic-component :component="$flagComponent"
48+
style="width: 24px; height: 24px; border-radius: 50%; background: #fff;" />
49+
</span>
5050
@endforeach
51-
@if($remainingFlags > 0)
52-
<span style="position: absolute; left: {{ (count($visibleFlags) * 18) + 8 }}px; z-index: 20;">
53-
<div
54-
class="flex items-center justify-center w-6 h-6 text-sm font-bold text-black rounded-full bg-white border border-gray-300">
55-
+{{ $remainingFlags }}
56-
</div>
57-
</span>
58-
@endif
51+
@if($remainingFlags > 0)
52+
<span style="position: absolute; left: {{ (count($visibleFlags) * 18) + 8 }}px; z-index: 20;">
53+
<div class="flex items-center justify-center w-6 h-6 text-sm font-bold text-black rounded-full bg-white border border-gray-300">
54+
+{{ $remainingFlags }}
55+
</div>
56+
</span>
57+
@endif
5958
</div>
6059
</div>
6160
</x-filament-forms::field-wrapper>

packages/localization/src/Filament/Tables/Columns/TranslationColumn.php

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,10 @@ protected function setUp(): void
3838
$flagClass .= ' trashed';
3939
}
4040

41-
return $flagClass;
41+
return [
42+
'flag' => $flagClass,
43+
'locale' => $translation->locale,
44+
];
4245
})->toArray();
4346

4447
return $flags;

0 commit comments

Comments
 (0)