-
I have an app built with petal_components and trying to setup backpex. My mix.exs now looks like this (according to the installation guide of backpex): defp deps do
[
# ...
{:petal_components, "~> 1.9"},
{:heroicons,
github: "tailwindlabs/heroicons",
tag: "v2.1.1",
sparse: "optimized",
app: false,
compile: false,
depth: 1},
# ...
]
Which leads to following conflict: $ mix deps.get
[...]
Dependencies have diverged:
* heroicons (https://github.com/tailwindlabs/heroicons.git - v2.1.1)
the dependency heroicons in mix.exs is overriding a child dependency:
> In mix.exs:
{:heroicons, [env: :prod, git: "https://github.com/tailwindlabs/heroicons.git", tag: "v2.1.1", sparse: "optimized", app: false, compile: false, depth: 1]}
> In deps/petal_components/mix.exs:
{:heroicons, "~> 0.5.3", [env: :prod, hex: "heroicons", repo: "hexpm", optional: false]}
Ensure they match or specify one of the above in your deps and set "override: true" I can set Anyone got backpex running together with petal_components? |
Beta Was this translation helpful? Give feedback.
Replies: 4 comments 8 replies
-
Hey @phortx! It seems that The "Backpex way" is also the way Phoenix integrates heroicons into new applications (e.g. created with Because the way heroicons are integrated is different in Backpex and One way to run Backpex together with In your defp deps do
[
...
- {:heroicons
+ {:heroicons_plugin,
github: "tailwindlabs/heroicons",
tag: "v2.1.1",
sparse: "optimized",
app: false,
compile: false,
depth: 1},
]
end and in your module.exports = {
...
plugins: [
...
// add this plugin
plugin(function ({ matchComponents, theme }) {
- let iconsDir = path.join(__dirname, "../deps/heroicons/optimized")
+ let iconsDir = path.join(__dirname, "../deps/heroicons_plugin/optimized")
let values = {}
let icons = [
["", "/24/outline"],
["-solid", "/24/solid"],
["-mini", "/20/solid"],
["-micro", "/16/solid"]
]
icons.forEach(([suffix, dir]) => {
fs.readdirSync(path.join(iconsDir, dir)).forEach(file => {
let name = path.basename(file, ".svg") + suffix
values[name] = { name, fullPath: path.join(iconsDir, dir, file) }
})
})
matchComponents({
"hero": ({ name, fullPath }) => {
let content = fs.readFileSync(fullPath).toString().replace(/\r?\n|\r/g, "")
let size = theme("spacing.6")
if (name.endsWith("-mini")) {
size = theme("spacing.5")
} else if (name.endsWith("-micro")) {
size = theme("spacing.4")
}
return {
[`--hero-${name}`]: `url('data:image/svg+xml;utf8,${content}')`,
"-webkit-mask": `var(--hero-${name})`,
"mask": `var(--hero-${name})`,
"mask-repeat": "no-repeat",
"background-color": "currentColor",
"vertical-align": "middle",
"display": "inline-block",
"width": size,
"height": size
}
}
}, { values })
})
],
} Some additional resources:
Thanks for the discussion! I see that some users already had problems with conflicting versions of Heroicons. I will add a section to the installation guide that covers the problem and the solution. |
Beta Was this translation helpful? Give feedback.
-
Guten Morgen Florian! Wow that was an amazing and comprehend answer. When there would be badg for that, you probably would just have won one :D I'll give it a try! Thank you very much for your time and your amazing work :) |
Beta Was this translation helpful? Give feedback.
-
Worked like a charm, thank you very much :) |
Beta Was this translation helpful? Give feedback.
-
Now I have the issue that backpex looks rather unstyled. All styles are loaded, no errors in JS Console, everything is setup according to the installation guide except DaisyUI. Is this related to petal_components too maybe? |
Beta Was this translation helpful? Give feedback.
Hey @phortx!
It seems that
petal_components
uses theheroicons
hex package to integrate the icons. The package ships Phoenix Components to be used for icon integration. Backpex doesn't use this package, but tracks the "tailwindlabs/heroicons" GitHub repository with mix to load the icons into the deps. It then requires you to provide a Tailwind CSS plugin to display icons for elements that have thehero-*
class.The "Backpex way" is also the way Phoenix integrates heroicons into new applications (e.g. created with
mix phx.new
).Because the way heroicons are integrated is different in Backpex and
petal_components
, you cannot useoverride: true
.One way to run Backpex together with
petal_com…