-
Notifications
You must be signed in to change notification settings - Fork 5
Close prop on tab and tabBar #43
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
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -222,6 +222,9 @@ const TabBar = (props: TabBarProps) => { | |
| {tabList.map((child: any, i) => { | ||
| const className = child.tabComponent.props.className; | ||
| const activeClassName = child.tabComponent.props.classNameActive; | ||
| const closeableTab = child.tabComponent.props.closeable | ||
| const { closeable } = props; | ||
| const shouldClose = closeableTab !== undefined ? (closeableTab && closeable) : closeable; | ||
| return ( | ||
| <li | ||
| id={child.id} | ||
|
|
@@ -232,7 +235,7 @@ const TabBar = (props: TabBarProps) => { | |
| onMouseUp={closeDragElement} | ||
| > | ||
| {child.tabComponent.props.tabHeader || child.tabComponent.props.text} | ||
| {props.closeable && | ||
| { shouldClose && | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. extra space |
||
| <span | ||
| className="close" | ||
| onClick={e => removeTab(child.id, e, child)}> | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -9,6 +9,7 @@ export interface TabProps { | |
| text?: string; | ||
| className?: string; | ||
| classNameActive?: string; | ||
| closeable?: boolean; | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Add default props |
||
| } | ||
|
|
||
| const Tab = (props: TabProps) => { | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -17,7 +17,7 @@ const TabInterface = () => { | |
| newTab={createNew} | ||
| className="small-tab" | ||
| > | ||
| <Tab text="first tab" classNameActive="red-header" className="the-rest"> | ||
| <Tab text="first tab" closeable={false}> | ||
| <form className="frm"> | ||
| <h1>Form 1</h1> | ||
| <p>Name</p> | ||
|
|
@@ -31,7 +31,7 @@ const TabInterface = () => { | |
| </form> | ||
| </Tab> | ||
|
|
||
| <Tab text="second tab" className="the-rest"> | ||
| <Tab text="second tab" > | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. extra space |
||
| <form className="frm"> | ||
| <h1>Form 2</h1> | ||
| <p>Name</p> | ||
|
|
||
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.
Why not use defaultProps?
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.
just missed it, definitely good to put it, in this case specifically, the props are inside the child component not on the parent itself, I defined the variables here for more readability when using it on the jsx after