Skip to content

fix:SponsorsLine scroll #573

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

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
87 changes: 51 additions & 36 deletions src/ui/components/landing/SponsorsLine.astro
Original file line number Diff line number Diff line change
Expand Up @@ -85,13 +85,13 @@
};
//templates
const sponsorCardsTemplate = document.querySelector(
"#sponsor-cards",
"#sponsor-cards"
) as HTMLTemplateElement;
const sponsorCardWithNameTemplate = document.querySelector(
"#sponsor-card-with-name",
"#sponsor-card-with-name"
) as HTMLTemplateElement;
const sponsorCardWithoutNameTemplate = document.querySelector(
"#sponsor-card-without-name",
"#sponsor-card-without-name"
) as HTMLTemplateElement;
if (
sponsorCardsTemplate &&
Expand All @@ -102,7 +102,7 @@
sponsors.forEach((type) => {
if (type.items.length) {
const cards = sponsorCardsTemplate.content.cloneNode(
true,
true
) as HTMLElement;
const headerName = cards.querySelector("#header-text")!;
headerName.textContent = `${sponsorConfig[type.name].header} sponsors`;
Expand All @@ -114,12 +114,12 @@
if (sponsorConfig[type.name].hasName) {
//WITH NAME
const card = sponsorCardWithNameTemplate.content.cloneNode(
true,
true
) as HTMLDivElement;

//dark image
const imgDark = card.querySelector(
"#avatar-dark",
"#avatar-dark"
)! as HTMLImageElement;
if (item.imageType === ImageType.IMAGE) {
imgDark.src = item.sponsorEntity.avatarUrl;
Expand All @@ -132,7 +132,7 @@
if (!item.imageType) {
imgDark.src = getImgLink(
item.sponsorEntity.avatarUrl,
sponsorConfig[type.name].size,
sponsorConfig[type.name].size
);
}
imgDark.alt = item.sponsorEntity.name || item.sponsorEntity.login;
Expand All @@ -141,14 +141,14 @@
imgDark.setAttribute(
"style",
`border-radius: ${roundPercentages}%; ${getStyleString(
item.darkStyle || {},
)}`,
item.darkStyle || {}
)}`
);

//light image

const imgLight = card.querySelector(
"#avatar-light",
"#avatar-light"
)! as HTMLImageElement;
if (item.imageType === ImageType.IMAGE) {
imgLight.src = item.sponsorEntity.avatarUrl;
Expand All @@ -161,29 +161,29 @@
if (!item.imageType) {
imgLight.src = getImgLink(
item.sponsorEntity.avatarUrl,
sponsorConfig[type.name].size,
sponsorConfig[type.name].size
);
}
imgLight.alt =
item.sponsorEntity.name || item.sponsorEntity.login;
imgLight.setAttribute(
"style",
`border-radius: ${roundPercentages}%; ${getStyleString(
item.lightStyle || {},
)}`,
item.lightStyle || {}
)}`
);

const imgWrapper = card.querySelector(
"#img-wrapper",
"#img-wrapper"
)! as HTMLDivElement;
imgWrapper.setAttribute(
"style",
`width: ${sponsorConfig[type.name].size}px; height: ${
sponsorConfig[type.name].size
}px`,
}px`
);
const gitLink = card.querySelector(
"#git-link",
"#git-link"
)! as HTMLLinkElement;
if (item.imageType) {
gitLink.href = `https://${item.sponsorEntity.login}`;
Expand All @@ -204,7 +204,7 @@
}
gitLink.rel = item.followLink ? "" : "nofollow";
const cardName = card.querySelector(
"#card-name",
"#card-name"
)! as HTMLDivElement;
if (item.sponsorEntity.name) {
cardName.textContent =
Expand All @@ -221,7 +221,7 @@
: "" + item.sponsorEntity.login;
}
const cardWrapper = card.querySelector(
"#card-wrapper",
"#card-wrapper"
)! as HTMLDivElement;
cardWrapper.classList.add("with_name");
if (sponsorConfig[type.name].hasCard) {
Expand All @@ -239,24 +239,24 @@
} else {
//WITHOUT NAME
const card = sponsorCardWithoutNameTemplate.content.cloneNode(
true,
true
) as HTMLDivElement;

//dark image
const imgDark = card.querySelector(
"#avatar-dark",
"#avatar-dark"
)! as HTMLImageElement;
const roundPercentages =
item.sponsorEntity.__typename === "User" ? 50 : 20;
imgDark.setAttribute(
"style",
`border-radius: ${roundPercentages}%`,
`border-radius: ${roundPercentages}%`
);
imgDark.setAttribute(
"style",
`border-radius: ${roundPercentages}%; ${getStyleString(
item.darkStyle || {},
)}`,
item.darkStyle || {}
)}`
);
if (item.imageType === ImageType.IMAGE) {
imgDark.src = item.sponsorEntity.avatarUrl;
Expand All @@ -269,24 +269,24 @@
if (!item.imageType) {
imgDark.src = getImgLink(
item.sponsorEntity.avatarUrl,
sponsorConfig[type.name].size,
sponsorConfig[type.name].size
);
}
imgDark.alt = item.sponsorEntity.name || item.sponsorEntity.login;

//light image
const imgLight = card.querySelector(
"#avatar-light",
"#avatar-light"
)! as HTMLImageElement;
imgLight.setAttribute(
"style",
`border-radius: ${roundPercentages}%`,
`border-radius: ${roundPercentages}%`
);
imgLight.setAttribute(
"style",
`border-radius: ${roundPercentages}%; ${getStyleString(
item.lightStyle || {},
)}`,
item.lightStyle || {}
)}`
);
if (item.imageType === ImageType.IMAGE) {
imgLight.src = item.sponsorEntity.avatarUrl;
Expand All @@ -299,23 +299,23 @@
if (!item.imageType) {
imgLight.src = getImgLink(
item.sponsorEntity.avatarUrl,
sponsorConfig[type.name].size,
sponsorConfig[type.name].size
);
}
imgLight.alt =
item.sponsorEntity.name || item.sponsorEntity.login;

const imgWrapper = card.querySelector(
"#img-wrapper",
"#img-wrapper"
)! as HTMLDivElement;
imgWrapper.setAttribute(
"style",
`width: ${sponsorConfig[type.name].size}px; height: ${
sponsorConfig[type.name].size
}px`,
}px`
);
const gitLink = card.querySelector(
"#git-link",
"#git-link"
)! as HTMLLinkElement;
if (item.imageType) {
gitLink.href = `https://${item.sponsorEntity.login}`;
Expand Down Expand Up @@ -697,18 +697,33 @@
}

.scroll {
overflow: auto;
-ms-overflow-style: none;
scrollbar-width: none;
overflow-x: auto;
overflow-y: hidden;
-ms-overflow-style: auto;
scrollbar-width: thin;
display: flex;
flex-direction: row;
height: 306px;
padding: 0 20px;
gap: 80px;
}

/* Show scrollbar on desktop */
.scroll::-webkit-scrollbar {
display: none;
display: block;
height: 8px;
background: #e8e8e8;
}
.scroll::-webkit-scrollbar-thumb {
background: #c1c1c1;
border-radius: 4px;
}

/* Hide scrollbar on mobile */
@media (max-width: 767px) {
.scroll::-webkit-scrollbar {
display: none;
}
}

.gradient-left,
Expand Down