From 1908d8ee6a9f128d1d622f7449349f87121a5f92 Mon Sep 17 00:00:00 2001 From: Tiago Moraes Date: Thu, 8 Feb 2024 11:58:36 -0300 Subject: [PATCH 1/6] update deps --- mix.exs | 7 ++++--- mix.lock | 11 ++++++----- 2 files changed, 10 insertions(+), 8 deletions(-) diff --git a/mix.exs b/mix.exs index 2ad7de1..41b7772 100644 --- a/mix.exs +++ b/mix.exs @@ -33,17 +33,18 @@ defmodule SurfaceSite.MixProject do # Type `mix help deps` for examples and options. defp deps do [ - {:surface, "~> 0.11.1"}, + {:surface, "~> 0.11", github: "surface-ui/surface", override: true}, + {:phoenix, "1.7.10"}, {:surface_markdown, "~> 0.6.1"}, {:nimble_publisher, "~> 0.1.2"}, {:html_entities, "~> 0.5"}, - {:phoenix, "1.7.7"}, {:phoenix_live_reload, "~> 1.2", only: :dev}, {:floki, ">= 0.30.0", only: :test}, - {:esbuild, "~> 0.7", runtime: Mix.env() == :dev}, + {:esbuild, "~> 0.8", runtime: Mix.env() == :dev}, # TODO: Tailwind # {:tailwind, "~> 0.2.0", runtime: Mix.env() == :dev}, {:jason, "~> 1.2"}, + {:dns_cluster, "~> 0.1.1"}, {:plug_cowboy, "~> 2.5"} ] end diff --git a/mix.lock b/mix.lock index b9047b2..0be34fc 100644 --- a/mix.lock +++ b/mix.lock @@ -3,6 +3,7 @@ "cowboy": {:hex, :cowboy, "2.10.0", "ff9ffeff91dae4ae270dd975642997afe2a1179d94b1887863e43f681a203e26", [:make, :rebar3], [{:cowlib, "2.12.1", [hex: :cowlib, repo: "hexpm", optional: false]}, {:ranch, "1.8.0", [hex: :ranch, repo: "hexpm", optional: false]}], "hexpm", "3afdccb7183cc6f143cb14d3cf51fa00e53db9ec80cdcd525482f5e99bc41d6b"}, "cowboy_telemetry": {:hex, :cowboy_telemetry, "0.4.0", "f239f68b588efa7707abce16a84d0d2acf3a0f50571f8bb7f56a15865aae820c", [:rebar3], [{:cowboy, "~> 2.7", [hex: :cowboy, repo: "hexpm", optional: false]}, {:telemetry, "~> 1.0", [hex: :telemetry, repo: "hexpm", optional: false]}], "hexpm", "7d98bac1ee4565d31b62d59f8823dfd8356a169e7fcbb83831b8a5397404c9de"}, "cowlib": {:hex, :cowlib, "2.12.1", "a9fa9a625f1d2025fe6b462cb865881329b5caff8f1854d1cbc9f9533f00e1e1", [:make, :rebar3], [], "hexpm", "163b73f6367a7341b33c794c4e88e7dbfe6498ac42dcd69ef44c5bc5507c8db0"}, + "dns_cluster": {:hex, :dns_cluster, "0.1.3", "0bc20a2c88ed6cc494f2964075c359f8c2d00e1bf25518a6a6c7fd277c9b0c66", [:mix], [], "hexpm", "46cb7c4a1b3e52c7ad4cbe33ca5079fbde4840dedeafca2baf77996c2da1bc33"}, "earmark": {:hex, :earmark, "1.4.46", "8c7287bd3137e99d26ae4643e5b7ef2129a260e3dcf41f251750cb4563c8fb81", [:mix], [], "hexpm", "798d86db3d79964e759ddc0c077d5eb254968ed426399fbf5a62de2b5ff8910a"}, "esbuild": {:hex, :esbuild, "0.8.1", "0cbf919f0eccb136d2eeef0df49c4acf55336de864e63594adcea3814f3edf41", [:mix], [{:castore, ">= 0.0.0", [hex: :castore, repo: "hexpm", optional: false]}, {:jason, "~> 1.4", [hex: :jason, repo: "hexpm", optional: false]}], "hexpm", "25fc876a67c13cb0a776e7b5d7974851556baeda2085296c14ab48555ea7560f"}, "file_system": {:hex, :file_system, "0.2.10", "fb082005a9cd1711c05b5248710f8826b02d7d1784e7c3451f9c1231d4fc162d", [:mix], [], "hexpm", "41195edbfb562a593726eda3b3e8b103a309b733ad25f3d642ba49696bf715dc"}, @@ -13,18 +14,18 @@ "mime": {:hex, :mime, "2.0.5", "dc34c8efd439abe6ae0343edbb8556f4d63f178594894720607772a041b04b02", [:mix], [], "hexpm", "da0d64a365c45bc9935cc5c8a7fc5e49a0e0f9932a761c55d6c52b142780a05c"}, "nimble_parsec": {:hex, :nimble_parsec, "1.4.0", "51f9b613ea62cfa97b25ccc2c1b4216e81df970acd8e16e8d1bdc58fef21370d", [:mix], [], "hexpm", "9c565862810fb383e9838c1dd2d7d2c437b3d13b267414ba6af33e50d2d1cf28"}, "nimble_publisher": {:hex, :nimble_publisher, "0.1.3", "ee856171ce221662009aecac709f96ed6339d7a6c1da43db7bb75a5016e4848f", [:mix], [{:earmark, "~> 1.4", [hex: :earmark, repo: "hexpm", optional: false]}, {:makeup, "~> 1.0", [hex: :makeup, repo: "hexpm", optional: false]}], "hexpm", "dbcf800c4567d7bb71bb985781d70a55af134f1353c3a49b609d7ca679280e1e"}, - "phoenix": {:hex, :phoenix, "1.7.7", "4cc501d4d823015007ba3cdd9c41ecaaf2ffb619d6fb283199fa8ddba89191e0", [:mix], [{:castore, ">= 0.0.0", [hex: :castore, repo: "hexpm", optional: false]}, {:jason, "~> 1.0", [hex: :jason, repo: "hexpm", optional: true]}, {:phoenix_pubsub, "~> 2.1", [hex: :phoenix_pubsub, repo: "hexpm", optional: false]}, {:phoenix_template, "~> 1.0", [hex: :phoenix_template, repo: "hexpm", optional: false]}, {:phoenix_view, "~> 2.0", [hex: :phoenix_view, repo: "hexpm", optional: true]}, {:plug, "~> 1.14", [hex: :plug, repo: "hexpm", optional: false]}, {:plug_cowboy, "~> 2.6", [hex: :plug_cowboy, repo: "hexpm", optional: true]}, {:plug_crypto, "~> 1.2", [hex: :plug_crypto, repo: "hexpm", optional: false]}, {:telemetry, "~> 0.4 or ~> 1.0", [hex: :telemetry, repo: "hexpm", optional: false]}, {:websock_adapter, "~> 0.5.3", [hex: :websock_adapter, repo: "hexpm", optional: false]}], "hexpm", "8966e15c395e5e37591b6ed0bd2ae7f48e961f0f60ac4c733f9566b519453085"}, + "phoenix": {:hex, :phoenix, "1.7.10", "02189140a61b2ce85bb633a9b6fd02dff705a5f1596869547aeb2b2b95edd729", [:mix], [{:castore, ">= 0.0.0", [hex: :castore, repo: "hexpm", optional: false]}, {:jason, "~> 1.0", [hex: :jason, repo: "hexpm", optional: true]}, {:phoenix_pubsub, "~> 2.1", [hex: :phoenix_pubsub, repo: "hexpm", optional: false]}, {:phoenix_template, "~> 1.0", [hex: :phoenix_template, repo: "hexpm", optional: false]}, {:phoenix_view, "~> 2.0", [hex: :phoenix_view, repo: "hexpm", optional: true]}, {:plug, "~> 1.14", [hex: :plug, repo: "hexpm", optional: false]}, {:plug_cowboy, "~> 2.6", [hex: :plug_cowboy, repo: "hexpm", optional: true]}, {:plug_crypto, "~> 1.2 or ~> 2.0", [hex: :plug_crypto, repo: "hexpm", optional: false]}, {:telemetry, "~> 0.4 or ~> 1.0", [hex: :telemetry, repo: "hexpm", optional: false]}, {:websock_adapter, "~> 0.5.3", [hex: :websock_adapter, repo: "hexpm", optional: false]}], "hexpm", "cf784932e010fd736d656d7fead6a584a4498efefe5b8227e9f383bf15bb79d0"}, "phoenix_html": {:hex, :phoenix_html, "3.3.3", "380b8fb45912b5638d2f1d925a3771b4516b9a78587249cabe394e0a5d579dc9", [:mix], [{:plug, "~> 1.5", [hex: :plug, repo: "hexpm", optional: true]}], "hexpm", "923ebe6fec6e2e3b3e569dfbdc6560de932cd54b000ada0208b5f45024bdd76c"}, "phoenix_live_reload": {:hex, :phoenix_live_reload, "1.4.1", "2aff698f5e47369decde4357ba91fc9c37c6487a512b41732818f2204a8ef1d3", [:mix], [{:file_system, "~> 0.2.1 or ~> 0.3", [hex: :file_system, repo: "hexpm", optional: false]}, {:phoenix, "~> 1.4", [hex: :phoenix, repo: "hexpm", optional: false]}], "hexpm", "9bffb834e7ddf08467fe54ae58b5785507aaba6255568ae22b4d46e2bb3615ab"}, - "phoenix_live_view": {:hex, :phoenix_live_view, "0.19.5", "6e730595e8e9b8c5da230a814e557768828fd8dfeeb90377d2d8dbb52d4ec00a", [:mix], [{:jason, "~> 1.0", [hex: :jason, repo: "hexpm", optional: true]}, {:phoenix, "~> 1.6.15 or ~> 1.7.0", [hex: :phoenix, repo: "hexpm", optional: false]}, {:phoenix_html, "~> 3.3", [hex: :phoenix_html, repo: "hexpm", optional: false]}, {:phoenix_template, "~> 1.0", [hex: :phoenix_template, repo: "hexpm", optional: false]}, {:phoenix_view, "~> 2.0", [hex: :phoenix_view, repo: "hexpm", optional: true]}, {:telemetry, "~> 0.4.2 or ~> 1.0", [hex: :telemetry, repo: "hexpm", optional: false]}], "hexpm", "b2eaa0dd3cfb9bd7fb949b88217df9f25aed915e986a28ad5c8a0d054e7ca9d3"}, + "phoenix_live_view": {:hex, :phoenix_live_view, "0.20.5", "6207acfdc6a824327d8d55c59b9c3398c0ddeac8935501ac0686921ad30482f3", [:mix], [{:jason, "~> 1.0", [hex: :jason, repo: "hexpm", optional: true]}, {:phoenix, "~> 1.6.15 or ~> 1.7.0", [hex: :phoenix, repo: "hexpm", optional: false]}, {:phoenix_html, "~> 3.3 or ~> 4.0", [hex: :phoenix_html, repo: "hexpm", optional: false]}, {:phoenix_template, "~> 1.0", [hex: :phoenix_template, repo: "hexpm", optional: false]}, {:phoenix_view, "~> 2.0", [hex: :phoenix_view, repo: "hexpm", optional: true]}, {:plug, "~> 1.15", [hex: :plug, repo: "hexpm", optional: false]}, {:telemetry, "~> 0.4.2 or ~> 1.0", [hex: :telemetry, repo: "hexpm", optional: false]}], "hexpm", "2c4d28e91f531a48e24a0ae2b24aad3d56ad122ddd424d2e220070dd9930f0c4"}, "phoenix_pubsub": {:hex, :phoenix_pubsub, "2.1.3", "3168d78ba41835aecad272d5e8cd51aa87a7ac9eb836eabc42f6e57538e3731d", [:mix], [], "hexpm", "bba06bc1dcfd8cb086759f0edc94a8ba2bc8896d5331a1e2c2902bf8e36ee502"}, "phoenix_template": {:hex, :phoenix_template, "1.0.4", "e2092c132f3b5e5b2d49c96695342eb36d0ed514c5b252a77048d5969330d639", [:mix], [{:phoenix_html, "~> 2.14.2 or ~> 3.0 or ~> 4.0", [hex: :phoenix_html, repo: "hexpm", optional: true]}], "hexpm", "2c0c81f0e5c6753faf5cca2f229c9709919aba34fab866d3bc05060c9c444206"}, "plug": {:hex, :plug, "1.15.3", "712976f504418f6dff0a3e554c40d705a9bcf89a7ccef92fc6a5ef8f16a30a97", [:mix], [{:mime, "~> 1.0 or ~> 2.0", [hex: :mime, repo: "hexpm", optional: false]}, {:plug_crypto, "~> 1.1.1 or ~> 1.2 or ~> 2.0", [hex: :plug_crypto, repo: "hexpm", optional: false]}, {:telemetry, "~> 0.4.3 or ~> 1.0", [hex: :telemetry, repo: "hexpm", optional: false]}], "hexpm", "cc4365a3c010a56af402e0809208873d113e9c38c401cabd88027ef4f5c01fd2"}, "plug_cowboy": {:hex, :plug_cowboy, "2.7.0", "3ae9369c60641084363b08fe90267cbdd316df57e3557ea522114b30b63256ea", [:mix], [{:cowboy, "~> 2.7.0 or ~> 2.8.0 or ~> 2.9.0 or ~> 2.10.0", [hex: :cowboy, repo: "hexpm", optional: false]}, {:cowboy_telemetry, "~> 0.3", [hex: :cowboy_telemetry, repo: "hexpm", optional: false]}, {:plug, "~> 1.14", [hex: :plug, repo: "hexpm", optional: false]}], "hexpm", "d85444fb8aa1f2fc62eabe83bbe387d81510d773886774ebdcb429b3da3c1a4a"}, - "plug_crypto": {:hex, :plug_crypto, "1.2.5", "918772575e48e81e455818229bf719d4ab4181fcbf7f85b68a35620f78d89ced", [:mix], [], "hexpm", "26549a1d6345e2172eb1c233866756ae44a9609bd33ee6f99147ab3fd87fd842"}, + "plug_crypto": {:hex, :plug_crypto, "2.0.0", "77515cc10af06645abbfb5e6ad7a3e9714f805ae118fa1a70205f80d2d70fe73", [:mix], [], "hexpm", "53695bae57cc4e54566d993eb01074e4d894b65a3766f1c43e2c61a1b0f45ea9"}, "ranch": {:hex, :ranch, "1.8.0", "8c7a100a139fd57f17327b6413e4167ac559fbc04ca7448e9be9057311597a1d", [:make, :rebar3], [], "hexpm", "49fbcfd3682fab1f5d109351b61257676da1a2fdbe295904176d5e521a2ddfe5"}, - "sourceror": {:hex, :sourceror, "0.12.3", "a2ad3a1a4554b486d8a113ae7adad5646f938cad99bf8bfcef26dc0c88e8fade", [:mix], [], "hexpm", "4d4e78010ca046524e8194ffc4683422f34a96f6b82901abbb45acc79ace0316"}, - "surface": {:hex, :surface, "0.11.1", "67fed94c1ca8e0ed2e0871beddb8be7cbb0aa9792ede5f2812ed61da438ea275", [:mix], [{:jason, "~> 1.0", [hex: :jason, repo: "hexpm", optional: false]}, {:phoenix_live_view, "~> 0.19.0", [hex: :phoenix_live_view, repo: "hexpm", optional: false]}, {:sourceror, "~> 0.12.0", [hex: :sourceror, repo: "hexpm", optional: false]}], "hexpm", "5e7068f51117b7f1aa1c098a6b724b5575e663af4b8f563c5ccd9ddace639222"}, + "sourceror": {:hex, :sourceror, "1.0.1", "ec2c41726d181adce888ac94b3f33b359a811b46e019c084509e02c70042e424", [:mix], [], "hexpm", "28225464ffd68bda1843c974f3ff7ccef35e29be09a65dfe8e3df3f7e3600c57"}, + "surface": {:git, "https://github.com/surface-ui/surface.git", "ff39d25153c54bc459045e0b1692599721e8c64a", []}, "surface_markdown": {:hex, :surface_markdown, "0.6.1", "c6a2eb9dedb978b3099b0c2721bc1f6f3d767dbf92b660dad29a3882878c9769", [:mix], [{:earmark, "~> 1.4", [hex: :earmark, repo: "hexpm", optional: false]}, {:jason, "~> 1.0", [hex: :jason, repo: "hexpm", optional: false]}, {:surface, "~> 0.8", [hex: :surface, repo: "hexpm", optional: false]}], "hexpm", "6f871737aabeef400a9b6e55c7ce47542bccc7dfd028c18303c5a8707d74c176"}, "telemetry": {:hex, :telemetry, "1.2.1", "68fdfe8d8f05a8428483a97d7aab2f268aaff24b49e0f599faa091f1d4e7f61c", [:rebar3], [], "hexpm", "dad9ce9d8effc621708f99eac538ef1cbe05d6a874dd741de2e689c47feafed5"}, "websock": {:hex, :websock, "0.5.3", "2f69a6ebe810328555b6fe5c831a851f485e303a7c8ce6c5f675abeb20ebdadc", [:mix], [], "hexpm", "6105453d7fac22c712ad66fab1d45abdf049868f253cf719b625151460b8b453"}, From d533613635fbc25ef77376f9be0e15314ce39e54 Mon Sep 17 00:00:00 2001 From: Tiago Moraes Date: Thu, 8 Feb 2024 12:02:01 -0300 Subject: [PATCH 2/6] fix warnings about using variables in template and undefined assigns (data) --- .../components/component_info.ex | 25 ++++++++++++++----- 1 file changed, 19 insertions(+), 6 deletions(-) diff --git a/lib/surface_site_web/components/component_info.ex b/lib/surface_site_web/components/component_info.ex index 9ac2549..21b3515 100644 --- a/lib/surface_site_web/components/component_info.ex +++ b/lib/surface_site_web/components/component_info.ex @@ -28,6 +28,12 @@ defmodule SurfaceSiteWeb.Components.ComponentInfo do :before_docs ] + data id, :string + data full_module_name, :string + data module_summary, :string + data module_doc, :string + data module_name, :string + @doc "The examples for the component" slot examples @@ -44,22 +50,29 @@ defmodule SurfaceSiteWeb.Components.ComponentInfo do {module_summary, module_doc} = fetch_module_doc(assigns.module) id = "ComponentInfo_#{module_name}" + assigns = + assigns + |> assign(:id, id) + |> assign(:full_module_name, full_module_name) + |> assign(:module_summary, module_summary) + |> assign(:module_doc, module_doc) + |> assign(:module_name, module_name) ~F""" -
-

{@title || full_module_name}

- {String.trim_trailing(module_summary || "", ".") |> Markdown.to_html(class: "subtitle")} +
+

{@title || @full_module_name}

+ {String.trim_trailing(@module_summary || "", ".") |> Markdown.to_html(class: "subtitle")}
<#slot {@examples} />
- {module_doc |> Markdown.to_html()} + {@module_doc |> Markdown.to_html()}
-
+
<#slot {@examples} />

- +
""" From b2e056e867fb9569a006c380bd8ffc0830689da3 Mon Sep 17 00:00:00 2001 From: Tiago Moraes Date: Thu, 8 Feb 2024 12:20:00 -0300 Subject: [PATCH 3/6] align with phx_new 1.7.10 --- assets/tailwind.config.js | 8 +- config/config.exs | 1 + config/dev.exs | 3 + config/runtime.exs | 2 + config/test.exs | 3 - lib/surface_site/application.ex | 4 +- .../components/core_components.ex | 75 +++++++++++-------- 7 files changed, 54 insertions(+), 42 deletions(-) diff --git a/assets/tailwind.config.js b/assets/tailwind.config.js index b779942..cce04c4 100644 --- a/assets/tailwind.config.js +++ b/assets/tailwind.config.js @@ -9,9 +9,9 @@ // module.exports = { // content: [ // "./js/**/*.js", -// "../lib/*_web.ex", -// "../lib/*_web/**/*.*ex", -// "../lib/*_web/**/*.sface", +// "../lib/surface_site_web.ex", +// "../lib/surface_site_web/**/*.*ex", +// "../lib/surface_site_web/**/*.sface", // "../priv/catalogue/**/*.{ex,sface}" // ], // theme: { @@ -45,7 +45,7 @@ // ["-mini", "/20/solid"] // ] // icons.forEach(([suffix, dir]) => { -// fs.readdirSync(path.join(iconsDir, dir)).map(file => { +// fs.readdirSync(path.join(iconsDir, dir)).forEach(file => { // let name = path.basename(file, ".svg") + suffix // values[name] = {name, fullPath: path.join(iconsDir, dir, file)} // }) diff --git a/config/config.exs b/config/config.exs index 49b7b0c..d0b0244 100644 --- a/config/config.exs +++ b/config/config.exs @@ -27,6 +27,7 @@ config :surface, :components, [ # Configures the endpoint config :surface_site, SurfaceSiteWeb.Endpoint, url: [host: "localhost"], + adapter: Phoenix.Endpoint.Cowboy2Adapter, render_errors: [ formats: [html: SurfaceSiteWeb.ErrorHTML, json: SurfaceSiteWeb.ErrorJSON], layout: false diff --git a/config/dev.exs b/config/dev.exs index 3db7c95..cd8acb1 100644 --- a/config/dev.exs +++ b/config/dev.exs @@ -63,3 +63,6 @@ config :phoenix, :stacktrace_depth, 20 # Initialize plugs at runtime for faster development compilation config :phoenix, :plug_init_mode, :runtime + +# Include HEEx debug annotations as HTML comments in rendered markup +config :phoenix_live_view, :debug_heex_annotations, true diff --git a/config/runtime.exs b/config/runtime.exs index 2ea1020..b44a958 100644 --- a/config/runtime.exs +++ b/config/runtime.exs @@ -36,6 +36,8 @@ if config_env() == :prod do host = System.get_env("PHX_HOST") || "surface-ui.org" port = String.to_integer(System.get_env("PORT") || "4000") + config :surface_site, :dns_cluster_query, System.get_env("DNS_CLUSTER_QUERY") + config :surface_site, SurfaceSiteWeb.Endpoint, url: [host: host, port: 443, scheme: "https"], http: [ diff --git a/config/test.exs b/config/test.exs index 82cd81d..69bafdf 100644 --- a/config/test.exs +++ b/config/test.exs @@ -7,9 +7,6 @@ config :surface_site, SurfaceSiteWeb.Endpoint, secret_key_base: "qick86rrt0cZHQpbf7BLKywNWLsT9FUWpg/f//xOmOw6ZD/rVBUd+f0KMzEw0jI+", server: false -# In test we don't send emails. -config :surface_site, SurfaceSite.Mailer, adapter: Swoosh.Adapters.Test - # Print only warnings and errors during test config :logger, level: :warning diff --git a/lib/surface_site/application.ex b/lib/surface_site/application.ex index c5505a0..555969d 100644 --- a/lib/surface_site/application.ex +++ b/lib/surface_site/application.ex @@ -8,9 +8,9 @@ defmodule SurfaceSite.Application do @impl true def start(_type, _args) do children = [ - # Start the PubSub system + {DNSCluster, query: Application.get_env(:surface_site, :dns_cluster_query) || :ignore}, {Phoenix.PubSub, name: SurfaceSite.PubSub}, - # Start the Endpoint (http/https) + # Start to serve requests, typically the last entry SurfaceSiteWeb.Endpoint ] diff --git a/lib/surface_site_web/components/core_components.ex b/lib/surface_site_web/components/core_components.ex index 5220267..4ed1dec 100644 --- a/lib/surface_site_web/components/core_components.ex +++ b/lib/surface_site_web/components/core_components.ex @@ -2,9 +2,9 @@ defmodule SurfaceSiteWeb.CoreComponents do @moduledoc """ Provides core UI components. - At the first glance, this module may seem daunting, but its goal is - to provide some core building blocks in your application, such as modals, - tables, and forms. The components are mostly markup and well documented + At first glance, this module may seem daunting, but its goal is to provide + core building blocks for your application, such as modals, tables, and + forms. The components consist mostly of markup and are well-documented with doc strings and declarative assigns. You may customize and style them in any way you want, based on your application growth and needs. @@ -96,7 +96,7 @@ defmodule SurfaceSiteWeb.CoreComponents do <.flash kind={:info} flash={@flash} /> <.flash kind={:info} phx-mounted={show("#flash")}>Welcome Back! """ - attr :id, :string, default: "flash", doc: "the optional id of flash container" + attr :id, :string, doc: "the optional id of flash container" attr :flash, :map, default: %{}, doc: "the map of flash messages to display" attr :title, :string, default: nil attr :kind, :atom, values: [:info, :error], doc: "used for styling and flash lookup" @@ -105,6 +105,8 @@ defmodule SurfaceSiteWeb.CoreComponents do slot :inner_block, doc: "the optional inner block that renders the flash message" def flash(assigns) do + assigns = assign_new(assigns, :id, fn -> "flash-#{assigns.kind}" end) + ~H"""
hide("##{@id}")} role="alert" class={[ - "fixed top-2 right-2 w-80 sm:w-96 z-50 rounded-lg p-3 ring-1", + "fixed top-2 right-2 mr-2 w-80 sm:w-96 z-50 rounded-lg p-3 ring-1", @kind == :info && "bg-emerald-50 text-emerald-800 ring-emerald-500 fill-cyan-900", @kind == :error && "bg-rose-50 text-rose-900 shadow-md ring-rose-500 fill-rose-900" ]} @@ -139,33 +141,36 @@ defmodule SurfaceSiteWeb.CoreComponents do <.flash_group flash={@flash} /> """ attr :flash, :map, required: true, doc: "the map of flash messages" + attr :id, :string, default: "flash-group", doc: "the optional id of flash container" def flash_group(assigns) do ~H""" - <.flash kind={:info} title="Success!" flash={@flash} /> - <.flash kind={:error} title="Error!" flash={@flash} /> - <.flash - id="client-error" - kind={:error} - title="We can't find the internet" - phx-disconnected={show(".phx-client-error #client-error")} - phx-connected={hide("#client-error")} - hidden - > - Attempting to reconnect <.icon name="hero-arrow-path" class="ml-1 h-3 w-3 animate-spin" /> - - - <.flash - id="server-error" - kind={:error} - title="Something went wrong!" - phx-disconnected={show(".phx-server-error #server-error")} - phx-connected={hide("#server-error")} - hidden - > - Hang in there while we get back on track - <.icon name="hero-arrow-path" class="ml-1 h-3 w-3 animate-spin" /> - +
+ <.flash kind={:info} title="Success!" flash={@flash} /> + <.flash kind={:error} title="Error!" flash={@flash} /> + <.flash + id="client-error" + kind={:error} + title="We can't find the internet" + phx-disconnected={show(".phx-client-error #client-error")} + phx-connected={hide("#client-error")} + hidden + > + Attempting to reconnect <.icon name="hero-arrow-path" class="ml-1 h-3 w-3 animate-spin" /> + + + <.flash + id="server-error" + kind={:error} + title="Something went wrong!" + phx-disconnected={show(".phx-server-error #server-error")} + phx-connected={hide("#server-error")} + hidden + > + Hang in there while we get back on track + <.icon name="hero-arrow-path" class="ml-1 h-3 w-3 animate-spin" /> + +
""" end @@ -293,9 +298,11 @@ defmodule SurfaceSiteWeb.CoreComponents do |> input() end - def input(%{type: "checkbox", value: value} = assigns) do + def input(%{type: "checkbox"} = assigns) do assigns = - assign_new(assigns, :checked, fn -> Phoenix.HTML.Form.normalize_value("checkbox", value) end) + assign_new(assigns, :checked, fn -> + Phoenix.HTML.Form.normalize_value("checkbox", assigns[:value]) + end) ~H"""
@@ -468,8 +475,10 @@ defmodule SurfaceSiteWeb.CoreComponents do - - + + Date: Thu, 8 Feb 2024 13:38:36 -0300 Subject: [PATCH 4/6] update to erlang 26.2.2 and elixir 1.16.1 --- .github/workflows/ci.yml | 4 ++-- .tool-versions | 4 ++-- elixir_buildpack.config | 4 ++-- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 822e2c9..ffc6ed7 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -14,8 +14,8 @@ jobs: fail-fast: false matrix: include: - - elixir: '1.14.5' - otp: '25.3.2.8' + - elixir: '1.16.1' + otp: '26.2.2' env: MIX_ENV: test steps: diff --git a/.tool-versions b/.tool-versions index bde48fc..1c43fd8 100644 --- a/.tool-versions +++ b/.tool-versions @@ -1,2 +1,2 @@ -erlang 25.3.2.8 -elixir 1.14.5-otp-25 +erlang 26.2.2 +elixir 1.16.1-otp-26 diff --git a/elixir_buildpack.config b/elixir_buildpack.config index 1e342d2..9b60c4b 100644 --- a/elixir_buildpack.config +++ b/elixir_buildpack.config @@ -1,2 +1,2 @@ -elixir_version=1.13.2 -erlang_version=24.2 +elixir_version=1.16.1 +erlang_version=26.2.2 From 31d4ddae5643d471b4eed40e824e391e5ea2c918 Mon Sep 17 00:00:00 2001 From: Tiago Moraes Date: Thu, 8 Feb 2024 13:39:12 -0300 Subject: [PATCH 5/6] fix `negative steps are not supported in Enum.slice/2` warning --- lib/surface_site_web/components/code.ex | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/surface_site_web/components/code.ex b/lib/surface_site_web/components/code.ex index b586469..33790a4 100644 --- a/lib/surface_site_web/components/code.ex +++ b/lib/surface_site_web/components/code.ex @@ -138,7 +138,7 @@ defmodule SurfaceSiteWeb.Components.Code do raise "invalid line range. Ending line cannot be 0" end - index_from..index_to + index_from..index_to//1 end defp normalize_line_range(value) do From 9ff306162815d0064ec5ccd91fd6b8258fcfec4a Mon Sep 17 00:00:00 2001 From: Tiago Moraes Date: Thu, 8 Feb 2024 14:24:14 -0300 Subject: [PATCH 6/6] mix format --- lib/surface_site_web/components/component_info.ex | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/lib/surface_site_web/components/component_info.ex b/lib/surface_site_web/components/component_info.ex index 21b3515..ea92bbe 100644 --- a/lib/surface_site_web/components/component_info.ex +++ b/lib/surface_site_web/components/component_info.ex @@ -28,11 +28,11 @@ defmodule SurfaceSiteWeb.Components.ComponentInfo do :before_docs ] - data id, :string - data full_module_name, :string - data module_summary, :string - data module_doc, :string - data module_name, :string + data id, :string + data full_module_name, :string + data module_summary, :string + data module_doc, :string + data module_name, :string @doc "The examples for the component" slot examples @@ -50,6 +50,7 @@ defmodule SurfaceSiteWeb.Components.ComponentInfo do {module_summary, module_doc} = fetch_module_doc(assigns.module) id = "ComponentInfo_#{module_name}" + assigns = assigns |> assign(:id, id)
<%= col[:label] %>Actions<%= col[:label] %> + Actions +