Add flag icons

This commit is contained in:
Eike Kettner 2021-03-26 22:16:10 +01:00
parent b89b19098e
commit 589e136883
4 changed files with 26 additions and 1 deletions

View File

@ -1,4 +1,5 @@
@import "@fortawesome/fontawesome-free/css/all";
@import "flag-icon-css/css/flag-icon.min";
/* all @import must be above this line */

5
package-lock.json generated
View File

@ -769,6 +769,11 @@
"to-regex-range": "^5.0.1"
}
},
"flag-icon-css": {
"version": "3.5.0",
"resolved": "https://registry.npmjs.org/flag-icon-css/-/flag-icon-css-3.5.0.tgz",
"integrity": "sha512-pgJnJLrtb0tcDgU1fzGaQXmR8h++nXvILJ+r5SmOXaaL/2pocunQo2a8TAXhjQnBpRLPtZ1KCz/TYpqeNuE2ew=="
},
"fraction.js": {
"version": "4.0.13",
"resolved": "https://registry.npmjs.org/fraction.js/-/fraction.js-4.0.13.tgz",

View File

@ -7,6 +7,7 @@
"@tailwindcss/forms": "^0.2.1",
"autoprefixer": "^10.2.5",
"cssnano": "^4.1.10",
"flag-icon-css": "^3.5.0",
"postcss": "^8.2.8",
"postcss-cli": "^8.3.1",
"postcss-import": "^14.0.0",

View File

@ -54,7 +54,8 @@ object StylesPlugin extends AutoPlugin {
val mode = stylesMode.value
npmInstall(npm, wd, logger)
val files = postCss(npx, inDir, outDir, wd, mode, logger) ++
copyWebfonts(wd, outDir, logger)
copyWebfonts(wd, outDir, logger) ++
copyFlags(wd, outDir, logger)
logger.info("Styles built")
files
},
@ -63,6 +64,7 @@ object StylesPlugin extends AutoPlugin {
val npm = stylesNpmCommand.value
val wd = (LocalRootProject / baseDirectory).value
npmInstall(npm, wd, logger)
}
)
@ -118,4 +120,20 @@ object StylesPlugin extends AutoPlugin {
IO.copy(fontDir.listFiles().map(f => f -> targetDir / f.name).toSeq)
IO.listFiles(targetDir).toSeq
}
def copyFlags(baseDir: File, outDir: File, logger: Logger): Seq[File] = {
val flagDir =
baseDir / "node_modules" / "flag-icon-css" / "flags"
val targetDir = outDir / "flags"
IO.createDirectory(targetDir)
val files = (flagDir ** "*")
.filter(_.isFile)
.get
.pair(Path.relativeTo(flagDir))
.map(t => (t._1, targetDir / t._2))
IO.copy(files)
(targetDir ** "*.svg").get()
}
}