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

Fix word breaks #1271

Merged
merged 3 commits into from
Jan 26, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
1 change: 1 addition & 0 deletions assets/base.css
Original file line number Diff line number Diff line change
Expand Up @@ -386,6 +386,7 @@ h5,
letter-spacing: calc(var(--font-heading-scale) * 0.06rem);
color: rgb(var(--color-foreground));
line-height: calc(1 + 0.3 / max(1, var(--font-heading-scale)));
word-break: break-word;
}

.h0 {
Expand Down
2 changes: 0 additions & 2 deletions assets/component-image-with-text.css
Original file line number Diff line number Diff line change
Expand Up @@ -311,13 +311,11 @@

.image-with-text__heading {
word-break: break-word;
hyphens: auto;
Copy link
Contributor

Choose a reason for hiding this comment

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

Remove usage of hyphens CSS property

Can you share a bit more context on the decision to remove hyphens? I probably missed this conversation, but would love to know the rationale behind this so we can have it documented :D

Copy link
Contributor

Choose a reason for hiding this comment

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

Hyphens are very unpredictable and override any other wrapping behaviours we try to apply. Word break, overflow break, etc... - they are all overridden by the hyphen rules. Unfortunately, on top of that, the rules are independent of whether or not the font actually supports hyphens. So you can get situations where the hyphens are breaking something that wouldn't otherwise be broken, and which would look okay with a - character, but where the - is not being drawn because of the font.

So to make it so that everything is predictable and all works the same, we are using word break. We will be revisiting this to instead use overflow-wrap: break-word, most likely, but that requires some additional work and testing. Also we need to consider what we want to do for other things like paragraphs and buttons.

It might just end up being a situation where we add a setting for the merchant to pick how they want this handled, especially to account for different expectations in different languages. Though things do get interesting with stores that multi-language, since settings aren't language specific.

margin-bottom: 0;
}

.image-with-text__text p {
word-break: break-word;
hyphens: auto;
margin-top: 0;
margin-bottom: 1rem;
}
Expand Down
4 changes: 2 additions & 2 deletions snippets/card-collection.liquid
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@
{%- endif -%}
<div class="card__content">
<div class="card__information">
<h3 class="card__heading h1">
<h3 class="card__heading">
<a href="{{ card_collection.url }}" class="full-unstyled-link">
{%- if card_collection.title != blank -%}
{{- card_collection.title | escape -}}
Expand All @@ -82,7 +82,7 @@
{% if settings.card_style == 'card' or card_collection.featured_image %}
<div class="card__content">
<div class="card__information">
<h3 class="card__heading{% if card_collection.featured_image == nil %} h1{% endif %}">
<h3 class="card__heading">
<a href="{{ card_collection.url }}" class="full-unstyled-link">
{%- if card_collection.title != blank -%}
{{- card_collection.title | escape -}}
Expand Down