unvt / charites

It is an application to style vector tiles easily
https://unvt.github.io/charites/
MIT License
54 stars 13 forks source link

Add build icon option to `charites build` #28

Closed naogify closed 3 years ago

naogify commented 3 years ago

Close #13

Add an option for building icon's sprite image and json.

You can build sprite image and json by adding --sprite option like below.

$ charites build style.yml style.json --sprite=https://example.github.io/icons

This option will replace style.json sprite url and convert icon's svg files to sprites image and json file.

You can also specify the svg files directory and dist directory like below.

$ charites build style.yml --sprite <sprite url> [<icon source>] [<icon destination>]

The default <icon source> is icons/, and the default <icons destination> is the directory this command runs.

naogify commented 3 years ago

@miya0001

I updated the option for build map icons. Please re-review it.

CLI manual is below

$ charites build style.yml --sprite-url [<sprite url>] --sprite-input [<icon source>] --sprite-output [<icon destination>]

Sample1: use default

$ charites build style.yml

This command will use ./icons/*.svg to generate files below. Because --sprite-input default value is ./icons/ and --sprite-output default value is ./.

Output

Icon name is defined by sprite url in style.yml . (eg, basic.json/png is created by sprite url http://localhost:8888/basic))

Sample2 use options

$ charites build style.yml --sprite-url http://localhost:8888/basic-white --sprite-input ./src/icons--sprite-output ./public

This command will use ./src/icons/*.svg to generate files below.

Output

miya0001 commented 3 years ago

@JinIgarashi Please review 😊

naogify commented 3 years ago

@JinIgarashi

Thank for your feedback!

However, I don't think we need to include this implementation on charites build because there is no clear relationship between inputted style.yaml and sprite icons.

The reason I used option is that I also want to add building sprite funtion to charites serve, like charites serve --sprite-url http://localhost:8888/sprite. So, I thougt it's better to use option to create sprite file to build command.

However, I thought it would be a good idea to provide both the charites sprite command and the charites serve --sprite-url http://localhost:800/sprite option, so that user can see the changes to the SVG icon on the map in real time, and also it would also make it easier to understand how to build sprites. What do you think?