Skip to content

Commit

Permalink
feature: show caption for labels #273
Browse files Browse the repository at this point in the history
  • Loading branch information
nwittstruck committed Mar 28, 2024
1 parent 44f87ad commit 12928e3
Show file tree
Hide file tree
Showing 5 changed files with 47 additions and 2 deletions.
4 changes: 4 additions & 0 deletions lib/mindwendel_web/live/brainstorming_live/show.html.heex
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,10 @@
) %>
<% end %>

<%= live_component(MindwendelWeb.LabelLive.CaptionsComponent,
brainstorming: @brainstorming
) %>

<%= live_component(MindwendelWeb.IdeaLive.IndexComponent,
ideas: @ideas,
brainstorming: @brainstorming,
Expand Down
3 changes: 3 additions & 0 deletions lib/mindwendel_web/live/label_live/captions_component.ex
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
defmodule MindwendelWeb.LabelLive.CaptionsComponent do
use MindwendelWeb, :live_component
end
14 changes: 14 additions & 0 deletions lib/mindwendel_web/live/label_live/captions_component.html.heex
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<div class="d-flex flex-row justify-content-end">
<%= for brainstorming_idea_label <- @brainstorming.labels do %>
<div class="m-1">
<span
class="badge rounded-pill"
id={"idea-label-#{uuid()}"}
data-color={brainstorming_idea_label.color}
phx-hook="SetIdeaLabelBackgroundColor"
>
<%= brainstorming_idea_label.name %>
</span>
</div>
<% end %>
</div>
4 changes: 2 additions & 2 deletions priv/gettext/default.pot
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ msgid "Idea created successfully"
msgstr ""

#: lib/mindwendel_web/live/brainstorming_live/show.html.heex:25
#: lib/mindwendel_web/live/brainstorming_live/show.html.heex:117
#: lib/mindwendel_web/live/brainstorming_live/show.html.heex:121
#, elixir-autogen, elixir-format
msgid "New Idea"
msgstr ""
Expand All @@ -122,7 +122,7 @@ msgstr ""
msgid "No ideas brainstormed"
msgstr ""

#: lib/mindwendel_web/live/brainstorming_live/show.html.heex:120
#: lib/mindwendel_web/live/brainstorming_live/show.html.heex:124
#, elixir-autogen, elixir-format
msgid "Open new idea page (Hotkey: i)"
msgstr ""
Expand Down
24 changes: 24 additions & 0 deletions test/mindwendel_web/live/label_live/captions_test.exs
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
defmodule MindwendelWeb.LabelLive.CaptionsTest do
alias MindwendelWeb.LabelLive.CaptionsComponent
use MindwendelWeb.ConnCase
import Phoenix.LiveViewTest

alias Mindwendel.Factory

setup do
%{brainstorming: Factory.insert!(:brainstorming)}
end

test "captions contain all labels", %{
brainstorming: brainstorming
} do
captions_component = render_component(CaptionsComponent, brainstorming: brainstorming)

# make sure that there is at least one label in the list:
assert Enum.count(brainstorming.labels) > 0

Enum.each(brainstorming.labels, fn label ->
assert captions_component =~ label.name
end)
end
end

0 comments on commit 12928e3

Please sign in to comment.