dwyl / fields-demo

Quick demo of the fields package.
GNU General Public License v2.0
3 stars 0 forks source link
# `fields` _demo_ Quick demo of the [**`fields`**](https://github.com/dwyl/fields) package to **build `Phoenix` Apps _much_ faster**. ![GitHub Workflow Status](https://img.shields.io/github/actions/workflow/status/dwyl/fields-demo/ci.yml?label=build&style=flat-square&branch=main) [![codecov.io](https://img.shields.io/codecov/c/github/dwyl/fields-demo/main.svg?style=flat-square)](https://codecov.io/github/dwyl/fields-demo?branch=main) [![Hex.pm](https://img.shields.io/hexpm/v/fields?color=brightgreen&style=flat-square)](https://hex.pm/packages/fields) [![docs](https://img.shields.io/badge/docs-amaze-brightgreen?style=flat-square)](https://hexdocs.pm/fields/api-reference.html) [![contributions welcome](https://img.shields.io/badge/contributions-welcome-brightgreen.svg?style=flat-square)](https://github.com/dwyl/fields/issues) [![HitCount](https://hits.dwyl.com/dwyl/fields-demo.svg)](https://hits.dwyl.com/dwyl/fields-demo)

Jump to the section that interests you:

Why?

To showcase fields in a basic Phoenix App a complete beginner can understand in 5 minutes.

What?

A tiny demo/example app using fields to store an "event participant registration form" that uses as many of the fields as possible in real-world ways.

Who?

This is aimed at people getting started with fields, both @dwyl and the wider Elixir community.

How?

Run the demo on your computer!

1. Clone from GitHub

Clone the project from GitHub:

git clone git@github.com:dwyl/fields-demo.git

2. Setup Dependencies & Database

Setup the project on localhost:

mix setup

3. Run the App

Run the app:

mix s

Open the app in your browser, you should expect to see:

TODO: add GIF of inputting data.

Build Log?

We wrote a comprehensive step-by-step log of everything we did when creating the fields-demo app:

If you feel we have skipped a step or anything is unclear, please open an issue

# Register for _Awesome_ Conf! awesome smiley

4. Create attendee schema

The goal is to allow people attending Awesome Conf to submit the following data:

4.1 gen.schema

Using the mix phx.gen.live command, run:

mix phx.gen.live Accounts Attendee attendees first_name:string last_name:string email:string --no-context

You should expect to see output similar to the following:

* creating lib/fields_demo_web/live/attendee_live/show.ex
* creating lib/fields_demo_web/live/attendee_live/index.ex
* creating lib/fields_demo_web/live/attendee_live/form_component.ex
* creating lib/fields_demo_web/live/attendee_live/index.html.heex
* creating lib/fields_demo_web/live/attendee_live/show.html.heex
* creating test/fields_demo_web/live/attendee_live_test.exs

Add the live routes to your browser scope in lib/fields_demo_web/router.ex:

    live "/attendees", AttendeeLive.Index, :index
    live "/attendees/new", AttendeeLive.Index, :new
    live "/attendees/:id/edit", AttendeeLive.Index, :edit

    live "/attendees/:id", AttendeeLive.Show, :show
    live "/attendees/:id/show/edit", AttendeeLive.Show, :edit

FieldsDemo

To start your Phoenix server:

Now you can visit localhost:4000 from your browser.

Ready to run in production? Please check our deployment guides.