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

LTR/RTL fixes #11905

Merged
merged 14 commits into from
Jan 23, 2024
Merged

LTR/RTL fixes #11905

merged 14 commits into from
Jan 23, 2024

Conversation

wackerow
Copy link
Member

@wackerow wackerow commented Jan 11, 2024

Description

  • Use LTR direction for content portion of pages without translated content available
    • (Not implemented on all pages yet. Started with applying to layouts, and tutorials landing page)
  • Force child components that use "common" namespace (always available for a locale) to use native text direction, overriding any upstream LTR declarations if page content is untranslated
  • Fix search modal direction-responsive css styling
  • Fix direction-responsive absolute positioning for some components

Preview URL

Screenshots:

https://deploy-preview-11905--ethereumorg.netlify.app/ar/developers/docs
ex. RTL locale, but content not translated:
image

https://deploy-preview-11905--ethereumorg.netlify.app/fa/developers/docs
ex. RTL locale where content is translated (unchanged, but for comparison))
image

RTL search modal:
image

"common" i18n namespace will always be available. This forces using the locale text-direction for these components, to override any cascading LTR overrides from pages with English-only content
insetInlineStart/End Chakra-UI style props not being recognized; refactored to use `style` prop
Copy link

netlify bot commented Jan 11, 2024

Deploy Preview for ethereumorg ready!

Name Link
🔨 Latest commit 22ee0d9
🔍 Latest deploy log https://app.netlify.com/sites/ethereumorg/deploys/65aaa5e60c542b000813e131
😎 Deploy Preview https://deploy-preview-11905--ethereumorg.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

@github-actions github-actions bot added content 🖋️ This involves copy additions or edits review needed 👀 tooling 🔧 Changes related to tooling of the project labels Jan 11, 2024
@wackerow
Copy link
Member Author

(Initial Netlify build failed from unrelated reasons which caused the check to fail... re-ran and it passed. Preview link from passing build is above, but the check never reset)

Comment on lines 40 to 56
insetStart={{ xl: "8" }}
style={{ insetInlineStart }}
Copy link
Member Author

Choose a reason for hiding this comment

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

This change was made throughout as the style props insetStart/End or insetInlineStart/End have not been working as expected with Chakra components. Using style fixes this, but then we lose access to the Chakra tokens. As an alternative to using css var(--eth-type-token) syntax, the useToken hook was used.

@@ -149,7 +151,7 @@ export const getSearchModalStyles = (): SystemStyleObject => ({
},

".DocSearch-Hit-Select-Icon:focus, .DocSearch-Hit-Select-Icon:hover": {
color: "switchBackground",
color: "switchBackground", // TODO: Remove? Causing low contrast in dark mode
Copy link
Member Author

Choose a reason for hiding this comment

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

image

@nloureiro When hovering directly over the arrow we get this low-contrast fill on dark mode:

image

It's not as bad in light mode image but is there a color token you would recommend that looks good in both?

Or maybe we just consider removing this hover effect since it only triggers when hovering over the arrow itself, but the action doesn't change compared to the rest of the box. This would be my preference.

Copy link
Member Author

Choose a reason for hiding this comment

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

These file changes affect the search modal

image

Comment on lines +94 to +95
p: 0,
ps: 2,
Copy link
Member Author

Choose a reason for hiding this comment

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

p: 0 overrides existing padding-left from @docsearch/css, then reassigns with direction-responsive ps

src/components/Search/utils.ts Show resolved Hide resolved
position="fixed"
zIndex="99"
zIndex="banner"
Copy link
Member Author

Choose a reason for hiding this comment

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

Fixes bug where menu contents (ie. UseCases pages) were overlaying this banner.

Copy link
Member

Choose a reason for hiding this comment

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

Nice!

@wackerow wackerow marked this pull request as ready for review January 12, 2024 02:43
src/pages/_app.tsx Outdated Show resolved Hide resolved
Copy link
Contributor

@TylerAPfledderer TylerAPfledderer left a comment

Choose a reason for hiding this comment

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

My thoughts regarding RTL support here 😄

@@ -65,7 +70,7 @@ const Breadcrumbs = ({
.slice(startDepth)

return (
<Breadcrumb {...props}>
<Breadcrumb {...props} dir={dir}>
Copy link
Contributor

Choose a reason for hiding this comment

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

Most instances of the dir prop should now be removed as this is redundant and is taken care of under the hood in the Chakra component structure/theme or by the use of an inset* prop.

An exception is where flexbox is used for content positioning, where CSS is not smart enough to handle RTL automatically with flex props. (I will point out the exceptions)

Copy link
Member Author

Choose a reason for hiding this comment

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

See other comment about specifically why I'm overriding these at the component level... same applied to this one.

src/components/CodeModal.tsx Outdated Show resolved Hide resolved
@@ -67,6 +71,7 @@ const FeedbackCard = ({ prompt, isArticle, ...props }: FeedbackCardProps) => {
mt="8"
w="full"
{...props}
dir={dir}
Copy link
Contributor

Choose a reason for hiding this comment

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

This is an exception where the dir prop should be kept, as flexbox is controlling the content positioning here.

Copy link
Member Author

Choose a reason for hiding this comment

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

Honestly I'm not having any problems with flex boxes here...

I'll double check all of your comments, but the reason for these was not just to use the dir for the chosen locale, but to specifically do so at the component level for components that:

  1. Exclusively use the "common" namespace for translations (which every language has before even being listed
  2. Are (or potentially) nested inside page content which may end up NOT being translated.

In this case (ie. /ar/developers/docs/blocks) html could be set to dir="rtl", the main content div could be set with dir="ltr" (overriden because contentNotTranslated=true), but then some components (ie. FeedbackCard) are fully translated, which should again run rtl.

The change here addressed this by independently setting the dir based on locale, without relying on html[dir] since the content it's nested in may flip it back.

Copy link
Member

Choose a reason for hiding this comment

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

Got it. Agreed, I think we need this for these "global" components.

src/components/Trilemma/index.tsx Outdated Show resolved Hide resolved
src/layouts/Docs.tsx Show resolved Hide resolved
src/lib/types.ts Outdated Show resolved Hide resolved
fixes direction of pointer emoji for RTL pages, taking into account if contentNotTranslated. updates component with latest TS conventions; removes passing relativePath prop, instead loading locally using useRouter. rm redundant isNext, using only isPrev bool to simplify and avoid conflicts
use useTranslation hook over Translation component
Copy link
Member

@pettinarip pettinarip left a comment

Choose a reason for hiding this comment

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

@wackerow amazing job!!!! thanks for the work done here. Looks really nice the RTL version!

==========
Few minor things that don't block this PR.

Small detail in the slider arrows, we shouldn't use rtl props here.
https://deploy-preview-11905--ethereumorg.netlify.app/fa/what-is-ethereum
image

Not aligned
image

The results from the search are not translated, right? if so, I think we shouldn't change the direction
image

@wackerow
Copy link
Member Author

@pettinarip

Small detail in the slider arrows, we shouldn't use rtl props here.

We should, but we need to pass { direction: "rtl" | "ltr" } to the useEmblaCarousel({ direction }), and flip the icons with flipForRtl (scaleX(-1))

Screen.Recording.2024-01-20.at.10.49.29.mov

Will put a patch up for this in a separate PR.


The results from the search are not translated, right? if so, I think we shouldn't change the direction

Yeah, they should be translated (if available):

image image

...but, these languages aren't translated 100%, so we're still going to end up with English results for that content (ie. Algolia parses /ar/whitepaper into the ar lang facet... if it has English content, this is included in the Arabic search results)

Can discuss how we'd like to approach this.


The Trophy icon I'll look into; also separate to this PR. Thanks for spotting!

@pettinarip
Copy link
Member

Nice, thanks @wackerow

@pettinarip pettinarip merged commit b4106cd into dev Jan 23, 2024
9 of 10 checks passed
@pettinarip pettinarip deleted the nx-ltr-en-content branch January 23, 2024 15:50
This was referenced Jan 31, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
content 🖋️ This involves copy additions or edits tooling 🔧 Changes related to tooling of the project
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants