diff --git a/config/config.exs b/config/config.exs index c4474b7..2c9e35d 100644 --- a/config/config.exs +++ b/config/config.exs @@ -65,15 +65,19 @@ config :phoenix, :json_library, Jason config :live_view_native, plugins: [ - LiveViewNative.SwiftUI + LiveViewNative.SwiftUI, + LiveViewNative.Jetpack ] config :mime, :types, %{ "text/swiftui" => ["swiftui"], + "text/jetpack" => ["jetpack"], "text/styles" => ["styles"] } -config :phoenix_template, :format_encoders, swiftui: Phoenix.HTML.Engine +config :phoenix_template, :format_encoders, + swiftui: Phoenix.HTML.Engine, + jetpack: Phoenix.HTML.Engine config :phoenix, :template_engines, neex: LiveViewNative.Engine diff --git a/lib/lax_native.ex b/lib/lax_native.ex index 3aee39c..1fff2e5 100644 --- a/lib/lax_native.ex +++ b/lib/lax_native.ex @@ -35,10 +35,12 @@ defmodule LaxNative do quote do use LiveViewNative.LiveView, formats: [ - :swiftui + :swiftui, + :jetpack ], layouts: [ - swiftui: {LaxWeb.Layouts.SwiftUI, :app} + swiftui: {LaxWeb.Layouts.SwiftUI, :app}, + jetpack: {LaxWeb.Layouts.Jetpack, :app} ] unquote(verified_routes()) diff --git a/lib/lax_web/components/core_components.jetpack.ex b/lib/lax_web/components/core_components.jetpack.ex new file mode 100644 index 0000000..9bc7758 --- /dev/null +++ b/lib/lax_web/components/core_components.jetpack.ex @@ -0,0 +1,19 @@ +defmodule LaxWeb.CoreComponents.Jetpack do + @moduledoc """ + Provides core UI components built for Jetpack. + + This file contains feature parity components to your applications's CoreComponent module. + The goal is to retain a common API for fast prototyping. Leveraging your existing knowledge + of the `LaxWeb.CoreComponents` functions you should expect identical functionality for similarly named + components between web and native. That means utilizing your existing `handle_event/3` functions to manage state + and stay focused on adding new templates for your native applications. + + The default components use `LiveViewNative.Jetpack.UtilityStyles`, a generated styling syntax + that allows you to call nearly any modifier. Refer to the documentation in `LiveViewNative.Jetpack` for more information. + + """ + + use LiveViewNative.Component + + import LiveViewNative.LiveForm.Component +end diff --git a/lib/lax_web/components/layouts.jetpack.ex b/lib/lax_web/components/layouts.jetpack.ex new file mode 100644 index 0000000..245ee4f --- /dev/null +++ b/lib/lax_web/components/layouts.jetpack.ex @@ -0,0 +1,5 @@ +defmodule LaxWeb.Layouts.Jetpack do + use LaxNative, [:layout, format: :jetpack] + + embed_templates "layouts_jetpack/*" +end diff --git a/lib/lax_web/components/layouts_jetpack/app.jetpack.neex b/lib/lax_web/components/layouts_jetpack/app.jetpack.neex new file mode 100644 index 0000000..0543398 --- /dev/null +++ b/lib/lax_web/components/layouts_jetpack/app.jetpack.neex @@ -0,0 +1 @@ +<%= @inner_content %> diff --git a/lib/lax_web/components/layouts_jetpack/root.jetpack.neex b/lib/lax_web/components/layouts_jetpack/root.jetpack.neex new file mode 100644 index 0000000..1b0302b --- /dev/null +++ b/lib/lax_web/components/layouts_jetpack/root.jetpack.neex @@ -0,0 +1,3 @@ +<.csrf_token /> +