Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: socials component #538

Open
wants to merge 4 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion lib/atomic/uploaders/profile_picture.ex
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ defmodule Atomic.Uploaders.ProfilePicture do
@moduledoc """
Uploader for profile pictures.
"""
use Atomic.Uploader, extensions: ~w(.jpg .jpeg .png .gif)
use Atomic.Uploader, extensions: ~w(.jpg .jpeg .png .gif), max_size: 500
alias Atomic.Accounts.User

@versions [:original]
Expand Down
2 changes: 1 addition & 1 deletion lib/atomic_web/components/sidebar.ex
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,7 @@ defmodule AtomicWeb.Components.Sidebar do

defp user_image(user) do
if user.profile_picture do
Uploaders.ProfilePicture.url({user, user.profile_picture}, :original)
Uploaders.ProfilePicture.url({user.profile_picture, user}, :original)
else
nil
end
Expand Down
29 changes: 29 additions & 0 deletions lib/atomic_web/components/socials.ex
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
defmodule AtomicWeb.Components.Socials do
@moduledoc false
use Phoenix.Component

def socials(assigns) do
~H"""
<%= if @entity.socials do %>
<div class="mt-4 flex gap-4">
<%= for {social, icon, url_base} <- [
{:tiktok, "tiktok.svg", "https://tiktok.com/"},
{:instagram, "instagram.svg", "https://instagram.com/"},
{:facebook, "facebook.svg", "https://facebook.com/"},
{:x, "x.svg", "https://x.com/"}
] do %>
<% social_value = Map.get(@entity.socials, social) %>
<%= if social_value do %>
<div class="flex flex-row items-center gap-x-1">
<img src={"/images/" <> icon} class="h-5 w-5" alt={social |> Atom.to_string() |> String.capitalize()} />
<.link class="text-blue-500" target="_blank" href={url_base <> social_value}>
<%= social |> Atom.to_string() |> String.capitalize() %>
</.link>
</div>
<% end %>
<% end %>
</div>
<% end %>
"""
end
end
1 change: 1 addition & 0 deletions lib/atomic_web/live/partner_live/show.ex
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ defmodule AtomicWeb.PartnerLive.Show do
use AtomicWeb, :live_view

import AtomicWeb.Components.Avatar
import AtomicWeb.Components.Socials

alias Atomic.Accounts
alias Atomic.Organizations
Expand Down
36 changes: 13 additions & 23 deletions lib/atomic_web/live/partner_live/show.html.heex
Original file line number Diff line number Diff line change
Expand Up @@ -21,37 +21,27 @@
</h1>
</div>
<%= if @partner.location do %>
<!-- Localização -->
<div class="flex flex-row items-center gap-x-1 text-md leading-6">
<.icon name="hero-map-pin" class="size-5 text-zinc-400" />
<.link class="text-blue-500" href={"https://www.google.com/maps/search/?api=1&query=#{@partner.location.name}"}><%= @partner.location.name %></.link>
<.icon name="hero-map-pin" class="h-5 w-5 text-zinc-400" />
<.link class="text-blue-500" href={"https://www.google.com/maps/search/?api=1&query=#{@partner.location.name}"}>
<%= @partner.location.name %>
</.link>
</div>
<% end %>

<%= if @partner.socials do %>
<div class="grid grid-cols-2 grid-rows-3 lg:flex lg:flex-row lg:gap-x-4">
<!-- Redes Sociais e Website -->
<div class="flex flex-wrap gap-x-4 items-center mt-2">
<!-- Website -->
<%= if @partner.socials.website do %>
<div class="flex flex-row items-center gap-x-1 ">
<.icon name="hero-globe-alt" class="size-5 text-zinc-400" />
<div class="flex flex-row items-center gap-x-1">
<.icon name="hero-globe-alt" class="h-5 w-5 text-zinc-400" />
<.link class="text-blue-500" href={@partner.socials.website}>Website</.link>
</div>
<% end %>
<%= if @partner.socials.instagram do %>
<div class="flex flex-row items-center gap-x-1 gap-y-0 sm:gap-y-2">
<img src="/images/instagram.svg" class="size-5" alt="Instagram" />
<.link class="text-blue-500" href={"https://instagram.com/" <> @partner.socials.instagram}>Instagram</.link>
</div>
<% end %>
<%= if @partner.socials.facebook do %>
<div class="flex flex-row items-center gap-x-1 gap-y-0 sm:gap-y-2">
<img src="/images/facebook.svg" class="size-5" alt="Facebook" />
<.link class="text-blue-500" href={"https://facebook.com/" <> @partner.socials.facebook}>Facebook</.link>
</div>
<% end %>
<%= if @partner.socials.x do %>
<div class="flex flex-row items-center gap-x-1 gap-y-0 sm:gap-y-2">
<img src="/images/x.svg" class="size-5" alt="X" />
<.link class="text-blue-500" href={"https://x.com/" <> @partner.socials.x}>X</.link>
</div>
<% end %>
<!-- Redes Sociais -->
<.socials entity={@partner} />
</div>
<% end %>
</div>
Expand Down
Loading