-
Notifications
You must be signed in to change notification settings - Fork 53
feat(Text): introduce dir attribute to support RTL #5
Conversation
As another option, could we just make |
Yes. And lots of additional markup just to have RTL support in other components. If we add |
Indeed, we actually have an |
using Text (and, what is more important, |
Levi, do I understand correctly that after you proposed change, the |
Can we define what "elements that contain text" means exactly? Just Text<span>Text only</span> This element has text only, no child elements. Text > empty inline child<span>Text only with <i class="an icon"></i></span> This element has text, but also has a Text > inline child > text<span>Text only with <span>more text</span>. This element has text, but also has a child element which contains only text. Text > button child > text<span>Text only with <button>technically text?</button>. Are buttons also considered to be text? Nearly every component contains text as some descendant. Where exactly should we be adding the |
typically if it is a combination of text+icon, the
https://www.w3.org/International/articles/inline-bidi-markup/ Text inside of the button might need Text inside of the button can be bidirectional, for example "Join team " where Join team would be translated to Hebrew/Arabic but the team name would be english. We are however not solving this case in this PR - most typically these texts come from parametrized translations, so that would be an advanced use case for our i18n story. |
The concern I have had with this PR is that it seems to conflate the styling purpose of the Text component with the RTL concerns. The Text component is about styling text. RTL to me seems to encompass more than just text and therefore perhaps its own mechanism or component.
Would the markup then look like this?: <button dir='auto'>
Join Team
</button> If we introduce the changes proposed in the PR, we'd end up with this: <button>
<span dir='auto'>Join Team</span>
</button> |
From RTL point of view both examples are equal. However, the second one renders one more element which is unnecessary. Is there a generic way to achieve 2? And for that case, please note that we will also need to support
|
@jurokapsiar can you please post the final update here on this PR so we can implement it? Thanks... |
In general, we need to get to a state where the text nodes are inside of elements that have If the text is composed of multiple parts (typically a translation with parameters), each of the parts needs to be separated in Requirements:
|
Codecov Report
@@ Coverage Diff @@
## master #5 +/- ##
==========================================
+ Coverage 88.3% 88.32% +0.01%
==========================================
Files 42 42
Lines 1454 1456 +2
Branches 186 212 +26
==========================================
+ Hits 1284 1286 +2
Misses 165 165
Partials 5 5
Continue to review full report at Codecov.
|
src/components/Text/Text.tsx
Outdated
|
||
const hasChidlren = childrenExist(children) | ||
|
||
const maybeDirAuto = !hasChidlren && typeof content === 'string' ? { dir: 'auto' } : null |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
hasChidlren
-> hasChildren
This proposal is aimed on introducing proper text rendering in RTL mode. Its idea consists of two points:
dir="auto"
attribute value to the text rendered byText
componentText
component to wrap this textual part