-
Notifications
You must be signed in to change notification settings - Fork 13
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
storybook: Add storybook and stories for route symbols #2228
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
/* This is your custom storybook stylesheet. */ | ||
@import "tailwindcss/base"; | ||
@import "tailwindcss/components"; | ||
@import "tailwindcss/utilities"; | ||
|
||
/* | ||
* Put your component styling within the Tailwind utilities layer. | ||
* See the https://hexdocs.pm/phoenix_storybook/sandboxing.html guide for more info. | ||
*/ | ||
|
||
@layer utilities { | ||
* { | ||
font-family: system-ui; | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
// If your components require any hooks or custom uploaders, or if your pages | ||
// require connect parameters, uncomment the following lines and declare them as | ||
// such: | ||
// | ||
// import * as Hooks from "./hooks"; | ||
// import * as Params from "./params"; | ||
// import * as Uploaders from "./uploaders"; | ||
|
||
// (function () { | ||
// window.storybook = { Hooks, Params, Uploaders }; | ||
// })(); | ||
|
||
// If your components require alpinejs, you'll need to start | ||
// alpine after the DOM is loaded and pass in an onBeforeElUpdated | ||
// | ||
// import Alpine from 'alpinejs' | ||
// window.Alpine = Alpine | ||
// document.addEventListener('DOMContentLoaded', () => { | ||
// window.Alpine.start(); | ||
// }); | ||
|
||
// (function () { | ||
// window.storybook = { | ||
// LiveSocketOptions: { | ||
// dom: { | ||
// onBeforeElUpdated(from, to) { | ||
// if (from._x_dataStack) { | ||
// window.Alpine.clone(from, to) | ||
// } | ||
// } | ||
// } | ||
// } | ||
// }; | ||
// })(); |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,6 +4,8 @@ defmodule DotcomWeb.Router do | |
use DotcomWeb, :router | ||
use Plug.ErrorHandler | ||
|
||
import PhoenixStorybook.Router | ||
|
||
alias DotcomWeb.ControllerHelpers | ||
|
||
@impl Plug.ErrorHandler | ||
|
@@ -314,6 +316,16 @@ defmodule DotcomWeb.Router do | |
get("/about_the_mbta/news_events", Redirector, to: "/news") | ||
end | ||
|
||
scope "/" do | ||
storybook_assets() | ||
end | ||
|
||
scope "/", DotcomWeb do | ||
# pipe_through([:secure, :browser, :browser_live, :basic_auth]) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Did you mean to use this line? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. In any case just wanted to flag that this is not behind basic auth! |
||
pipe_through(:browser) | ||
live_storybook("/storybook", backend_module: Elixir.DotcomWeb.Storybook) | ||
end | ||
|
||
scope "/", DotcomWeb do | ||
pipe_through([:secure, :browser]) | ||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
defmodule DotcomWeb.Storybook do | ||
use PhoenixStorybook, | ||
otp_app: :dotcom_web, | ||
content_path: Path.expand("../../storybook", __DIR__), | ||
# assets path are remote path, not local file-system paths | ||
css_path: "/assets/storybook.css", | ||
js_path: "/assets/storybook.js", | ||
sandbox_class: "dotcom-web" | ||
end |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -24,6 +24,7 @@ defmodule DotCom.Mixfile do | |
ignore_warnings: ".dialyzer.ignore-warnings" | ||
], | ||
deps: deps(), | ||
aliases: aliases(), | ||
|
||
# docs | ||
name: "MBTA Website", | ||
|
@@ -84,6 +85,7 @@ defmodule DotCom.Mixfile do | |
{:ecto, "3.12.4"}, | ||
{:eflame, "1.0.1", only: :dev}, | ||
{:ehmon, [github: "mbta/ehmon", only: :prod]}, | ||
{:esbuild, "~> 0.8", runtime: Mix.env() == :dev}, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'm curious if this effects whether the build works for prod? |
||
{:ex_doc, "0.34.2", only: :dev}, | ||
{:ex_machina, "2.8.0", only: [:dev, :test]}, | ||
{:ex_unit_summary, "0.1.0", only: [:dev, :test]}, | ||
|
@@ -124,6 +126,7 @@ defmodule DotCom.Mixfile do | |
# currently release candidate, but used in Phoenix 1.7 generator: https://github.com/phoenix-diff/phoenix-diff/blob/f320791d24bc3248fbdde557978235829313aa06/priv/data/sample-app/1.7.14/default/mix.exs#L42 | ||
{:phoenix_live_view, "~> 1.0.0-rc.6", override: true}, | ||
{:phoenix_pubsub, "2.1.3"}, | ||
{:phoenix_storybook, "~> 0.6.0"}, | ||
{:phoenix_view, "~> 2.0"}, | ||
{:plug, "1.16.1"}, | ||
{:plug_cowboy, "2.7.2"}, | ||
|
@@ -143,6 +146,7 @@ defmodule DotCom.Mixfile do | |
{:server_sent_event_stage, "1.2.1"}, | ||
{:sizeable, "1.0.2"}, | ||
{:sweet_xml, "0.7.4", only: [:dev, :prod]}, | ||
{:tailwind, "~> 0.2.0", runtime: Mix.env() == :dev}, | ||
{:telemetry, "1.3.0", override: true}, | ||
{:telemetry_metrics, "1.0.0", override: true}, | ||
{:telemetry_metrics_splunk, "0.0.6-alpha"}, | ||
|
@@ -157,4 +161,16 @@ defmodule DotCom.Mixfile do | |
{:ymlr, "5.1.3", only: [:dev]} | ||
] | ||
end | ||
|
||
defp aliases do | ||
[ | ||
setup: ["deps.get", "assets.setup", "assets.build"], | ||
"assets.deploy": [ | ||
"tailwind storybook --minify", | ||
"phx.digest" | ||
], | ||
"assets.setup": ["tailwind.install --if-missing", "esbuild.install --if-missing"], | ||
"assets.build": ["tailwind default", "esbuild default"] | ||
] | ||
end | ||
end |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
defmodule Storybook.Root do | ||
# See https://hexdocs.pm/phoenix_storybook/PhoenixStorybook.Index.html for full index | ||
# documentation. | ||
|
||
use PhoenixStorybook.Index | ||
|
||
def folder_icon, do: {:fa, "book-open", :light, "psb-mr-1"} | ||
def folder_name, do: "Storybook" | ||
|
||
def entry("welcome") do | ||
[ | ||
name: "Welcome Page", | ||
icon: {:fa, "hand-wave", :thin} | ||
] | ||
end | ||
end |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Did you want to delete this?