mirror of
https://github.com/woutdp/live_svelte
synced 2026-05-24 01:18:53 +00:00
* remove old link in example page. add real time for ecto example * upgraded tailwind 4 and latest phoenix for example * fixed svelte component remounting on server events * generate auto ids for duplicate components * handle static svelte components in live view parent properly * prepare release 0.17.3 release * adjust the live_svelte version in mix.exs
40 lines
1.4 KiB
JavaScript
40 lines
1.4 KiB
JavaScript
const plugin = require("tailwindcss/plugin")
|
|
const fs = require("fs")
|
|
const path = require("path")
|
|
|
|
module.exports = plugin(function ({matchComponents, theme}) {
|
|
let iconsDir = path.join(__dirname, "../../priv/hero_icons/optimized")
|
|
let values = {}
|
|
let icons = [
|
|
["", "/24/outline"],
|
|
["-solid", "/24/solid"],
|
|
["-mini", "/20/solid"],
|
|
]
|
|
icons.forEach(([suffix, dir]) => {
|
|
fs.readdirSync(path.join(iconsDir, dir)).map(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, "")
|
|
return {
|
|
[`--hero-${name}`]: `url('data:image/svg+xml;utf8,${content}')`,
|
|
"-webkit-mask": `var(--hero-${name})`,
|
|
mask: `var(--hero-${name})`,
|
|
"background-color": "currentColor",
|
|
"vertical-align": "middle",
|
|
display: "inline-block",
|
|
width: theme("spacing.5"),
|
|
height: theme("spacing.5"),
|
|
}
|
|
},
|
|
},
|
|
{values}
|
|
)
|
|
})
|