-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'develop' into sf/improve-index-and-show-partners-pages-…
…design
- Loading branch information
Showing
4 changed files
with
46 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
defmodule AtomicWeb.Components.Socials do | ||
@moduledoc false | ||
|
||
use AtomicWeb, :component | ||
|
||
attr :entity, :map, required: true | ||
|
||
def socials(assigns) do | ||
assigns = assign(assigns, :socials_with_values, get_social_values(assigns.entity)) | ||
|
||
~H""" | ||
<div class="grid grid-cols-2 gap-2 md:flex md:flex-row"> | ||
<%= for {social, icon, url_base, social_value} <- @socials_with_values do %> | ||
<%= if social_value do %> | ||
<div class="flex flex-row items-center gap-x-2"> | ||
<img src={"/images/" <> icon} class="h-5 w-5" alt={Atom.to_string(social)} /> | ||
<.link class="capitalize text-blue-500" target="_blank" href={url_base <> social_value}> | ||
<%= Atom.to_string(social) %> | ||
</.link> | ||
</div> | ||
<% end %> | ||
<% end %> | ||
</div> | ||
""" | ||
end | ||
|
||
defp get_social_values(entity) do | ||
get_socials() | ||
|> Enum.map(fn {social, icon, url_base} -> | ||
social_value = Map.get(entity, social) | ||
{social, icon, url_base, social_value} | ||
end) | ||
end | ||
|
||
def get_socials do | ||
[ | ||
{:tiktok, "tiktok.svg", "https://tiktok.com/"}, | ||
{:instagram, "instagram.svg", "https://instagram.com/"}, | ||
{:facebook, "facebook.svg", "https://facebook.com/"}, | ||
{:x, "x.svg", "https://x.com/"} | ||
] | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters