Skip to content

Commit

Permalink
Add label to services
Browse files Browse the repository at this point in the history
  • Loading branch information
mbardelmeijer committed Aug 21, 2023
1 parent 8b7f817 commit cdf5993
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 1 deletion.
9 changes: 9 additions & 0 deletions config/social-share.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,40 +3,49 @@
return [
'services' => [
'facebook' => [
'label' => 'Facebook',
'url' => 'https://www.facebook.com/sharer/sharer.php?u=#url#&text=#text#',
'color' => '#1777f2',
],
// @DEPRECATED. Is replaced with `x`. The values of `x` are the same.
'twitter' => [
'name' => 'x',
'label' => 'X',
'url' => 'https://x.com/intent/tweet?url=#url#',
'color' => '#000000',
],
'x' => [
'label' => 'X',
'url' => 'https://x.com/intent/tweet?url=#url#', // @TODO: replace with actual URL if `tweet` get's renamed.
'color' => '#000000',
],
'linkedin' => [
'label' => 'LinkedIn',
'url' => 'https://www.linkedin.com/sharing/share-offsite/?url=#url#&summary=#text#',
'color' => '#0077b5',
],
'whatsapp' => [
'label' => 'WhatsApp',
'url' => 'https://wa.me/?text=#textWithUrl#',
'color' => '#4dc247',
],
'pinterest' => [
'label' => 'Pinterest',
'url' => 'https://pinterest.com/pin/create/button/?url=#url#',
'color' => '#cb2027',
],
'reddit' => [
'label' => 'Reddit',
'url' => 'https://www.reddit.com/submit?url=#url#&title=#text#',
'color' => '#ff5700',
],
'telegram' => [
'label' => 'Telegram',
'url' => 'https://telegram.me/share/url?url=#url#&text=#text#',
'color' => '#0088cc',
],
'email' => [
'label' => 'Email',
'url' => 'mailto:?body=#textWithUrl#',
'color' => '#848484',
],
Expand Down
2 changes: 1 addition & 1 deletion resources/views/social-share.blade.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<div class="social-share social-share--size-{{ $size }} social-share--style-{{ $style }} {{ $class }}">
@foreach ($services as $service)
<a class="social-share-service" style="--color: {{ $service->color }};" href="{{ $service->url() }}" target="_blank" rel="noopener nofollow">
<a class="social-share-service" style="--color: {{ $service->color }};" href="{{ $service->url() }}" target="_blank" rel="noopener nofollow" title="{{ $service->label }}">
{!! $service->icon() !!}
</a>
@endforeach
Expand Down
3 changes: 3 additions & 0 deletions src/ConfiguredSocialShareService.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@

class ConfiguredSocialShareService
{
public string $label;

public string $url;

public string $color;
Expand All @@ -15,6 +17,7 @@ public function __construct(public SocialShare $socialShare, public string $name
}

$this->name = config('social-share.services.'.$this->name.'.name', $name);
$this->label = config('social-share.services.'.$this->name.'.label');
$this->url = config('social-share.services.'.$this->name.'.url');
$this->color = config('social-share.services.'.$this->name.'.color');
}
Expand Down

0 comments on commit cdf5993

Please sign in to comment.