Catalog npm
Back to packageRELEASE DETAILS

1.0.0

npm

5stars

:star::star::star::star::star:

Published3 Dec 2019
Direct dependencies13
Transitive dependenciesNot calculated

README

Current package documentation

5star

:star::star::star::star::star:

A quickly generating 5 stars for rating based on SVG technique utility tool.

CHINESE DOC

Features

  • supports display and click modes.
  • optimizes SVG files by sogo.
  • supports remote url file and local file.
  • generates fast.
  • supports configuration and cli usages.

Warn :warning:

  • 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

output-emoji.svg

  • 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

output-emoji-click.svg

Getting started

  • If there is the following directory structure: examples

    examples
    ├── config.json
    ├── star-active.svg
    └── star-normal.svg
    
  • config.json

    {
      "normal": "star-normal.svg",
      "active": "star-active.svg",
      "space": 0,
      "width": "auto",
      "height": "auto",
      "computeSpace": true,
      "mode": "display",
      "output": "output.svg"
    }
    
  • run the following command in current directory examples

    ➜  examples git:(master) ✗ npx 5stars
    5stars  start generating ...
            complete reading star-active.svg
            complete reading star-normal.svg
            complete creating new symbol element star-a
            complete creating new symbol element star-b
            start to output output.svg
            done!
    
  • output.svg

    output

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 -->
    <svg class="5stars-svg" data-width="0.5" id="5stars-svg" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" width="100%" height="100%"
    viewBox="0 0 309.335 53.867">
      <!-- Generator: 5stars. https://github.com/zhansingsong/5stars -->
      <!-- content -->
    </svg>
    

    manipulate output.svg how to display by data-width="0.5" attribute of the output svg.

    The following output is data-width="0.7":

  • click mode

    <svg class="5stars-svg" id="5stars-svg" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" width="100%" height="100%"
    viewBox="0 0 309.335 53.867">
      <!-- Generator: 5stars. https://github.com/zhansingsong/5stars -->
      <!-- content -->
    </svg>
    

    If you want to control when the click operation ends, You can override window._5stars_click_cb_(n):

    window._5stars_click_cb_ = function (n) {
      // end click operation when returning true
      return n == 5;
    }
    

    Example

    <!DOCTYPE html>
    <html lang="en">
    <head>
      <meta charset="UTF-8">
      <meta name="viewport" content="width=device-width, initial-scale=1.0">
      <meta http-equiv="X-UA-Compatible" content="ie=edge">
      <title>5stars click mode</title>
    </head>
    <body>
      <script>
      window._5stars_click_cb_ = function (n) {
        // end click operation when returning true
        return n == 5;
      }
      </script>
    
      <svg class="5stars-svg" id="5stars-svg" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink"  width="100%" height="100%"
      viewBox="0 0 269.335 53.867">
        <!-- Generator: 5stars. https://github.com/zhansingsong/5stars -->
        <!-- content -->
      </svg>
    </body>
    </html>
    

config options

// defaults
const 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.

Downloads & popularity

Awaiting observations

No metric observations yet

Download counts and popularity will appear here as the collector receives them.

Declared dependencies 13

Native requirements
13 direct targetsNot calculated transitive count
Package / targetRequirementRelationship
ajv
Environment
{
  "local_name": "ajv",
  "alias": false,
  "peer_metadata": null
}
^6.10.2runtime
bluebird
Environment
{
  "local_name": "bluebird",
  "alias": false,
  "peer_metadata": null
}
^3.7.2runtime
chalk
Environment
{
  "local_name": "chalk",
  "alias": false,
  "peer_metadata": null
}
^3.0.0runtime
commander
Environment
{
  "local_name": "commander",
  "alias": false,
  "peer_metadata": null
}
^4.0.1runtime
debug
Environment
{
  "local_name": "debug",
  "alias": false,
  "peer_metadata": null
}
^4.1.1runtime
fs-extra
Environment
{
  "local_name": "fs-extra",
  "alias": false,
  "peer_metadata": null
}
^8.1.0runtime
jsdom
Environment
{
  "local_name": "jsdom",
  "alias": false,
  "peer_metadata": null
}
^15.2.1runtime
request
Environment
{
  "local_name": "request",
  "alias": false,
  "peer_metadata": null
}
^2.88.0runtime
request-promise
Environment
{
  "local_name": "request-promise",
  "alias": false,
  "peer_metadata": null
}
^4.2.5runtime
svgo
Environment
{
  "local_name": "svgo",
  "alias": false,
  "peer_metadata": null
}
^1.3.2runtime
eslint
Environment
{
  "local_name": "eslint",
  "alias": false,
  "peer_metadata": null
}
^6.7.2development
husky
Environment
{
  "local_name": "husky",
  "alias": false,
  "peer_metadata": null
}
^3.1.0development
lint-staged
Environment
{
  "local_name": "lint-staged",
  "alias": false,
  "peer_metadata": null
}
^9.5.0development

Distribution files

1 collected
Distribution 1

Source distribution

Source file
Checksums from source
{
  "integrity": "sha512-RldoTDHGIdTkvj2BJtpobmGiwjBj9q0UUH25wUmyPl5QCRqaj8eASkkSQ4vSX+Vd7dXKtQKz46u4e3U/k1mD/A==",
  "shasum": "56ac0f26e25456056189a95523c21fa61addd8b4",
  "tarball": "https://registry.npmjs.org/5stars/-/5stars-1.0.0.tgz",
  "fileCount": 6,
  "unpackedSize": 21779,
  "npm-signature": "-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJd5l0RCRA9TVsSAnZWagAA+GsQAJL7FDXwW6q0QLRbTvjc\nOpc4xDV9lt7MXe/STrdnqrZsOpk4+foHlSZcoJCBfyItRV9qojCp6h4jVMio\nK+t4rEC4ckTWLLdRkiUW4P3FiXvq7J6E3+6NdAR0MBPifz28lBIDhypaUXu1\nl8YsaqnPuTOgTQgKcSfGwNedUQ1MCU751oiwBaWbvHR06h2tMnt8mGuPGgiM\nx2nHTdp92vVcpkQlltjHZNwYLUgIUBgjM1DWOxyh8X2IpBXK9HU4vFAwzVq0\nFmc86ZpZCEQ6kcLbCOItA//E9Llb1XFBFFnT7tURoizr6HzYP0GfIx/ZT96A\nMKhtGiIbrwEs8PB3pVWRlRDdNStH2tlbo6paT5qvXbXlRlEMe9dMcrY1Ndfn\ncJaOy0t4GI0DLQWGf0xZkVP8kSX62N+dBfhIknsoMF61ufJDbmnbHRhJkeID\nLAS1GTXw38Z1i8jl4ME1hbWfYS5H+D8ad2L/a0LjqdWp2IM5bBIwox3G81IX\nFzU1nOr5FBj0YizAgXPsgMeNTTjQA7+QSIFLJTkrOEw0Sr3NBAmWBwAqrkn9\nQ2xazKi4vRi2lXuqfcDtf/SffsoxnuDvXachfUsHT5TgAsT1DLBUmopJAz/T\n/lv6OJKpSDCH6IBlMqvx+VX0SsNfQlO3s9g6kSjOKtNpJHcJyT1Jeti6pqR4\nweP0\r\n=dep7\r\n-----END PGP SIGNATURE-----\r\n",
  "signatures": [
    {
      "keyid": "SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA",
      "sig": "MEUCIQD0QKpyFdfwdwiRTjhFmc32Gjkum29yveOfAnB9HRzqSwIgWdahVKLBq94cdvCYxn6ooNwX6eoWTxoRhNJss8EIPMY="
    }
  ]
}

Metadata history

Meaningful changes
Current collected state Current

Observed since 20 Oct, 20:38 UTC

No superseded metadata states collected. Unchanged observations do not create new revisions.

Record identity

package_version:c27980d5e13ba5bafa50575ea927ebca3a690757efe4bd0eddf23afdfac35883

Other collected versions

View all collected versions →