-
Notifications
You must be signed in to change notification settings - Fork 54
Conversation
<> | ||
Text may be aligned to the left, right, center or be justified. | ||
<br /> | ||
You need to use Text as a block element (<code>as='div'</code>) so that textAlign prop can |
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.
Probably you already considered this, but why don't we just add display: 'block'
in the styles if the textAlign prop is provided?
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.
Good that you opened this conversation. I have considered it briefly but thought it might be unexpected behavior for the user.
Giving it a second thought if a user adds textAlign
they probably expect the Text
component to behave as a block otherwise alignment does not make sense. So I think you're right here. Let me make the change and ask others to chip in as well: @layershifter @kuzhelov @miroslavstastny
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.
applied display: 'block'
when textAlign
prop is provided
Codecov Report
@@ Coverage Diff @@
## master #1668 +/- ##
=========================================
Coverage ? 70.97%
=========================================
Files ? 860
Lines ? 7142
Branches ? 2052
=========================================
Hits ? 5069
Misses ? 2067
Partials ? 6
Continue to review full report at Codecov.
|
8f57afd
to
42609ec
Compare
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.
LGTM, nice cleanups too! 👍
@@ -36,7 +37,7 @@ export interface HeaderProps | |||
description?: ShorthandValue<HeaderDescriptionProps> | |||
|
|||
/** Align header content. */ | |||
textAlign?: 'left' | 'center' | 'right' | 'justified' |
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.
My main question is whether we want to have a design term for alignment (like we had here previously) or expose a CSS property like you are doing in this PR.
My opinion is that we should stick with a design term, for that reason left, center, right, justified
work for me better that all the valid CSS values (-moz-initial
is definitely not a design term, if you need it, use styles).
And I would even think about replacing left
and right
with start
and end
to comply with our direction-agnostic terminology.
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.
I agree with @miroslavstastny points. I guess @Bugaa92 was just following the way it is already implemented in the Header
component. Maybe the best option would be to introduce a different prop (something that does not necessarily correlate directly to css prop), and provide the mention values there as options.
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.
@miroslavstastny - very good points, I'm confident others agree; I see @mnajdova liked the message so 3 votes already.
The only issue I have with our start
and end
as values of textAlign
prop is that they mean something different for the actual textAlign
CSS prop.
So when we'll have
<Text textAlign="end" .. />
will we render
<span style="text-align:right" ../>
or
<span style="text-align:end" ../>
?
These have different functionality in RTL mode as you can see here:
https://codesandbox.io/s/scrollableelement-wm5tb
The options I see right now are:
1. have textAlign
prop with values 'start' | 'end' | 'center' | 'justified'
and forward values as they are to CSS textAlign
2. have textAlign
prop with values 'start' | 'end' | 'center' | 'justified'
and:
- forward values as they are to CSS
textAlign
forcenter
andjustified
- convert
start
andend
prop values toleft
andright
CSS values
3. keep textAlign
prop with values 'left' | 'right' | 'center' | 'justified'
(as it is now for Header
) and forward values as they are to CSS textAlign
4. have textAlign
prop with values 'before' | 'after' | 'center' | 'justified'
and:
- forward values as they are to CSS
textAlign
forcenter
andjustified
- convert
before
andafter
prop values toleft
andright
CSS values
@mnajdova @miroslavstastny what's your take on all this?
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.
FWIW in your codesandbox example you are not using Stardust Provider
, with that the results are different in RTL:
Source
<>
LTR Provider
<Provider styles={{border: '2px dashed red', padding: '20px'}}>
<Text textAlign="right">Test align right</Text>
<Text textAlign="end">Test align end</Text>
</Provider>
<br/>
RTL Provider
<Provider rtl styles={{border: '2px dashed red', padding: '20px'}}>
<Text textAlign="right">Test align right</Text>
<Text textAlign="end">Test align end</Text>
</Provider>
</>
So this makes end
CSS value useless in my eyes.
I would go with option 2 and, as @mnajdova suggests, think about renaming textAlign prop to mentally detach it from the CSS prop.
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.
I would go with option 2
done
as @mnajdova suggests, think about renaming textAlign prop
what about having it just align
? we already have it for other components (Menu
, Dropdown
, FlexItem
) and even though it has different meaning in the other component I think it's obvious what the meaning is for Text
and Header
.
So, what do you guys think about renaming textAlign
prop to align
? @mnajdova @miroslavstastny
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.
Agree, I vote for align
too
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.
done, thanks guys!
42609ec
to
078e509
Compare
078e509
to
116708b
Compare
116708b
to
cc6eff4
Compare
cc6eff4
to
01aa16d
Compare
- changed textAlign prop possible values; - added method to convert textAlign prop value to CSS prop value
55d90cd
to
95c1cac
Compare
95c1cac
to
2b936ed
Compare
feat(Text): add textAlign prop
BREAKING CHANGE MITIGATION
Header
'stextAlign
prop values changed from'left' | 'center' | 'right' | 'justified'
to'start' | 'end' | 'center' | 'justified'
mitigation: change
textAlign="left"
totextAlign="start"
andtextAlign="right"
totextAlign="end"
Description
This PR adds
textAlign
prop to theText
component in order to allow users to align content to the left, right, center or have it justified.