Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -252,7 +252,7 @@ class="inline-block rounded-full border border-gray-200 bg-gray-50 px-2.5 py-0.5
rel="noopener noreferrer"
class="inline-flex items-center gap-1 text-xs font-medium text-purple-600 hover:text-purple-800 dark:text-purple-400 dark:hover:text-purple-200 transition-colors"
>
<x-dynamic-component :component="'heroicon-m-'.\Illuminate\Support\Str::kebab($platform->getIcon()->name)" class="h-3.5 w-3.5 shrink-0" />
<x-filament::icon :icon="$platform->getBrandIcon()" class="h-3.5 w-3.5 shrink-0" />
{{ $platform->getLabel() }}
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 12 12" class="h-3 w-3 shrink-0" fill="none" stroke="currentColor" stroke-width="1.5">
<path stroke-linecap="round" stroke-linejoin="round" d="M2.5 9.5 9.5 2.5M5 2.5h4.5V7" />
Expand Down
18 changes: 17 additions & 1 deletion app-modules/panel-app/src/Pages/ProfilePage.php
Original file line number Diff line number Diff line change
Expand Up @@ -254,13 +254,29 @@ public function form(Schema $schema): Schema
Grid::make(2)->schema([
Select::make('platform')
->label(__('panel-app::profile.fields.platform'))
->options(SocialPlatform::class)
->options(fn (): array => collect(SocialPlatform::cases())
->mapWithKeys(fn (SocialPlatform $platform): array => [
$platform->value => sprintf(
'<span class="flex items-center gap-2">%s %s</span>',
svg($platform->getBrandIcon(), 'h-4 w-4')->toHtml(),
e($platform->getLabel()),
),
])
->all())
->allowHtml()
->required(fn (Get $get): bool => filled($get('handle')))
->live()
->afterStateUpdated(static function (Get $get, Set $set): void {
if (blank($get('platform'))) {
$set('handle', null);
}
})
->columnSpan(1),

TextInput::make('handle')
->label(__('panel-app::profile.fields.handle'))
->placeholder(__('panel-app::profile.placeholders.handle'))
->disabled(fn (Get $get): bool => blank($get('platform')))
Comment thread
coderabbitai[bot] marked this conversation as resolved.
->required(fn (Get $get): bool => filled($get('platform')))
->live(onBlur: true)
->afterStateUpdated(function (Get $get, TextInput $component): void {
Expand Down
12 changes: 12 additions & 0 deletions app-modules/profile/src/Enums/SocialPlatform.php
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,18 @@ public function getIcon(): Heroicon
};
}

public function getBrandIcon(): string
{
return match ($this) {
self::Instagram => 'fab-instagram',
self::Twitter => 'fab-x-twitter',
self::Website => 'fas-globe',
self::YouTube => 'fab-youtube',
self::Bluesky => 'fab-bluesky',
self::LinkedIn => 'fab-linkedin',
};
}

public function getUrl(string $handle): string
{
if (str_starts_with($handle, 'http://') || str_starts_with($handle, 'https://')) {
Expand Down