Skip to content

Commit

Permalink
Use heroicons from git, closes phoenixframework#5622 (phoenixframewor…
Browse files Browse the repository at this point in the history
  • Loading branch information
josevalim authored Nov 13, 2023
1 parent f06eed4 commit 7de3ea0
Show file tree
Hide file tree
Showing 11 changed files with 26 additions and 58 deletions.
15 changes: 0 additions & 15 deletions installer/lib/phx_new/generator.ex
Original file line number Diff line number Diff line change
Expand Up @@ -73,21 +73,6 @@ defmodule Phx.New.Generator do
:keep ->
File.mkdir_p!(target)

:zip ->
parent_dir = Path.dirname(target)
Mix.shell().info([:green, "* extracting ", :reset, Path.relative_to_cwd(target)])

File.mkdir_p!(parent_dir)
zip_contents = mod.render(name, source, project.binding)
{:ok, zip} = :zip.zip_open(zip_contents, [:memory])
{:ok, files} = :zip.zip_get(zip)

Enum.map(files, fn {path, contents} ->
full_path = Path.join(parent_dir, path)
File.mkdir_p!(Path.dirname(full_path))
File.write!(full_path, contents)
end)

:text ->
create_file(target, mod.render(name, source, project.binding))

Expand Down
6 changes: 1 addition & 5 deletions installer/lib/phx_new/single.ex
Original file line number Diff line number Diff line change
Expand Up @@ -70,11 +70,7 @@ defmodule Phx.New.Single do
template(:css, [
{:eex, :web,
"phx_assets/app.css": "assets/css/app.css",
"phx_assets/tailwind.config.js": "assets/tailwind.config.js"},
{:eex, :web,
"phx_assets/heroicons/LICENSE.md": "assets/vendor/heroicons/LICENSE.md",
"phx_assets/heroicons/UPGRADE.md": "assets/vendor/heroicons/UPGRADE.md"},
{:zip, :web, "phx_assets/heroicons/optimized.zip": "assets/vendor/heroicons/optimized"}
"phx_assets/tailwind.config.js": "assets/tailwind.config.js"}
])

template(:js, [
Expand Down
21 changes: 0 additions & 21 deletions installer/templates/phx_assets/heroicons/LICENSE.md

This file was deleted.

6 changes: 0 additions & 6 deletions installer/templates/phx_assets/heroicons/UPGRADE.md

This file was deleted.

Binary file not shown.
2 changes: 1 addition & 1 deletion installer/templates/phx_assets/tailwind.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ module.exports = {
// See your `CoreComponents.icon/1` for more information.
//
plugin(function({matchComponents, theme}) {
let iconsDir = path.join(__dirname, "./vendor/heroicons/optimized")
let iconsDir = path.join(__dirname, "..<%= if @in_umbrella, do: "/../.." %>/deps/heroicons/optimized")
let values = {}
let icons = [
["", "/24/outline"],
Expand Down
8 changes: 7 additions & 1 deletion installer/templates/phx_single/mix.exs
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,13 @@ defmodule <%= @app_module %>.MixProject do
{:floki, ">= 0.30.0", only: :test},<% end %><%= if @dashboard do %>
{:phoenix_live_dashboard, "~> 0.8.2"},<% end %><%= if @javascript do %>
{:esbuild, "~> 0.8", runtime: Mix.env() == :dev},<% end %><%= if @css do %>
{:tailwind, "~> 0.2.0", runtime: Mix.env() == :dev},<% end %><%= if @mailer do %>
{:tailwind, "~> 0.2", runtime: Mix.env() == :dev},
{:heroicons,
github: "tailwindlabs/heroicons",
tag: "v2.0.18",
app: false,
compile: false,
sparse: "optimized"},<% end %><%= if @mailer do %>
{:swoosh, "~> 1.3"},
{:finch, "~> 0.13"},<% end %>
{:telemetry_metrics, "~> 0.6"},
Expand Down
8 changes: 7 additions & 1 deletion installer/templates/phx_umbrella/apps/app_name_web/mix.exs
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,13 @@ defmodule <%= @web_namespace %>.MixProject do
{:floki, ">= 0.30.0", only: :test},<% end %><%= if @dashboard do %>
{:phoenix_live_dashboard, "~> 0.8.2"},<% end %><%= if @javascript do %>
{:esbuild, "~> 0.8", runtime: Mix.env() == :dev},<% end %><%= if @css do %>
{:tailwind, "~> 0.2.0", runtime: Mix.env() == :dev},<% end %>
{:tailwind, "~> 0.2", runtime: Mix.env() == :dev},
{:heroicons,
github: "tailwindlabs/heroicons",
tag: "v2.0.18",
app: false,
compile: false,
sparse: "optimized"},<% end %>
{:telemetry_metrics, "~> 0.6"},
{:telemetry_poller, "~> 1.0"},<%= if @gettext do %>
{:gettext, "~> 0.20"},<% end %><%= if @app_name != @web_app_name do %>
Expand Down
11 changes: 3 additions & 8 deletions installer/test/phx_new_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -151,16 +151,11 @@ defmodule Mix.Tasks.Phx.NewTest do

# tailwind
assert_file("phx_blog/assets/css/app.css")
assert_file "phx_blog/assets/tailwind.config.js", fn file ->

assert_file("phx_blog/assets/tailwind.config.js", fn file ->
assert file =~ "phx_blog_web.ex"
assert file =~ "phx_blog_web/**/*.*ex"
end

assert_file("phx_blog/assets/vendor/heroicons/LICENSE.md")
assert_file("phx_blog/assets/vendor/heroicons/UPGRADE.md")
assert_file("phx_blog/assets/vendor/heroicons/optimized/24/outline/cake.svg")
assert_file("phx_blog/assets/vendor/heroicons/optimized/24/solid/cake.svg")
assert_file("phx_blog/assets/vendor/heroicons/optimized/20/solid/cake.svg")
end)

refute File.exists?("phx_blog/priv/static/assets/app.css")
refute File.exists?("phx_blog/priv/static/assets/app.js")
Expand Down
6 changes: 6 additions & 0 deletions integration_test/mix.exs
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,12 @@ defmodule Phoenix.Integration.MixProject do
{:argon2_elixir, "~> 3.0"},
{:pbkdf2_elixir, "~> 2.0"},
{:tailwind, "~> 0.2"},
{:heroicons,
github: "tailwindlabs/heroicons",
tag: "v2.0.18",
app: false,
compile: false,
sparse: "optimized"},
{:finch, "~> 0.13"}
]
end
Expand Down
1 change: 1 addition & 0 deletions integration_test/mix.lock
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
"finch": {:hex, :finch, "0.16.0", "40733f02c89f94a112518071c0a91fe86069560f5dbdb39f9150042f44dcfb1a", [:mix], [{:castore, "~> 0.1 or ~> 1.0", [hex: :castore, repo: "hexpm", optional: false]}, {:mime, "~> 1.0 or ~> 2.0", [hex: :mime, repo: "hexpm", optional: false]}, {:mint, "~> 1.3", [hex: :mint, repo: "hexpm", optional: false]}, {:nimble_options, "~> 0.4 or ~> 1.0", [hex: :nimble_options, repo: "hexpm", optional: false]}, {:nimble_pool, "~> 0.2.6 or ~> 1.0", [hex: :nimble_pool, repo: "hexpm", optional: false]}, {:telemetry, "~> 0.4 or ~> 1.0", [hex: :telemetry, repo: "hexpm", optional: false]}], "hexpm", "f660174c4d519e5fec629016054d60edd822cdfe2b7270836739ac2f97735ec5"},
"floki": {:hex, :floki, "0.34.3", "5e2dcaec5d7c228ce5b1d3501502e308b2d79eb655e4191751a1fe491c37feac", [:mix], [], "hexpm", "9577440eea5b97924b4bf3c7ea55f7b8b6dce589f9b28b096cc294a8dc342341"},
"gettext": {:hex, :gettext, "0.22.3", "c8273e78db4a0bb6fba7e9f0fd881112f349a3117f7f7c598fa18c66c888e524", [:mix], [{:expo, "~> 0.4.0", [hex: :expo, repo: "hexpm", optional: false]}], "hexpm", "935f23447713954a6866f1bb28c3a878c4c011e802bcd68a726f5e558e4b64bd"},
"heroicons": {:git, "https://github.com/tailwindlabs/heroicons.git", "f64c10b59dcd6417732a984ce4376bed13799485", [tag: "v2.0.18", sparse: "optimized"]},
"hpax": {:hex, :hpax, "0.1.2", "09a75600d9d8bbd064cdd741f21fc06fc1f4cf3d0fcc335e5aa19be1a7235c84", [:mix], [], "hexpm", "2c87843d5a23f5f16748ebe77969880e29809580efdaccd615cd3bed628a8c13"},
"jason": {:hex, :jason, "1.4.1", "af1504e35f629ddcdd6addb3513c3853991f694921b1b9368b0bd32beb9f1b63", [:mix], [{:decimal, "~> 1.0 or ~> 2.0", [hex: :decimal, repo: "hexpm", optional: true]}], "hexpm", "fbb01ecdfd565b56261302f7e1fcc27c4fb8f32d56eab74db621fc154604a7a1"},
"mime": {:hex, :mime, "2.0.5", "dc34c8efd439abe6ae0343edbb8556f4d63f178594894720607772a041b04b02", [:mix], [], "hexpm", "da0d64a365c45bc9935cc5c8a7fc5e49a0e0f9932a761c55d6c52b142780a05c"},
Expand Down

0 comments on commit 7de3ea0

Please sign in to comment.