From d1d3c11c6ca40a830d781bd8816eaa9efa9c7e80 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=F0=9F=8E=B7=F0=9F=90=A2=20S=2E=20P=2E=20O=2E=20Clayton?= Date: Fri, 20 Jan 2023 22:17:15 -0500 Subject: [PATCH] Lots of updates :) --- assets/tailwind.config.js | 40 ++-- config/dev.exs | 2 +- .../components/core_components.ex | 25 --- .../components/layouts/root.html.heex | 2 +- lib/swornforged_web/controllers/page_html.ex | 102 +++++++++ .../controllers/page_html/assets.html.heex | 0 .../controllers/page_html/home.html.heex | 201 +++++++++++------- .../controllers/page_html/moves.html.heex | 0 .../controllers/page_html/oracles.html.heex | 0 9 files changed, 258 insertions(+), 114 deletions(-) create mode 100644 lib/swornforged_web/controllers/page_html/assets.html.heex create mode 100644 lib/swornforged_web/controllers/page_html/moves.html.heex create mode 100644 lib/swornforged_web/controllers/page_html/oracles.html.heex diff --git a/assets/tailwind.config.js b/assets/tailwind.config.js index e3bf241..5b5a21f 100644 --- a/assets/tailwind.config.js +++ b/assets/tailwind.config.js @@ -1,26 +1,40 @@ // See the Tailwind configuration guide for advanced usage // https://tailwindcss.com/docs/configuration -const plugin = require("tailwindcss/plugin") +const plugin = require("tailwindcss/plugin"); module.exports = { - content: [ - "./js/**/*.js", - "../lib/*_web.ex", - "../lib/*_web/**/*.*ex" - ], + content: ["./js/**/*.js", "../lib/*_web.ex", "../lib/*_web/**/*.*ex"], theme: { extend: { colors: { brand: "#FD4F00", - } + }, }, }, plugins: [ require("@tailwindcss/forms"), - plugin(({addVariant}) => addVariant("phx-no-feedback", [".phx-no-feedback&", ".phx-no-feedback &"])), - plugin(({addVariant}) => addVariant("phx-click-loading", [".phx-click-loading&", ".phx-click-loading &"])), - plugin(({addVariant}) => addVariant("phx-submit-loading", [".phx-submit-loading&", ".phx-submit-loading &"])), - plugin(({addVariant}) => addVariant("phx-change-loading", [".phx-change-loading&", ".phx-change-loading &"])) - ] -} + require("@tailwindcss/typography"), + plugin(({ addVariant }) => + addVariant("phx-no-feedback", [".phx-no-feedback&", ".phx-no-feedback &"]) + ), + plugin(({ addVariant }) => + addVariant("phx-click-loading", [ + ".phx-click-loading&", + ".phx-click-loading &", + ]) + ), + plugin(({ addVariant }) => + addVariant("phx-submit-loading", [ + ".phx-submit-loading&", + ".phx-submit-loading &", + ]) + ), + plugin(({ addVariant }) => + addVariant("phx-change-loading", [ + ".phx-change-loading&", + ".phx-change-loading &", + ]) + ), + ], +}; diff --git a/config/dev.exs b/config/dev.exs index d11222a..2dfd7db 100644 --- a/config/dev.exs +++ b/config/dev.exs @@ -60,7 +60,7 @@ config :swornforged, SwornforgedWeb.Endpoint, ] # Enable dev routes for dashboard and mailbox -config :swornforged, dev_routes: true +config :swornforged, dev_routes: true, datasworn_debug: true # Do not include metadata nor timestamps in development logs config :logger, :console, format: "[$level] $message\n" diff --git a/lib/swornforged_web/components/core_components.ex b/lib/swornforged_web/components/core_components.ex index a652731..2107669 100644 --- a/lib/swornforged_web/components/core_components.ex +++ b/lib/swornforged_web/components/core_components.ex @@ -401,31 +401,6 @@ defmodule SwornforgedWeb.CoreComponents do """ end - @doc """ - Renders a header with title. - """ - attr :class, :string, default: nil - - slot :inner_block, required: true - slot :subtitle - slot :actions - - def header(assigns) do - ~H""" -
-
-

- <%= render_slot(@inner_block) %> -

-

- <%= render_slot(@subtitle) %> -

-
-
<%= render_slot(@actions) %>
-
- """ - end - @doc ~S""" Renders a table with generic styling. diff --git a/lib/swornforged_web/components/layouts/root.html.heex b/lib/swornforged_web/components/layouts/root.html.heex index 420683a..c6b2283 100644 --- a/lib/swornforged_web/components/layouts/root.html.heex +++ b/lib/swornforged_web/components/layouts/root.html.heex @@ -11,7 +11,7 @@ - + <%= @inner_content %> diff --git a/lib/swornforged_web/controllers/page_html.ex b/lib/swornforged_web/controllers/page_html.ex index c87ebbe..b56592c 100644 --- a/lib/swornforged_web/controllers/page_html.ex +++ b/lib/swornforged_web/controllers/page_html.ex @@ -2,4 +2,106 @@ defmodule SwornforgedWeb.PageHTML do use SwornforgedWeb, :html embed_templates "page_html/*" + + def get_in(data, keys, default) do + case get_in(data, keys) do + nil -> default + result -> result + end + end + + def srd_category_card(assigns) do + assigns = + assign(assigns, + card_colors: %{ + :asset_types => "bg-blue-500", + :encounters => "bg-rose-500", + :move_categories => "bg-violet-500", + :oracle_categories => "bg-amber-500" + } + ) + + ~H""" + + <%= @title %> + + """ + end + + def srd_header(assigns) do + ~H""" +
+

<%= @title %>

+
+ """ + end + + def srd_type_title(assigns) do + ~H""" +

<%= render_slot(@inner_block) %>

+ """ + end + + def srd_subtype_title(assigns) do + ~H""" +

<%= render_slot(@inner_block) %>

+ """ + end + + def srd_type_container(assigns) do + ~H""" +
+ <%= render_slot(@inner_block) %> +
+ """ + end + + def srd_item_inner_title(assigns) do + ~H""" +

<%= render_slot(@inner_block) %>

+ """ + end + + def srd_item(assigns) do + ~H""" +
+

+ @item["$id"]}><%= render_slot(@title) %> +

+
+
+ <%= render_slot(@inner_block) %> +

+ Source +
+ <%= get_in(@item, ["Source", "Title"]) %> + + p.<%= get_in(@item, ["Source", "Page"]) %> + +

+
+
+
+ Raw JSON +
+
<%= Jason.encode!(@item, pretty: true, escape: :html_safe) %>
+
+
+
+
+
+ """ + end end diff --git a/lib/swornforged_web/controllers/page_html/assets.html.heex b/lib/swornforged_web/controllers/page_html/assets.html.heex new file mode 100644 index 0000000..e69de29 diff --git a/lib/swornforged_web/controllers/page_html/home.html.heex b/lib/swornforged_web/controllers/page_html/home.html.heex index fd66b7b..cf0689f 100644 --- a/lib/swornforged_web/controllers/page_html/home.html.heex +++ b/lib/swornforged_web/controllers/page_html/home.html.heex @@ -1,76 +1,129 @@ -

Swornforged

-
-
-

Assets

-
-

- asset_type["$id"]}><%= asset_type["Display"]["Title"] %> -

- -
-
- -
-

Moves

-
-

- move_category["$id"]}> - <%= move_category["Display"]["Title"] %> - -

- -
+<.srd_header title="Swornforged" /> +
+
+ <.srd_category_card category={:asset_types} title="Asset Types" /> + <.srd_category_card category={:oracle_categories} title="Oracle Categories" /> + <.srd_category_card category={:move_categories} title="Move Categories" /> + <.srd_category_card category={:encounters} title="Encounters" />
+
+ <.srd_type_container> + <.srd_type_title>Assets +
+ <.srd_subtype_title> + asset_type["$id"]}><%= get_in(asset_type, ["Display", "Title"]) %> + +
    +
  • + <.srd_item item={asset}> + <:title><%= get_in(asset, ["Display", "Title"]) %> +
      +
    1. +
      + +
      + <%= raw(Earmark.as_html!(ability["Text"], compact_output: true)) %> +
      +
      +
    2. +
    + +
  • +
+
+ + <.srd_type_container> + <.srd_type_title>Oracles +
+ <.srd_subtype_title> + oracle_category["$id"]}> + <%= get_in(oracle_category, ["Display", "Title"]) %> + + +
    +
  • + <.srd_item item={oracle}> + <:title><%= get_in(oracle, ["Display", "Title"]) %> +
    +
    + <%= raw(Earmark.as_html!(str, compact_output: true)) %> +
    + + + + + + + + + + + + + +
    RollResult
    <%= row["Floor"] %>-<%= row["Ceiling"] %> + <%= raw(Earmark.as_html!(row["Result"], compact_output: true)) %> +
    +
    +
    +
    + <.srd_item_inner_title> + <%= get_in(inner_oracle, ["Display", "Title"]) %> + +
    +
    + <%= raw(Earmark.as_html!(str, compact_output: true)) %> +
    + + + + + + + + + + + + + +
    RollResult
    <%= row["Floor"] %>-<%= row["Ceiling"] %> + <%= raw(Earmark.as_html!(row["Result"], compact_output: true)) %> +
    +
    +
    + +
  • +
+
+ + <.srd_type_container> + <.srd_type_title>Moves +
+ <.srd_subtype_title> + move_category["$id"]}> + <%= get_in(move_category, ["Display", "Title"]) %> + + +
    +
  • + <.srd_item item={move}> + <:title><%= get_in(move, ["Display", "Title"]) %> +
    + <%= raw( + Earmark.as_html!(move["Text"], gfm: true, gfm_tables: true, compact_output: true) + ) %> +
    + +
  • +
+
+ +
diff --git a/lib/swornforged_web/controllers/page_html/moves.html.heex b/lib/swornforged_web/controllers/page_html/moves.html.heex new file mode 100644 index 0000000..e69de29 diff --git a/lib/swornforged_web/controllers/page_html/oracles.html.heex b/lib/swornforged_web/controllers/page_html/oracles.html.heex new file mode 100644 index 0000000..e69de29