### Install and Configure Filament Social Share Source: https://context7.com/tappnetwork/filament-social-share/llms.txt Instructions for installing the Filament Social Share plugin via Composer and publishing its configuration file. It also includes adding plugin styles to the Filament theme. ```bash # Install the package composer require tapp/filament-social-share # Publish the configuration file php artisan vendor:publish --tag="filament-social-share-config" ``` ```css @source '../../../../vendor/tapp/filament-social-share'; ``` -------------------------------- ### Install Filament Social Share Package Source: https://github.com/tappnetwork/filament-social-share/blob/main/README.md Installs the Filament Social Share package using Composer. This is the first step to integrate the sharing functionality into your Filament application. ```bash composer require tapp/filament-social-share ``` -------------------------------- ### Configure Filament Social Share Action Icon Source: https://github.com/tappnetwork/filament-social-share/blob/main/README.md Example of the published configuration file for Filament Social Share, showing how to set the default icon for the share action. ```php return [ 'action' => [ 'icon' => 'heroicon-m-share', ], ]; ``` -------------------------------- ### Custom Authorization Check Before Sharing - PHP Source: https://github.com/tappnetwork/filament-social-share/blob/main/README.md This example implements a custom authorization check before allowing a user to share content. If the user lacks the 'share_content' permission, a notification is sent, and an exception is thrown. ```php use Filament\Notifications\Notification; use Tapp\FilamentSocialShare\Actions\SocialShareAction; SocialShareAction::make() ->facebook() ->linkedin() ->before(function () { // Check if user has permission to share if (!auth()->user()->can('share_content')) { Notification::make() ->title('Permission Denied') ->body('You do not have permission to share content.') ->danger() ->send(); throw new \Exception('Unauthorized sharing attempt'); } }) ``` -------------------------------- ### Conditional Social Share Configuration (PHP) Source: https://github.com/tappnetwork/filament-social-share/blob/main/README.md Provides an example of dynamically configuring social share buttons based on certain conditions, such as user preferences or premium status. This allows for personalized sharing options. ```php $action = SocialShareAction::make() ->facebook() ->linkedin(); // Conditionally customize based on user preferences if ($user->prefers_custom_colors) { $action->facebookColor('#custom-color') ->linkedinColor('#another-color'); } if ($user->is_premium) { $action->reddit() ->redditTooltip('Premium user sharing'); } ``` -------------------------------- ### Send Notification After Sharing - PHP Source: https://github.com/tappnetwork/filament-social-share/blob/main/README.md This example demonstrates sending a Filament notification after the social sharing modal is displayed. It utilizes the `after()` method to trigger the notification logic. ```php use Filament\Notifications\Notification; use Tapp\FilamentSocialShare\Actions\SocialShareAction; SocialShareAction::make() ->facebook() ->linkedin() ->after(function () { // Send notification after user opens share modal Notification::make() ->title('Share options displayed') ->body('The social sharing options have been presented to the user.') ->success() ->send(); }), ``` -------------------------------- ### Run Tests - Bash Source: https://github.com/tappnetwork/filament-social-share/blob/main/README.md This command executes the project's test suite using Composer. It's a standard way to ensure code quality and verify functionality. ```bash composer test ``` -------------------------------- ### Configure Social Platform Icons, Tooltips, and Colors Source: https://context7.com/tappnetwork/filament-social-share/llms.txt Illustrates how to customize the appearance of social share buttons using named parameters or a fluent API. This includes setting custom icons, tooltips, and colors for each platform. ```php use Tapp\FilamentSocialShare\Actions\SocialShareAction; // Using named parameters SocialShareAction::make() ->x( enabled: true, icon: 'fab-x-twitter', tooltip: 'Share on X', color: '#000000' ) ->facebook( icon: 'fab-facebook-f', tooltip: 'Share on Facebook', color: '#1877f2' ) ->linkedin( icon: 'fab-linkedin-in', tooltip: 'Share on LinkedIn', color: '#0077b5' ) ->reddit( icon: 'fab-reddit-alien', tooltip: 'Post to Reddit', color: '#ff4500' ) ->email( icon: 'heroicon-o-envelope', tooltip: 'Share via Email', color: '#6b7280' ) // Using dedicated methods (fluent API) SocialShareAction::make() ->facebook() ->facebookIcon('fab-facebook-f') ->facebookTooltip('Share this post on Facebook') ->facebookColor('#1877f2') ->linkedin() ->linkedinIcon('fab-linkedin-in') ->linkedinTooltip('Share on LinkedIn network') ->linkedinColor('#0077b5') ``` -------------------------------- ### Configure Static and Dynamic URLs and Text for Sharing Source: https://context7.com/tappnetwork/filament-social-share/llms.txt Shows how to set the URL and text content for social shares. It covers both static values and dynamic generation using Closures, which is particularly useful for table actions where data is record-specific. ```php use Tapp\FilamentSocialShare\Actions\SocialShareAction; // Static URL and text SocialShareAction::make() ->urlToShare('https://github.com/TappNetwork/filament-social-share') ->text('Filament Social Share Plugin') ->facebook() ->x() // Dynamic URL using Closure (useful in table actions) SocialShareAction::make() ->urlToShare(fn ($record) => route('articles.show', $record)) ->text(fn ($record) => $record->title) ->facebook() ->linkedin() ``` -------------------------------- ### Basic SocialShareAction Usage Source: https://context7.com/tappnetwork/filament-social-share/llms.txt Demonstrates the basic implementation of the SocialShareAction for sharing content on various social media platforms. It shows how to enable specific platforms and use the native browser share API. ```php use Tapp\FilamentSocialShare\Actions\SocialShareAction; // Basic usage with multiple platforms SocialShareAction::make() ->x() ->facebook() ->linkedin() ->reddit() ->email() // Using native browser Web Share API instead of modal SocialShareAction::make() ->nativeBrowserShare() // Custom URL and text to share SocialShareAction::make() ->urlToShare('https://example.com/article/123') ->text('Check out this amazing article!') ->facebook() ->linkedin() ``` -------------------------------- ### Execute Custom Logic with Lifecycle Hooks Source: https://context7.com/tappnetwork/filament-social-share/llms.txt Use 'before' and 'after' hooks to execute custom logic, such as logging, sending notifications, or performing authorization checks, before or after the social sharing action is triggered. These hooks allow for dynamic behavior based on user actions or application state. ```php use Tapp\FilamentSocialShare\Actions\SocialShareAction; use Filament\Notifications\Notification; use Illuminate\Support\Facades\Log; // Logging and notifications SocialShareAction::make() ->facebook() ->linkedin() ->before(function () { Log::info('User opened social share modal', [ 'user_id' => auth()->id(), 'timestamp' => now(), 'url' => request()->url() ]); }) ->after(function () { Notification::make() ->title('Share options displayed') ->body('The social sharing options have been presented.') ->success() ->send(); }) // Authorization check before sharing SocialShareAction::make() ->facebook() ->linkedin() ->before(function () { if (!auth()->user()->can('share_content')) { Notification::make() ->title('Permission Denied') ->body('You do not have permission to share content.') ->danger() ->send(); throw new \Exception('Unauthorized sharing attempt'); } }) // Analytics tracking SocialShareAction::make() ->facebook() ->x() ->before(function () { event('social_share_initiated', [ 'user_id' => auth()->id(), 'content_type' => 'article', 'content_id' => request()->route('id') ]); }) ``` -------------------------------- ### Configure Social Share Buttons with Mixed Approach (PHP) Source: https://github.com/tappnetwork/filament-social-share/blob/main/README.md Demonstrates the flexibility of configuring social share buttons by combining named parameters and dedicated methods. This 'mixed approach' allows for maximum customization, enabling developers to choose the most suitable method for each setting. ```php SocialShareAction::make() ->facebook(icon: 'fab-facebook-f') // Named parameter for icon ->facebookTooltip('Custom tooltip') // Dedicated method for tooltip ->facebookColor('#1877f2') // Dedicated method for color ->linkedin(color: '#0077b5') // Named parameter for color ->linkedinIcon('fab-linkedin-in') // Dedicated method for icon ->reddit() // Enable with all defaults ->redditColor('#ff4500') ``` -------------------------------- ### Configure Social Share Buttons with Named Parameters (PHP) Source: https://github.com/tappnetwork/filament-social-share/blob/main/README.md Illustrates configuring Facebook, LinkedIn, and Reddit share buttons using named parameters directly within their respective methods. This approach allows for concise customization of enabled status, icons, tooltips, and colors. ```php SocialShareAction::make() ->facebook( enabled: true, icon: 'fab-facebook-f', tooltip: 'Share this post on Facebook', color: '#1877f2' ) ->linkedin( icon: 'fab-linkedin-in', color: '#0077b5', tooltip: 'Share on LinkedIn network' ) ->reddit( color: '#ff4500', tooltip: 'Post to Reddit' ) ``` -------------------------------- ### Publish Filament Social Share Configuration Source: https://github.com/tappnetwork/filament-social-share/blob/main/README.md Publishes the configuration file for the Filament Social Share package. This allows for customization of the action's icon. ```bash php artisan vendor:publish --tag="filament-social-share-config" ``` -------------------------------- ### Custom Logic Before/After Sharing (PHP) Source: https://github.com/tappnetwork/filament-social-share/blob/main/README.md Demonstrates how to add custom logic before and after the social sharing process using the `before` and `after` methods of SocialShareAction. This allows for pre-sharing notifications or post-sharing logging. ```php use Tapp\FilamentSocialShare\Actions\SocialShareAction; use Filament\Notifications\Notification; SocialShareAction::make() ->before(function () { // Execute before sharing modal opens Notification::make() ->title('Opening share options...') ->info() ->send(); }) ->after(function () { // Execute after sharing process \Log::info('User opened social share modal'); }) ->facebook() ->linkedin() ``` -------------------------------- ### Configure Social Share Buttons with Dedicated Methods (PHP) Source: https://github.com/tappnetwork/filament-social-share/blob/main/README.md Shows an alternative method for configuring social share buttons (Facebook, LinkedIn, Reddit) by chaining dedicated methods for icons, tooltips, and colors. This provides a more verbose but potentially clearer way to set individual properties. ```php SocialShareAction::make() ->facebook() ->facebookIcon('fab-facebook-f') ->facebookTooltip('Share this amazing post on Facebook') ->facebookColor('#1877f2') ->linkedin() ->linkedinColor('#0077b5') ->linkedinTooltip('Share on LinkedIn network') ->reddit() ->redditColor('#ff4500') ``` -------------------------------- ### Log Sharing Activity - PHP Source: https://github.com/tappnetwork/filament-social-share/blob/main/README.md This snippet shows how to log user activity before and after the social sharing modal is presented. It uses the `before()` method to log the initiation of sharing and the `after()` method to log its successful display. ```php use Illuminate\Support\Facades\Log; use Tapp\FilamentSocialShare\Actions\SocialShareAction; SocialShareAction::make() ->facebook() ->linkedin() ->before(function () { // Log that user initiated sharing Log::info('User opened social share modal', [ 'user_id' => auth()->id(), 'timestamp' => now(), 'url' => request()->url() ]); }) ->after(function () { // Log completion Log::info('Social share modal displayed successfully'); }) ``` -------------------------------- ### Customize Filament Action Appearance and Behavior Source: https://context7.com/tappnetwork/filament-social-share/llms.txt Customize the appearance and behavior of the SocialShareAction using standard Filament action methods. Options include changing the button to an icon, setting custom labels and icons, controlling visibility, and conditionally enabling social platforms. ```php use Tapp\FilamentSocialShare\Actions\SocialShareAction; // Icon button instead of text button SocialShareAction::make() ->facebook() ->linkedin() ->iconButton() // Custom label and visibility SocialShareAction::make() ->label('Share This') ->icon('heroicon-o-share') ->facebook() ->x() ->visible(fn () => auth()->check()) // Conditional platform enabling $action = SocialShareAction::make() ->facebook() ->linkedin(); if ($user->prefers_custom_colors) { $action->facebookColor('#custom-color') ->linkedinColor('#another-color'); } if ($user->is_premium) { $action->reddit() ->redditTooltip('Premium user sharing'); } ``` -------------------------------- ### Integrate Social Share Action in Filament Resources Source: https://context7.com/tappnetwork/filament-social-share/llms.txt Add the SocialShareAction to your Filament resources, either in the header of a ListRecords page or within the table actions for individual records. This enables users to easily share content directly from the admin panel. ```php use Tapp\FilamentSocialShare\Actions\SocialShareAction; // In a Filament Resource ListRecords page protected function getHeaderActions(): array { return [ SocialShareAction::make() ->urlToShare(fn () => url()->current()) ->text('Check out our admin panel') ->facebook() ->linkedin() ->x() ->email(), ]; } // In a Filament Table public function table(Table $table): Table { return $table ->columns([/* ... */]) ->actions([ SocialShareAction::make() ->urlToShare(fn ($record) => route('posts.show', $record)) ->text(fn ($record) => "Read: {$record->title}") ->facebook() ->x() ->iconButton(), ]); } ``` -------------------------------- ### Customize Social Share Action as IconButton (PHP) Source: https://github.com/tappnetwork/filament-social-share/blob/main/README.md Shows how to customize the appearance of the social share action to use an icon button instead of a standard button. This is achieved by chaining the `iconButton()` method to the SocialShareAction. ```php use Tapp\FilamentSocialShare\Actions\SocialShareAction; SocialShareAction::make() ->facebook() ->iconButton(), ``` -------------------------------- ### Track Analytics Before Sharing - PHP Source: https://github.com/tappnetwork/filament-social-share/blob/main/README.md This code snippet demonstrates tracking user intent to share content in analytics before the sharing process begins. It uses the `before()` method to fire a custom analytics event with relevant user and content details. ```php use Tapp\FilamentSocialShare\Actions\SocialShareAction; SocialShareAction::make() ->facebook() ->linkedin() ->before(function () { // Track sharing intent in analytics event('social_share_initiated', [ 'user_id' => auth()->id(), 'content_type' => 'article', 'content_id' => request()->route('id') ]); }) ``` -------------------------------- ### Add Reddit Share Button (PHP) Source: https://github.com/tappnetwork/filament-social-share/blob/main/README.md Demonstrates how to add a Reddit share button using the SocialShareAction. It shows basic usage, customization with icon, tooltip, and color, and using dedicated methods for configuration. ```php use Tapp\FilamentSocialShare\Actions\SocialShareAction; SocialShareAction::make() ->reddit() // With custom icon, tooltip, and color SocialShareAction::make() ->reddit( enabled: true, icon: 'fab-reddit-alien', tooltip: 'Share on Reddit', color: '#ff4500' ) // Using dedicated methods SocialShareAction::make() ->reddit() ->redditIcon('fab-reddit-alien') ->redditTooltip('Post to Reddit') ->redditColor('#ff4500') ``` -------------------------------- ### Configure Default Share Button Icon Source: https://context7.com/tappnetwork/filament-social-share/llms.txt Modify the default icon used for the social share button by updating the configuration file. This allows for a consistent look across your Filament application. ```php // config/filament-social-share.php return [ 'action' => [ 'icon' => 'heroicon-m-share', // Default icon for the share button ], ]; ``` -------------------------------- ### Configure Modal with Social Platform Options in Filament Source: https://github.com/tappnetwork/filament-social-share/blob/main/README.md Configures the Filament Social Share action to display a modal with options for sharing on various social platforms and email when the native browser share is not used. ```php use Tapp\FilamentSocialShare\Actions\SocialShareAction; SocialShareAction::make() ->x() ->facebook() ->linkedin() ->reddit() ->email() ``` -------------------------------- ### Configure X (Twitter) Share Button in Filament Source: https://github.com/tappnetwork/filament-social-share/blob/main/README.md Adds the X (Twitter) share button to the Filament Social Share action. It supports custom icons, tooltips, and colors, and can be configured using dedicated methods. ```php use Tapp\FilamentSocialShare\Actions\SocialShareAction; SocialShareAction::make() ->x() // With custom icon, tooltip, and color SocialShareAction::make() ->x( enabled: true, icon: 'fab-x', tooltip: 'Share on X', color: '#000000' ) // Using dedicated methods SocialShareAction::make() ->x() ->xIcon('fab-x') ->xTooltip('Share this post on X') ->xColor('#000000') ``` -------------------------------- ### Apply Filament Social Share Plugin Styles Source: https://github.com/tappnetwork/filament-social-share/blob/main/README.md Adds the necessary CSS to your Filament theme file to apply the plugin's styles. This ensures the share action and its modal are displayed correctly. ```css @source '../../../../vendor/tapp/filament-social-share'; ``` -------------------------------- ### Configure Facebook Share Button in Filament Source: https://github.com/tappnetwork/filament-social-share/blob/main/README.md Adds the Facebook share button to the Filament Social Share action. It allows for customization of the icon, tooltip, and color, and provides dedicated methods for configuration. ```php use Tapp\FilamentSocialShare\Actions\SocialShareAction; SocialShareAction::make() ->facebook() // With custom icon, tooltip, and color SocialShareAction::make() ->facebook( enabled: true, icon: 'fab-facebook-f', tooltip: 'Share on Facebook', color: '#1877f2' ) // Using dedicated methods SocialShareAction::make() ->facebook() ->facebookIcon('fab-facebook-f') ->facebookTooltip('Share this post on Facebook') ->facebookColor('#1877f2') ``` -------------------------------- ### Use Native Browser Share API with Filament Social Share Source: https://github.com/tappnetwork/filament-social-share/blob/main/README.md Enables the native browser share functionality for the Filament Social Share action. This utilizes the browser's built-in sharing capabilities. ```php use Tapp\FilamentSocialShare\Actions\SocialShareAction; SocialShareAction::make() ->nativeBrowserShare() ``` -------------------------------- ### Configure LinkedIn Share Button in Filament Source: https://github.com/tappnetwork/filament-social-share/blob/main/README.md Integrates the LinkedIn share button into the Filament Social Share action. Customization options include icon, tooltip, and color, with dedicated methods available for fine-tuning. ```php use Tapp\FilamentSocialShare\Actions\SocialShareAction; SocialShareAction::make() ->linkedin() // With custom icon, tooltip, and color SocialShareAction::make() ->linkedin( enabled: true, icon: 'fab-linkedin-in', tooltip: 'Share on LinkedIn', color: '#0077b5' ) // Using dedicated methods SocialShareAction::make() ->linkedin() ->linkedinIcon('fab-linkedin-in') ->linkedinTooltip('Share on LinkedIn network') ->linkedinColor('#0077b5') ``` -------------------------------- ### Add Email Share Button (PHP) Source: https://github.com/tappnetwork/filament-social-share/blob/main/README.md Illustrates how to add an Email share button using the SocialShareAction. It covers basic implementation, customization of icon, tooltip, and color, and utilizing specific methods for these settings. ```php use Tapp\FilamentSocialShare\Actions\SocialShareAction; SocialShareAction::make() ->email() // With custom icon, tooltip, and color SocialShareAction::make() ->email( enabled: true, icon: 'heroicon-o-envelope', tooltip: 'Share via Email', color: '#6b7280' ) // Using dedicated methods SocialShareAction::make() ->email() ->emailIcon('heroicon-o-envelope') ->emailTooltip('Send via Email') ->emailColor('#6b7280') ``` -------------------------------- ### Set Custom Text for Sharing in Filament Source: https://github.com/tappnetwork/filament-social-share/blob/main/README.md Enables setting custom text to be shared along with the URL, overriding the default behavior of using the page title as the shared text. ```php use Tapp\FilamentSocialShare\Actions\SocialShareAction; SocialShareAction::make() ->text('Social Share Filament Plugin') ``` -------------------------------- ### Set Custom URL for Sharing in Filament Source: https://github.com/tappnetwork/filament-social-share/blob/main/README.md Allows you to specify a custom URL to be shared using the Filament Social Share action, overriding the default behavior of sharing the current URL. ```php use Tapp\FilamentSocialShare\Actions\SocialShareAction; SocialShareAction::make() ->urlToShare('https://github.com/TappNetwork/filament-social-share') ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.