Skip to content

Commit 86d72d3

Browse files
committed
☂️ Complete the Tailwind v4 setup
1 parent dac33b3 commit 86d72d3

File tree

6 files changed

+78
-77
lines changed

6 files changed

+78
-77
lines changed

assets/css/app.css

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,33 @@
1+
/* See the Tailwind configuration guide for advanced usage
2+
https://tailwindcss.com/docs/configuration */
3+
14
@import "tailwindcss";
25

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+
333
/* 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: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,6 @@ config :tailwind,
4646
version: "4.0.9",
4747
logr: [
4848
args: ~w(
49-
--config=assets/tailwind.config.js
5049
--input=assets/css/app.css
5150
--output=priv/static/assets/app.css
5251
),

lib/logr_web/components/core_components.ex

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -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.3", runtime: Mix.env() == :dev},
46+
{:tailwind, "~> 0.3.0", runtime: Mix.env() == :dev},
4747
{:heroicons,
4848
github: "tailwindlabs/heroicons",
4949
tag: "v2.1.1",

0 commit comments

Comments
 (0)