-
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.
* Basic card * Responsiveness * Ability to set parameters on card * Fix warning * Implement suggestions * Change name * Update seeds
- Loading branch information
1 parent
a1585a9
commit 44ade10
Showing
13 changed files
with
282 additions
and
3 deletions.
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,37 @@ | ||
defmodule Atomic.Organizations.Card do | ||
@moduledoc """ | ||
The membership card for an organization | ||
""" | ||
use Atomic.Schema | ||
import Ecto.Changeset | ||
|
||
@optional_fields [ | ||
:name_size, | ||
:name_color, | ||
:name_x, | ||
:name_y, | ||
:number_size, | ||
:number_color, | ||
:number_x, | ||
:number_y | ||
] | ||
|
||
@primary_key false | ||
embedded_schema do | ||
field :name_size, :float | ||
field :name_color, :string | ||
field :name_x, :float | ||
field :name_y, :float | ||
field :number_size, :float | ||
field :number_color, :string | ||
field :number_x, :float | ||
field :number_y, :float | ||
end | ||
|
||
# TODO: Validations | ||
|
||
def changeset(card, attrs) do | ||
card | ||
|> cast(attrs, @optional_fields) | ||
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
defmodule Atomic.Uploaders.Card do | ||
use Waffle.Definition | ||
use Waffle.Ecto.Definition | ||
alias Atomic.Organizations.Organization | ||
|
||
@versions [:original] | ||
@extension_whitelist ~w(.svg .jpg .jpeg .gif .png) | ||
|
||
def validate({file, _}) do | ||
file.file_name | ||
|> Path.extname() | ||
|> String.downcase() | ||
|> then(&Enum.member?(@extension_whitelist, &1)) | ||
|> case do | ||
true -> :ok | ||
false -> {:error, "invalid file type"} | ||
end | ||
end | ||
|
||
def filename(version, _) do | ||
version | ||
end | ||
|
||
def storage_dir(_version, {_file, %Organization{} = scope}) do | ||
"uploads/atomic/cards/#{scope.id}" | ||
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
defmodule AtomicWeb.CardLive.Show do | ||
use AtomicWeb, :live_view | ||
|
||
alias Atomic.Organizations | ||
alias Atomic.Uploaders | ||
|
||
@impl true | ||
def mount(_params, _session, socket) do | ||
{:ok, socket} | ||
end | ||
|
||
@impl true | ||
def handle_params(%{"membership_id" => id}, _, socket) do | ||
membership = Organizations.get_membership!(id, [:user, :organization]) | ||
|
||
{:noreply, | ||
socket | ||
|> assign(:page_title, page_title(socket.assigns.live_action)) | ||
|> assign(:membership, membership)} | ||
end | ||
|
||
defp page_title(:show), do: "Membership Card" | ||
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
<%= if @membership.organization.card_image != nil do %> | ||
<div class="fixed z-0 top-0 left-0 bg-black w-screen h-screen"></div> | ||
<div | ||
class=" overflow-x-hidden overflow-y-hidden sm:rotate-0 z-50 rotate-90 scale-150 sm:scale-100 fixed top-0 left-0 w-screen h-screen bg-contain bg-center bg-no-repeat" | ||
style={"background-image: url(" <> Uploaders.Card.url({@membership.organization.card_image, @membership.organization}, :original) <> ")"} | ||
> | ||
<p | ||
class="absolute top-1/2 left-1/2 " | ||
style={"font-size: " <> to_string(@membership.organization.card.name_size) <> "vw; color: " <> @membership.organization.card.name_color <> "; transform: translate(" <> to_string(@membership.organization.card.name_x) <> "%, " <> to_string(@membership.organization.card.name_y) <> "%);"} | ||
> | ||
<%= @membership.user.name %> | ||
</p> | ||
<p | ||
class="absolute top-1/2 left-1/2 " | ||
style={"font-size: " <> to_string(@membership.organization.card.number_size) <> "vw; color: " <> @membership.organization.card.number_color <> "; transform: translate(" <> to_string(@membership.organization.card.number_x) <> "%, " <> to_string(@membership.organization.card.number_y) <> "%);"} | ||
> | ||
<%= @membership.number %> | ||
</p> | ||
</div> | ||
<% else %> | ||
<div> | ||
<h1>This organization does not have a membership card</h1> | ||
</div> | ||
<% 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
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,10 @@ | ||
defmodule Atomic.Repo.Migrations.AddCards do | ||
use Ecto.Migration | ||
|
||
def change do | ||
alter table(:organizations) do | ||
add :card_image, :string | ||
add :card, :map, default: %{}, null: true | ||
end | ||
end | ||
end |
Oops, something went wrong.