Skip to content

Commit b52b8f8

Browse files
authored
Merge pull request #8 from logr-project/tailwind-v4
🎇 Tailwind v4
2 parents f2b1cd0 + 5110411 commit b52b8f8

File tree

7 files changed

+88
-89
lines changed

7 files changed

+88
-89
lines changed

assets/css/app.css

Lines changed: 32 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,33 @@
1-
@import "tailwindcss/base";
2-
@import "tailwindcss/components";
3-
@import "tailwindcss/utilities";
1+
/* See the Tailwind configuration guide for advanced usage
2+
https://tailwindcss.com/docs/configuration */
43

5-
/* This file is for your main application CSS */
4+
@import "tailwindcss";
5+
6+
@plugin "@tailwindcss/forms";
7+
@plugin "./tailwind_heroicons.js";
8+
9+
@variant phx-click-loading ([".phx-click-loading&", ".phx-click-loading &"]);
10+
@variant phx-submit-loading ([".phx-submit-loading&", ".phx-submit-loading &"]);
11+
@variant phx-change-loading ([".phx-change-loading&", ".phx-change-loading &"]);
12+
13+
@theme {
14+
--color-brand: oklch(66.64% 0.2202 37.57)
15+
}
16+
17+
/*
18+
* Make LiveView wrapper divs transparent for layout.
19+
* This makes it possible to use LiveViews as flex children for example.
20+
*/
21+
[data-phx-root-id] {
22+
display: contents
23+
}
24+
25+
/* Helper class for the default table component style that adds
26+
* rounded corners to the table rows.
27+
*/
28+
@utility rounded-table-corner {
29+
@apply first:before:absolute first:before:h-full first:before:w-4 first:before:top-0 first:before:-left-4 first:before:group-hover:bg-zinc-50 first:before:sm:rounded-l-xl last:before:absolute last:before:h-full last:before:w-4 last:before:top-0 last:before:-right-4 last:before:group-hover:bg-zinc-50 last:before:sm:rounded-r-xl;
30+
}
31+
32+
33+
/* This file is for your main application CSS */

assets/css/tailwind_heroicons.js

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
const plugin = require("tailwindcss/plugin")
2+
const fs = require("fs")
3+
const path = require("path")
4+
5+
// Embeds Heroicons (https://heroicons.com) into your app.css bundle
6+
// See your `CoreComponents.icon/1` for more information.
7+
//
8+
module.exports = plugin(function ({ matchComponents, theme }) {
9+
let iconsDir = path.join(__dirname, "../../deps/heroicons/optimized")
10+
let values = {}
11+
let icons = [
12+
["", "/24/outline"],
13+
["-solid", "/24/solid"],
14+
["-mini", "/20/solid"],
15+
["-micro", "/16/solid"]
16+
]
17+
icons.forEach(([suffix, dir]) => {
18+
fs.readdirSync(path.join(iconsDir, dir)).forEach(file => {
19+
let name = path.basename(file, ".svg") + suffix
20+
values[name] = { name, fullPath: path.join(iconsDir, dir, file) }
21+
})
22+
})
23+
matchComponents({
24+
"hero": ({ name, fullPath }) => {
25+
let content = fs.readFileSync(fullPath).toString().replace(/\r?\n|\r/g, "")
26+
let size = theme("spacing.6")
27+
if (name.endsWith("-mini")) {
28+
size = theme("spacing.5")
29+
} else if (name.endsWith("-micro")) {
30+
size = theme("spacing.4")
31+
}
32+
return {
33+
[`--hero-${name}`]: `url('data:image/svg+xml;utf8,${content}')`,
34+
"-webkit-mask": `var(--hero-${name})`,
35+
"mask": `var(--hero-${name})`,
36+
"mask-repeat": "no-repeat",
37+
"background-color": "currentColor",
38+
"vertical-align": "middle",
39+
"display": "inline-block",
40+
"width": size,
41+
"height": size
42+
}
43+
}
44+
}, { values })
45+
})
46+

assets/tailwind.config.js

Lines changed: 0 additions & 74 deletions
This file was deleted.

config/config.exs

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -43,14 +43,13 @@ config :esbuild,
4343

4444
# Configure tailwind (the version is required)
4545
config :tailwind,
46-
version: "3.4.3",
46+
version: "4.0.9",
4747
logr: [
4848
args: ~w(
49-
--config=tailwind.config.js
50-
--input=css/app.css
51-
--output=../priv/static/assets/app.css
49+
--input=assets/css/app.css
50+
--output=priv/static/assets/app.css
5251
),
53-
cd: Path.expand("../assets", __DIR__)
52+
cd: Path.expand("..", __DIR__)
5453
]
5554

5655
# Configures Elixir's Logger

lib/logr_web/components/core_components.ex

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -318,7 +318,7 @@ defmodule LogrWeb.CoreComponents do
318318
name={@name}
319319
value="true"
320320
checked={@checked}
321-
class="rounded border-zinc-300 text-zinc-900 focus:ring-0"
321+
class="rounded-sm border-zinc-300 text-zinc-900 focus:ring-0"
322322
{@rest}
323323
/>
324324
{@label}
@@ -335,7 +335,7 @@ defmodule LogrWeb.CoreComponents do
335335
<select
336336
id={@id}
337337
name={@name}
338-
class="mt-2 block w-full rounded-md border border-gray-300 bg-white shadow-sm focus:border-zinc-400 focus:ring-0 sm:text-sm"
338+
class="mt-2 block w-full rounded-md border border-gray-300 bg-white shadow-xs focus:border-zinc-400 focus:ring-0 sm:text-sm"
339339
multiple={@multiple}
340340
{@rest}
341341
>
@@ -581,7 +581,7 @@ defmodule LogrWeb.CoreComponents do
581581
width, height, and background color classes.
582582
583583
Icons are extracted from the `deps/heroicons` directory and bundled within
584-
your compiled app.css by the plugin in your `assets/tailwind.config.js`.
584+
your compiled app.css by the plugin in your `assets/css/tailwind_heroicons.js`.
585585
586586
## Examples
587587

mix.exs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ defmodule Logr.MixProject do
4343
{:floki, ">= 0.30.0", only: :test},
4444
{:phoenix_live_dashboard, "~> 0.8.3"},
4545
{:esbuild, "~> 0.8", runtime: Mix.env() == :dev},
46-
{:tailwind, "~> 0.2", runtime: Mix.env() == :dev},
46+
{:tailwind, "~> 0.3.0", runtime: Mix.env() == :dev},
4747
{:heroicons,
4848
github: "tailwindlabs/heroicons",
4949
tag: "v2.1.1",

mix.lock

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
%{
22
"argon2_elixir": {:hex, :argon2_elixir, "3.2.1", "f47740bf9f2a39ffef79ba48eb25dea2ee37bcc7eadf91d49615591d1a6fce1a", [:make, :mix], [{:comeonin, "~> 5.3", [hex: :comeonin, repo: "hexpm", optional: false]}, {:elixir_make, "~> 0.6", [hex: :elixir_make, repo: "hexpm", optional: false]}], "hexpm", "a813b78217394530b5fcf4c8070feee43df03ffef938d044019169c766315690"},
33
"bandit": {:hex, :bandit, "1.6.7", "42f30e37a1c89a2a12943c5dca76f731a2313e8a2e21c1a95dc8241893e922d1", [:mix], [{:hpax, "~> 1.0", [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", "551ba8ff5e4fc908cbeb8c9f0697775fb6813a96d9de5f7fe02e34e76fd7d184"},
4-
"castore": {:hex, :castore, "1.0.11", "4bbd584741601eb658007339ea730b082cc61f3554cf2e8f39bf693a11b49073", [:mix], [], "hexpm", "e03990b4db988df56262852f20de0f659871c35154691427a5047f4967a16a62"},
4+
"castore": {:hex, :castore, "1.0.12", "053f0e32700cbec356280c0e835df425a3be4bc1e0627b714330ad9d0f05497f", [:mix], [], "hexpm", "3dca286b2186055ba0c9449b4e95b97bf1b57b47c1f2644555879e659960c224"},
55
"comeonin": {:hex, :comeonin, "5.5.1", "5113e5f3800799787de08a6e0db307133850e635d34e9fab23c70b6501669510", [:mix], [], "hexpm", "65aac8f19938145377cee73973f192c5645873dcf550a8a6b18187d17c13ccdb"},
66
"db_connection": {:hex, :db_connection, "2.7.0", "b99faa9291bb09892c7da373bb82cba59aefa9b36300f6145c5f201c7adf48ec", [:mix], [{:telemetry, "~> 0.4 or ~> 1.0", [hex: :telemetry, repo: "hexpm", optional: false]}], "hexpm", "dcf08f31b2701f857dfc787fbad78223d61a32204f217f15e881dd93e4bdd3ff"},
77
"decimal": {:hex, :decimal, "2.3.0", "3ad6255aa77b4a3c4f818171b12d237500e63525c2fd056699967a3e7ea20f62", [:mix], [], "hexpm", "a4d66355cb29cb47c3cf30e71329e58361cfcb37c34235ef3bf1d7bf3773aeac"},
@@ -34,7 +34,7 @@
3434
"plug_crypto": {:hex, :plug_crypto, "2.1.0", "f44309c2b06d249c27c8d3f65cfe08158ade08418cf540fd4f72d4d6863abb7b", [:mix], [], "hexpm", "131216a4b030b8f8ce0f26038bc4421ae60e4bb95c5cf5395e1421437824c4fa"},
3535
"postgrex": {:hex, :postgrex, "0.20.0", "363ed03ab4757f6bc47942eff7720640795eb557e1935951c1626f0d303a3aed", [:mix], [{:db_connection, "~> 2.1", [hex: :db_connection, repo: "hexpm", optional: false]}, {:decimal, "~> 1.5 or ~> 2.0", [hex: :decimal, repo: "hexpm", optional: false]}, {:jason, "~> 1.0", [hex: :jason, repo: "hexpm", optional: true]}, {:table, "~> 0.1.0", [hex: :table, repo: "hexpm", optional: true]}], "hexpm", "d36ef8b36f323d29505314f704e21a1a038e2dc387c6409ee0cd24144e187c0f"},
3636
"swoosh": {:hex, :swoosh, "1.17.10", "3bfce0e716f92c85579c8b7bb390f1d287f388e4961bfb9343fe191ec4214225", [:mix], [{:bandit, ">= 1.0.0", [hex: :bandit, repo: "hexpm", optional: true]}, {:cowboy, "~> 1.1 or ~> 2.4", [hex: :cowboy, repo: "hexpm", optional: true]}, {:ex_aws, "~> 2.1", [hex: :ex_aws, repo: "hexpm", optional: true]}, {:finch, "~> 0.6", [hex: :finch, repo: "hexpm", optional: true]}, {:gen_smtp, "~> 0.13 or ~> 1.0", [hex: :gen_smtp, repo: "hexpm", optional: true]}, {:hackney, "~> 1.9", [hex: :hackney, repo: "hexpm", optional: true]}, {:jason, "~> 1.0", [hex: :jason, repo: "hexpm", optional: false]}, {:mail, "~> 0.2", [hex: :mail, repo: "hexpm", optional: true]}, {:mime, "~> 1.1 or ~> 2.0", [hex: :mime, repo: "hexpm", optional: false]}, {:mua, "~> 0.2.3", [hex: :mua, repo: "hexpm", optional: true]}, {:multipart, "~> 0.4", [hex: :multipart, repo: "hexpm", optional: true]}, {:plug, "~> 1.9", [hex: :plug, repo: "hexpm", optional: true]}, {:plug_cowboy, ">= 1.0.0", [hex: :plug_cowboy, repo: "hexpm", optional: true]}, {:req, "~> 0.5 or ~> 1.0", [hex: :req, repo: "hexpm", optional: true]}, {:telemetry, "~> 0.4.2 or ~> 1.0", [hex: :telemetry, repo: "hexpm", optional: false]}], "hexpm", "277f86c249089f4fc7d70944987151b76424fac1d348d40685008ba88e0a2717"},
37-
"tailwind": {:hex, :tailwind, "0.2.4", "5706ec47182d4e7045901302bf3a333e80f3d1af65c442ba9a9eed152fb26c2e", [:mix], [{:castore, ">= 0.0.0", [hex: :castore, repo: "hexpm", optional: false]}], "hexpm", "c6e4a82b8727bab593700c998a4d98cf3d8025678bfde059aed71d0000c3e463"},
37+
"tailwind": {:hex, :tailwind, "0.3.1", "a89d2835c580748c7a975ad7dd3f2ea5e63216dc16d44f9df492fbd12c094bed", [:mix], [], "hexpm", "98a45febdf4a87bc26682e1171acdedd6317d0919953c353fcd1b4f9f4b676a2"},
3838
"telemetry": {:hex, :telemetry, "1.3.0", "fedebbae410d715cf8e7062c96a1ef32ec22e764197f70cda73d82778d61e7a2", [:rebar3], [], "hexpm", "7015fc8919dbe63764f4b4b87a95b7c0996bd539e0d499be6ec9d7f3875b79e6"},
3939
"telemetry_metrics": {:hex, :telemetry_metrics, "1.1.0", "5bd5f3b5637e0abea0426b947e3ce5dd304f8b3bc6617039e2b5a008adc02f8f", [:mix], [{:telemetry, "~> 0.4 or ~> 1.0", [hex: :telemetry, repo: "hexpm", optional: false]}], "hexpm", "e7b79e8ddfde70adb6db8a6623d1778ec66401f366e9a8f5dd0955c56bc8ce67"},
4040
"telemetry_poller": {:hex, :telemetry_poller, "1.1.0", "58fa7c216257291caaf8d05678c8d01bd45f4bdbc1286838a28c4bb62ef32999", [:rebar3], [{:telemetry, "~> 1.0", [hex: :telemetry, repo: "hexpm", optional: false]}], "hexpm", "9eb9d9cbfd81cbd7cdd24682f8711b6e2b691289a0de6826e58452f28c103c8f"},

0 commit comments

Comments
 (0)