~reykjalin/inner_circle

ref: 55b0fba2e5c80ff882b4593b59864c3037dd8195 inner_circle/lib/inner_circle_web/live/create_post_live/index.html.heex -rw-r--r-- 2.5 KiB
55b0fba2 — Kristófer R Set CI ubuntu version to focal 9 months ago
                                                                                
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
<div
  class="my-5 p-5 md:p-10 border rounded-md bg-white"
>
  <h2 class="text-2xl mb-5">New Post</h2>

  <.form let={f} for={@changeset} url="#"
    id="post-form"
    class="flex flex-col bg-white"
    phx-change="validate"
    phx-submit="save"
    >

    <%= label f, :body, class: "font-bold" %>
    <%= textarea f, :body, autofocus: true, class: "border px-4 py-3 mb-5" %>
    <%= error_tag f, :body %>

    <p class="my-5">
      You're allowed to upload up to <%= @uploads.media.max_entries %> items
      (max <%= @uploads.media.max_file_size / 1_000_000_000 %> GB each).
    </p>

    <%= live_file_input @uploads.media, class: "my-5" %>

    <%= for {_ref, error} <- @uploads.media.errors do %>
      <p class="my-5 text-red-700">
        <%= humanize(error) %>
      </p>
    <% end %>

    <section id="uploads" phx-drop-target={ @uploads.media.ref }>
      <hr class="my-5">
      <%= for entry <- @uploads.media.entries do %>
        <div class="flex flex-col md:flex-row items-center justify-between">
          <div class="w-2/12">
            <%= if String.starts_with?(entry.client_type, "image") do %>
              <%= live_img_preview entry, width: 100 %>
            <% end %>
            <%= if String.starts_with?(entry.client_type, "video") do %>
              <p><%= entry.client_name %></p>
            <% end %>
          </div>


          <div class="w-6/12">
            <label for={ "media-#{ entry.ref }" }><%= entry.progress %>%</label>
            <progress class="w-full" name={ "media-#{ entry.ref }" } max="100" value={ entry.progress } >
              <%= entry.progress %>%
            </progress>
          </div>

          <div class="w-2/12 text-center">
            <a
              href="#cancel-media-upload"
              class="link"
              phx-click="cancel"
              phx-value-ref={ entry.ref } >
              Remove
            </a>
          </div>

          <div class="w-2/12">
            <%= for error <- upload_errors(@uploads.media, entry) do %>
              <div>
                <%= humanize(error) %>
              </div>
            <% end %>
            <%= for err <- upload_errors(@uploads.media) do %>
              <div>
                <%= humanize(err) %>
              </div>
            <% end %>
          </div>
        </div>

        <hr class="my-5">
      <% end %>
    </section>

    <%= submit "Save", phx_disable_with: "Saving...", class: "border rounded-md px-4 py-3 bg-blue-600 text-white hover:bg-blue-500" %>
  </.form>
</div>