Skip to content

Commit 7ea3302

Browse files
Update LiveView to 1.1 (#145)
* Update LiveView to 1.1 * Allow string type
1 parent cf6af0b commit 7ea3302

File tree

22 files changed

+156
-145
lines changed

22 files changed

+156
-145
lines changed

.tool-versions

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
1-
elixir 1.14.5
1+
elixir 1.16.3
22
erlang 25.1.2
33
nodejs 16.13.0

CHANGELOG.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,14 @@
11
# Changelog
22

3+
## Unreleased
4+
5+
### Breaking
6+
- Update for liveview > 1.0
7+
- Stop generating phx-feedback-for in favour of `Phoenix.Component.used_input?`
8+
- Require Elixir 1.15
9+
- Require Phoenix HTML 4.0
10+
https://github.com/phoenixframework/phoenix_live_view/blob/v1.0/CHANGELOG.md#core-components
11+
312
## v2.5.2 - 2025-08-11
413
- Brought back `unchecked_value` & `checked_value` for checkboxes in `ui_input` and `ui_raw_input`.
514

demo/config/config.exs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ config :bitstyles_phoenix_demo, BitstylesPhoenixDemoWeb.Endpoint,
2424

2525
# Configure esbuild (the version is required)
2626
config :esbuild,
27-
version: "0.12.18",
27+
version: "0.25.0",
2828
default: [
2929
args:
3030
~w(js/app.js --bundle --target=es2017 --outdir=../priv/static/assets --external:/fonts/* --external:/images/*),
@@ -33,7 +33,7 @@ config :esbuild,
3333
]
3434

3535
config :dart_sass,
36-
version: "1.43.4",
36+
version: "1.61.0",
3737
default: [
3838
args: ~w(css/app.scss ../priv/static/assets/app.css),
3939
cd: Path.expand("../assets", __DIR__)

demo/config/test.exs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ config :bitstyles_phoenix,
1111
trim_e2e_classes: [enabled: false]
1212

1313
# Print only warnings and errors during test
14-
config :logger, level: :warn
14+
config :logger, level: :warning
1515

1616
# Initialize plugs at runtime for faster test compilation
1717
config :phoenix, :plug_init_mode, :runtime

demo/lib/bitstyles_phoenix_demo/thing.ex

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@ defmodule BitstylesPhoenixDemo.Thing do
77
field(:name, :string)
88
end
99

10-
def changeset(schema \\ %__MODULE__{}, params \\ %{}) do
11-
schema
10+
def changeset(params) do
11+
%__MODULE__{}
1212
|> cast(params, [:name])
1313
|> validate_required([:name])
1414
end

demo/lib/bitstyles_phoenix_demo_web.ex

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,10 @@ defmodule BitstylesPhoenixDemoWeb do
33

44
def controller do
55
quote do
6-
use Phoenix.Controller, namespace: BitstylesPhoenixDemoWeb
6+
use Phoenix.Controller, formats: [:html]
77

88
import Plug.Conn
9-
import BitstylesPhoenixDemoWeb.Gettext
9+
use Gettext, backend: BitstylesPhoenixDemoWeb.Gettext
1010
alias BitstylesPhoenixDemoWeb.Router.Helpers, as: Routes
1111
end
1212
end
@@ -15,11 +15,12 @@ defmodule BitstylesPhoenixDemoWeb do
1515
quote do
1616
use Phoenix.View,
1717
root: "lib/bitstyles_phoenix_demo_web/templates",
18-
namespace: BitstylesPhoenixDemoWeb
18+
namespace: BitstylesPhoenixDemoWeb,
19+
pattern: "**/*"
1920

2021
# Import convenience functions from controllers
2122
import Phoenix.Controller,
22-
only: [get_flash: 1, get_flash: 2, view_module: 1, view_template: 1]
23+
only: [get_csrf_token: 0, get_flash: 1, get_flash: 2, view_module: 1, view_template: 1]
2324

2425
use BitstylesPhoenix.Alpine3
2526

@@ -62,24 +63,24 @@ defmodule BitstylesPhoenixDemoWeb do
6263
def channel do
6364
quote do
6465
use Phoenix.Channel
65-
import BitstylesPhoenixDemoWeb.Gettext
66+
use Gettext, backend: BitstylesPhoenixDemoWeb.Gettext
6667
end
6768
end
6869

6970
defp view_helpers do
7071
quote do
72+
# Import basic rendering functionality (render, render_layout, etc)
73+
import Phoenix.View
74+
import Phoenix.Component
7175
# Use all HTML functionality (forms, tags, etc)
72-
use Phoenix.HTML
76+
import Phoenix.HTML
77+
import Phoenix.HTML.Form
7378

7479
use BitstylesPhoenix
7580
# Import LiveView and .heex helpers (live_render, live_patch, <.form>, etc)
76-
import Phoenix.Component
77-
78-
# Import basic rendering functionality (render, render_layout, etc)
79-
import Phoenix.View
8081

8182
import BitstylesPhoenixDemoWeb.ErrorHelpers
82-
import BitstylesPhoenixDemoWeb.Gettext
83+
use Gettext, backend: BitstylesPhoenixDemoWeb.Gettext
8384
alias BitstylesPhoenixDemoWeb.Router.Helpers, as: Routes
8485
end
8586
end

demo/lib/bitstyles_phoenix_demo_web/controllers/page_controller.ex

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,18 @@ defmodule BitstylesPhoenixDemoWeb.PageController do
22
alias BitstylesPhoenixDemo.Thing
33
use BitstylesPhoenixDemoWeb, :controller
44

5+
plug :put_layout, {BitstylesPhoenixDemoWeb.LayoutView, :app}
6+
57
def index(conn, _params) do
68
changeset =
7-
Thing.changeset()
9+
Thing.changeset(%{name: ""})
810
|> Map.put(:action, "update")
911

1012
conn
1113
|> put_flash(:info, "Welcome to the Demo !!!")
1214
|> put_flash(:warning, "Let's pretend we have a warning.")
1315
|> put_flash(:error, "Let's pretend we have an error.")
16+
|> put_view(BitstylesPhoenixDemoWeb.PageView)
1417
|> render("index.html", changeset: changeset)
1518
end
1619
end
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
defmodule BitstylesPhoenixDemoWeb.Gettext do
2-
use Gettext, otp_app: :bitstyles_phoenix_demo
2+
use Gettext.Backend, otp_app: :bitstyles_phoenix_demo
33
end

demo/lib/bitstyles_phoenix_demo_web/live/demo_live.ex

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,6 @@ defmodule BitstylesPhoenixDemoWeb.DemoLive do
88
|> put_flash(:warning, "Let's pretend we have a warning.")
99
|> put_flash(:error, "Let's pretend we have an error.")
1010

11-
{:noreply, push_redirect(socket, to: "/live")}
11+
{:noreply, push_navigate(socket, to: "/live")}
1212
end
1313
end

demo/lib/bitstyles_phoenix_demo_web/templates/layout/app.html.heex

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -18,24 +18,24 @@
1818
</:small_sidebar>
1919
<:sidebar_content>
2020
<.ui_sidebar_nav>
21-
<.ui_sidebar_nav_item><.ui_button href={Routes.page_path(@conn, :index)} class="u-flex-grow-1 e2e-sidebar-alpine" variant="nav">Alpine 3</.ui_button></.ui_sidebar_nav_item>
22-
<.ui_sidebar_nav_item><.ui_button href={Routes.live_path(@conn, BitstylesPhoenixDemoWeb.DemoLive)} class="u-flex-grow-1 e2e-sidebar-live" variant="nav">Live</.ui_button></.ui_sidebar_nav_item>
21+
<.ui_sidebar_nav_item><.ui_button href={Routes.page_path(@conn, :index)} class="u-flex-grow-1 e2e-sidebar-alpine" shape="nav">Alpine 3</.ui_button></.ui_sidebar_nav_item>
22+
<.ui_sidebar_nav_item><.ui_button href={Routes.live_path(@conn, BitstylesPhoenixDemoWeb.DemoLive)} class="u-flex-grow-1 e2e-sidebar-live" shape="nav">Live</.ui_button></.ui_sidebar_nav_item>
2323
</.ui_sidebar_nav>
2424
</:sidebar_content>
2525
<:main :let={s}>
2626
<.ui_js_sidebar_open sidebar={s} class="u-margin-s e2e-sidebar-open"/>
27-
<%= if content = get_flash(@conn, :info) do %>
27+
<%= if content = Phoenix.Flash.get(@flash, :info) do %>
2828
<.ui_flash variant={[:positive, :full]}>
2929
<%= content %>
3030
</.ui_flash>
3131
<% end %>
32-
<%= if content = get_flash(@conn, :warning) do %>
32+
<%= if content = Phoenix.Flash.get(@flash, :warning) do %>
3333
<.ui_flash variant={[:warning, :full]}>
3434
<.ui_icon name="exclamation" class="u-flex-shrink-0 u-margin-m-right" />
3535
<%= content %>
3636
</.ui_flash>
3737
<% end %>
38-
<%= if content = get_flash(@conn, :error) do %>
38+
<%= if content = Phoenix.Flash.get(@flash, :error) do %>
3939
<.ui_flash variant={[:danger, :full]}>
4040
<.ui_icon name="exclamation" class="u-flex-shrink-0 u-margin-m-right" />
4141
<%= content %>

0 commit comments

Comments
 (0)