Skip to content
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 dates and descriptions to boxes #34

Merged
merged 1 commit into from
Sep 7, 2024
Merged
Show file tree
Hide file tree
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
13 changes: 9 additions & 4 deletions styles.scss
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,6 @@ header {
}

// Box elements

.box,
pre {
border: $line-thickness solid $main-colour;
Expand All @@ -189,13 +188,13 @@ pre {
align-items: center;
grid-template-rows: auto auto;
grid-template-areas:
"boxEmoji boxTitle"
"boxEmoji boxSubtitle";
"boxEmoji boxTitle boxDate"
"boxEmoji boxSubtitle boxSubtitle";

@include desktop {
$emoji-box-size: 8rem;
padding: 1rem;
gap: 0.5rem;
gap: 0.25rem;
grid-template-columns: $emoji-box-size auto;
min-height: $emoji-box-size;
div.box-emoji {
Expand Down Expand Up @@ -239,6 +238,12 @@ pre {
grid-area: boxSubtitle;
margin: 0;
}

.box-date {
grid-area: boxDate;
margin: 1rem;
text-align: right;
}
}

// Code blocks
Expand Down
8 changes: 7 additions & 1 deletion website/__init__.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
from typing import Any, Dict, List, Optional
from urllib.parse import urlencode as encode_url_query, urlunparse as construct_url

from whenever import Date

from website import html, markdown, xml
from website.data import Blogpost, Project, get_data
from website.utils import strftime
Expand Down Expand Up @@ -56,11 +58,13 @@ def get_project_box(
href = f"/projects/{project_or_blogpost.project_id}"
emoji = project.emoji
subtitle = project.description_no_emoji
dt = Date.from_py_date(project.last_updated.py_datetime().date())
case Blogpost() as blogpost:
title = blogpost.title
href = f"/blog/{project_or_blogpost.blogpost_id}"
emoji = blogpost.emoji
subtitle = strftime(blogpost.last_updated, r"%Y-%m-%d")
subtitle = blogpost.description
dt = blogpost.first_posted

title_header_element = html.h2 if is_on_its_own_page else html.h3
title_element = (
Expand All @@ -76,10 +80,12 @@ def get_project_box(
else html.div(emoji, _class="box-emoji")
)
subtitle_element = html.p(subtitle, _class="box-subtitle")
date_element = html.p(dt.format_common_iso(), _class="box-date")
return html.div(
title_element,
emoji_element,
subtitle_element,
date_element,
_class="project box drop-shadow",
)

Expand Down
Loading