-
Notifications
You must be signed in to change notification settings - Fork 4k
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
feat(Tab): Add vertical tabbing #1894
feat(Tab): Add vertical tabbing #1894
Conversation
Codecov Report
@@ Coverage Diff @@
## master #1894 +/- ##
==========================================
+ Coverage 99.75% 99.75% +<.01%
==========================================
Files 145 145
Lines 2477 2484 +7
==========================================
+ Hits 2471 2478 +7
Misses 6 6
Continue to review full report at Codecov.
|
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.
@mclarentgp Thanks for PR, I've left some comments, but I need time to pay more attention to this PR.
src/collections/Menu/Menu.d.ts
Outdated
@@ -81,7 +81,7 @@ export interface MenuProps { | |||
stackable?: boolean; | |||
|
|||
/** A menu can be formatted to show tabs of information. */ | |||
tabular?: boolean | 'right'; | |||
tabular?: boolean | 'right' | 'left'; |
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.
Can you clarify necessity of left
value? There is no special CSS for it, so it's left
by default.
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.
Ahh, sorry you are correct this doesn't need to be changed. Will undo changes.
src/collections/Grid/GridColumn.js
Outdated
@@ -112,4 +113,11 @@ GridColumn.propTypes = { | |||
width: PropTypes.oneOf(SUI.WIDTHS), | |||
} | |||
|
|||
GridColumn.create = createShorthandFactory( |
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.
createShorthandFactory
accepts only two agruments, in this case correct usage is:
createShorthandFactory(GridColumn, children => ({ children }))
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 will update this to the correct usage.
@DENSENDEW Sorry I don't quite understand? I'm still fairly new to some of this and it's my first PR. |
src/modules/Tab/Tab.js
Outdated
@@ -96,19 +102,42 @@ class Tab extends Component { | |||
}) | |||
} | |||
|
|||
renderColumn(columnProps) { | |||
return GridColumn.create(columnProps) | |||
} |
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.
Since this is a pass-through method, let's just call GridColumn.create
instead of this.renderColumn
and drop this method.
src/modules/Tab/Tab.js
Outdated
@@ -64,7 +69,8 @@ class Tab extends Component { | |||
] | |||
|
|||
static defaultProps = { | |||
menu: { attached: true, tabular: true }, | |||
menu: { attached: true, tabular: true, vertical: false, fluid: false }, | |||
grid: { segmentWidth: 12, tabWidth: 4 }, |
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.
In keeping with the Tab terminology, let's go with paneWidth
instead of segmentWidth
.
src/modules/Tab/Tab.js
Outdated
{menu.props.tabular !== 'right' && this.renderColumn({ width: grid.tabWidth, children: menu })} | ||
{this.renderColumn({ | ||
width: grid.segmentWidth, | ||
children: _.invoke(_.get(panes, `[${activeIndex}]`), 'render', this.props), |
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.
This line:
_.invoke(_.get(panes, `[${activeIndex}]`), 'render', this.props)
is duplicated in the main render()
method. Let's pull this line into a method like renderActivePane()
to contain it.
src/modules/Tab/Tab.js
Outdated
{this.renderColumn({ | ||
width: grid.segmentWidth, | ||
children: _.invoke(_.get(panes, `[${activeIndex}]`), 'render', this.props), | ||
stretched: true } |
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.
Closing curly on the same line as the closing paren and wrapping curly please.
- stretched: true }
-})
+ stretched: true,
+})}
src/modules/Tab/Tab.js
Outdated
@@ -64,7 +69,8 @@ class Tab extends Component { | |||
] | |||
|
|||
static defaultProps = { | |||
menu: { attached: true, tabular: true }, | |||
menu: { attached: true, tabular: true, vertical: false, fluid: false }, |
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.
No need to add vertical: false, fluid: false
as these are not set by default.
@@ -37,6 +39,9 @@ class Tab extends Component { | |||
/** Shorthand props for the Menu. */ | |||
menu: PropTypes.object, | |||
|
|||
/** Shorthand props for the Grid. */ | |||
grid: PropTypes.object, |
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.
Shorthand can be a string, number, props object, or an element. It is then passed to a shorthand factory, such as Grid.create(grid)
.
In this case, the user cannot pass normal Grid props such as celled
or padded
because this object is not used in a shorthand factory for the Grid. This is some kind of configuration rather than shorthand.
I'd like to reserve the grid
prop for actual Grid props so users can control that if needed. That said, I'm not so sure of the best API for these values. Here are some ideas, would love feedback:
Top level props
Make paneWidth
and tabWidth
top level props rather than nested in grid
. This makes room for grid
to be true shorthand, however, those props are only applicable if menu.vertical
is set so it might be a bit odd as well.
Omit and use rest for shorthand
The current grid
object needs to be spread on the Grid
in order to be true Grid props. We could leave it as is and just omit paneWidth
and tabWidth
from the grid
value before spreading it:
const { paneWidth, tabWidth, ...gridProps } = grid
<Grid {...gridProps>
{GridColumn.create({ width: tabWidth })}
{GridColumn.create({ width: paneWidth })}
</Grid>
I think I'm leaning toward the omit/rest approach, what are your ideas?
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 think I like the idea of omit/rest as it appears to give the best solution to maintaining the true grid props and the pane/tab width props
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.
@levithomason I went ahead and made the omit/rest change. Let me know if you decide you want to use a different approach.
src/modules/Tab/Tab.js
Outdated
{menu.props.attached !== 'bottom' && menu} | ||
{_.invoke(_.get(panes, `[${activeIndex}]`), 'render', this.props)} | ||
{menu.props.attached === 'bottom' && menu} | ||
{menu.props.vertical === true && grid} |
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.
The vertical
menu prop makes the case for two clean return values here. We can also avoid creating a null
grid in the case of non-vertical menus:
if (menu.props.vertical) {
return <ElementType {...rest}>{this.renderVertical(menu)}<ElementType>
}
// ...the old return value as-is
I've pushed a minor update and will merge on pass. |
Whoops, sorry for the delay! |
Released in |
In the current implementation it's impossible to set tabs to be in a vertical format.
This pr changes this.