Commit Graph

49 Commits

Author SHA1 Message Date
chris48s
8a98824e5e use SVG2 hrefs (#10918)
* use SVG2 hrefs

* add note to badge-maker changelog
2025-03-03 17:58:48 +00:00
LitoMore
d51b47a9fd fix badge style when logo only (#10794)
* fix badge style when logo only

* simply logo-only condition

* Update variable name

* Update and add snapshots

* Fixes

* Update test and snapshot

* fix tests
2025-01-26 16:10:03 +00:00
chris48s
152b8e9a64 fix badge-maker package tests (#10809) 2025-01-18 19:16:59 +00:00
chris48s
8cd1480e5f fix missing comma in badge-maker docs example (#10808) 2025-01-12 10:11:12 +00:00
chris48s
fb816ecf93 Upgrade to Chai 5.x (#10732)
* remove chai-string plugin

* upgrade chai and sinon-chai

* update chai imports

* migrate badge-maker tests to ESM
2024-12-11 19:28:45 +00:00
valkyrie_pilot
9ab1a906b2 Add option for IDs to have a prefix (#10576)
* Add option for IDs to have a prefix

* Switch to suffixes to protect ID values

* Document idSuffix

* Fix validation error message consistency

* Fix ID suffix regex test

* Add tests

* snapshot tests for idSuffix covering all 5 badge styles

* tweak docs

* update typescript definitions

* badge-maker 4.1.0 release

---------

Co-authored-by: chris48s <git@chris-shaw.dev>
2024-10-13 16:47:50 +00:00
chris48s
5c8129904f Expose logoBase64 and links in badge-maker NPM package (#10283)
* expose `logoBase64` and `links` in badge-maker NPM package

* add test assertion for logoBase64

* pass (public) `logoBase64` as (internal) `logo`

* badge-maker 4.0.0 release

---------

Co-authored-by: Sergey Kupletsky <s.kupletsky@gmail.com>
2024-06-24 14:53:31 +01:00
chris48s
677e713310 Remove logoPosition (#10284)
* remove logoPosition param

* finish the job of removing logoPosition

---------

Co-authored-by: Sergey Kupletsky <s.kupletsky@gmail.com>
2024-06-24 13:26:48 +00:00
chris48s
13800175ce ensure color is string before calling toLowerCase() (#10129) 2024-05-20 13:32:29 +00:00
LitoMore
915ab742d9 feat(logos): support auto-sizing mode (#9191)
Co-authored-by: chris48s <git@chris-shaw.dev>
2024-04-22 11:46:00 +00:00
chris48s
8e7d44c349 use brightgreen for build passing in package docs (#9917) 2024-02-04 21:01:47 +00:00
Kurt McKee
9874db7841 Fix several typos (#9658) 2023-10-13 15:40:57 +00:00
chris48s
f84ccb24ae upgrade to npm 9 (#9323) 2023-07-16 15:07:20 +01:00
dependabot[bot]
b9d96755ec chore(deps-dev): bump prettier from 2.8.8 to 3.0.0 (#9357)
* chore(deps-dev): bump prettier from 2.8.8 to 3.0.0

Bumps [prettier](https://github.com/prettier/prettier) from 2.8.8 to 3.0.0.
- [Release notes](https://github.com/prettier/prettier/releases)
- [Changelog](https://github.com/prettier/prettier/blob/main/CHANGELOG.md)
- [Commits](https://github.com/prettier/prettier/compare/2.8.8...3.0.0)

---
updated-dependencies:
- dependency-name: prettier
  dependency-type: direct:development
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>

* reformat all the things (prettier 3)

* update tests to await calls to prettier.format()

---------

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: chris48s <git@chris-shaw.dev>
2023-07-10 09:27:51 +00:00
dependabot[bot]
6af9328e6d chore(deps-dev): bump is-svg from 4.3.2 to 5.0.0 (#8959)
* chore(deps-dev): bump is-svg from 4.3.2 to 5.0.0

Bumps [is-svg](https://github.com/sindresorhus/is-svg) from 4.3.2 to 5.0.0.
- [Release notes](https://github.com/sindresorhus/is-svg/releases)
- [Commits](https://github.com/sindresorhus/is-svg/compare/v4.3.2...v5.0.0)

---
updated-dependencies:
- dependency-name: is-svg
  dependency-type: direct:development
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>

* import is-svg with async dynamic imports

---------

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: chris48s <git@chris-shaw.dev>
Co-authored-by: chris48s <chris48s@users.noreply.github.com>
2023-04-16 13:07:57 +01:00
chris48s
cf83fb3235 migrate package tests to GHA (#8351)
migrate package tests to GHA
2022-09-05 21:00:20 +01:00
chris48s
32dd99c540 Two minor docstring fixes (#7216)
* fix XmlElement ref in docstring

* make sure jsdoc picks up renderDownloadsBadge() docstring
2021-11-03 18:49:10 +00:00
Pierre-Yves B
8fd54b1b8d Switch all shields.io links to https (#6935) 2021-08-22 17:20:59 +01:00
chris48s
779c1ffaad fix incorrect colorsForBackground detection (#6939)
* pass an actual color to colorsForBackground (closes #6936)

* improve test coverage for non-default font color
2021-08-22 16:59:25 +01:00
chris48s
e8c78d55b3 Migrate flat, flat-square, plastic and social to use XmlElement (#6883)
* start changelog entry for v4

* migrate Flat/FlatSquare/Plastic to use XmlElement

* move brightnessThreshold into colorsForBackground

* move old renderLogo function inline into social()

this is the only place it is now used

* use XmlElement in social()

* don't quote numbers if we don't need to

* remove intermediate calls to .render()

leave everything as XmlElement objects right till the end
then make one final call to .render()
which cascades aaall the way through the tree

* factor out code for assembling logo element

* use scale consts in social

* remove NullElement

now we've removed all the intermediate calls to render()
we can just use an empty string

* write leftlink so it doesn't look like a bool

Co-authored-by: Caleb Cartwright <calebcartwright@users.noreply.github.com>
2021-08-21 20:44:14 +01:00
Pierre-Yves B
68fb0b7bab Run on node 14 in production, drop node 10 support for badge-maker and update test matrix (#6652) 2021-06-21 20:46:55 +01:00
chris48s
81c7d377d2 badge-maker 3.3.1 release (#6568) 2021-06-02 17:57:28 +01:00
Paul Melnikow
cdd68fee7f Make for-the-badge letter spacing more predictable, and rewrite layout logic (#5754)
* Rewrite for-the-badge renderer
* Update snapshots
* Remove pixel grid alignment in for-the-badge
* abstract XML stringification to XmlElement class

Co-authored-by: chris48s <chris48s@users.noreply.github.com>
Co-authored-by: chris48s <chris.shaw480@gmail.com>
2021-05-26 20:55:28 +01:00
Paul Melnikow
f1a5dd9427 Align style prop of coalesceBadge() with internal makeBadge() (#5726)
This is an analogous change to #5719 for `’template’` and `’style’`. (See the top comment for more explanation.)
2020-10-20 19:16:38 -04:00
dependabot-preview[bot]
800b61ab46 Build(deps): bump anafanafo from 2.0.0-beta.1 to 2.0.0 in /badge-maker (#5746)
Bumps [anafanafo](https://github.com/metabolize/anafanafo) from 2.0.0-beta.1 to 2.0.0.
- [Release notes](https://github.com/metabolize/anafanafo/releases)
- [Commits](https://github.com/metabolize/anafanafo/compare/anafanafo@2.0.0-beta.1...anafanafo@2.0.0)

Signed-off-by: dependabot-preview[bot] <support@dependabot.com>

Co-authored-by: dependabot-preview[bot] <27856297+dependabot-preview[bot]@users.noreply.github.com>
Co-authored-by: repo-ranger[bot] <39074581+repo-ranger[bot]@users.noreply.github.com>
2020-10-18 16:07:01 +00:00
Paul Melnikow
4415d07e8b A few straight refactors in badge-renderers (#5716)
These are aimed at improving readability and a bit of DRY.
2020-10-17 11:27:09 -04:00
Paul Melnikow
1184938ed1 Align label and message props of coalesceBadge() with internal makeBadge() (#5719)
There is an internal `makeBadge()` function which is called from a few places in the server and from the public `makeBadge()` function which is a light wrapper. (Eventually we want to dogfood the public API: that's the work of #4950, and this helps with it by aligning the interfaces.)

Related to that is #3370, which is about aligning the `serviceData` schema (i.e. the result of `handle()`) with the public `makeBadge()` function.

A legacy quirk of the _private_ `makeBadge()` function is accepting a `text: ['label', 'message']` array instead of separate `{ label, message }` props like the rest of the codebase. `coalesceBadge()` has to translate from `{ label, message }` to `text: ['label', message']`. This removes that bit of indirection.

It also rewrites most of the tests of `coalesceBadge()` to use `.includes()`, providing IMO a slight improvement in readability.
2020-10-16 18:06:32 -04:00
Paul Melnikow
af3f720113 Improve appearance of for-the-badge and social badges by measuring correct font (#5696)
Even before #2311, Shields has measured all badge text using 11px Verdana, which is the correct font for plastic, flat, and flat-square.

However the for-the-badge style uses 10px Verdana and bold 10px Verdana, and the social badge uses bold 11px _Helvetica_. This causes these badges to be wider or narrower than they should be, and the text to be stretched accordingly.

Since the for-the-badge style relies on synthetic letter spacing (we just multiply the computed length in code) there is room to massage this further. Our test badges all look as good or better than before, so I think it should not block merging this, however we might need to get it right before the downstream problem in squint goes away. (There's also #4691 which this doesn't attempt to address.)

Fixes #4275
2020-10-15 20:06:46 -04:00
Paul Melnikow
cd70bf5246 Prettify the SVG snapshots (and a couple cleanups) (#5714)
I’m running into some strange issues working on badge-maker in #5696, where the images look good but the snapshots have changed in unexpected ways. I’m finding them a little tricky to debug.

This saves the prettified snapshots instead, which I think will make them easier to compare and debug. They may have to be updated when we upgrade prettier.

I also inlined a few things in the test file.
2020-10-15 19:40:14 -04:00
Pierre-Yves B
e0604d855b Update badge-maker to version 3.3.0 (#5661) 2020-10-06 17:52:05 +01:00
dependabot-preview[bot]
501c53a0b4 Build(deps): bump css-color-converter from 1.1.1 to 2.0.0 in /badge-maker (#5615)
* Build(deps): bump css-color-converter in /badge-maker

Bumps [css-color-converter](https://github.com/andyjansson/css-color-converter) from 1.1.1 to 2.0.0.
- [Release notes](https://github.com/andyjansson/css-color-converter/releases)
- [Changelog](https://github.com/andyjansson/css-color-converter/blob/master/CHANGELOG.md)
- [Commits](https://github.com/andyjansson/css-color-converter/commits)

Signed-off-by: dependabot-preview[bot] <support@dependabot.com>

* Update implementation and package-lock.json

* Fix some URLs which switched to HTTP

Co-authored-by: dependabot-preview[bot] <27856297+dependabot-preview[bot]@users.noreply.github.com>
Co-authored-by: PyvesB <PyvesDev@gmail.com>
2020-09-28 09:16:57 +01:00
Pierre-Yves B
f1007a5ee2 Remove duplicate normalizeColor calls (#5534)
* Remove duplicate normalizeColor calls

* Clarify behaviour with comment
2020-09-13 22:11:22 +02:00
Pierre-Yves B
bf4fd96059 Remove camelcase dependency from badge-maker package (#5533) 2020-09-13 09:17:07 +02:00
Pierre-Yves B
06dff040c6 Rework isCSSColor check (#5508)
* Rework isCSSColor check

* Expand tests and accept strings with whitespace

* Remove void(0) edge-case test
2020-09-12 12:04:41 +02:00
Pierre-Yves B
471f3f4ad1 Use black font when background color is too light (#5467)
* Use black font when background color is too light

* Tweak dark color

* Extract magic brightness numbers to constants

* Fix snapshot tests

* Switch threshold to 0.69
2020-09-07 19:07:28 +02:00
chris48s
32ac819813 package 3.2.0 (#5319) 2020-07-13 20:32:36 +01:00
Evelyn Hathaway
c1ded757c7 feat: add accessible text alternative in when a graphic and link (#5289)
Co-authored-by: chris48s <chris48s@users.noreply.github.com>
2020-07-13 20:07:26 +01:00
dependabot-preview[bot]
0fdc062e24 Build(deps): bump camelcase from 5.3.1 to 6.0.0 in /badge-maker (#5175)
Bumps [camelcase](https://github.com/sindresorhus/camelcase) from 5.3.1 to 6.0.0.
- [Release notes](https://github.com/sindresorhus/camelcase/releases)
- [Commits](https://github.com/sindresorhus/camelcase/compare/v5.3.1...v6.0.0)

Signed-off-by: dependabot-preview[bot] <support@dependabot.com>

Co-authored-by: dependabot-preview[bot] <27856297+dependabot-preview[bot]@users.noreply.github.com>
Co-authored-by: repo-ranger[bot] <39074581+repo-ranger[bot]@users.noreply.github.com>
2020-06-06 21:01:44 +00:00
chris48s
084285755f Package 3.1.0 (#5160)
* exclude typedef tests from npm pack
* update docs
* bump version
2020-06-03 18:44:15 +01:00
Xianming Zhong
d0f3f2251f add type definitions to badge-maker package (#5126)
* add types for badge-maker
* update package.json and readme with tsd tests

Co-authored-by: chris48s <chris48s@users.noreply.github.com>
2020-06-02 20:30:25 +01:00
chris48s
7b5f43fee8 add missing dependency (#5159)
* add missing dependency
* bump version

closes #5158
2020-06-02 20:10:43 +01:00
chris48s
c03a73b573 v3 stable (#5037)
* fix outdated docblock
* 3.0.0
2020-05-06 19:51:21 +01:00
chris48s
13d75e0607 upgrade to prettier 2 (#5051)
* arrowParens: avoid
* remove trailingComma setting
2020-05-05 21:07:43 +01:00
Makarenko Anton
6ca2fa0c89 Fix rendering in Firefox on Windows (#5038)
Close #4813
2020-05-04 20:01:15 -04:00
chris48s
6e58db0379 require node 10+ in badge-maker package.json (#5010) 2020-05-02 17:46:22 +01:00
chris48s
17374873ad fix link width params (#4991)
closes #4989

Co-authored-by: repo-ranger[bot] <39074581+repo-ranger[bot]@users.noreply.github.com>
2020-05-01 20:55:57 +00:00
chris48s
612a43aaa9 Update test matrix and docs (#4992)
* update test matrix

* update docs
2020-04-30 21:33:59 +01:00
chris48s
d8840b83e7 fix logo placement with custom logoWidth value (#4946) 2020-04-25 16:34:34 +01:00
chris48s
3ba05cb184 📦 version 3 (#4756)
* Validate input to BadgeFactory.create() (#3875)

* validate input to create()

* remove deprecated properties (#3881)

* remove BadgeFactory class (#3884)

* Template literal templates (#4459)

- Remove use of the doT template library and move to generating SVG output using javascript template literals.
- Drop SVGO and mostly manually implement the optimisations.
- Add a bunch more tests

Co-authored-by: Paul Melnikow <github@paulmelnikow.com>

* drop raster support in package CLI (#4523)

* drop raster support in package CLI
* update docs

* rename gh-badges package to badge-maker

* rename gh-badges dir to badge-maker

* update relative imports and other refs to in parent dir

'gh-badges' --> 'badge-maker'

* update snyk service tests

This change is only tangentially related

We've used the shields repo as an example for these tests so
moving files around in our repo has a knock-on effect on them

* add missing type hints to dev style page

* write the changelog/migration guide for v3

* use extension in README CLI example

* update CLI help

whoops - missed this in #4523

* bump version

* update for self-hosting users

* README updates

* drop .format param from CLI, always output SVG

* Change text[] to label and message, Remove JSON output

- Change text[] to label and message
- Fix message only badge
- Remove JSON output format
- Update the docs

* update package-lock

* rename 'template' to 'style'

* handle invalid styles in coalesceBadge

* ensure makeBadge is passed a string for template in coalesceBadge()

issue #4925

* fix (logo/no label text/label color specified) case

issue #4926

* add example of (logo/no label text/label color specified) to style debug page

* update type defs

* padding fix for FTB style

Co-authored-by: Paul Melnikow <github@paulmelnikow.com>
2020-04-23 20:05:48 +01:00