Skip to content
This repository has been archived by the owner on Feb 25, 2020. It is now read-only.

Add ability to customize whether label should be rendered beneath or beside icon #103

Merged
merged 2 commits into from
Apr 1, 2019

Conversation

benoitdion
Copy link
Contributor

Motivation

The BottomTabBar options allow for very fined grained customization but were missing a couple extension point to allow apps to override whether labels should be rendered beneath or beside the icon

Test plan

  • Verify the horizontal prop is available to tabBarLabel option.
  • Verify shouldRenderLabelBeneath option can be used to override the default behavior.

@benoitdion
Copy link
Contributor Author

@satya164 @brentvatne who could help review this?

@brentvatne
Copy link
Member

cc @satya164 - what do you think?

@satya164
Copy link
Member

Looks good, but I'd change the option name to something simpler. Words like beneath will be prone to typos imo.

@slorber
Copy link
Member

slorber commented Mar 14, 2019

looks nice, but what about iconPosition or something instead? Maybe some users will want to be able to put the icon on the top/right/left/bottom

@brentvatne
Copy link
Member

brentvatne commented Mar 15, 2019

@slorber - if we use labelPosition we need to invert left and right when RTL is enabled but yeah i'd be ok with that

@benoitdion
Copy link
Contributor Author

The current name was inspired by internal variables but I agree we can do better. How about labelOrientation?

@satya164
Copy link
Member

I think iconPosition/labelPosition suggested by @slorber sounds the simpler. Maybe let's go with labelPosition.

@benoitdion benoitdion force-pushed the horizontal-label branch 2 times, most recently from a384867 to 1a5c3fc Compare March 15, 2019 14:43
@benoitdion
Copy link
Contributor Author

went with tabDirection since it's really the direction of the content of a tab more than just the icon or label. The current implementation also only supports "left" and "top" and I'm really trying to be surgical with this change to avoid breaking any existing use cases.

@benoitdion
Copy link
Contributor Author

any additional feedback @brentvatne @satya164?

Copy link
Member

@brentvatne brentvatne left a comment

Choose a reason for hiding this comment

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

left some comments. i don't think i'm totally on board with the tabDirection name, it's unclear to me what this means. tabBarItemOrientation might be better


if (tabDirection) {
let direction;
if (typeof direction === 'string') {
Copy link
Member

Choose a reason for hiding this comment

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

this will never be a string

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Err, this is supposed to be tabDirection. I'll check later but this may not be the latest commit :(. My bad

Copy link
Contributor Author

Choose a reason for hiding this comment

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

updated

if (typeof direction === 'string') {
direction = tabDirection;
} else {
direction = tabDirection({
Copy link
Member

Choose a reason for hiding this comment

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

this else clause will only be entered when tabDirection is falsey, and then we try to call tabDirection as a function which will error

Copy link
Contributor Author

Choose a reason for hiding this comment

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

we're checking tabDirection above

@@ -23,6 +23,7 @@ export type TabBarOptions = {
showIcon: boolean,
labelStyle: any,
tabStyle: any,
tabDirection: any,
Copy link
Member

Choose a reason for hiding this comment

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

could use better type for this, unclear what it's meant to be and what the default is

Copy link
Contributor Author

@benoitdion benoitdion Mar 25, 2019

Choose a reason for hiding this comment

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

modeled the type after how I'd to it in typescript. Let me know if there's a better way to do this in flow. After this goes in I may take a stab at typing more of the any's in this file.

@benoitdion
Copy link
Contributor Author

@brentvatne updated name to tabBarItemOrientation. Let me know if there's anything else.

@satya164
Copy link
Member

Orientation doesn't feel right to me either. It sounds like potrait or landscape orientation. IMO labelPosition: 'bottom' | 'right' is much more clear and explicit.

@benoitdion
Copy link
Contributor Author

position is confusing as @brentvatne mentioned for when we want to have proper RTL support. It's tabBarItemOrientation so it's specific to the orientation of the content inside of the tab bar item.

Copy link
Member

@satya164 satya164 left a comment

Choose a reason for hiding this comment

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

We discussed with @brentvatne and I think tabBarPosition: 'beside-icon' | 'below-icon' sounds the best

@benoitdion
Copy link
Contributor Author

@satya164 updated!

@brentvatne
Copy link
Member

sorry for another change here 😅 i think that tabBarPosition is a bit confusing because we're talking about labels, so it should be labelPosition or tabItemLabelPosition, i don't have a strong preference either way between those two. the values would be the same as @satya164 mentioned above re: 'beside-icon' | 'below-icon'

@benoitdion
Copy link
Contributor Author

@brentvatne that's a fair point. A lot of the previous naming proposals like tabDirection row/column were referring to the entire tab item since that's what this change is really about. The new naming does make it specific to having an icon and a label and how they're position relative to each other.

@satya164
Copy link
Member

satya164 commented Mar 27, 2019

oops sorry, my mistake. I meant to say labelPosition

@slorber
Copy link
Member

slorber commented Mar 30, 2019

Hey. Just wonder if we shouldn't plan for supporting next having the label on right left top or bottom. I feel the 2 value names chosen would not permit to add the 2 potential other values here and may lead to a breaking change

Also feed orientation to the label render function
@benoitdion
Copy link
Contributor Author

@brentvatne @satya164 updated to labelPosition

@slorber label on the right/bottom isn't something I've seen in any app so I'm not sure we want to support it just because we can. With that said, if it becomes a use-case it's easy to add support for new values and possibly deprecate the existing ones over time. That wouldn't be a breaking change. For the time being, I like that we're constraining the names to the capabilities supported.

@satya164 satya164 merged commit 0914a25 into react-navigation:master Apr 1, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants