diff --git a/bloom_site/lib/bloom_site_web/components/badge.ex b/bloom_site/lib/bloom_site_web/components/badge.ex
new file mode 100644
index 0000000..c078258
--- /dev/null
+++ b/bloom_site/lib/bloom_site_web/components/badge.ex
@@ -0,0 +1,32 @@
+defmodule BloomSiteWeb.Components.Badge do
+ use Phoenix.Component
+
+ @moduledoc """
+ Badge component
+ """
+
+ attr(:variant, :string, doc: "Badge variant", default: "primary")
+
+ attr(:class, :string, default: "", doc: "Class for badge")
+ attr(:rest, :global)
+
+ slot(:inner_block, required: true)
+
+ def badge(assigns) do
+ ~H"""
+
+ <%= render_slot(@inner_block) %>
+
+ """
+ end
+
+ defp variant_class("primary"), do: "bg-black text-gray-100"
+ defp variant_class("secondary"), do: "bg-white border border-black"
+end
diff --git a/bloom_site/storybook/bloom_components/badge.story.exs b/bloom_site/storybook/bloom_components/badge.story.exs
new file mode 100644
index 0000000..224e7a3
--- /dev/null
+++ b/bloom_site/storybook/bloom_components/badge.story.exs
@@ -0,0 +1,21 @@
+defmodule BloomSite.Storybook.BloomComponents.Badge do
+ use PhoenixStorybook.Story, :component
+
+ def function, do: &BloomSiteWeb.Components.Badge.badge/1
+
+ def variations do
+ [
+ %Variation{
+ id: :primary,
+ slots: ["Badge"]
+ },
+ %Variation{
+ id: :secondary,
+ attributes: %{
+ variant: "secondary"
+ },
+ slots: ["Badge"]
+ }
+ ]
+ end
+end
diff --git a/lib/bloom/components/badge.ex b/lib/bloom/components/badge.ex
new file mode 100644
index 0000000..987aebd
--- /dev/null
+++ b/lib/bloom/components/badge.ex
@@ -0,0 +1,32 @@
+defmodule Bloom.Components.Badge do
+ use Phoenix.Component
+
+ @moduledoc """
+ Badge component
+ """
+
+ attr(:variant, :string, doc: "Badge variant", default: "primary")
+
+ attr(:class, :string, default: "", doc: "Class for badge")
+ attr(:rest, :global)
+
+ slot(:inner_block, required: true)
+
+ def badge(assigns) do
+ ~H"""
+
+ <%= render_slot(@inner_block) %>
+
+ """
+ end
+
+ defp variant_class("primary"), do: "bg-black text-gray-100"
+ defp variant_class("secondary"), do: "bg-white border border-black"
+end
diff --git a/lib/tasks/install.ex b/lib/tasks/install.ex
index 5ec454a..66d2124 100644
--- a/lib/tasks/install.ex
+++ b/lib/tasks/install.ex
@@ -81,7 +81,7 @@ defmodule Mix.Tasks.Bloom.Install do
Mix.shell().info("Usage: mix bloom.install [component_name]")
Mix.shell().info(
- "Available components: avatar | glow_button | code_snippet | hero | gradient_text | bento_grid | card | marquee"
+ "Available components: avatar | glow_button | code_snippet | hero | gradient_text | bento_grid | card | marquee | badge"
)
end
diff --git a/priv/templates/badge.ex b/priv/templates/badge.ex
new file mode 100644
index 0000000..82e8fc5
--- /dev/null
+++ b/priv/templates/badge.ex
@@ -0,0 +1,32 @@
+defmodule <%= @module_name %>Web.Components.Badge do
+ use Phoenix.Component
+
+ @moduledoc """
+ Badge component
+ """
+
+ attr(:variant, :string, doc: "Badge variant", default: "primary")
+
+ attr(:class, :string, default: "", doc: "Class for badge")
+ attr(:rest, :global)
+
+ slot(:inner_block, required: true)
+
+ def badge(assigns) do
+ ~H"""
+
+ <%%= render_slot(@inner_block) %>
+
+ """
+ end
+
+ defp variant_class("primary"), do: "bg-black text-gray-100"
+ defp variant_class("secondary"), do: "bg-white border border-black"
+end
diff --git a/test/tasks/install_test.exs b/test/tasks/install_test.exs
index 56a5a78..6508c4d 100644
--- a/test/tasks/install_test.exs
+++ b/test/tasks/install_test.exs
@@ -39,7 +39,7 @@ defmodule Mix.Tasks.Bloom.InstallTest do
expect(ShellMock, :info, fn msg ->
assert msg ==
- "Available components: avatar | glow_button | code_snippet | hero | gradient_text | bento_grid | card | marquee"
+ "Available components: avatar | glow_button | code_snippet | hero | gradient_text | bento_grid | card | marquee | badge"
end)
Mix.Tasks.Bloom.Install.run(["nonexistent_component"])
@@ -52,7 +52,7 @@ defmodule Mix.Tasks.Bloom.InstallTest do
expect(ShellMock, :info, fn msg ->
assert msg ==
- "Available components: avatar | glow_button | code_snippet | hero | gradient_text | bento_grid | card | marquee"
+ "Available components: avatar | glow_button | code_snippet | hero | gradient_text | bento_grid | card | marquee | badge"
end)
Mix.Tasks.Bloom.Install.run([])