Skip to content
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

feat(logos): support auto-size mode #9191

Merged
merged 2 commits into from Apr 22, 2024
Merged

Conversation

LitoMore
Copy link
Contributor

@LitoMore LitoMore commented May 22, 2023

Resolves #8372

I will add test and documentation once we finalize the idea.

Principles

This path was initially wrapped in a viewBox="0 0 24 24" and centered. We need to reset the position to {x: 0, y: 0} of the path before updating its viewBox.

Notes

  • The parameter name logoSize and its value name cover may not be the best. Just let me know what you prefer.
  • Both load-simple-icons.js and svg-helper.js called loadSimpleIcons(), we could reorganize the code to improve its performance.

New params

  • logoSize
  • logoHeight

Previews

http://localhost:8080/badge/gaming-chip-ED1C24?logo=amd&logoColor=white&logoSize=auto
http://localhost:8080/badge/gaming-ED1C24?logo=amd&labelColor=gray&logoSize=auto
http://localhost:8080/badge/gaming-ED1C24?logo=amd&labelColor=555&logoSize=auto
http://localhost:8080/badge/gaming-ED1C24?logo=amd&labelColor=555&logoSize=auto&logoHeight=10
http://localhost:8080/badge/gaming-ED1C24?logo=amd&labelColor=555&logoSize=auto&logoWidth=20
http://localhost:8080/badge/gaming-eee?logo=amd&logoColor=black&labelColor=ED1C24&logoSize=auto
http://localhost:8080/badge/gaming-555?logo=amd&logoColor=black&labelColor=ED1C24&logoSize=auto

pr-9191-badges-shields.fly.dev previews







Production previews

![](https://img.shields.io/badge/gaming-chip-ED1C24?logo=amd&logoColor=white&logoSize=auto)
![](https://img.shields.io/badge/gaming-ED1C24?logo=amd&labelColor=gray&logoSize=auto)
![](https://img.shields.io/badge/gaming-ED1C24?logo=amd&labelColor=555&logoSize=auto)
![](https://img.shields.io/badge/gaming-ED1C24?logo=amd&labelColor=555&logoSize=auto&logoHeight=10)
![](https://img.shields.io/badge/gaming-ED1C24?logo=amd&labelColor=555&logoSize=auto&logoWidth=40)
![](https://img.shields.io/badge/gaming-eee?logo=amd&logoColor=black&labelColor=ED1C24&logoSize=auto)
![](https://img.shields.io/badge/gaming-555?logo=amd&logoColor=black&labelColor=ED1C24&logoSize=auto)







@LitoMore LitoMore changed the title feat(logos): support cover mode feat(logos): support auto-size mode May 22, 2023
@github-actions
Copy link
Contributor

github-actions bot commented May 22, 2023

Messages
📖 ✨ Thanks for your contribution to Shields, @LitoMore!

Generated by 🚫 dangerJS against b22cfdb

@socket-security
Copy link

socket-security bot commented May 22, 2023

👍 Dependency issues cleared. Learn more about Socket for GitHub ↗︎

This PR previously contained dependency changes with security issues that have been resolved, removed, or ignored.

View full report↗︎

@chris48s
Copy link
Member

chris48s commented May 23, 2023

Thanks for having a look at this.

@calebcartwright - in terms of the concept (i.e: "do we think this feature is a good idea?", as opposed to "is this good code?"), what are your views on this one?

There is some more detail/discussion in #8372

@calebcartwright
Copy link
Member

@calebcartwright - in terms of the concept (i.e: "do we think this feature is a good idea?", as opposed to "is this good code?"), what are your views on this one?

I agree that the auto-sizing feature is a good idea. I haven't looked at the implementation at all so not sure what the current state on this topic is, but my only preference is that this behavior be an explicit opt-in (e.g. via a query param). I say that because it feels like this is relevant in more niche use cases and I don't want to apply it by default as I suspect that would be accompanied with a large number of unknowns

@chris48s
Copy link
Member

chris48s commented Jun 4, 2023

OK, sounds reasonable. I'll put this one on my list to review the code then

@chris48s chris48s self-requested a review June 4, 2023 18:47
@chris48s
Copy link
Member

I've had a look over this. Broadly, the implementation looks fine. I'll leave a few comments inline.

We would need to add some documentation for this param. In the new frontend, globally available params are documented in

Other admin: there are failing tests and merge conflicts that would need to be sorted.

@chris48s
Copy link
Member

In terms of naming, I'm slightly unsure what the best name for this param is either, but I'm keen to get this right as once it is out there, we're basically stuck with it forever.

Some other viable suggestions are ?logoSize=auto or ?logoSize=fit. Naming things is hard.

Any other maintainers have a view on this?

@calebcartwright
Copy link
Member

Any other maintainers have a view on this?

I've a mild preference for ?logoSize=auto

@socket-security
Copy link

socket-security bot commented Jun 19, 2023

New and removed dependencies detected. Learn more about Socket for GitHub ↗︎

Package New capabilities Transitives Size Publisher

View full report↗︎

@LitoMore LitoMore force-pushed the logo-cover-mode branch 2 times, most recently from d544d98 to b03a4c1 Compare June 19, 2023 09:45
@LitoMore LitoMore marked this pull request as ready for review June 19, 2023 09:45
@github-actions
Copy link
Contributor

🚀 Updated review app: https://pr-9191-badges-shields.fly.dev

2 similar comments
@github-actions
Copy link
Contributor

🚀 Updated review app: https://pr-9191-badges-shields.fly.dev

@github-actions
Copy link
Contributor

🚀 Updated review app: https://pr-9191-badges-shields.fly.dev

@calebcartwright
Copy link
Member

Recognize this has some conflicts that would be blockers, but in general, where did we land as far as our target strategic direction with this one?

@chris48s
Copy link
Member

where did we land as far as our target strategic direction with this one?

My last comment was

add the logoSize=auto param as a first step and then see where we think we should go next based on user feedback. Adding that doesn't prevent us adding more params later. Once we have added params or settings, removing or changing them is harder: We can't really version a service like we can with a library.

and P-Y 👍d it You good with that?

@calebcartwright
Copy link
Member

where did we land as far as our target strategic direction with this one?

My last comment was

add the logoSize=auto param as a first step and then see where we think we should go next based on user feedback. Adding that doesn't prevent us adding more params later. Once we have added params or settings, removing or changing them is harder: We can't really version a service like we can with a library.

and P-Y +1d it You good with that?

Ah yes, it's coming back to me now. This was one you and I discussed synchronously on the team call and I'd intended to comment indicating my 👍 but forgot to do so. Apologies for the noise, but yes indeed, I'm 👍 with that

@LitoMore
Copy link
Contributor Author

I've resolved conflicts and rebased with the latest code.

@LitoMore LitoMore requested a review from PyvesB August 27, 2023 02:02
@calebcartwright
Copy link
Member

Seems CI is still rather unhappy. One is just the linter, and a quick npm run prettier should fix, but the others failing jobs have test failures, e.g.:

https://github.com/badges/shields/actions/runs/6156362420?pr=9191

AssertionError: expected { openapi: '3.0.0', …(3) } to deeply equal { openapi: '3.0.0', …(3) }
at Context. (file:///home/runner/work/shields/shields/core/base-service/openapi.spec.js:411:15)
at process.processImmediate (node:internal/timers:476:21)

@chris48s
Copy link
Member

@LitoMore
Copy link
Contributor Author

@chris48s The exposed logoHeight should be removed now.

@github-actions
Copy link
Contributor

🚀 Updated review app: https://pr-9191-badges-shields.fly.dev

Copy link
Member

@chris48s chris48s left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks. I think we've now got the behaviour to expose settled.

I've now had a proper look over the code and flagged some points we'll need to get settled before we can merge. It is mostly quite minor stuff now though.

lib/logos.js Outdated Show resolved Hide resolved
core/base-service/openapi.js Outdated Show resolved Hide resolved
services/endpoint/endpoint.service.js Outdated Show resolved Hide resolved
services/endpoint/endpoint.service.js Outdated Show resolved Hide resolved
core/base-service/openapi.js Outdated Show resolved Hide resolved
lib/logos.js Show resolved Hide resolved
@LitoMore LitoMore force-pushed the logo-cover-mode branch 4 times, most recently from d4fafe3 to 9eaaddb Compare April 3, 2024 18:45
Copy link
Contributor

🚀 Updated review app: https://pr-9191-badges-shields.fly.dev

Copy link
Member

@chris48s chris48s left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for following up - latest changes LGTM. I've pushed another commit just resolving the merge conflicts on package.json and package-lock.json

@chris48s chris48s enabled auto-merge April 22, 2024 11:43
@chris48s chris48s added this pull request to the merge queue Apr 22, 2024
Merged via the queue into badges:master with commit 915ab74 Apr 22, 2024
21 checks passed
@LitoMore LitoMore deleted the logo-cover-mode branch April 22, 2024 11:52
@chris48s chris48s added the core Server, BaseService, GitHub auth label Apr 22, 2024
@chris48s
Copy link
Member

Quick FYI.
I deployed this to production today, but hit a bit of an issue. Its unrelated to this PR, but basically this happened #10077 but in production this time.

There's nothing you can do to help - its an issue with fly.io - but in order to get things stable I had to roll back to the previous release. I'll try deploying again later in the week, but just wanted to clarify what happened because this was deployed for a bit and then rolled back.

@LitoMore LitoMore mentioned this pull request Apr 28, 2024
github-merge-queue bot pushed a commit to jsr-io/jsr that referenced this pull request May 8, 2024
The JSR logo has been added to Simple Icons since
simple-icons/simple-icons#10794.

I used the `logoSize` parameter to make the logo fit the badge. The
feature was introduced at badges/shields#9191.

Currently, we can't use `logoSize` in the response due to
badges/shields#10132. So I passed these
parameters with search parameters instead.
github-merge-queue bot pushed a commit to jsr-io/jsr that referenced this pull request May 9, 2024
The JSR logo has been added to Simple Icons since
simple-icons/simple-icons#10794.

I used the `logoSize` parameter to make the logo fit the badge. The
feature was introduced at badges/shields#9191.

Currently, we can't use `logoSize` in the response due to
badges/shields#10132. So I passed these
parameters with search parameters instead.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
core Server, BaseService, GitHub auth
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add auto-size support for Simple Icons logos
4 participants