Skip to content

Commit

Permalink
feat: Add dm_navbar.
Browse files Browse the repository at this point in the history
  • Loading branch information
GSMLG-BOT committed Feb 12, 2025
1 parent d3ac69d commit a2f525d
Show file tree
Hide file tree
Showing 2 changed files with 125 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
defmodule Storybook.Components.Navbar do
# :live_component or :page are also available
use PhoenixStorybook.Story, :component

def function, do: &PhoenixDuskmoon.Component.Navbar.dm_navbar/1
def description, do: "A navbar element."

def variations do
[
%Variation{
id: :default,
attributes: %{
class: "shadow"
},
slots: [
"""
<:left>
Star Wars
</:left>
<:right>
<button>action</button>
</:right>
"""
]
}
]
end
end
97 changes: 97 additions & 0 deletions apps/phoenix_duskmoon/lib/phoenix_duskmoon/component/navbar.ex
Original file line number Diff line number Diff line change
@@ -0,0 +1,97 @@
defmodule PhoenixDuskmoon.Component.Navbar do
@moduledoc """
Duskmoon UI Navbar Component
"""
use PhoenixDuskmoon.Component, :html

# import PhoenixDuskmoon.Component.Link
# import PhoenixDuskmoon.Component.Icons

@doc """
Generates a navbar.
## Example
<.dm_navbar>
</.dm_navbar>
"""
@doc type: :component
attr(:id, :any,
default: false,
doc: """
html attribute id
"""
)

attr(:class, :any,
default: "",
doc: """
html attribute class
"""
)

attr(:start_class, :any,
default: "",
doc: """
Navbar left part container class
"""
)

attr(:center_class, :any,
default: "",
doc: """
Navbar center part container class
"""
)

attr(:end_class, :any,
default: "",
doc: """
Navbar right part container class
"""
)

slot(:start_part,
required: false,
doc: """
Navbar left part
"""
)

slot(:center_part,
required: false,
doc: """
Navbar center part
"""
)

slot(:end_part,
required: false,
doc: """
Navbar right part
"""
)

def dm_navbar(assigns) do
assigns =
assigns
|> assign_new(:logo, fn -> [] end)
|> assign_new(:user_profile, fn -> [] end)

~H"""
<div id={@id} class={["navbar", @class]}>
<div class={["navbar-start", @start_class]}>
<%= render_slot(@start_part) %>
</div>
<div class={["navbar-center", @center_class]}>
<%= render_slot(@center_part) %>
</div>
<div class={["navbar-end", @end_class]}>
<%= render_slot(@end_part) %>
</div>
</div>
"""
end
end

0 comments on commit a2f525d

Please sign in to comment.