Skip to content

Simplify print style for links with URL text - #8848

Merged
chosak merged 4 commits into
mainfrom
feature/cleaner-print-links
Jul 16, 2025
Merged

Simplify print style for links with URL text#8848
chosak merged 4 commits into
mainfrom
feature/cleaner-print-links

Conversation

@chosak

@chosak chosak commented Jun 25, 2025

Copy link
Copy Markdown
Member

Currently the site print style marks up links with their URL, for example, given a link with text "Example" that points to example.com, the link will render like

Example (example.com)

This is overly verbose in cases where the link text is actually the same as the URL, in which case you get duplication, like

example.com/foo (https://example.com/foo)

This commit attempts to modify this markup logic to avoid this duplication, while keeping existing behavior for all other links.

This is implemented by adding a new class on the backend to links with URL link text, and having our frontend CSS hide the URL markup if that class exists. It isn't possible to implement this logic in CSS alone.

The backend logic attempts to be smart; for example, a link to https://www.consumerfinance.gov/foo that has link text of "consumerfinance.gov/foo" will still get the simplified styling.

See internal DeCo#641 for context.

Notes and todos

@anselmbradford I'm opening this as a draft as it needs some frontend love and content review. Please feel free to modify the class that gets applied, and also please audit this on the pages you're tracking with this issue to ensure it only applies where desired.

@chosak
chosak requested a review from anselmbradford June 25, 2025 17:52
@@ -34,7 +34,7 @@
a.m-info-unit__heading-link::after,

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Unrelated to this PR, but is there a bug on

a.o-header__logo-img::after,

Note that the print view of pages does include (cfpb.gov) and (cfpb.gov/es) on the header logo:

image

The template code (1, 2) uses o-header__logo for the <a>, not o-header__logo-img.

@chosak
chosak force-pushed the feature/cleaner-print-links branch from 443379f to ae66b37 Compare June 25, 2025 17:59
Currently the site print style marks up links with their URL, for
example, given a link with text "Example" that points to example.com,
the link will render like

Example (example.com)

This is overly verbose in cases where the link text is actually the
same as the URL, in which case you get duplication, like

example.com/foo (https://example.com/foo)

This commit attempts to modify this markup logic to avoid this
duplication, while keeping existing behavior for all other links.

This is implemented by adding a new class on the backend to links
with URL link text, and having our frontend CSS hide the URL markup
if that class exists. It isn't possible to implement this logic in
CSS alone.

The backend logic attempts to be smart; for example, a link to
https://www.consumerfinance.gov/foo that has link text of
"consumerfinance.gov/foo" will still get the simplified styling.

See internal DeCo#641 for context.
@chosak
chosak force-pushed the feature/cleaner-print-links branch from ae66b37 to bf5a764 Compare June 25, 2025 18:11
@chosak
chosak marked this pull request as ready for review July 8, 2025 15:34
@chosak
chosak added this pull request to the merge queue Jul 16, 2025
Merged via the queue into main with commit b630e5b Jul 16, 2025
27 of 31 checks passed
@chosak
chosak deleted the feature/cleaner-print-links branch July 16, 2025 21:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants