ethereum-org-website icon indicating copy to clipboard operation
ethereum-org-website copied to clipboard

Stop ButtonLink wrapping unnecessarily on InfoBanner

Open minimalsm opened this issue 2 years ago • 9 comments

Is your feature request related to a problem? Please describe.

When the paragraph content on our InfoBanner component wraps, it also causes the ButtonLink text to wrap unnecessarily.

Describe the solution you'd like

When the text wraps onto a second line, the button should not wrap unless it runs out of space.

Screenshots

Example in Dutch

Screenshot 2022-04-08 at 12 04 06

Example in English

Screenshot 2022-04-08 at 12 08 56

Desired solution

Screenshot 2022-04-08 at 12 08 48

Additional context

There are some cases where we DO want this ButtonLink copy to wrap, so removing adding white-space: nowrap; in all cases doesn't seem like a viable solution.

Want to contribute?

We love contributions from the Ethereum community! Please comment on an issue if you're interested in helping out with a PR.

minimalsm avatar Apr 08 '22 11:04 minimalsm

would like to take this on

KaranKaira avatar Apr 08 '22 15:04 KaranKaira

There are some cases where we DO want this ButtonLink copy to wrap

What would an example of that look like?

maxehnert avatar Apr 11 '22 19:04 maxehnert

@maxehnert one example is with more verbose languages. Ukrainian often requires two lines for the Button copy or it would overflow/cause horizontal scrolling.

Here is our homepage in Ukrarian for reference:

Screenshot 2022-04-12 at 22 41 10

minimalsm avatar Apr 12 '22 21:04 minimalsm

Hey @minimalsm, if there is no update on this I can take a look.

vluna avatar Apr 18 '22 20:04 vluna

Hi, just poking around the repo. I immediately thought white-space: nowrap; as well, so glad you acknowledged it. I would guess it could still work, but maybe adding a max-width of some kind could help. It may need responsive queries if going the max-width route, though. Just leaving this for whoever is/will work on it. Ping me if needed. :)

ianrandmckenzie avatar May 26 '22 02:05 ianrandmckenzie

Hi, I would like to work on this issue. @ianrandmckenzie would this be ok? button would be wrapped on screen size less than 480px

@media screen and (min-width: 480px) {
  .kQBZHz {
    white-space: nowrap;
  }
}

Dark-Knight11 avatar Jun 08 '22 11:06 Dark-Knight11

@Dark-Knight11 of course, I was just offering a suggestion. Feel free to dive in :)

ianrandmckenzie avatar Jun 09 '22 20:06 ianrandmckenzie

I thought of another method to achieve the required result instead of being dependant on screen size, we can look for length of text inside the button and apply wrapping accordingly

var x = document.getElementsByClassName('ButtonLink__StyledLinkButton-sc-a8k023-0');
var customStyle = {
    whiteSpace: "nowrap"
};
for (let i in x) {
    if (x[i].innerHTML.length < 20) {
        Object.assign(x[i].style, customStyle)
    }
}

I'm a little confused about the word limit so can anyone help me with it? @minimalsm can u please look into this If its good to go then lmk in which file should I write this code

Dark-Knight11 avatar Jun 11 '22 13:06 Dark-Knight11

This issue is stale because it has been open 45 days with no activity.

github-actions[bot] avatar Jul 31 '22 08:07 github-actions[bot]

@minimalsm - I know this issue has gone a little stale, but please see the PR that corrects this. I did end up using white-space: nowrap;, but I applied the property directly as inline-styling to ONLY the button mentioned in the issue (in 17 different language iterations), this way no changes will occur to any other ButtonLink tags on the site. Thanks!

Andy-Waine avatar Aug 15 '22 19:08 Andy-Waine

Closed by #7447

minimalsm avatar Sep 09 '22 12:09 minimalsm