JFreeman
JFreeman

Reputation: 1004

Shields.io hardcode download count badge

Shields seems quite powerful and from this tutorial I have a sense I could just design a custom badge. Because my download count for my app is coming from multiple websites I don't think I can get a proper estimate so I want to hardcode it in.

How can I make a badge that looks like the download count badge from shields.io but allows me to enter any number I want?

(I know this is a dumb usage considering the point of shields, but all the rest of my projects use shields.io badges keeping track of sourceforge download count so to maintain consistency I want this one to have the same badge.)

Upvotes: 0

Views: 605

Answers (1)

JFreeman
JFreeman

Reputation: 1004

My final solution was actually thanks to a helpful tutorial on github.

Shields lets you do multiple colors in one badge:

Each badge has three main configuration options:

  1. Subject - Text on the left side of the badge; the background color for this is normally gray (specifically, #555555)
  2. Status - Text on the right side of the badge; usually the name of a service or a status code; the background color can be chosen by modifying the next option
  3. Color - The background color for the text on the right side of the badge; colors can be chosen by name, or by a given hex code (i.e. #B7F5B2)

Putting this together in a string you can put any text you want for subject and status and then just change the color to make a download badge:

https://img.shields.io/badge/Downloads-10,000-green.svg

(Note: for multiword solutions you will need %20 to represent a space)

Upvotes: 0

Related Questions