Skip to content

Commit

Permalink
fix menu stories
Browse files Browse the repository at this point in the history
  • Loading branch information
woylie committed Jul 28, 2024
1 parent b76bfdb commit 68da0f7
Show file tree
Hide file tree
Showing 4 changed files with 80 additions and 31 deletions.
30 changes: 23 additions & 7 deletions lib/doggo/storybook/menu_button.ex
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,32 @@ defmodule Doggo.Storybook.MenuButton do
@moduledoc false
alias PhoenixStorybook.Stories.Variation

def template do
def dependent_components, do: [:menu]

def template(opts) do
dependent_components = opts[:dependent_components]
menu_fun = dependent_components[:menu]

menu =
if menu_fun do
"""
<.#{menu_fun} id="actions-menu" labelledby="actions-button" hidden>
<:item>Copy</:item>
<:item>Paste</:item>
<:item role="separator"></:item>
<:item>Sort lines</:item>
</.#{menu_fun}>
"""
else
"""
<p>Please compile the <code>menu</code> component to see a complete preview.</p>
"""
end

"""
<div>
<.psb-variation/>
<Doggo.menu id="actions-menu" labelledby="actions-button" hidden>
<:item>Copy</:item>
<:item>Paste</:item>
<:item role="separator"></:item>
<:item>Sort lines</:item>
</Doggo.menu>
#{menu}
</div>
"""
end
Expand Down
27 changes: 19 additions & 8 deletions lib/doggo/storybook/menu_item.ex
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,25 @@ defmodule Doggo.Storybook.MenuItem do
@moduledoc false
alias PhoenixStorybook.Stories.Variation

def template do
"""
<Doggo.menu label="Actions">
<:item>
<.psb-variation/>
</:item>
</Doggo.menu>
"""
def dependent_components, do: [:menu]

def template(opts) do
dependent_components = opts[:dependent_components]
menu_fun = dependent_components[:menu]

if menu_fun do
"""
<.#{menu_fun} label="Actions">
<:item>
<.psb-variation/>
</:item>
</.#{menu_fun}>
"""
else
"""
<p>Please compile the <code>menu</code> component to see a complete preview.</p>
"""
end
end

def variations(_opts) do
Expand Down
27 changes: 19 additions & 8 deletions lib/doggo/storybook/menu_item_checkbox.ex
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,25 @@ defmodule Doggo.Storybook.MenuItemCheckbox do
@moduledoc false
alias PhoenixStorybook.Stories.Variation

def template do
"""
<Doggo.menu label="Actions">
<:item>
<.psb-variation/>
</:item>
</Doggo.menu>
"""
def dependent_components, do: [:menu]

def template(opts) do
dependent_components = opts[:dependent_components]
menu_fun = dependent_components[:menu]

if menu_fun do
"""
<.menu label="Actions">
<:item>
<.psb-variation/>
</:item>
</.menu>
"""
else
"""
<p>Please compile the <code>menu</code> component to see a complete preview.</p>
"""
end
end

def variations(_opts) do
Expand Down
27 changes: 19 additions & 8 deletions lib/doggo/storybook/menu_item_radio_group.ex
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,25 @@ defmodule Doggo.Storybook.MenuItemRadioGroup do
@moduledoc false
alias PhoenixStorybook.Stories.Variation

def template do
"""
<Doggo.menu label="Actions">
<:item>
<.psb-variation/>
</:item>
</Doggo.menu>
"""
def dependent_components, do: [:menu]

def template(opts) do
dependent_components = opts[:dependent_components]
menu_fun = dependent_components[:menu]

if menu_fun do
"""
<.menu label="Actions">
<:item>
<.psb-variation/>
</:item>
</.menu>
"""
else
"""
<p>Please compile the <code>menu</code> component to see a complete preview.</p>
"""
end
end

def variations(_opts) do
Expand Down

0 comments on commit 68da0f7

Please sign in to comment.