-
-
Notifications
You must be signed in to change notification settings - Fork 5.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Template literal templates #4459
Conversation
get flat, flat-square and plastic styles working + factor out common code to a base class
e944eee
to
4e7c4d7
Compare
This pull request introduces 3 alerts when merging 4e7c4d7 into c05394d - view on LGTM.com new alerts:
|
This pull request introduces 2 alerts when merging 7eae7df into c05394d - view on LGTM.com new alerts:
|
This pull request introduces 1 alert when merging c2bf4fd into c05394d - view on LGTM.com new alerts:
|
this is the default
This accounts for several things: 1. Changes in one-char variable names 2. Removed some whitespace 3. I've dropped the <rect> to <path> optimisation
This pull request introduces 1 alert when merging 5bba06f into c05394d - view on LGTM.com new alerts:
|
labelColor is always true anyway now we've given the param a default
at this layer of the application, a logo should already be a base64 encoded string. `logo: 'javascript'` renders <image x="5" y="3" width="14" height="14" xlink:href="javascript"/> which isn't really what we want to test Passing logoColor to makeBadge() is completely meaningless
rightWidth++ | ||
const methodName = camelcase(template) | ||
if (!(methodName in badgeRenderers)) { | ||
throw new Error(`Unknown template: '${template}'`) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not blocking, though at some point this should be consolidated with the style validation logicin gh-badges/lib/index.js.
This is looking good! |
additional changes made since this review
Yep. Good call - that's now at https://shields-staging-pr-4459.herokuapp.com/dev/styles Having looked at all those, I spotted another issue which I've fixed in 34db0f2 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🎉
Cheers for review all :) I've merged this onto the v3-dev branch. Over the weekend I'll review where I got to with the v3 roadmap: what else needs to go into v3.0/what can wait till v3.1 and pick up the rest of this. I'd like to get to a stage where we can ship this sooner rather than later. |
- 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>
- 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>
* 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>
This turned into an absolute beast, but I think we're finally good for review. I suspect the review process for this one is going to be pretty involved too. I'll mark up the diff with a couple of specific comments, but here's some high level notes:
v3-dev
branch, notmaster
. Getting this merged will unblock the rest of the work we need to do on V3 so hopefully we'll be able to get the rest of the breaking changes done and merged to master once we can draw a line under this.<rect>
with a<path>
element if the<path>
takes up less characters. I haven't bothered implementing this optimisation. This does mean that we'll serve a few extra characters for every badge (the re-generated snapshots in ed24253 give an idea of the impact of this), but I think the tradeoff is OK.flat
,flat-square
andplastic
are all sufficiently similar that they are best thought of as slight variations of the same thing so they are implemented as child classes of a base class. This allows most of the implementation to be shared.for-the-badge
andsocial
styles were so different that they don't really shoehorn into that pattern, so those two are just implemented as completely bespoke render functions, as opposed to as subclasses ofBadge
.escapeXml()
?Closes #2428
Refs #3587