diff --git a/app-modules/panel-app/resources/views/components/profile-preview-card.blade.php b/app-modules/panel-app/resources/views/components/profile-preview-card.blade.php index f10c5700..dea705d8 100644 --- a/app-modules/panel-app/resources/views/components/profile-preview-card.blade.php +++ b/app-modules/panel-app/resources/views/components/profile-preview-card.blade.php @@ -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" > - + {{ $platform->getLabel() }} diff --git a/app-modules/panel-app/src/Pages/ProfilePage.php b/app-modules/panel-app/src/Pages/ProfilePage.php index 8b1f0722..fb551c21 100644 --- a/app-modules/panel-app/src/Pages/ProfilePage.php +++ b/app-modules/panel-app/src/Pages/ProfilePage.php @@ -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( + '%s %s', + 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'))) ->required(fn (Get $get): bool => filled($get('platform'))) ->live(onBlur: true) ->afterStateUpdated(function (Get $get, TextInput $component): void { diff --git a/app-modules/profile/src/Enums/SocialPlatform.php b/app-modules/profile/src/Enums/SocialPlatform.php index db6eaf65..af2d3db4 100644 --- a/app-modules/profile/src/Enums/SocialPlatform.php +++ b/app-modules/profile/src/Enums/SocialPlatform.php @@ -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://')) {