diff --git a/README.md b/README.md index dbaccd4..b4d09bf 100644 --- a/README.md +++ b/README.md @@ -168,6 +168,13 @@ https://github-profile-trophy.vercel.app/?username=ryo-ma&row=2&column=3

+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 Available themes. diff --git a/src/card.ts b/src/card.ts index 1763a31..3403c97 100644 --- a/src/card.ts +++ b/src/card.ts @@ -38,6 +38,12 @@ export class Card { 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); this.height = this.getHeight(row);