-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
125 additions
and
0 deletions.
There are no files selected for viewing
28 changes: 28 additions & 0 deletions
28
apps/duskmoon_storybook_web/lib/storybook/components/navbar.story.exs
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,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
97
apps/phoenix_duskmoon/lib/phoenix_duskmoon/component/navbar.ex
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,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 |