-
-
Notifications
You must be signed in to change notification settings - Fork 21.3k
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
Add card_width
variable to the repository card #3368
#3359
base: master
Are you sure you want to change the base?
Changes from 6 commits
0f2e07e
39c75af
6348f24
3241da6
3afdb19
4bc71ad
bf70a72
bc645c0
1c0928b
ab5419b
0de9a70
81a24f5
829e1ab
5467847
7cd57f2
18db53d
49b72b8
49aef2e
fa2a74d
d6816a3
91ba93e
4147062
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -16,7 +16,8 @@ export default async (req, res) => { | |
hide, | ||
hide_title, | ||
hide_border, | ||
card_width, | ||
card_width, // Add card_width and card_height here | ||
card_height, // Add card_height here | ||
title_color, | ||
text_color, | ||
bg_color, | ||
|
@@ -84,6 +85,7 @@ export default async (req, res) => { | |
hide_title: parseBoolean(hide_title), | ||
hide_border: parseBoolean(hide_border), | ||
card_width: parseInt(card_width, 10), | ||
card_height: parseInt(card_height, 10), | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Let's not do this in this pull request but do it later in another pull request. |
||
hide: parseArray(hide), | ||
title_color, | ||
text_color, | ||
|
@@ -104,7 +106,7 @@ export default async (req, res) => { | |
`max-age=${CONSTANTS.ERROR_CACHE_SECONDS / 2}, s-maxage=${ | ||
CONSTANTS.ERROR_CACHE_SECONDS | ||
}, stale-while-revalidate=${CONSTANTS.ONE_DAY}`, | ||
); // Use lower cache period for errors. | ||
); // Use a lower cache period for errors. | ||
return res.send(renderError(err.message, err.secondaryMessage)); | ||
} | ||
}; |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -49,9 +49,11 @@ const getBadgeSVG = (label, textColor) => ` | |
* | ||
* @param {RepositoryData} repo Repository data. | ||
* @param {Partial<RepoCardOptions>} options Card options. | ||
* @param {number} card_width The width of the card. | ||
* @param {number} card_height The height of the card. | ||
* @returns {string} Repository card SVG object. | ||
*/ | ||
const renderRepoCard = (repo, options = {}) => { | ||
const renderRepoCard = (repo, options = {card_width,card_height}) => { | ||
airwakz marked this conversation as resolved.
Show resolved
Hide resolved
|
||
const { | ||
name, | ||
nameWithOwner, | ||
|
@@ -73,6 +75,8 @@ const renderRepoCard = (repo, options = {}) => { | |
border_radius, | ||
border_color, | ||
locale, | ||
card_width, | ||
card_height, | ||
} = options; | ||
|
||
const lineHeight = 10; | ||
|
@@ -87,8 +91,7 @@ const renderRepoCard = (repo, options = {}) => { | |
.map((line) => `<tspan dy="1.2em" x="25">${encodeHTML(line)}</tspan>`) | ||
.join(""); | ||
|
||
const height = | ||
(descriptionLines > 1 ? 120 : 110) + descriptionLines * lineHeight; | ||
const height = card_height || (descriptionLines > 1 ? 120 : 110) + descriptionLines * lineHeight; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Let's add a minimum card height to prevent the card height from being too small to display the card's content. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. what height should i take There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. `/**
// Calculate a minimum card height to ensure content is visible // Calculate the final card height // ... (rest of the function) const card = new Card({ // ... (rest of the function) return card.render(`
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Judging from a repository with only a 1 line description, this height should be There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Please apply changes to the pull request. It is hard for me to review pasted code 😅. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. You should apply the conditions for your minimum height here. |
||
|
||
const i18n = new I18n({ | ||
locale, | ||
|
@@ -115,13 +118,13 @@ const renderRepoCard = (repo, options = {}) => { | |
icons.star, | ||
totalStars, | ||
"stargazers", | ||
ICON_SIZE, | ||
ICON_SIZE | ||
); | ||
const svgForks = iconWithLabel( | ||
icons.fork, | ||
totalForks, | ||
"forkcount", | ||
ICON_SIZE, | ||
ICON_SIZE | ||
); | ||
|
||
const starAndForkCount = flexLayout({ | ||
|
@@ -134,10 +137,13 @@ const renderRepoCard = (repo, options = {}) => { | |
gap: 25, | ||
}).join(""); | ||
|
||
// Calculate the card width and height based on the provided arguments or defaults | ||
const width = card_width || 400; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We also need to apply a minimum card width. Similar to is done in the langs and stats cards. |
||
|
||
const card = new Card({ | ||
defaultTitle: header.length > 35 ? `${header.slice(0, 35)}...` : header, | ||
titlePrefixIcon: icons.contribs, | ||
width: 400, | ||
width, | ||
height, | ||
border_radius, | ||
colors, | ||
|
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.
@airwakz can you remove these changes? These changes are not related to the pinned card. You should add your changes to https://github.com/anuraghazra/github-readme-stats/blob/master/api/pin.js.