Support adaptive width (column=-1) (#130)

* Support adaptive width

* Update readme

* Fix typo error

* Delete package-lock.json
This commit is contained in:
solstice23 2022-04-04 17:34:49 +08:00 • committed by GitHub
parent 94f9b41814
commit e8b06776e1
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 13 additions and 0 deletions

View file

@ -168,6 +168,13 @@ https://github-profile-trophy.vercel.app/?username=ryo-ma&row=2&column=3
<img width="330" src="https://user-images.githubusercontent.com/6661165/91659474-c07f7400-eb0a-11ea-84f2-eb6b42547829.png"> <img width="330" src="https://user-images.githubusercontent.com/6661165/91659474-c07f7400-eb0a-11ea-84f2-eb6b42547829.png">
</p> </p>
Adaptive column
```
https://github-profile-trophy.vercel.app/?username=ryo-ma&column=-1
```
You can set `columns` to `-1` to adapt the width to the number of trophies, the parameter `row` will be ignored.
## Apply theme ## Apply theme
Available themes. Available themes.

View file

@ -38,6 +38,12 @@ export class Card {
trophyList.sortByRank(); trophyList.sortByRank();
if (this.maxColumn == -1) {
this.maxColumn = trophyList.length;
this.width = this.panelSize * this.maxColumn +
this.marginWidth * (this.maxColumn - 1);
}
const row = this.getRow(trophyList); const row = this.getRow(trophyList);
this.height = this.getHeight(row); this.height = this.getHeight(row);