Home Live View
Mix Test
Before to start lets run the inital test suite with mix test
First Surface LiveView
Lets create our first Surface Live View.
live_air/lib/live_air_web/live/home_live/index.ex
And the sface template
live_air/lib/live_air_web/live/home_live/index.sface
```
<div>
Home
</div>
```
We also want to edit the router.ex
to point the homepage to our Live View
Replace get "/", PageController, :home
by live "/", HomeLive.Index, :new
We can now run mix phx.server
Great we have our first Live View.
First Moon/Surface Component
Lets test our Live View with a simple button
In your live_air/lib/live_air_web/live/home_live/index.sface
Let replace it by
You also need to add the following to your live_air/lib/live_air_web/live/home_live/index.ex
alias Moon.Design.Button
alias Moon.Design.BottomSheet
def handle_event("set_open", _, socket) do
BottomSheet.open("modal_bottom_sheet")
{:noreply, socket}
end
def handle_event(“set_close”, _, socket) do BottomSheet.close(“modal_bottom_sheet”) {:noreply, socket} end
Let run mix phx.server
and see our modal/bottomsheet in action
However if we run mix test
our previous test are failing
Let’s investigate
We see that live_air/test/live_air_web/controllers/page_controller_test.exs
that is failing because we removed the original homepage.
Let’s replace it with a temporary test until the homepage is completed
Lets run again mix test
Feel free to visit Moon Design Documentation and try out the different components. They are provided with full examples and data.