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 design system link styling #163

Merged
merged 1 commit into from
Sep 22, 2021
Merged

Add design system link styling #163

merged 1 commit into from
Sep 22, 2021

Conversation

aduth
Copy link
Member

@aduth aduth commented Sep 22, 2021

Why: So that links are styled using the design system, instead of browser defaults.

An alternative can be to configure the $theme-global-link-styles SASS variable. However, this applies to all links in the layout, which may have unexpected repercussions. Instead, extending Kramdown ensures that styles are only applied to parsed Markdown content.

Before After
image image

Kramdown monkey-patching reference: https://github.com/gettalong/kramdown/blob/0b0a9e0/lib/kramdown/parser/kramdown/link.rb#L37-L51

**Why**: So that links are styled using the design system, instead of browser defaults.
Copy link
Contributor

@zachmargolis zachmargolis left a comment

Choose a reason for hiding this comment

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

LGTM

Comment on lines +5 to +7
def add_link(el, *args)
el.attr['class'] = [*el.attr['class'], 'usa-link'].join(' ') if el.type == :a
super(el, *args)
Copy link
Member Author

Choose a reason for hiding this comment

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

Could serve as motivation to bump to Ruby >=2.7 😄

Suggested change
def add_link(el, *args)
el.attr['class'] = [*el.attr['class'], 'usa-link'].join(' ') if el.type == :a
super(el, *args)
def add_link(el, ...)
el.attr['class'] = [*el.attr['class'], 'usa-link'].join(' ') if el.type == :a
super(el, ...)

@aduth aduth merged commit a659c62 into main Sep 22, 2021
@aduth aduth deleted the aduth-ds-links branch September 22, 2021 17:23
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