Skip to content
This repository has been archived by the owner on Sep 11, 2024. It is now read-only.

Make ToastContainer compatible with RTL layout #8230

Merged
merged 14 commits into from
Apr 14, 2022
Merged

Make ToastContainer compatible with RTL layout #8230

merged 14 commits into from
Apr 14, 2022

Conversation

luixxiul
Copy link
Contributor

@luixxiul luixxiul commented Apr 5, 2022

Signed-off-by: Suguru Hirahara luixxiul@users.noreply.github.com

Cherry-picked from #8217

This PR removes the unnecessary rules which have not worked.

before

I guess the rules have been forgotten to be removed.

This also replaces float + margin + line-height properties with ones available for flexbox.

Why flexbox?

Because it realizes what is intended with the current style rules.

At first, the intention of these rules is to align the title on the middle of the area.
before1

Next, the counter is placed on the middle of the line by specifying the same line-height property as the title:
before

If you remove the line-height property manually, you should get the result as below.
before1

By the way, one of the the intentions of flexbox property is:

Making all the children of a container take up an equal amount of the available width/height

Therefore, flexbox is expected to realize what is intended here.

Current implementation:

LTR layout:
before1

RTL layout (emulating it by adding dir="rtl" to the html tag):
before2

  • The indicator is not displayed at the end of the row
  • margin-left does not create the gap between the buttons

With this PR:

LTR layout:
after2

RTL layout:
rtl

Yellow: margin
Purple: padding

These right side padding areas in the title and description areas should be taken care of by #8217.

type: task


This change is marked as an internal change (Task), so will not be included in the changelog.

Preview: https://pr8230--matrix-react-sdk.netlify.app
⚠️ Do you trust the author of this PR? Maybe this build will steal your keys or give you malware. Exercise caution. Use test accounts.

@luixxiul luixxiul requested a review from a team as a code owner April 5, 2022 07:15
@github-actions github-actions bot added the T-Task Refactoring, enabling or disabling functionality, other engineering tasks label Apr 5, 2022
@codecov
Copy link

codecov bot commented Apr 5, 2022

Codecov Report

Merging #8230 (f0ed532) into develop (7a1a2c4) will not change coverage.
The diff coverage is n/a.

@@           Coverage Diff            @@
##           develop    #8230   +/-   ##
========================================
  Coverage    29.82%   29.82%           
========================================
  Files          875      875           
  Lines        50024    50024           
  Branches     12727    12727           
========================================
  Hits         14918    14918           
  Misses       35106    35106           
Impacted Files Coverage Δ
src/components/structures/ToastContainer.tsx 0.00% <ø> (ø)

Signed-off-by: Suguru Hirahara <luixxiul@users.noreply.github.com>
- Use properties available for flexbox
- Align the title of the toast to the center

Signed-off-by: Suguru Hirahara <luixxiul@users.noreply.github.com>
Signed-off-by: Suguru Hirahara <luixxiul@users.noreply.github.com>
Copy link
Member

@turt2live turt2live left a comment

Choose a reason for hiding this comment

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

This PR also needs a title to describe what the user-facing bug is, per the contributing guidelines. This would make review a bit easier.

Once updated, happy to send this off for design review.

@@ -108,12 +108,13 @@ limitations under the License.
}

.mx_Toast_title {
display: flex;
Copy link
Member

Choose a reason for hiding this comment

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

I don't think we need a flexbox here? What is it fixing?

Copy link
Contributor Author

@luixxiul luixxiul Apr 9, 2022

Choose a reason for hiding this comment

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

  • it aligns the title and the icon counter (if any) horizontally
  • it assures the gap between the title and the icon counter without using margin padding-left: 8px;
  • it automatically calculates the flow of the child elements

I edited the first post to explain the reason why flexbox should realize what is intended here.

@@ -122,12 +123,11 @@ limitations under the License.
vertical-align: middle;
}

span {
padding-left: 8px;
float: right;
Copy link
Member

Choose a reason for hiding this comment

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

this might have been deliberate, even in a RTL language - will have to check with design.

Copy link
Contributor Author

@luixxiul luixxiul Apr 9, 2022

Choose a reason for hiding this comment

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

I don't think this is intended ↓

before2

Unless this would be expected to cover something in addition to <span>{ countIndicator }</span>, this should work.

@luixxiul luixxiul changed the title Fix _ToastContainer.scss Make ToastContainer compatible with RTL layout Apr 9, 2022
@luixxiul
Copy link
Contributor Author

luixxiul commented Apr 9, 2022

@turt2live could you please review again? Basically this PR does not fix something what users face currently, instead it makes the toast compatible with RTL layout worked on #8217.

@luixxiul luixxiul requested a review from turt2live April 9, 2022 06:25
@turt2live turt2live requested review from a team and removed request for turt2live April 9, 2022 06:30
@t3chguy t3chguy requested a review from turt2live April 11, 2022 08:20
@janogarcia
Copy link
Contributor

The improvements proposed in the PR description to make the toast work as expected in RTL mode make sense to me. 👍 I won't go into more details as this component is pending a proper, in-depth redesign.

Copy link
Member

@turt2live turt2live left a comment

Choose a reason for hiding this comment

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

Thanks!

@turt2live turt2live merged commit eb1d9b8 into matrix-org:develop Apr 14, 2022
@luixxiul luixxiul deleted the rtl-pick branch May 7, 2022 15:29
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
T-Task Refactoring, enabling or disabling functionality, other engineering tasks
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants