Skip to content

Commit

Permalink
style: layout
Browse files Browse the repository at this point in the history
  • Loading branch information
0x4007 committed Nov 29, 2023
1 parent 4a29158 commit ef83273
Show file tree
Hide file tree
Showing 2 changed files with 109 additions and 60 deletions.
107 changes: 56 additions & 51 deletions static/scripts/display-issues.ts
Original file line number Diff line number Diff line change
@@ -1,77 +1,82 @@
import { GitHubIssue } from "../github-types";

export function displayIssues(container: HTMLDivElement, issues: GitHubIssue[]) {
container.innerHTML = "";
const existingIssueIds = new Set(Array.from(container.querySelectorAll(".issue-element-inner")).map((element) => element.getAttribute("data-issue-id")));

// container.innerHTML = "";

let delay = 0;
const baseDelay = 125; // Base delay in milliseconds

issues.forEach((issue, index) => {
const issueWrapper = document.createElement("div");
const issueElement = document.createElement("div");
issueWrapper.classList.add("issue-element-wrapper");
issueElement.classList.add("issue-element-inner");
issueWrapper.classList.add("issue-fade-in");
if (!existingIssueIds.has(issue.id.toString())) {
const issueWrapper = document.createElement("div");
const issueElement = document.createElement("div");
issueElement.setAttribute("data-issue-id", issue.id.toString());
issueWrapper.classList.add("issue-element-wrapper");
issueElement.classList.add("issue-element-inner");
issueWrapper.classList.add("issue-fade-in");

// Calculate the delay using an approximation of the cubic-bezier(0,1,1,1) easing function
delay = baseDelay * ((index * index) / (issues.length - 1));
// Calculate the delay using an approximation of the cubic-bezier(0,1,1,1) easing function
delay = baseDelay * ((index * index) / (issues.length - 1));

issueElement.style.animationDelay = `${delay}ms`;
issueElement.style.animationDelay = `${delay}ms`;

// Parse organization name and repository name from the issue's URL
// Parse organization name and repository name from the issue's URL

const urlRegex = /(https?:\/\/[^\s]+)/g;
const mirrorUrls = issue.body.match(urlRegex);
const urlRegex = /(https?:\/\/[^\s]+)/g;
const mirrorUrls = issue.body.match(urlRegex);

const urlPattern = /https:\/\/github\.com\/([^/]+)\/([^/]+)\//;
const match = mirrorUrls?.shift()?.match(urlPattern);
const organizationName = match?.[1];
const repositoryName = match?.[2];
const urlPattern = /https:\/\/github\.com\/([^/]+)\/([^/]+)\//;
const match = mirrorUrls?.shift()?.match(urlPattern);
const organizationName = match?.[1];
const repositoryName = match?.[2];

type LabelKey = "Pricing: " | "Time: " | "Priority: ";
type LabelKey = "Pricing: " | "Time: " | "Priority: ";

const labelOrder: Record<LabelKey, number> = { "Pricing: ": 1, "Time: ": 2, "Priority: ": 3 };
const labelOrder: Record<LabelKey, number> = { "Pricing: ": 1, "Time: ": 2, "Priority: ": 3 };

issue.labels.sort((a, b) => {
const matchA = a.name.match(/^(Pricing|Time|Priority): /)?.[0] as LabelKey | undefined;
const matchB = b.name.match(/^(Pricing|Time|Priority): /)?.[0] as LabelKey | undefined;
const orderA = matchA ? labelOrder[matchA] : 0;
const orderB = matchB ? labelOrder[matchB] : 0;
return orderA - orderB;
});
issue.labels.sort((a, b) => {
const matchA = a.name.match(/^(Pricing|Time|Priority): /)?.[0] as LabelKey | undefined;
const matchB = b.name.match(/^(Pricing|Time|Priority): /)?.[0] as LabelKey | undefined;
const orderA = matchA ? labelOrder[matchA] : 0;
const orderB = matchB ? labelOrder[matchB] : 0;
return orderA - orderB;
});

// Filter labels that begin with specific prefixes
const filteredLabels = issue.labels.filter((label) => {
return label.name.startsWith("Time: ") || label.name.startsWith("Pricing: ") || label.name.startsWith("Priority: ");
});
// Filter labels that begin with specific prefixes
const filteredLabels = issue.labels.filter((label) => {
return label.name.startsWith("Time: ") || label.name.startsWith("Pricing: ") || label.name.startsWith("Priority: ");
});

// Map the filtered labels to HTML elements
const labels = filteredLabels.map((label) => {
// Remove the prefix from the label name
const name = label.name.replace(/(Time|Pricing|Priority): /, "");
// Map the filtered labels to HTML elements
const labels = filteredLabels.map((label) => {
// Remove the prefix from the label name
const name = label.name.replace(/(Time|Pricing|Priority): /, "");

return `<div class="label">${name}</div>`;
});
return `<div class="label">${name}</div>`;
});

issueElement.innerHTML = `
<h3>${issue.title}</h3>
<div class="partner"><p class="organization-name">${organizationName}</p><p class="repository-name">${repositoryName}</p></div>
<div class="labels">${labels.join("")}</div>
issueElement.innerHTML = `
<div class="info"><div class="labels">${labels.join("")}</div><div class="partner"><p class="organization-name">${organizationName}</p><p class="repository-name">${repositoryName}</p></div></div>
<div class="title"><h3>${issue.title}</h3></div>
`;

issueElement.addEventListener("click", () => {
console.log(issue);
issueElement.addEventListener("click", () => {
console.log(issue);

// console.log(foundUrls);
// window.open(foundUrls?.shift(), "_blank");
});
// console.log(foundUrls);
// window.open(foundUrls?.shift(), "_blank");
});

issueWrapper.appendChild(issueElement);
issueWrapper.appendChild(issueElement);

// Append the issue element after the delay
setTimeout(() => {
container.appendChild(issueWrapper);
// Trigger the animation by adding the 'visible' class
issueElement.classList.add("visible");
}, delay);
// Append the issue element after the delay
setTimeout(() => {
container.appendChild(issueWrapper);
// Trigger the animation by adding the 'visible' class
issueElement.classList.add("visible");
}, delay);
}
});
}
62 changes: 53 additions & 9 deletions static/style.css
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ body {
from {
opacity: 0;
/* background-color: #fff; */
filter: blur(16px);
filter: blur(48px);
margin-left: 100vw;
}
to {
Expand All @@ -52,6 +52,9 @@ body {
/* border-radius: 8px; */
padding: 8px;
/* border-left: 1px solid; */
max-width: 640px;
margin: auto;
border-left: 1px solid #80808010;
}

#issues-container * {
Expand All @@ -71,14 +74,16 @@ body {
border-bottom: none;
} */
#issues-container > div {
padding: 8px 16px;
padding: 0 16px;
border-bottom: 1px solid #80808040;
/* opacity: 0.875 */
/* margin: 24px auto; */
/* line-height: 1; */
overflow: hidden;
border-left: 1px solid #80808040;
border-right: 1px solid #80808040;
cursor: pointer;
/* width: 640px; */
}
#issues-container > div:hover {
opacity: 1 !important;
Expand All @@ -92,11 +97,16 @@ body {
}

h3 {
margin: auto;
margin: 12px;
line-height: 1;
white-space: pre;
/* white-space: pre; */
font-size: 16px;
/* font-weight: 100; */
/* text-align: left; */
/* display: inline-block; */
/* vertical-align: middle; */
text-overflow: ellipsis;
vertical-align: middle;
}

p {
Expand All @@ -113,8 +123,11 @@ p {
}

.issue-element-inner {
margin: 12px auto;
/* margin: 24px auto; */
position: relative;
text-align: left;
display: flex;
padding: 12px 0px;
}

p.organization-name {
Expand All @@ -136,7 +149,7 @@ p.repository-name {
display: inline-block;
padding: 4px 6px;
border-radius: 4px;
margin: 8px 4px 0px;
margin: 0px 4px 0px;
font-size: 12px;
/* font-weight: 400; */
/* line-height: 1; */
Expand All @@ -149,13 +162,44 @@ p.repository-name {
/* cursor: pointer; */
width: 64px;
letter-spacing: 0.5px;
flex-grow: 3;
}
.labels {
text-align: right;
display: inline-block;
display: flex;
}

.partner {
position: absolute;
top: 0;
right: 0;
/* position: absolute; */
bottom: 0;
text-align: right;
margin: 4px 4px 0;
}

body {
text-align: center;
}
.info {
/* position: absolute; */
/* top: 0; */
/* right: 0; */
/* transform: translateY(-25%); */
/* padding: 10px; */
/* z-index: -1; */
/* width: 248px; */
/* display: inline-block; */
}

.title {
/* padding: 24px; */
/* display: inline-block; */
/* text-align: left; */
/* position: absolute; */
/* background: #ffffff10; */
/* z-index: 1; */
/* backdrop-filter: blur(4px); */
/* flex-grow: 1; */
/* vertical-align: middle; */
display: flex;
}

0 comments on commit ef83273

Please sign in to comment.