petalframework / petal_boilerplate

Phoenix + Tailwind + Petal Components Boilerplate
https://petal.build
152 stars 21 forks source link

FunctionClauseError in PetalComponents.Button.get_color_classes/1 #20

Closed rsas closed 9 months ago

rsas commented 9 months ago

Hello team, trying PETAL for the first time on OSX and running into an exception. I did the following:

  1. git clone
  2. mix setup
  3. mix phx.server
  4. open localhost:4000

and then I get this:

[info] GET / [debug] Processing with PetalBoilerplateWeb.PageController.home/2 Parameters: %{} Pipelines: [:browser] [info] Sent 500 in 87ms [error] #PID<0.503.0> running Phoenix.Endpoint.SyncCodeReloadPlug (connection #PID<0.502.0>, stream id 1) terminated Server: localhost:4000 (http) Request: GET / (exit) an exception was raised: (FunctionClauseError) no function clause matching in PetalComponents.Button.get_color_classes/1 (petal_components 1.3.0) lib/petal_components/button.ex:169: PetalComponents.Button.get_color_classes(%{disabled: false, size: "md", loading: false, color: "dark", variant: "solid", with_icon: false, user_added_classes: ""}) (petal_components 1.3.0) lib/petal_components/button.ex:149: PetalComponents.Button.button_classes/1 (petal_components 1.3.0) lib/petal_components/button.ex:59: PetalComponents.Button."button (overridable 1)"/1 (phoenix_live_view 0.19.5) lib/phoenix_live_view/tag_engine.ex:68: Phoenix.LiveView.TagEngine.component/3 (petal_boilerplate 0.1.0) lib/petal_boilerplate_web/controllers/page_html/home.html.heex:107: anonymous fn/2 in PetalBoilerplateWeb.PageHTML.home/1 (phoenix_live_view 0.19.5) lib/phoenix_live_view/engine.ex:150: Phoenix.HTML.Safe.Phoenix.LiveView.Rendered.to_iodata/1 (phoenix_live_view 0.19.5) lib/phoenix_live_view/engine.ex:166: Phoenix.HTML.Safe.Phoenix.LiveView.Rendered.to_iodata/3 (phoenix 1.7.7) lib/phoenix/controller.ex:1008: anonymous fn/5 in Phoenix.Controller.template_render_to_iodata/4 (telemetry 1.2.1) /Users/rsas/elixir/petal_boilerplate/deps/telemetry/src/telemetry.erl:321: :telemetry.span/3 (phoenix 1.7.7) lib/phoenix/controller.ex:974: Phoenix.Controller.render_and_send/4 (petal_boilerplate 0.1.0) lib/petal_boilerplate_web/controllers/page_controller.ex:1: PetalBoilerplateWeb.PageController.action/2 (petal_boilerplate 0.1.0) lib/petal_boilerplate_web/controllers/page_controller.ex:1: PetalBoilerplateWeb.PageController.phoenix_controller_pipeline/2 (phoenix 1.7.7) lib/phoenix/router.ex:430: Phoenix.Router.call/5 (petal_boilerplate 0.1.0) lib/petal_boilerplate_web/endpoint.ex:1: PetalBoilerplateWeb.Endpoint.plug_builder_call/2 (petal_boilerplate 0.1.0) deps/plug/lib/plug/debugger.ex:136: PetalBoilerplateWeb.Endpoint."call (overridable 3)"/2 (petal_boilerplate 0.1.0) lib/petal_boilerplate_web/endpoint.ex:1: PetalBoilerplateWeb.Endpoint.call/2 (phoenix 1.7.7) lib/phoenix/endpoint/sync_code_reload_plug.ex:22: Phoenix.Endpoint.SyncCodeReloadPlug.do_call/4 (plug_cowboy 2.6.1) lib/plug/cowboy/handler.ex:11: Plug.Cowboy.Handler.init/2 (cowboy 2.10.0) /Users/rsas/elixir/petal_boilerplate/deps/cowboy/src/cowboy_handler.erl:37: :cowboy_handler.execute/2 (cowboy 2.10.0) /Users/rsas/elixir/petal_boilerplate/deps/cowboy/src/cowboy_stream_h.erl:306: :cowboy_stream_h.execute/3

rsas commented 9 months ago

Ok, got it working by removing the instances of

<.button color="dark" label="Dark" ... />

in lib/petal_boilerplate_web/controllers/page_html/home.html.heex.

nhobes commented 9 months ago

Oh thanks for letting us know. It seems like it was stuck on an old version of Petal Components so if you had upgraded to the latest version (1.9), it should have worked without removing that button. I've upgraded petal components on the boilerplate now, so shouldn't be an issue hopefully.

rsas commented 9 months ago

Thank you for the quick response, I believe you forgot to remove version: "3.2.4", in config/config.exs which I had to remove manually making it work.

rsas commented 9 months ago

and a version bump to {:phoenix_live_dashboard, "~> 0.8.3"}, might be needed as well to avoid this:

== Compilation error in file lib/phoenix/live_dashboard/page_live.ex == ** (RuntimeError) use Phoenix.HTML is no longer supported in v4.0.

To keep compatibility with previous versions, add {:phoenix_html_helpers, "~> 1.0"} to your mix.exs deps and then, instead of "use Phoenix.HTML", you might:

import Phoenix.HTML
import Phoenix.HTML.Form
use PhoenixHTMLHelpers

(phoenix_html 4.0.0) expanding macro: Phoenix.HTML.__using__/1
lib/phoenix/live_dashboard/page_live.ex:8: Phoenix.LiveDashboard.PageLive (module)
(elixir 1.16.1) expanding macro: Kernel.use/1
lib/phoenix/live_dashboard/page_live.ex:8: Phoenix.LiveDashboard.PageLive (module)
expanding macro: Phoenix.LiveDashboard.Web.__using__/1
lib/phoenix/live_dashboard/page_live.ex:8: Phoenix.LiveDashboard.PageLive (module)
(elixir 1.16.1) expanding macro: Kernel.use/2
lib/phoenix/live_dashboard/page_live.ex:8: Phoenix.LiveDashboard.PageLive (module)

could not compile dependency :phoenix_live_dashboard, "mix compile" failed. Errors may have been logged above. You can recompile this dependency with "mix deps.compile phoenix_live_dashboard --force", update it with "mix deps.update phoenix_live_dashboard" or clean it with "mix deps.clean phoenix_live_dashboard"

nhobes commented 9 months ago

Doh! Thanks for pointing this out - forgot to commit that line. Also bumped {:phoenix_live_dashboard, "~> 0.8.3"}. Gave it a test and all working smoothly now 🙌