-
Notifications
You must be signed in to change notification settings - Fork 6.8k
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(material-experimental/mdc-tabs): add default fitInkBarToContent option #17556
Changes from 3 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 |
---|---|---|
|
@@ -25,7 +25,12 @@ import { | |
import {ANIMATION_MODULE_TYPE} from '@angular/platform-browser/animations'; | ||
import {MAT_RIPPLE_GLOBAL_OPTIONS, RippleGlobalOptions} from '@angular/material/core'; | ||
import {FocusMonitor} from '@angular/cdk/a11y'; | ||
import {_MatTabNavBase, _MatTabLinkBase} from '@angular/material/tabs'; | ||
import { | ||
_MatTabNavBase, | ||
_MatTabLinkBase, | ||
MAT_TABS_CONFIG, | ||
MatTabsConfig | ||
} from '@angular/material/tabs'; | ||
import {DOCUMENT} from '@angular/common'; | ||
import {Directionality} from '@angular/cdk/bidi'; | ||
import {ViewportRuler} from '@angular/cdk/scrolling'; | ||
|
@@ -81,8 +86,13 @@ export class MatTabNav extends _MatTabNavBase implements AfterContentInit { | |
* @deprecated @breaking-change 9.0.0 `platform` parameter to become required. | ||
*/ | ||
@Optional() platform?: Platform, | ||
@Optional() @Inject(ANIMATION_MODULE_TYPE) animationMode?: string) { | ||
@Optional() @Inject(ANIMATION_MODULE_TYPE) animationMode?: string, | ||
@Optional() @Inject(MAT_TABS_CONFIG) defaultConfig?: MatTabsConfig) { | ||
super(elementRef, dir, ngZone, changeDetectorRef, viewportRuler, platform, animationMode); | ||
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. Should we pass the 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. This extends |
||
this.disablePagination = defaultConfig && defaultConfig.disablePagination != null ? | ||
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. Isn't this one handled by the base class already? 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. Unfortunately not, it extends |
||
defaultConfig.disablePagination : false; | ||
this.fitInkBarToContent = defaultConfig && defaultConfig.fitInkBarToContent != null ? | ||
defaultConfig.fitInkBarToContent : false; | ||
} | ||
|
||
ngAfterContentInit() { | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
/** | ||
* @license | ||
* Copyright Google LLC All Rights Reserved. | ||
* | ||
* Use of this source code is governed by an MIT-style license that can be | ||
* found in the LICENSE file at https://angular.io/license | ||
*/ | ||
import {InjectionToken} from '@angular/core'; | ||
|
||
/** Object that can be used to configure the default options for the tabs module. */ | ||
export interface MatTabsConfig { | ||
/** Duration for the tab animation. Must be a valid CSS value (e.g. 600ms). */ | ||
animationDuration?: string; | ||
|
||
/** | ||
* Whether pagination should be disabled. This can be used to avoid unnecessary | ||
* layout recalculations if it's known that pagination won't be required. | ||
*/ | ||
disablePagination?: boolean; | ||
|
||
/** | ||
* Whether the ink bar should fit its width to the size of the tab label content. | ||
* This only applies to the MDC-based tabs. | ||
*/ | ||
fitInkBarToContent?: boolean; | ||
} | ||
|
||
/** Injection token that can be used to provide the default options the tabs module. */ | ||
export const MAT_TABS_CONFIG = new InjectionToken<MatTabsConfig>('MAT_TABS_CONFIG'); | ||
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. I think this name is inconsistent with other components 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. Based on in-person conversation, we'll file an issue for the inconsistent naming across components and address in the v10 range. |
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.
Might be a good idea to also add assertions that the values here are truthy.
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 point, I added an expectation that the indicator's parent element is truthy