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

USWDS-Site - What's new: Update post preview structure and styles #2979

Merged
merged 28 commits into from
Dec 11, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
647be14
Update post preview styles; allow custom preview url
amyleadem Nov 20, 2024
0e83a74
Add sample posts
amyleadem Nov 20, 2024
c77ea37
Merge branch 'main' of https://github.com/uswds/uswds-site into al-wh…
amyleadem Nov 20, 2024
7b360a4
Separate post.html and post-preview.html
amyleadem Nov 20, 2024
ca4c58f
Update content on sample posts
amyleadem Nov 21, 2024
3eebc4f
Add underline to post-title link styles
amyleadem Nov 21, 2024
4858824
Refine styles for "news and updates"; remove h3 from in-page nav
amyleadem Nov 21, 2024
3abcf7b
Merge branch 'main' of https://github.com/uswds/uswds-site into al-wh…
amyleadem Nov 21, 2024
ecadaf6
Remove excerpt_link_text
amyleadem Nov 21, 2024
95b14b6
Format code
amyleadem Nov 21, 2024
80e627a
Move date below byline
amyleadem Nov 21, 2024
f9ccd69
Move utility clases off of post.html
amyleadem Nov 21, 2024
f659984
Restore measure-4 on post.html
amyleadem Nov 21, 2024
39e8f6a
Move utility classes off of post-content
amyleadem Nov 21, 2024
c0774a6
Format code
amyleadem Nov 22, 2024
41fd023
Add comments to includes
amyleadem Nov 25, 2024
c4d016a
Replace excerpt_link_url > custom_url; Add comment
amyleadem Nov 25, 2024
55d9f08
Create .post-meta subheading styles.
amyleadem Nov 25, 2024
fece742
Move post styles to posts partial
amyleadem Nov 25, 2024
cca2c85
Add article wrapper to post.html; add include comment
amyleadem Nov 25, 2024
0a1b612
Replace custom_url -> preview_url
amyleadem Nov 26, 2024
e9f2d18
Format code
amyleadem Nov 29, 2024
2b25d81
Tweak lead copy
amyleadem Nov 29, 2024
61aaf20
Remove demo posts
amyleadem Nov 29, 2024
a4a2f63
Update all-news.md
annepetersen Dec 9, 2024
11d17df
Update overview.md
annepetersen Dec 9, 2024
94ce244
Merge branch 'main' of https://github.com/uswds/uswds-site into al-wh…
amyleadem Dec 9, 2024
e6a115f
Merge branch 'main' of https://github.com/uswds/uswds-site into al-wh…
amyleadem Dec 10, 2024
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
15 changes: 15 additions & 0 deletions _includes/post-meta.html
mejiaj marked this conversation as resolved.
Show resolved Hide resolved
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{% comment %}
Date and author info for posts.

Used in _posts and post previews on `/about/whats-new/`
{% endcomment %}

<div class="post-meta">
{% if post.author %}
<span class="site-subheading">By {{ post.author }}</span>
{% endif %}

<time class="site-subheading" datetime="{{ post.date | date: '%FT%T' }}">
{{ post.date | date: '%B %-d, %Y' }}
</time>
</div>
38 changes: 38 additions & 0 deletions _includes/post-preview.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
{% comment %}
Post previews used in the news feeds found on:
- `/about/whats-new/`
- `/about/whats-new/all`
{% endcomment %}

{% assign post = include.post %}
{% assign post_id = post.title | default: post.id | slugify %}

{% comment %}
Assign header link url
- default: link to the post's generated page
- custom: link to a custom location declared in `post.preview_url`
{% endcomment %}
{% assign post_url = site.baseurl | append: post.url %}
{% assign preview_url = post.preview_url | default: post_url %}

<article id="{{ post_id }}" class="post-preview">
<header class="post-preview__header">
<p class="post-category site-subheading">
{{ post.tags[0] }}
amyleadem marked this conversation as resolved.
Show resolved Hide resolved
</p>

<{{ include.heading | default:"h2" }} class="post-preview__title">
mejiaj marked this conversation as resolved.
Show resolved Hide resolved
<a href="{{ preview_url }}">
{{ post.title }}
</a>
</{{ include.heading | default:"h2" }}>

{% include post-meta.html %}
</header>

<div class="post-preview__content site-prose">
<p>
{{ post.lead | default: post.excerpt }}
</p>
</div>
</article>
29 changes: 9 additions & 20 deletions _includes/post.html
Copy link
Contributor Author

@amyleadem amyleadem Nov 22, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note

Developers: I separated out the post excerpt/preview part of this file into post-preview.html. I did that because it felt like the structure of the markup was different enough to warrant separate files, and I also was finding it difficult to easily read the code.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

praise: Much cleaner template, nice work.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was going to say the same thing! Great work here Amy!

Original file line number Diff line number Diff line change
@@ -1,33 +1,22 @@
{% comment %}
Structure for the pages inside of _posts
{% endcomment %}

{% assign post = include.post %}
<article id="{{ post.id | default: post.title | slugify }}"{% if include.excerpt %} class="post-excerpt padding-top-2 border-top-2px margin-top-4 measure-6"{% endif %}>
amyleadem marked this conversation as resolved.
Show resolved Hide resolved
<header class="post-meta">
<article>
<header>
<p class="post-category site-subheading">
{{ post.tags[0] }}
</p>

<h1 class="post-title font-lang-11 tablet:font-lang-14 text-thin">
Copy link
Contributor Author

@amyleadem amyleadem Nov 22, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note

Moved the styles from the utility classes into uswds-theme-custom-styles for easier style and markup management.

{% if include.excerpt %}<a href="{{ site.baseurl }}{{ post.url }}">{% endif %}
<h1 class="post-title">
{{ post.title }}
{% if include.excerpt %}</a>{% endif %}
</h1>

{% if post.author %}
<span class="post-date site-subheading">By {{ post.author }}</span>
{% endif %}
<time class="post-date site-subheading" datetime="{{ post.date | date: '%FT%T' }}">
{{ post.date | date: '%B %-d, %Y' }}
</time>
{% include post-meta.html %}
</header>

<div class="post-content site-prose {% if include.excerpt == true %}{% else%}measure-4 {% endif %}margin-top-4">
{% if include.excerpt == true %}
<p class="post-excerpt">
{{ post.lead | default: post.excerpt }}
</p>

<p class="post-more margin-top-2"><a href="{{ site.baseurl }}{{ post.url }}">Continue reading</a></p>
{% else %}
<div class="post-content site-prose">
{{ post.content }}
{% endif %}
</div>
</article>
68 changes: 2 additions & 66 deletions css/_uswds-theme-custom-styles.scss
mejiaj marked this conversation as resolved.
Show resolved Hide resolved
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@
@import "custom-styles/highlight";
@import "custom-styles/copy-code-btn";
@import "custom-styles/graphic-list";
@import "custom-styles/posts";


// ========================================
// CUSTOM PROJECT SASS
Expand Down Expand Up @@ -1568,69 +1570,7 @@ iframe {
margin-bottom: units(4);
}

.post-excerpt {
margin-top: units(5);

.post-title {
margin-top: 0;
margin-bottom: 0;

a {
color: inherit;
text-decoration: none;

&:hover {
color: color($site-primary);
text-decoration: underline;
}
}
}

.post-category {
margin-top: 0;
}

.post-category + .post-title {
margin-top: 0;
}

.post-content p {
margin-bottom: 0;
margin-top: units(0.5);
}
} // .post-excerpt

.post-date {
display: block;
letter-spacing: normal;
text-transform: none;
}

.post-title {
@include typeset-h2;
@include u-measure(1);
}

.post-outdated-content {
margin-bottom: units(4);
margin-top: units(-5);
z-index: z-index("top");

@include at-media("tablet") {
position: sticky;
top: 0;
}

@include at-media("desktop") {
margin-left: units(4);
margin-top: 0;
top: units($height-nav-secondary);
}

.usa-alert__body {
margin-left: 0;
}
}

// Utilities CSS --------------------- //

Expand Down Expand Up @@ -3186,10 +3126,6 @@ body {
}
}

.post-content h2 {
line-height: lh("lang", 2);
}

.page-website-standards {
.site-subheading {
display: none;
Expand Down
80 changes: 80 additions & 0 deletions css/custom-styles/_posts.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
.post-preview {
@include u-border-top("1px", "gray-30");
@include u-margin-y(3);
@include u-measure(6);

&__title,
&__content,
&__header,
.post-category {
@include u-margin-y(2);
}

&__header {
@include u-margin-top(3);
}

&__title {
@include typeset("lang", "lg", 3);
@include u-text("bold");

a {
color: inherit;

&:hover {
color: color($site-primary);
}
}
}

&__content p {
@include u-font("lang", "xs");
}
Comment on lines +30 to +32
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

polish: This doesn't make much of a difference and could mean one less style to maintain.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fair. I like that it adds a tiny bit more visual hierarchy, but happy to remove it if that is the team's preference. It is not a must-have for me.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's really a tiny difference of 15.04px → 16px.

}

.post-meta .site-subheading {
@include u-margin-y("105");
display: block;
letter-spacing: normal;
text-transform: none;
}

.post-title {
@include u-measure(1);
@include typeset("lang", "xl", 2);
@include u-text("thin");

@include at-media("tablet") {
@include typeset("lang", "2xl", 2);
}
}

.post-content {
@include u-margin-top(4);
@include u-measure(4);

h2 {
line-height: lh("lang", 2);
}
}

.post-outdated-content {
margin-bottom: units(4);
margin-top: units(-5);
z-index: z-index("top");

@include at-media("tablet") {
position: sticky;
top: 0;
}

@include at-media("desktop") {
margin-left: units(4);
margin-top: 0;
top: units($height-nav-secondary);
}

.usa-alert__body {
margin-left: 0;
}
}
4 changes: 2 additions & 2 deletions pages/whats-new/all-news.md
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
---
title: All news and updates
layout: styleguide
lead: Here's the full listing of all USWDS product updates, articles, case studies and more.
lead: The full listing of all USWDS product updates, articles, case studies and more.
permalink: /about/whats-new/all/
category: About
type: posts
in_page_nav_headings: false
---

{% for post in site.posts %}
{% include post.html post=post excerpt=true %}
{% include post-preview.html post=post %}
{% endfor %}
6 changes: 4 additions & 2 deletions pages/whats-new/overview.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ permalink: /about/whats-new/
layout: styleguide
title: What’s new
category: About
lead: Here you can find the latest news and information about USWDS. Learn more about our product development and process, dive deeper into our monthly call topics, and see how we work with our partners to impact the government technology space.
lead: Get the latest USWDS news and information here. Learn more about our product development and process, dive deeper into our monthly call topics, and see how we work with our partners to improve the government technology space.
columns:
- title: New users
source: New Users
Expand Down Expand Up @@ -34,6 +34,7 @@ cards:
body: "How our growing community of government engineers, content specialists, and designers participate and contribute to improving USWDS."
linkText: "USWDS GitHub discussion"
linkUrl: "https://github.com/uswds/uswds/discussions"
in_page_nav_headings: "h2"
---

{% include site-card-list.html
Expand All @@ -42,10 +43,11 @@ cards:
listItemClasses="desktop:grid-col-6"
%}

{:.margin-top-2.text-normal.font-lang-md.text-gray-70}
## News and updates

{% for post in site.posts limit:4 %}
{% include post.html post=post excerpt=true %}
{% include post-preview.html post=post heading="h3"%}
{% endfor %}

---
Expand Down
Loading