From ae26d0ed11f18c9117adddccb68f15fdb69128ff Mon Sep 17 00:00:00 2001 From: sloane <1699281+sloanelybutsurely@users.noreply.github.com> Date: Wed, 21 Feb 2024 09:17:58 -0500 Subject: [PATCH] wip: install tailwind --- assets/css/app.css | 4 ++++ assets/tailwind.config.js | 22 ++++++++++++++++++++++ config/config.exs | 9 +++++++++ lib/sloane_sh/watch.ex | 2 ++ mix.exs | 12 ++++++++++-- mix.lock | 2 ++ priv/site/layouts/root.html.eex | 1 + 7 files changed, 50 insertions(+), 2 deletions(-) create mode 100644 assets/css/app.css create mode 100644 assets/tailwind.config.js diff --git a/assets/css/app.css b/assets/css/app.css new file mode 100644 index 0000000..71a77f0 --- /dev/null +++ b/assets/css/app.css @@ -0,0 +1,4 @@ +@import "tailwindcss/base"; +@import "tailwindcss/components"; +@import "tailwindcss/utilities"; + diff --git a/assets/tailwind.config.js b/assets/tailwind.config.js new file mode 100644 index 0000000..76fe451 --- /dev/null +++ b/assets/tailwind.config.js @@ -0,0 +1,22 @@ +// See the Tailwind configuration guide for advanced usage +// https://tailwindcss.com/docs/configuration + +let plugin = require('tailwindcss/plugin') + +module.exports = { + content: [ + './js/**/*.js', + '../lib/*_web.ex', + '../lib/*_web/**/*.*ex' + ], + theme: { + extend: {}, + }, + 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 &'])) + ] +} diff --git a/config/config.exs b/config/config.exs index 2b5efec..39e0e36 100644 --- a/config/config.exs +++ b/config/config.exs @@ -2,3 +2,12 @@ import Config config :logger, :default_formatter, format: "$time $metadata[$level] $message\n" + +config :tailwind, version: "3.4.1", default: [ + args: ~w( + --config=tailwind.config.js + --input=css/app.css + --output=../priv/output/assets/app.css + ), + cd: Path.expand("../assets", __DIR__) +] diff --git a/lib/sloane_sh/watch.ex b/lib/sloane_sh/watch.ex index cfaa5e1..87ce35a 100644 --- a/lib/sloane_sh/watch.ex +++ b/lib/sloane_sh/watch.ex @@ -29,6 +29,8 @@ defmodule SloaneSH.Watch do FileSystem.subscribe(watcher_pid) + Tailwind.install_and_run(:default, ~w[--watch]) |> dbg() + state = %__MODULE__{ctx: ctx, watcher_pid: watcher_pid} {:ok, state, {:continue, :build}} diff --git a/mix.exs b/mix.exs index 191ad5f..f0eb7cc 100644 --- a/mix.exs +++ b/mix.exs @@ -7,7 +7,8 @@ defmodule SloaneSH.MixProject do version: "0.1.0", elixir: "~> 1.16", start_permanent: Mix.env() == :prod, - deps: deps() + deps: deps(), + aliases: aliases() ] end @@ -26,7 +27,14 @@ defmodule SloaneSH.MixProject do {:earmark, "~> 1.4"}, {:earmark_parser, "~> 1.4"}, {:plug, "~> 1.15"}, - {:bandit, "~> 1.2"} + {:bandit, "~> 1.2"}, + {:tailwind, "~> 0.2"} + ] + end + + defp aliases do + [ + "assets.deploy": ["tailwind default --minify"] ] end end diff --git a/mix.lock b/mix.lock index 11f5828..ccba40b 100644 --- a/mix.lock +++ b/mix.lock @@ -1,5 +1,6 @@ %{ "bandit": {:hex, :bandit, "1.2.2", "569fe5d0efb107c9af37a1e37e25ce2ceec293101a2d4bc512876fc3207192b5", [:mix], [{:hpax, "~> 0.1.1", [hex: :hpax, repo: "hexpm", optional: false]}, {:plug, "~> 1.14", [hex: :plug, repo: "hexpm", optional: false]}, {:telemetry, "~> 0.4 or ~> 1.0", [hex: :telemetry, repo: "hexpm", optional: false]}, {:thousand_island, "~> 1.0", [hex: :thousand_island, repo: "hexpm", optional: false]}, {:websock, "~> 0.5", [hex: :websock, repo: "hexpm", optional: false]}], "hexpm", "2f89adb7281c78d4e75733e0a9e1b24f46f84d2993963d6fa57d0eafadec5f03"}, + "castore": {:hex, :castore, "1.0.5", "9eeebb394cc9a0f3ae56b813459f990abb0a3dedee1be6b27fdb50301930502f", [:mix], [], "hexpm", "8d7c597c3e4a64c395980882d4bca3cebb8d74197c590dc272cfd3b6a6310578"}, "earmark": {:hex, :earmark, "1.4.46", "8c7287bd3137e99d26ae4643e5b7ef2129a260e3dcf41f251750cb4563c8fb81", [:mix], [], "hexpm", "798d86db3d79964e759ddc0c077d5eb254968ed426399fbf5a62de2b5ff8910a"}, "earmark_parser": {:hex, :earmark_parser, "1.4.39", "424642f8335b05bb9eb611aa1564c148a8ee35c9c8a8bba6e129d51a3e3c6769", [:mix], [], "hexpm", "06553a88d1f1846da9ef066b87b57c6f605552cfbe40d20bd8d59cc6bde41944"}, "file_system": {:hex, :file_system, "1.0.0", "b689cc7dcee665f774de94b5a832e578bd7963c8e637ef940cd44327db7de2cd", [:mix], [], "hexpm", "6752092d66aec5a10e662aefeed8ddb9531d79db0bc145bb8c40325ca1d8536d"}, @@ -7,6 +8,7 @@ "mime": {:hex, :mime, "2.0.5", "dc34c8efd439abe6ae0343edbb8556f4d63f178594894720607772a041b04b02", [:mix], [], "hexpm", "da0d64a365c45bc9935cc5c8a7fc5e49a0e0f9932a761c55d6c52b142780a05c"}, "plug": {:hex, :plug, "1.15.3", "712976f504418f6dff0a3e554c40d705a9bcf89a7ccef92fc6a5ef8f16a30a97", [:mix], [{:mime, "~> 1.0 or ~> 2.0", [hex: :mime, repo: "hexpm", optional: false]}, {:plug_crypto, "~> 1.1.1 or ~> 1.2 or ~> 2.0", [hex: :plug_crypto, repo: "hexpm", optional: false]}, {:telemetry, "~> 0.4.3 or ~> 1.0", [hex: :telemetry, repo: "hexpm", optional: false]}], "hexpm", "cc4365a3c010a56af402e0809208873d113e9c38c401cabd88027ef4f5c01fd2"}, "plug_crypto": {:hex, :plug_crypto, "2.0.0", "77515cc10af06645abbfb5e6ad7a3e9714f805ae118fa1a70205f80d2d70fe73", [:mix], [], "hexpm", "53695bae57cc4e54566d993eb01074e4d894b65a3766f1c43e2c61a1b0f45ea9"}, + "tailwind": {:hex, :tailwind, "0.2.2", "9e27288b568ede1d88517e8c61259bc214a12d7eed271e102db4c93fcca9b2cd", [:mix], [{:castore, ">= 0.0.0", [hex: :castore, repo: "hexpm", optional: false]}], "hexpm", "ccfb5025179ea307f7f899d1bb3905cd0ac9f687ed77feebc8f67bdca78565c4"}, "telemetry": {:hex, :telemetry, "1.2.1", "68fdfe8d8f05a8428483a97d7aab2f268aaff24b49e0f599faa091f1d4e7f61c", [:rebar3], [], "hexpm", "dad9ce9d8effc621708f99eac538ef1cbe05d6a874dd741de2e689c47feafed5"}, "thousand_island": {:hex, :thousand_island, "1.3.2", "bc27f9afba6e1a676dd36507d42e429935a142cf5ee69b8e3f90bff1383943cd", [:mix], [{:telemetry, "~> 0.4 or ~> 1.0", [hex: :telemetry, repo: "hexpm", optional: false]}], "hexpm", "0e085b93012cd1057b378fce40cbfbf381ff6d957a382bfdd5eca1a98eec2535"}, "typed_struct": {:hex, :typed_struct, "0.3.0", "939789e3c1dca39d7170c87f729127469d1315dcf99fee8e152bb774b17e7ff7", [:mix], [], "hexpm", "c50bd5c3a61fe4e198a8504f939be3d3c85903b382bde4865579bc23111d1b6d"}, diff --git a/priv/site/layouts/root.html.eex b/priv/site/layouts/root.html.eex index 6a10708..3eb4fac 100644 --- a/priv/site/layouts/root.html.eex +++ b/priv/site/layouts/root.html.eex @@ -4,6 +4,7 @@