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: Enhance what's new page layout #3115

Open
wants to merge 26 commits into
base: al-whats-new-directory-change
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 20 commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
175a065
Create jump-links include
amyleadem Feb 18, 2025
5924b46
Add version vars for other USWDS products
amyleadem Feb 18, 2025
6b0ff00
Add post-preview.html conditionals for category and date
amyleadem Feb 18, 2025
e4f32f4
Add
amyleadem Feb 18, 2025
9bb0485
Update layout for pages and add new styles
amyleadem Feb 18, 2025
7eb1062
Merge branch 'main' of https://github.com/uswds/uswds-site into al-wh…
amyleadem Feb 18, 2025
98d834a
Merge branch 'al-whats-new-directory-change' of https://github.com/us…
amyleadem Feb 18, 2025
e0ce487
Run prettier
amyleadem Feb 18, 2025
e7af702
Merge branch 'al-whats-new-directory-change' of https://github.com/us…
amyleadem Feb 18, 2025
5397251
Remove consolidated changelog code
amyleadem Feb 18, 2025
6b3b66a
Add id for #latest-releases
amyleadem Feb 18, 2025
bde2472
Remove unnecessary classes from jump-links.html
amyleadem Feb 18, 2025
3e85a9e
Rename posts.scss -> whats-new.scss
amyleadem Feb 18, 2025
542f519
Rename whats-new-card-group
amyleadem Feb 18, 2025
9b5dda3
Remove unnecessary include.listItemClasses
amyleadem Feb 18, 2025
a6010e4
Remove unnecessary span
amyleadem Feb 18, 2025
aa2bc2f
Clean up site-card/site-card-list.html
amyleadem Feb 18, 2025
97aff1a
Update all news title -> "All news and events"
amyleadem Feb 18, 2025
0e261c1
Fix figma link
amyleadem Feb 19, 2025
35c5eb4
Update design kit link to point to release notes
amyleadem Feb 19, 2025
d698d30
Update subheading default element to span
amyleadem Feb 20, 2025
84d5637
Add comment about include purpose; improve readability
amyleadem Feb 21, 2025
9961107
Wrap include.headingClasses in conditional
amyleadem Feb 21, 2025
5d18a6c
Annotate required/optional for site-card vars
amyleadem Feb 21, 2025
333d592
Replace capture with assign
amyleadem Feb 21, 2025
f5b91d3
Merge branch 'al-whats-new-directory-change' of https://github.com/us…
amyleadem Feb 21, 2025
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
2 changes: 2 additions & 0 deletions _config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
title: U.S. Web Design System (USWDS)
description: USWDS makes it easier to build accessible, mobile-friendly government websites.
uswds_version: 3.11.0
uswds_compile_version: 1.2.1
uswds_design_kit_version: 3.0
uswds_email: [email protected]
federalist_base: "https://federalist-3b6ba08e-0df4-44c9-ac73-6fc193b0e19c.sites.pages.cloud.gov/preview/uswds/uswds"
federalist_component_preview: "iframe.html?id="
Expand Down
25 changes: 25 additions & 0 deletions _includes/jump-links.html
Copy link
Contributor

Choose a reason for hiding this comment

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

issue (non-blocking): We already have a jump links component in _includes/accessibility-tests/jump-links.html.

We should avoid repeating ourselves in the future and create a more flexible jump links component that can be reused. This would allow you to re-use the reduced motion styles and avoid setting them in multiple places, like accessibility-tests.html.

Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
<!-- Turn on smooth scroll animation for anchor links -->
Copy link
Contributor

Choose a reason for hiding this comment

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

issue: Can you add a comment with a brief description and where this is used?

Are there any settings related to this component?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Added a comment in 84d5637

<style>
html {
scroll-behavior: smooth;
}

@media screen and (prefers-reduced-motion: reduce) {
html {
scroll-behavior: auto;
}
}
</style>

<ul class="site-checklist-jump-links">
{% for link in page.jump_links %}
<li>
<a href="#{{ link.href | default: link.text | downcase | slugify }}">
Copy link
Contributor

Choose a reason for hiding this comment

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

polish: Is downcase needed here? Slugify in Jekyll docs says it already handles lowercase.

Slugify

Convert a string into a lowercase URL "slug".

Suggested change
<a href="#{{ link.href | default: link.text | downcase | slugify }}">
<a href="#{{ link.href | default: link.text | slugify }}">

Copy link
Contributor

Choose a reason for hiding this comment

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

More polish: You could improve readability by saving this in a variable.

  {% for link in page.jump_links %}

    {% assign link_href = link.href | default: link.text | slugify %}

    <li>
      <a href="#{{ link_href }}">

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Made these updates in 84d5637

<svg class="usa-icon" aria-hidden="true" role="img">
<use href="{{ site.baseurl }}/assets/img/sprite.svg#arrow_downward"></use>
</svg>
{{ link.text }}
Copy link
Contributor

Choose a reason for hiding this comment

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

thought: If link.text is always available this is fine, but without checking for it you could run into issues.

For example
If it isn't passed you'll still have a list item, link, and icon but it'll be empty and the href will be broken (unless link.href exists).

Copy link
Contributor Author

@amyleadem amyleadem Feb 21, 2025

Choose a reason for hiding this comment

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

It feels to me like link.text should be mandatory here. Any objection to leaving it as is?

</a>
</li>
{% endfor %}
</ul>
18 changes: 10 additions & 8 deletions _includes/post-preview.html
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,13 @@

<article id="{{ post_id }}" class="post-preview">
<header class="post-preview__header">
<p class="post-category site-subheading">
{{ post.tags[0] }}
</p>
{% if include.category %}
<p class="post-category site-subheading">
{{ post.tags[0] }}
</p>
{% endif %}
Comment on lines +19 to +23
Copy link
Contributor Author

@amyleadem amyleadem Feb 18, 2025

Choose a reason for hiding this comment

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

Note

On the main what's new page, I removed the tag eyebrow to conserve vertical real estate. I added it back in on the "All news and updates" page. Flag if you would like this changed.


<{{ include.heading | default:"h2" }} class="post-preview__title">
<{{ include.heading | default:"h2" }} class="post-preview__title {{ include.headingClasses }}">
Copy link
Contributor

Choose a reason for hiding this comment

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

polish: Where's this class needed? What happens when headingClasses is empty?

I see an empty space in the what's new preview

<!-- about/whats-new/ -->
<h3 class="post-preview__title ">

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Added a conditional for include.headingClasses in 9961107

{% unless preview_url == "none" %}
<a href="{{ preview_url }}">
{% endunless %}
Expand All @@ -30,12 +32,12 @@
{% endunless %}
</{{ include.heading | default:"h2" }}>

{% include post-meta.html %}
{% if include.date %}
{% include post-meta.html %}
{% endif %}
Comment on lines +35 to +37
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Note

On the main what's new page, I removed the date to conserve vertical real estate. I added it back in on the "All news and updates" page. Flag if you would like this changed.

</header>

<div class="post-preview__content site-prose">
<p>
{{ post.lead | default: post.excerpt | markdownify }}
</p>
<p>{{ post.lead | default: post.excerpt | markdownify }}</p>
</div>
</article>
9 changes: 8 additions & 1 deletion _includes/site-card-list.html
Original file line number Diff line number Diff line change
@@ -1,17 +1,24 @@
{% comment %}
Container for site card group.

Seen in "What's New" page - `/about/whats-new/`
{% endcomment %}

<ul class="usa-card-group {{ include.listClasses }}">
{% for card in include.cards %}
<li class="usa-card site-component-card {{ include.listItemClasses }}">
{% include site-card.html
containerClasses=include.containerClasses
heading=card.heading
headingElement=include.headingElement
subheading=card.subheading
subheadingElement=include.subheadingElement
image=card.image
imageAlt=card.imageAlt
body=card.body
linkUrl=card.linkUrl
linkText=card.linkText
linkClasses=include.linkClasses
%}
</li>
{% endfor %}
Expand Down
28 changes: 24 additions & 4 deletions _includes/site-card.html
Copy link
Contributor

Choose a reason for hiding this comment

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

thought: Something for next time. This component could benefit from using capture to avoid having so many settings. It also gives flexibility to the author by using the markup that they need.

For example:

<!-- Set in template and passed to include. -->
{% capture card_heading %}
  <div>A subheading</div>
  <h3>The heading</h3>
{% endcapture %}


<!-- Component re-uses `card_heading`  -->
<header class="usa-card__header">
  {{ include.card_heading }}
</header>

Original file line number Diff line number Diff line change
@@ -1,20 +1,40 @@
{% comment %}
Single card element for `site-card-list`.

Variables:
- heading: String heading for a single card.
- headingElement: The heading HTML element type.
- subheading: String subheading for a single card.
- subheadingElement: The subheading HTML element type.
- body: String body that gets placed in a paragraph tag.
- image: The card image.
- imageAlt: The alt tag for the image.
- linkUrl: String for the link url.
- linkText: String link label.
- linkClasses: Classes for the link element.
Copy link
Contributor

Choose a reason for hiding this comment

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

issue: Are all these settings required or are some optional?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Added notes about required vs optional in 5d18a6c

{% endcomment %}
<div class="usa-card__container">

<div class="usa-card__container {{ include.containerClasses }}">
<header class="usa-card__header">
<h2 class="usa-card__heading font-lang-lg">{{ include.heading }}</h2>
{% if include.subheading %}
<{{ include.subheadingElement | default:"h2" }} class="site-subheading">{{ include.subheading }}</{{ include.subheadingElement | default:"h2" }}>
{% endif %}
<{{ include.headingElement | default:"h3" }} class="usa-card__heading font-lang-lg">{{ include.heading }}</{{ include.headingElement | default:"h3" }}>
</header>
{% if include.image %}
<div class="usa-card__media">
<div class="usa-card__img">
<img
src="{{ include.image }}"
alt="{{ include.imageAlt }}"
/>
</div>
</div>
{% endif %}
<div class="usa-card__body font-lang-sm">
<p>{{ include.body }}</p>
</div>
<div class="usa-card__footer">
<a class="usa-button site-button" href="{{ include.linkUrl }}">{{ include.linkText }}</a>
<a class="usa-button site-button {{ include.linkClasses }}" href="{{ include.linkUrl }}">{{ include.linkText }}</a>
</div>
</div>
2 changes: 1 addition & 1 deletion css/_uswds-theme-custom-styles.scss
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
@import "custom-styles/highlight";
@import "custom-styles/copy-code-btn";
@import "custom-styles/graphic-list";
@import "custom-styles/posts";
@import "custom-styles/whats-new";

// ========================================
// CUSTOM PROJECT SASS
Expand Down
80 changes: 0 additions & 80 deletions css/custom-styles/_posts.scss

This file was deleted.

Loading