Skip to content

Commit

Permalink
add storybook folder to formatter config, format
Browse files Browse the repository at this point in the history
  • Loading branch information
woylie committed Dec 13, 2023
1 parent 354dc13 commit 1a4cb86
Show file tree
Hide file tree
Showing 17 changed files with 93 additions and 76 deletions.
6 changes: 5 additions & 1 deletion .formatter.exs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,11 @@
[
plugins: [Phoenix.LiveView.HTMLFormatter],
import_deps: [:phoenix, :phoenix_live_view],
inputs: ["{mix,.formatter}.exs", "{config,lib,test}/**/*.{heex,ex,exs}"],
inputs: [
"{mix,.formatter}.exs",
"{config,lib,test}/**/*.{heex,ex,exs}",
"priv/storybook/**/*.exs"
],
line_length: 80,
locals_without_parens: [slot: 2]
]
32 changes: 16 additions & 16 deletions priv/storybook/components/action_bar.story.exs
Original file line number Diff line number Diff line change
Expand Up @@ -12,23 +12,23 @@ defmodule Storybook.Components.ActionBar do
since Doggo does not ship with a default icon library.
""",
slots: [
"""
<:item label="Edit" on_click={JS.push("edit")}>
<Doggo.icon size={:small}>Edit</Doggo.icon>
</:item>
""",
"""
<:item label="Move" on_click={JS.push("move")}>
<Doggo.icon size={:small}>Move</Doggo.icon>
</:item>
""",
"""
<:item label="Archive" on_click={JS.push("archive")}>
<Doggo.icon size={:small}>Archive</Doggo.icon>
</:item>
"""
"""
<:item label="Edit" on_click={JS.push("edit")}>
<Doggo.icon size={:small}>Edit</Doggo.icon>
</:item>
""",
"""
<:item label="Move" on_click={JS.push("move")}>
<Doggo.icon size={:small}>Move</Doggo.icon>
</:item>
""",
"""
<:item label="Archive" on_click={JS.push("archive")}>
<Doggo.icon size={:small}>Archive</Doggo.icon>
</:item>
"""
]
}
]
end
end
end
32 changes: 16 additions & 16 deletions priv/storybook/components/app_bar.story.exs
Original file line number Diff line number Diff line change
Expand Up @@ -15,23 +15,23 @@ defmodule Storybook.Components.AppBar do
title: "Page title"
},
slots: [
"""
<:navigation label="Open menu" on_click={JS.push("toggle-menu")}>
<Doggo.icon>Menu</Doggo.icon>
</:navigation>
""",
"""
<:action label="Search" on_click={JS.push("search")}>
<Doggo.icon>Search</Doggo.icon>
</:action>
""",
"""
<:action label="Like" on_click={JS.push("like")}>
<Doggo.icon>Like</Doggo.icon>
</:action>
"""
"""
<:navigation label="Open menu" on_click={JS.push("toggle-menu")}>
<Doggo.icon>Menu</Doggo.icon>
</:navigation>
""",
"""
<:action label="Search" on_click={JS.push("search")}>
<Doggo.icon>Search</Doggo.icon>
</:action>
""",
"""
<:action label="Like" on_click={JS.push("like")}>
<Doggo.icon>Like</Doggo.icon>
</:action>
"""
]
}
]
end
end
end
6 changes: 3 additions & 3 deletions priv/storybook/components/breadcrumb.story.exs
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@ defmodule Storybook.Components.Breadcrumb do
%Variation{
id: :default,
slots: [
~s(<:item patch="/categories">Categories</:item>),
~s(<:item patch="/categories/1">Reviews</:item>),
~s(<:item patch="/categories/1/articles/1">The Movie</:item>)
~s(<:item patch="/categories">Categories</:item>),
~s(<:item patch="/categories/1">Reviews</:item>),
~s(<:item patch="/categories/1/articles/1">The Movie</:item>)
]
}
]
Expand Down
4 changes: 2 additions & 2 deletions priv/storybook/components/button.story.exs
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ defmodule Storybook.Components.Button do
id: :danger_button,
attributes: %{variant: :danger},
slots: ["danger"]
},
}
]
},
%VariationGroup{
Expand Down Expand Up @@ -118,4 +118,4 @@ defmodule Storybook.Components.Button do
}
]
end
end
end
4 changes: 2 additions & 2 deletions priv/storybook/components/button_link.story.exs
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ defmodule Storybook.Components.ButtonLink do
id: :danger_button,
attributes: %{variant: :danger},
slots: ["danger"]
},
}
]
},
%VariationGroup{
Expand Down Expand Up @@ -118,4 +118,4 @@ defmodule Storybook.Components.ButtonLink do
}
]
end
end
end
2 changes: 1 addition & 1 deletion priv/storybook/components/date.story.exs
Original file line number Diff line number Diff line change
Expand Up @@ -30,4 +30,4 @@ defmodule Storybook.Components.Date do
}
]
end
end
end
4 changes: 2 additions & 2 deletions priv/storybook/components/datetime.story.exs
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ defmodule Storybook.Components.Datetime do
value: ~U[2023-02-05 12:22:06.003Z],
precision: :minute
}
},
}
]
end
end
end
5 changes: 3 additions & 2 deletions priv/storybook/components/fallback.story.exs
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,8 @@ defmodule Storybook.Components.Fallback do
id: :with_nil,
attributes: %{
value: nil,
formatter: &DateTime.to_unix/1}
formatter: &DateTime.to_unix/1
}
}
]
},
Expand All @@ -59,4 +60,4 @@ defmodule Storybook.Components.Fallback do
}
]
end
end
end
2 changes: 1 addition & 1 deletion priv/storybook/components/field_description.story.exs
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,4 @@ defmodule Storybook.Components.FieldDescription do
}
]
end
end
end
2 changes: 1 addition & 1 deletion priv/storybook/components/field_errors.story.exs
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,4 @@ defmodule Storybook.Components.FieldErrors do
}
]
end
end
end
2 changes: 1 addition & 1 deletion priv/storybook/components/flash_group.story.exs
Original file line number Diff line number Diff line change
Expand Up @@ -19,4 +19,4 @@ defmodule Storybook.Components.FlashGroup do
}
]
end
end
end
2 changes: 1 addition & 1 deletion priv/storybook/components/label.story.exs
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,4 @@ defmodule Storybook.Components.Label do
}
]
end
end
end
4 changes: 2 additions & 2 deletions priv/storybook/components/property_list.story.exs
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ defmodule Storybook.Components.Icon do
%Variation{
id: :default,
slots: [
~s(<:prop label="Name">George</:prop>),
~s(<:prop label="Age">42</:prop>)
~s(<:prop label="Name">George</:prop>),
~s(<:prop label="Age">42</:prop>)
]
}
]
Expand Down
28 changes: 14 additions & 14 deletions priv/storybook/components/stack.story.exs
Original file line number Diff line number Diff line change
Expand Up @@ -8,25 +8,25 @@ defmodule Storybook.Components.Stack do
%Variation{
id: :default,
slots: [
"""
<div>Hello!</div>
<div>Bye!</div>
"""
]
"""
<div>Hello!</div>
<div>Bye!</div>
"""
]
},
%Variation{
id: :recursive,
attributes: %{recursive: true},
slots: [
"""
<div>
<div>Hello!</div>
<div>Are you good boy?</div>
</div>
<div>Bye!</div>
"""
]
"""
<div>
<div>Hello!</div>
<div>Are you good boy?</div>
</div>
<div>Bye!</div>
"""
]
}
]
end
end
end
2 changes: 1 addition & 1 deletion priv/storybook/components/time.story.exs
Original file line number Diff line number Diff line change
Expand Up @@ -41,4 +41,4 @@ defmodule Storybook.Components.Time do
def format(time) do
"#{time.hour}h #{time.minute}m"
end
end
end
32 changes: 22 additions & 10 deletions priv/storybook/welcome.story.exs
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,12 @@ defmodule Storybook.MyPage do
<div class="lsb-welcome-page">
<p>
We generated your storybook with an example of a page and a component.
Feel free to explore the generated <code class="inline">*.story.exs</code> files generated into your
project folder, and start adding yours: <strong>just drop new story & index files into your
</strong><code class="inline">/storybook</code> <strong>folder</strong> and refresh your storybook.
Feel free to explore the generated <code class="inline">*.story.exs</code>
files generated into your
project folder, and start adding yours:
<strong>just drop new story & index files into your </strong><code class="inline">/storybook</code>
<strong>folder</strong>
and refresh your storybook.
</p>
<p>
Expand All @@ -34,18 +37,18 @@ defmodule Storybook.MyPage do
{"Stories overview", doc_link("Story")},
{"Describe components with Variations", doc_link("Stories.Variation")},
{"And stack them with VariationGroups", doc_link("Stories.VariationGroup")},
{"Pimp your sidebar with Index files", doc_link("Index")},
]}/>
{"Pimp your sidebar with Index files", doc_link("Index")}
]} />
<p>
This should be enough to get you started but you might also <strong>checkout advanced guides
</strong>(tabs in the upper-right corner of this page).
This should be enough to get you started but you might also <strong>checkout advanced guides </strong>(tabs in the upper-right corner of this page).
</p>
</div>
"""
end

def render(assigns = %{tab: guide}) when guide in ~w(components sandboxing icons)a do
def render(assigns = %{tab: guide})
when guide in ~w(components sandboxing icons)a do
assigns =
assign(assigns,
guide: guide,
Expand All @@ -54,7 +57,11 @@ defmodule Storybook.MyPage do

~H"""
<p class="md:lsb-text-lg lsb-leading-relaxed lsb-text-slate-400 lsb-w-full lsb-text-left lsb-mb-4 lsb-mt-2 lsb-italic">
<a class="hover:text-indigo-700" href={"https://hexdocs.pm/phx_live_storybook/#{@guide}.html"} target="_blank">
<a
class="hover:text-indigo-700"
href={"https://hexdocs.pm/phx_live_storybook/#{@guide}.html"}
target="_blank"
>
This guide is also available on Hexdocs among others.
</a>
</p>
Expand All @@ -75,7 +82,12 @@ defmodule Storybook.MyPage do
<%= dt %>
</dt>
<dd class="lsb-mt-1 lsb-text-base lsb-text-slate-400 sm:lsb-col-span-2 sm:lsb-mt-0 lsb-group lsb-cursor-pointer lsb-max-w-full">
<a class="group-hover:lsb-text-indigo-700 lsb-max-w-full lsb-inline-block lsb-truncate" href={link} target="_blank" %>
<a
class="group-hover:lsb-text-indigo-700 lsb-max-w-full lsb-inline-block lsb-truncate"
href={link}
target="_blank"
%
>
<%= link %>
</a>
</dd>
Expand Down

0 comments on commit 1a4cb86

Please sign in to comment.