-
Notifications
You must be signed in to change notification settings - Fork 375
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Feature - Field translated text (#1505)
This PR fix definitely the TranslatedText component for the MVP. It's a same UX approach that legacy version. Let's get a simple solution working and consider a better solution later. The issue related to #1425 --------- Co-authored-by: Alec Ritson <[email protected]> Co-authored-by: Glenn Jacobs <[email protected]>
- Loading branch information
1 parent
62af43e
commit e32d2cc
Showing
23 changed files
with
246 additions
and
107 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -26,6 +26,7 @@ | |
'richtext' => [ | ||
'label' => 'Rich Text', | ||
], | ||
'locales' => 'Locales', | ||
], | ||
], | ||
'toggle' => [ | ||
|
65 changes: 49 additions & 16 deletions
65
packages/admin/resources/views/forms/components/translated-text.blade.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,21 +1,54 @@ | ||
<x-dynamic-component | ||
:component="$getFieldWrapperView()" | ||
:field="$field" | ||
> | ||
<x-dynamic-component | ||
:component="$getFieldWrapperView()" | ||
:field="$field" | ||
x-data="{ showTranslations: {{ $getExpanded() ? 'true' : 'false' }} }" | ||
> | ||
|
||
<div x-data="{ state: $wire.entangle('{{ $getStatePath() }}') }"> | ||
@foreach ($getLanguages() as $language) | ||
|
||
<div class="mt-2"> | ||
<x-filament::input.wrapper> | ||
<x-filament::input | ||
type="text" | ||
x-model="state.{{ $language->code }}" | ||
/> | ||
</x-filament::input.wrapper> | ||
</div> | ||
<div x-data="{ state: $wire.entangle('{{ $getStatePath() }}') }"> | ||
<div class="flex items-center gap-2"> | ||
@if ($getMoreLanguages()->count()) | ||
<span x-show="showTranslations" | ||
class="items-center w-8 place-content-center text-xs font-normal p-2 rounded shadow-sm bg-gray-200 text-gray-400 dark:bg-white/5 dark:text-white uppercase"> | ||
{{ Str::upper($getDefaultLanguage()->code) }} | ||
</span> | ||
@endif | ||
<x-filament::input.wrapper class="w-full"> | ||
{{ $getComponentByLanguage($getDefaultLanguage()) }} | ||
</x-filament::input.wrapper> | ||
</div> | ||
|
||
@if ($getMoreLanguages()->count()) | ||
@foreach ($getMoreLanguages() as $language) | ||
<div x-show="showTranslations" class="flex items-center gap-2 mt-4"> | ||
<span x-show="showTranslations" | ||
class="w-8 text-xs font-normal p-2 rounded shadow-sm bg-gray-200 text-gray-400 dark:bg-white/5 dark:text-white uppercase"> | ||
{{ Str::upper($language->code) }} | ||
</span> | ||
<x-filament::input.wrapper class="w-full"> | ||
{{ $getComponentByLanguage($language) }} | ||
</x-filament::input.wrapper> | ||
</div> | ||
@endforeach | ||
@endif | ||
</div> | ||
|
||
@if ($getMoreLanguages()->count()) | ||
<div class="mt-2"> | ||
<x-filament::button | ||
x-on:click.prevent="showTranslations = !showTranslations" | ||
size="xs" | ||
color="gray" | ||
> | ||
<x-filament::icon | ||
alias="lunar::languages" | ||
@class(['w-3.5 h-3.5 inline-flex']) | ||
/> | ||
<span class="ml-2"> | ||
{{ __('lunarpanel::fieldtypes.translatedtext.form.locales') }} | ||
</span> | ||
</x-filament::button> | ||
</button> | ||
</div> | ||
@endif | ||
|
||
</x-dynamic-component> | ||
</x-dynamic-component> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
15 changes: 15 additions & 0 deletions
15
packages/admin/src/Support/Forms/Components/TranslatedRichEditor.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
<?php | ||
|
||
namespace Lunar\Admin\Support\Forms\Components; | ||
|
||
use Filament\Forms\Components\RichEditor; | ||
|
||
class TranslatedRichEditor extends RichEditor | ||
{ | ||
public function setUp(): void | ||
{ | ||
parent::setUp(); | ||
|
||
$this->hiddenLabel(); | ||
} | ||
} |
Oops, something went wrong.