|
| 1 | +// See the Tailwind configuration guide for advanced usage |
| 2 | +// https://tailwindcss.com/docs/configuration |
| 3 | + |
| 4 | +const plugin = require("tailwindcss/plugin") |
| 5 | +const fs = require("fs") |
| 6 | +const path = require("path") |
| 7 | + |
| 8 | +module.exports = { |
| 9 | + content: [ |
| 10 | + "./js/**/*.js", |
| 11 | + "../lib/phoenix_app_web.ex", |
| 12 | + "../lib/phoenix_app_web/**/*.*ex" |
| 13 | + ], |
| 14 | + theme: { |
| 15 | + extend: { |
| 16 | + colors: { |
| 17 | + brand: "#FD4F00", |
| 18 | + } |
| 19 | + }, |
| 20 | + }, |
| 21 | + plugins: [ |
| 22 | + require("@tailwindcss/forms"), |
| 23 | + // Allows prefixing tailwind classes with LiveView classes to add rules |
| 24 | + // only when LiveView classes are applied, for example: |
| 25 | + // |
| 26 | + // <div class="phx-click-loading:animate-ping"> |
| 27 | + // |
| 28 | + plugin(({addVariant}) => addVariant("phx-click-loading", [".phx-click-loading&", ".phx-click-loading &"])), |
| 29 | + plugin(({addVariant}) => addVariant("phx-submit-loading", [".phx-submit-loading&", ".phx-submit-loading &"])), |
| 30 | + plugin(({addVariant}) => addVariant("phx-change-loading", [".phx-change-loading&", ".phx-change-loading &"])), |
| 31 | + |
| 32 | + // Embeds Heroicons (https://heroicons.com) into your app.css bundle |
| 33 | + // See your `CoreComponents.icon/1` for more information. |
| 34 | + // |
| 35 | + plugin(function({matchComponents, theme}) { |
| 36 | + let iconsDir = path.join(__dirname, "../deps/heroicons/optimized") |
| 37 | + let values = {} |
| 38 | + let icons = [ |
| 39 | + ["", "/24/outline"], |
| 40 | + ["-solid", "/24/solid"], |
| 41 | + ["-mini", "/20/solid"], |
| 42 | + ["-micro", "/16/solid"] |
| 43 | + ] |
| 44 | + icons.forEach(([suffix, dir]) => { |
| 45 | + fs.readdirSync(path.join(iconsDir, dir)).forEach(file => { |
| 46 | + let name = path.basename(file, ".svg") + suffix |
| 47 | + values[name] = {name, fullPath: path.join(iconsDir, dir, file)} |
| 48 | + }) |
| 49 | + }) |
| 50 | + matchComponents({ |
| 51 | + "hero": ({name, fullPath}) => { |
| 52 | + let content = fs.readFileSync(fullPath).toString().replace(/\r?\n|\r/g, "") |
| 53 | + let size = theme("spacing.6") |
| 54 | + if (name.endsWith("-mini")) { |
| 55 | + size = theme("spacing.5") |
| 56 | + } else if (name.endsWith("-micro")) { |
| 57 | + size = theme("spacing.4") |
| 58 | + } |
| 59 | + return { |
| 60 | + [`--hero-${name}`]: `url('data:image/svg+xml;utf8,${content}')`, |
| 61 | + "-webkit-mask": `var(--hero-${name})`, |
| 62 | + "mask": `var(--hero-${name})`, |
| 63 | + "mask-repeat": "no-repeat", |
| 64 | + "background-color": "currentColor", |
| 65 | + "vertical-align": "middle", |
| 66 | + "display": "inline-block", |
| 67 | + "width": size, |
| 68 | + "height": size |
| 69 | + } |
| 70 | + } |
| 71 | + }, {values}) |
| 72 | + }) |
| 73 | + ] |
| 74 | +} |
0 commit comments