From 26792ba369f64768da332c90986e82ae2803beb9 Mon Sep 17 00:00:00 2001 From: aagjalpankaj Date: Wed, 11 Sep 2024 23:06:46 +0200 Subject: [PATCH 1/3] feat: social icon for link --- app/Enums/Social.php | 31 +++++++++++++++++++ .../icons/socials/facebook.blade.php | 11 +++++++ .../components/icons/socials/github.blade.php | 9 ++++++ .../icons/socials/instagram.blade.php | 11 +++++++ .../icons/socials/linkedin.blade.php | 9 ++++++ .../icons/socials/stackoverflow.blade.php | 11 +++++++ .../icons/socials/twitter.blade.php | 9 ++++++ .../icons/socials/youtube.blade.php | 11 +++++++ .../components/links/list-item.blade.php | 11 +++++++ 9 files changed, 113 insertions(+) create mode 100644 app/Enums/Social.php create mode 100644 resources/views/components/icons/socials/facebook.blade.php create mode 100644 resources/views/components/icons/socials/github.blade.php create mode 100644 resources/views/components/icons/socials/instagram.blade.php create mode 100644 resources/views/components/icons/socials/linkedin.blade.php create mode 100644 resources/views/components/icons/socials/stackoverflow.blade.php create mode 100644 resources/views/components/icons/socials/twitter.blade.php create mode 100644 resources/views/components/icons/socials/youtube.blade.php diff --git a/app/Enums/Social.php b/app/Enums/Social.php new file mode 100644 index 000000000..de5bb09f1 --- /dev/null +++ b/app/Enums/Social.php @@ -0,0 +1,31 @@ + self::Twitter, + str_contains($url, 'linkedin.com') => self::LinkedIn, + str_contains($url, 'github.com') => self::GitHub, + str_contains($url, 'stackoverflow.com') => self::StackOverflow, + str_contains($url, 'facebook.com') => self::Facebook, + str_contains($url, 'instagram.com') => self::Instagram, + str_contains($url, 'youtube.com') => self::YouTube, + default => null, + }; + } +} diff --git a/resources/views/components/icons/socials/facebook.blade.php b/resources/views/components/icons/socials/facebook.blade.php new file mode 100644 index 000000000..99fa8e834 --- /dev/null +++ b/resources/views/components/icons/socials/facebook.blade.php @@ -0,0 +1,11 @@ + + + + + + + diff --git a/resources/views/components/icons/socials/github.blade.php b/resources/views/components/icons/socials/github.blade.php new file mode 100644 index 000000000..ee7b6b2c6 --- /dev/null +++ b/resources/views/components/icons/socials/github.blade.php @@ -0,0 +1,9 @@ + + + + + diff --git a/resources/views/components/icons/socials/instagram.blade.php b/resources/views/components/icons/socials/instagram.blade.php new file mode 100644 index 000000000..686e88408 --- /dev/null +++ b/resources/views/components/icons/socials/instagram.blade.php @@ -0,0 +1,11 @@ + + + + + + + diff --git a/resources/views/components/icons/socials/linkedin.blade.php b/resources/views/components/icons/socials/linkedin.blade.php new file mode 100644 index 000000000..d89e3e053 --- /dev/null +++ b/resources/views/components/icons/socials/linkedin.blade.php @@ -0,0 +1,9 @@ + + + + + diff --git a/resources/views/components/icons/socials/stackoverflow.blade.php b/resources/views/components/icons/socials/stackoverflow.blade.php new file mode 100644 index 000000000..7c0afd9ce --- /dev/null +++ b/resources/views/components/icons/socials/stackoverflow.blade.php @@ -0,0 +1,11 @@ + + + + + + + diff --git a/resources/views/components/icons/socials/twitter.blade.php b/resources/views/components/icons/socials/twitter.blade.php new file mode 100644 index 000000000..fd7481567 --- /dev/null +++ b/resources/views/components/icons/socials/twitter.blade.php @@ -0,0 +1,9 @@ + + + + + diff --git a/resources/views/components/icons/socials/youtube.blade.php b/resources/views/components/icons/socials/youtube.blade.php new file mode 100644 index 000000000..dd548fe21 --- /dev/null +++ b/resources/views/components/icons/socials/youtube.blade.php @@ -0,0 +1,11 @@ + + + + + + + diff --git a/resources/views/components/links/list-item.blade.php b/resources/views/components/links/list-item.blade.php index a45f1ab04..db34e59f5 100644 --- a/resources/views/components/links/list-item.blade.php +++ b/resources/views/components/links/list-item.blade.php @@ -14,6 +14,17 @@ class="items-center justify-center px-4 font-bold text-white transition duration-300 ease-in-out" >
+ + @php + $social = App\Enums\Social::getSocialFromUrl($link->url); + @endphp + + @if($social!== null) + + @includeIf('components.icons.socials.' . $social->value) + + @endif +

{{ $link->description }}

From df4d9dd1b36793f2458449d4be1a7b5fa6dd0d53 Mon Sep 17 00:00:00 2001 From: aagjalpankaj Date: Thu, 19 Sep 2024 20:04:47 +0200 Subject: [PATCH 2/3] feat: few more icons and refactoring --- app/Enums/Social.php | 7 +++++-- .../components/icons/socials/facebook.blade.php | 13 +++++-------- .../views/components/icons/socials/github.blade.php | 1 - .../components/icons/socials/instagram.blade.php | 13 +++++-------- .../components/icons/socials/linkedin.blade.php | 1 - .../icons/socials/stackoverflow.blade.php | 13 +++++-------- .../components/icons/socials/twitter.blade.php | 1 - .../components/icons/socials/website.blade.php | 7 +++++++ .../components/icons/socials/whatsapp.blade.php | 8 ++++++++ .../components/icons/socials/youtube.blade.php | 13 +++++-------- 10 files changed, 40 insertions(+), 37 deletions(-) create mode 100644 resources/views/components/icons/socials/website.blade.php create mode 100644 resources/views/components/icons/socials/whatsapp.blade.php diff --git a/app/Enums/Social.php b/app/Enums/Social.php index de5bb09f1..6ad573904 100644 --- a/app/Enums/Social.php +++ b/app/Enums/Social.php @@ -13,8 +13,10 @@ enum Social: string case Facebook = 'facebook'; case Instagram = 'instagram'; case YouTube = 'youtube'; + case WhatsApp = 'whatsapp'; + case Website = 'website'; - public static function getSocialFromUrl(string $url): ?self + public static function getSocialFromUrl(string $url): self { return match (true) { str_contains($url, 'twitter.com'), @@ -25,7 +27,8 @@ public static function getSocialFromUrl(string $url): ?self str_contains($url, 'facebook.com') => self::Facebook, str_contains($url, 'instagram.com') => self::Instagram, str_contains($url, 'youtube.com') => self::YouTube, - default => null, + str_contains($url, 'whatsapp.com') => self::WhatsApp, + default => self::Website, }; } } diff --git a/resources/views/components/icons/socials/facebook.blade.php b/resources/views/components/icons/socials/facebook.blade.php index 99fa8e834..683ca143a 100644 --- a/resources/views/components/icons/socials/facebook.blade.php +++ b/resources/views/components/icons/socials/facebook.blade.php @@ -1,11 +1,8 @@ - - - + - - + diff --git a/resources/views/components/icons/socials/github.blade.php b/resources/views/components/icons/socials/github.blade.php index ee7b6b2c6..39268fdc0 100644 --- a/resources/views/components/icons/socials/github.blade.php +++ b/resources/views/components/icons/socials/github.blade.php @@ -1,4 +1,3 @@ - - - + - - + diff --git a/resources/views/components/icons/socials/linkedin.blade.php b/resources/views/components/icons/socials/linkedin.blade.php index d89e3e053..b9169c1b5 100644 --- a/resources/views/components/icons/socials/linkedin.blade.php +++ b/resources/views/components/icons/socials/linkedin.blade.php @@ -1,4 +1,3 @@ - - - + - - + diff --git a/resources/views/components/icons/socials/twitter.blade.php b/resources/views/components/icons/socials/twitter.blade.php index fd7481567..14cb0f1ab 100644 --- a/resources/views/components/icons/socials/twitter.blade.php +++ b/resources/views/components/icons/socials/twitter.blade.php @@ -1,4 +1,3 @@ - + + diff --git a/resources/views/components/icons/socials/whatsapp.blade.php b/resources/views/components/icons/socials/whatsapp.blade.php new file mode 100644 index 000000000..d8c4f9f25 --- /dev/null +++ b/resources/views/components/icons/socials/whatsapp.blade.php @@ -0,0 +1,8 @@ + + + + diff --git a/resources/views/components/icons/socials/youtube.blade.php b/resources/views/components/icons/socials/youtube.blade.php index dd548fe21..1640745f8 100644 --- a/resources/views/components/icons/socials/youtube.blade.php +++ b/resources/views/components/icons/socials/youtube.blade.php @@ -1,11 +1,8 @@ - - - + - - + From 4f4b4b5ca25cf782151f9e5017fb9217c8837784 Mon Sep 17 00:00:00 2001 From: aagjalpankaj Date: Thu, 19 Sep 2024 21:03:09 +0200 Subject: [PATCH 3/3] feat: few more icons and refactoring --- .../views/components/icons/socials/website.blade.php | 8 ++------ resources/views/components/links/list-item.blade.php | 12 +++--------- 2 files changed, 5 insertions(+), 15 deletions(-) diff --git a/resources/views/components/icons/socials/website.blade.php b/resources/views/components/icons/socials/website.blade.php index d26151886..307bce694 100644 --- a/resources/views/components/icons/socials/website.blade.php +++ b/resources/views/components/icons/socials/website.blade.php @@ -1,7 +1,3 @@ - - + + diff --git a/resources/views/components/links/list-item.blade.php b/resources/views/components/links/list-item.blade.php index db34e59f5..64639b3f0 100644 --- a/resources/views/components/links/list-item.blade.php +++ b/resources/views/components/links/list-item.blade.php @@ -15,15 +15,9 @@ class="items-center justify-center px-4 font-bold text-white transition duration >
- @php - $social = App\Enums\Social::getSocialFromUrl($link->url); - @endphp - - @if($social!== null) - - @includeIf('components.icons.socials.' . $social->value) - - @endif + + @include('components.icons.socials.' . App\Enums\Social::getSocialFromUrl($link->url)->value) +

{{ $link->description }}