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

CTA Block: Excessive bottom padding #5397

Open
jmuzina opened this issue Oct 23, 2024 · 2 comments
Open

CTA Block: Excessive bottom padding #5397

jmuzina opened this issue Oct 23, 2024 · 2 comments

Comments

@jmuzina
Copy link
Member

jmuzina commented Oct 23, 2024

While building canonical/canonical.com#1406, I noticed a visual quirk with the CTA block: we have given it padding-bottom: $spv--x-large here:

padding-bottom: $spv--x-large;

This causes some extra spacing beneath the CTA block that is not present in CTA blocks that don't use our .p-cta-block.

Default:
Screenshot 2024-10-23 at 3 19 22 PM

Expected (no bottom padding):
Screenshot 2024-10-23 at 3 19 37 PM

Copy link

Thank you for reporting us your feedback!

The internal ticket has been created: https://warthogs.atlassian.net/browse/WD-16100.

This message was autogenerated

@jmuzina
Copy link
Member Author

jmuzina commented Dec 18, 2024

Bringing this one back into discussion, as it's gotten a bit stale and we need further alignment before we proceed with implementing it.

The core of the problem is that the CTA block can sometimes contain a Button element, which has its own bottom margin that, when combines with bottom padding from p-cta-block, creates excessive bottom spacing beneath the CTA block.

However, the CTA block does not always have a button: sometimes, it just has an anchor element. So, blanket removing that bottom padding would cause the anchor to throw off the baseline alignment and not have enough spacing when there is only a link.

We should not apply paragraph block styling to the links, as they are inline elements.

Maybe, a decent way of fixing this without making API changes is to apply paragraph bottom margin (not the rest of paragraph styles) to anchor elements in CTA blocks

.p-cta-block {
  a {
     // apply paragraph element bottom spacing
     margin-bottom: map-get($sp-after, p) - map-get($nudges, p);
  } 
}

We could make this even more specific by targeting a:only-child to only add that spacing for links that don't have buttons next to them, but I'm not sure if that's appropriate or needed, and it feels a bit dirty.

CC @lyubomir-popov @bartaz

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant