5star
⭐️⭐️⭐️⭐️⭐️
A quickly generating 5 stars for rating based on SVG technique utility tool.
Features
- supports
display
andclick
modes. - optimizes SVG files by sogo.
- supports remote url file and local file.
- generates fast.
- supports
configuration
andcli
usages.
Warn ⚠️
- normal svg file and active svg file must be the same size, the both files are required as well.
- normal svg file and active svg file need to be filled,in order to ensure 'click' mode work.
Try it out
display
mode
npx 5stars -a https://raw.githubusercontent.com/zhansingsong/5stars/master/svgs/emoji-a.svg -b https://raw.githubusercontent.com/zhansingsong/5stars/master/svgs/emoji-b.svg -o output-emoji.svg -s 20
click
mode
npx 5stars -a https://raw.githubusercontent.com/zhansingsong/5stars/master/svgs/emoji-a.svg -b https://raw.githubusercontent.com/zhansingsong/5stars/master/svgs/emoji-b.svg -o output-emoji-click.svg -m click -s 20
Getting started
-
If there is the following directory structure: examples
examples├── config.json├── star-active.svg└── star-normal.svg -
config.json
-
run the following command in current directory examples
➜ examples git: ✗ npx 5stars5stars start generating ...complete reading star-active.svgcomplete reading star-normal.svgcomplete creating new symbol element star-acomplete creating new symbol element star-bstart to output output.svgdone! -
output.svg
Usage
npx 5stars # use default config.json
npx 5stars -c yourConfigFile
npx 5stars --a star-normal.svg --b star-active.svg
-
display
mode<!-- output.svg --><!-- Generator: 5stars. https://github.com/zhansingsong/5stars --><!-- content -->manipulate
output.svg
how to display bydata-width="0.5"
attribute of the output svg.The following output is
data-width="0.7"
: -
click
mode<!-- Generator: 5stars. https://github.com/zhansingsong/5stars --><!-- content -->If you want to control when the click operation ends, You can override
window._5stars_click_cb_(n)
:window {// end click operation when returning truereturn n == 5;}5stars click mode<!-- Generator: 5stars. https://github.com/zhansingsong/5stars --><!-- content -->
config options
// defaultsconst config = // normal svg file normal: undefined // active svg file active: undefined // space between stars space: 0 // width of normal and active svg files width: 'auto' // height of normal and active svg files height: 'auto' // output path output: './output.svg' // if space isn't included on computing svg width. computeSpace: false // generation mode: display | click mode: 'display';
- normal: normal svg file, required.
- active: active svg file, required.
- space: space between stars.
- width: width of normal and active svg files.
- height: height of normal and active svg files.
- output: output path relative to current directory.
- computeSpace: if space isn't included on computing svg width.
- mode: generation mode
- display
- click
CLI
Usage: 5stars [options]
Options:
-v, --version output the version number
-c, --config [config] config file
-a, --normal [normal] normal svg file
-b, --active [active] active svg file
-s, --space [space] space between stars
--width [width] width of normal and active svg files
--height [height] height of normal and active svg files
-o, --output [output] output path
-m, --mode [mode] generation mode
-M, --no-compute-space if space is not included on computing svg width.
-h, --help output usage information
Examples:
$ 5stars # use default config.json
$ 5stars -c yourConfig.json
$ 5stars -a star-normal.svg -b star-active.svg
License
MIT.