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: Tabs: Initial clean up, get rtl and ltr consistent #5431

Merged
merged 5 commits into from
Mar 11, 2025

Conversation

margaree
Copy link
Contributor

Part of this ticket

The purpose of this PR is to get the LTR and RTL styles consistent in order to make reading the vdiffs easier with the changes to use the new tab structure/component

Copy link
Contributor

Thanks for the PR! 🎉

We've deployed an automatic preview for this PR - you can see your changes here:

URL https://live.d2l.dev/prs/BrightspaceUI/core/pr-5431/

Note

The build needs to finish before your changes are deployed.
Changes to the PR will automatically update the instance.

margin-left: 0;
}
:host([dir="rtl"]:first-child) .d2l-tab-text {
margin-left: 0.6rem;
Copy link
Contributor Author

@margaree margaree Mar 11, 2025

Choose a reason for hiding this comment

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

margin-right for first child for LTR is actually 0.5rem so this was inconsistent in RTL. Let me know if there was a reason why that I'm missing.

Copy link
Member

Choose a reason for hiding this comment

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

Can we remove RtlMixin entirely from some of these are is the dir attribute still needed for something?

Copy link
Member

Choose a reason for hiding this comment

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

Ah I see Dave already asked that elsewhere -- ignore this one.

width: calc(100% - 0.6rem);
}
:host([dir="rtl"]:first-child) .d2l-tab-selected-indicator {
margin-left: 0.6rem;
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is handled in the css for d2l-tab-selected-indicator above.

@@ -37,7 +37,6 @@ export const TabMixin = superclass => class extends SkeletonMixin(superclass) {
width: calc(100% - 1.2rem);
}
:host(:first-child) .d2l-tab-selected-indicator {
margin-inline-end: 0.6rem;
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This wasn't needed

@@ -15,7 +15,6 @@ class Tab extends TabMixin(LitElement) {
white-space: nowrap;
}
:host(:first-child) .d2l-tab-text {
margin-inline-end: 0.6rem;
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This wasn't yet used but was inconsistent with the current LTR behaviour (which would have margin-inline-end as 0.5rem)

@@ -19,34 +19,6 @@ const reduceMotion = matchMedia('(prefers-reduced-motion: reduce)').matches;

const scrollButtonWidth = 56;

// remove once IE11 is no longer supported
if (!Array.prototype.findIndex) {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

no longer needed

@margaree margaree marked this pull request as ready for review March 11, 2025 16:23
@margaree margaree requested a review from a team as a code owner March 11, 2025 16:23
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
@dbatiste
Copy link
Contributor

If we want to go so far as to eliminate the use of RtlMixin, I think we would need to check document.documentElement.getAttribute('dir') === 'rtl' in the Javascript, similar to what I did for the PopoverMixin.

@bearfriend
Copy link
Contributor

bearfriend commented Mar 11, 2025

Only skimmed this but if it's relevant to this or future changes remember we have --d2l-document-direction if needed

@margaree
Copy link
Contributor Author

If we want to go so far as to eliminate the use of RtlMixin, I think we would need to check document.documentElement.getAttribute('dir') === 'rtl' in the Javascript, similar to what I did for the PopoverMixin.

We check for dir in a variety of places in the js in tabs.js. In each spot I can just do a document.documentElement.getAttribute('dir') !== / === 'rtl'. Instead of that, is there a spot we'd recommend for putting a property? Or should we still be using RtlMixin so a re-render gets triggers if dir changes?

@dbatiste
Copy link
Contributor

dbatiste commented Mar 11, 2025

Instead of that, is there a spot we'd recommend for putting a property? Or should we still be using RtlMixin so a re-render gets triggers if dir changes?

I'm fine with doing the getAttribute(...) call for each of the few functions that need it. One of the functions contains 4 usages of dir that would obviously be replaced by just one call.

But if we want to store the value in a shared spot to reduce the calls, we'd just want to do it in a spot such that it gets updated when we change the language in our demo pages. I'm not convinced this is worth it.

I might be inclined to put the document.documentElement.getAttribute('dir') === 'rtl', in a isRTL method though.

@margaree margaree merged commit ab02660 into main Mar 11, 2025
7 checks passed
@margaree margaree deleted the tabs-consistent-styles-cleanup branch March 11, 2025 19:16
Copy link

🎉 This PR is included in version 3.88.4 🎉

The release is available on:

Your semantic-release bot 📦🚀

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

Successfully merging this pull request may close these issues.

4 participants