forked from MapComplete/MapComplete
Undo some changes to fix the build, move svg-check into generateLayerOverview as to move fs out of the dependency tree for the webpage
This commit is contained in:
parent
39cc043f8b
commit
e9004a2190
7 changed files with 543 additions and 130 deletions
|
@ -281,10 +281,9 @@ class LayerOverviewUtils {
|
|||
then: th.icon,
|
||||
}))
|
||||
const proto: LayoutConfigJson = JSON.parse(
|
||||
readFileSync(
|
||||
"./assets/themes/mapcomplete-changes/mapcomplete-changes.proto.json",
|
||||
{ encoding: "utf8" }
|
||||
)
|
||||
readFileSync("./assets/themes/mapcomplete-changes/mapcomplete-changes.proto.json", {
|
||||
encoding: "utf8",
|
||||
})
|
||||
)
|
||||
const protolayer = <LayerConfigJson>(
|
||||
proto.layers.filter((l) => l["id"] === "mapcomplete-changes")[0]
|
||||
|
@ -441,6 +440,34 @@ class LayerOverviewUtils {
|
|||
convertState.tagRenderings
|
||||
).convertStrict(themeFile, themePath)
|
||||
|
||||
if (themeFile.icon.endsWith(".svg")) {
|
||||
try {
|
||||
ScriptUtils.ReadSvgSync(json.icon, (svg) => {
|
||||
const width: string = svg.$.width
|
||||
const height: string = svg.$.height
|
||||
if (width !== height) {
|
||||
const e =
|
||||
`the icon for theme ${json.id} is not square. Please square the icon at ${json.icon}` +
|
||||
` Width = ${width} height = ${height}`
|
||||
;(json.hideFromOverview ? warnings : errors).push(e)
|
||||
}
|
||||
|
||||
const w = parseInt(width)
|
||||
const h = parseInt(height)
|
||||
if (w < 370 || h < 370) {
|
||||
const e: string = [
|
||||
`the icon for theme ${json.id} is too small. Please rescale the icon at ${json.icon}`,
|
||||
`Even though an SVG is 'infinitely scaleable', the icon should be dimensioned bigger. One of the build steps of the theme does convert the image to a PNG (to serve as PWA-icon) and having a small dimension will cause blurry images.`,
|
||||
` Width = ${width} height = ${height}; we recommend a size of at least 500px * 500px and to use a square aspect ratio.`,
|
||||
].join("\n")
|
||||
;(json.hideFromOverview ? warnings : errors).push(e)
|
||||
}
|
||||
})
|
||||
} catch (e) {
|
||||
console.error("Could not read " + json.icon + " due to " + e)
|
||||
}
|
||||
}
|
||||
|
||||
this.writeTheme(themeFile)
|
||||
fixed.set(themeFile.id, themeFile)
|
||||
} catch (e) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue