Skip to content

Commit

Permalink
Adds Labels to the HUD (#5)
Browse files Browse the repository at this point in the history
  • Loading branch information
KenwoodFox authored Jan 10, 2025
1 parent c2448b6 commit 84f7d01
Show file tree
Hide file tree
Showing 3 changed files with 83 additions and 48 deletions.
8 changes: 8 additions & 0 deletions app/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,10 @@ def fetch_github_data():
if issue.assignees
else []
),
"labels": [
{"name": label.name, "color": f"#{label.color}"}
for label in issue.labels
],
"additions": 0,
"deletions": 0,
}
Expand All @@ -119,6 +123,10 @@ def fetch_github_data():
if pr.assignees
else []
),
"labels": [
{"name": label.name, "color": f"#{label.color}"}
for label in pr.labels
],
"additions": pr_details.additions,
"deletions": pr_details.deletions,
}
Expand Down
50 changes: 32 additions & 18 deletions app/static/style.css
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,7 @@ body {
/* Each Card */
.card {
display: flex;
flex-direction: row;
background: #333;
border: 1px solid #555;
padding: 5px;
Expand All @@ -146,20 +147,11 @@ body {
min-height: 60px;
}

/* ========================= */
/* Card Left (Number Column) */
/* ========================= */
/* ===================== */
/* Number Box (leftmost) */
/* ===================== */

.card-left {
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
text-align: center;
flex: 0 0 100px; /* Fixed width */
}

.number {
.number-box {
font-size: 3em;
font-weight: bold;
text-align: center;
Expand All @@ -173,7 +165,7 @@ body {
height: 100%;
}

.number .repo-name {
.number-box .repo-name {
font-weight: normal;
position: absolute;
bottom: 0px;
Expand All @@ -186,11 +178,11 @@ body {
font-size: min(0.3em, 4vw);
}

/* ========================= */
/* Card Right (Content) */
/* ========================= */
/* ========= */
/* Card Data */
/* ========= */

.card-right {
.card-data {
flex: 1;
display: flex;
flex-direction: column;
Expand Down Expand Up @@ -268,6 +260,28 @@ body {
color: #f44336;
}

/* ====== */
/* Labels */
/* ====== */

.card-labels {
flex: 2;
gap: 5px;
text-align: center;
}

.card-labels .issue-label {
display: inline-block;
padding: 3px 8px;
margin: 2px;
font-size: 0.85em;
font-weight: bold;
color: #fff;
border-radius: 12px; /* Rounded rectangle */
text-align: center;
white-space: nowrap; /* Prevent text wrapping */
}

/* ========================= */
/* Refresh Indicator */
/* ========================= */
Expand Down
73 changes: 43 additions & 30 deletions app/templates/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -40,16 +40,14 @@ <h2>Issues ({{ issues_count }})</h2>
<div class="card-container">
{% for issue in issues %}
<div class="card">
<!-- Left Column: Number & Repo Name -->
<div class="card-left">
<div class="number">
<div class="card-number">#{{ issue.number }}</div>
<div class="repo-name">{{ issue.repo_name }}</div>
</div>
<!-- Number & Repo Name -->
<div class="number-box">
<div class="card-number">#{{ issue.number }}</div>
<div class="repo-name">{{ issue.repo_name }}</div>
</div>

<!-- Right Column: Title, Meta, Assignees -->
<div class="card-right">
<!-- Data Column: Title, Meta, Assignees -->
<div class="card-data">
<div class="card-content">
<span class="card-title">{{ issue.title }}</span>
<span class="card-meta">Opened by {{ issue.user }}</span>
Expand All @@ -62,6 +60,15 @@ <h2>Issues ({{ issues_count }})</h2>
</div>
{% endif %}
</div>

<!-- Labels Column -->
<div class="card-labels">
{% for label in issue.labels %}
<div class="issue-label" style="background-color: {{ label.color }};">
{{ label.name }}
</div>
{% endfor %}
</div>
</div>
{% endfor %}
</div>
Expand All @@ -73,32 +80,38 @@ <h2>Pull Requests ({{ pull_requests_count }})</h2>
<div class="card-container">
{% for pr in pull_requests %}
<div class="card">
<!-- Left Column: Number & Repo Name -->
<div class="card-left">
<div class="number">
<div class="card-number">#{{ pr.number }}</div>
<div class="repo-name">{{ pr.repo_name }}</div>
</div>
<!-- Number & Repo Name -->
<div class="number-box">
<div class="card-number">#{{ pr.number }}</div>
<div class="repo-name">{{ pr.repo_name }}</div>
</div>

<!-- Right Column: Title, Meta, Changes -->
<div class="card-right">
<div class="card-content">
<span class="card-title">{{ pr.title }}</span>
<span class="card-meta">Opened by {{ pr.user }}</span>
{% if pr.assignees %}
<div class="card-assignee">
{% for assignee in pr.assignees %}
<div class="assignee-name">{{ assignee }}</div>
{% endfor %}
</div>
{% endif %}
<!-- Title, Meta, Changes -->
<div class="card-data">
<span class="card-title">{{ pr.title }}</span>
<span class="card-meta">Opened by {{ pr.user }}</span>
{% if pr.assignees %}
<div class="card-assignee">
{% for assignee in pr.assignees %}
<div class="assignee-name">{{ assignee }}</div>
{% endfor %}
</div>
<div class="card-changes">
<span class="changes-additions">+{{ pr.additions }}</span>
<span class="changes-divider">/</span>
<span class="changes-deletions">-{{ pr.deletions }}</span>
{% endif %}
</div>

<!-- Labels Column -->
<div class="card-labels">
{% for label in pr.labels %}
<div class="issue-label" style="background-color: {{ label.color }};">
{{ label.name }}
</div>
{% endfor %}
</div>

<div class="card-changes">
<span class="changes-additions">+{{ pr.additions }}</span>
<span class="changes-divider">/</span>
<span class="changes-deletions">-{{ pr.deletions }}</span>
</div>
</div>
{% endfor %}
Expand Down

0 comments on commit 84f7d01

Please sign in to comment.