-
Notifications
You must be signed in to change notification settings - Fork 3.4k
feat(tab): custom class names for tab elements #11332
feat(tab): custom class names for tab elements #11332
Conversation
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.
Thank you for the contribution!
@@ -21,6 +21,7 @@ | |||
* | |||
* @param {string=} label Optional attribute to specify a simple string as the tab label | |||
* @param {boolean=} ng-disabled If present and expression evaluates to truthy, disabled tab selection. | |||
* @param {string=} md-class-name Optional attribute to specify a class name for the tab button |
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.
For consistency with other APIs like md-menu-class
, md-menu-container-class
, and md-input-class
, we should probably call this one md-tab-class
.
@@ -82,7 +83,8 @@ function MdTab () { | |||
active: '=?mdActive', | |||
disabled: '=?ngDisabled', | |||
select: '&?mdOnSelect', | |||
deselect: '&?mdOnDeselect' | |||
deselect: '&?mdOnDeselect', | |||
className: '@mdClassName' |
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 we make this optional with @?
?
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.
Thanks for the quick updates! I have a few more minor ones. Also please squash your commits and then force push up your changes to the remote branch.
@@ -82,7 +83,8 @@ function MdTab () { | |||
active: '=?mdActive', | |||
disabled: '=?ngDisabled', | |||
select: '&?mdOnSelect', | |||
deselect: '&?mdOnDeselect' | |||
deselect: '&?mdOnDeselect', | |||
className: '@?mdTabClass' |
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.
Please change className
to tabClass
.
src/components/tabs/tabs.spec.js
Outdated
@@ -450,6 +450,16 @@ describe('<md-tabs>', function () { | |||
expect(tab.find('md-tab-label').text()).toBe('test'); | |||
expect(tab.find('md-tab-body').length).toBe(0); | |||
}); | |||
it('should render a class name accordingly', function () { |
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.
Let's call this should apply tab class on the associated md-tab-item
.
@@ -21,6 +21,7 @@ | |||
* | |||
* @param {string=} label Optional attribute to specify a simple string as the tab label | |||
* @param {boolean=} ng-disabled If present and expression evaluates to truthy, disabled tab selection. | |||
* @param {string=} md-tab-class Optional attribute to specify a class name for the tab button |
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.
Let's say "Optional attribute to specify a class that will be applied to the tab's button".
Thanks for your good feedback. I updated the code accordingly. |
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
@rossgardt can you please rebase? |
`md-class-name` attribute to provide custom classes for `md-tab`. This is mostly about more testability of the md-tabs component. Fixes #3028
@Splaktar done ✅ |
This solves #3028.
PR Checklist
Please check that your PR fulfills the following requirements:
PR Type
What kind of change does this PR introduce?
What is the current behavior?
We can only select
tab-data-item
elements vianth-
selectors.This makes solid UI tests difficult.
Issue Number: #3028
What is the new behavior?
You can assign class names via
md-class-name
attributeto the
md-tab
directive. Those will be rendered into the DOM.Does this PR introduce a breaking change?
Other information