Merge branch 'master' into mwc-tab-styles-for-real

This commit is contained in:
Elliott Marquez 2019-12-04 13:10:12 +11:00
commit d76125de6a
3 changed files with 71 additions and 13 deletions

View File

@ -11,6 +11,16 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
- CSS styling options to `mwc-tab` - CSS styling options to `mwc-tab`
- `active` attribute to `mwc-tab` when (de)activated - `active` attribute to `mwc-tab` when (de)activated
### Fixed
- **BREAKING:VISUAL** `mwc-tab` will now automatically size slotted images. Also
slotted image will override icon font.
### Changed
- **BREAKING** `mwc-tab` can now only have slotted content via the
`hasImageIcon` flag.
## [0.11.1] - 2019-11-26 ## [0.11.1] - 2019-11-26
### Fixed ### Fixed

View File

@ -90,6 +90,41 @@ limitations under the License.
<mwc-tab icon="camera"></mwc-tab> <mwc-tab icon="camera"></mwc-tab>
</mwc-tab-bar> </mwc-tab-bar>
<h3>Image Icons</h3>
<mwc-tab-bar activeIndex="2">
<mwc-tab hasImageIcon>
<svg width="10px" height="10px">
<circle
r="5px"
cx="5px"
cy="5px"
color="red">
</circle>
</svg>
</mwc-tab>
<mwc-tab hasImageIcon>
<svg width="10px" height="10px">
<rect
width="10px"
height="10px"
color="green">
</rect>
</svg>
</mwc-tab>
<mwc-tab hasImageIcon>
<svg width="14.143px" height="14.143px">
<rect
width="10px"
height="10px"
color="blue"
y="2.071px"
x="2.071px"
style="transform:rotate(45deg);transform-origin:center;">
</rect>
</svg>
</mwc-tab>
</mwc-tab-bar>
<h3>With Icons - Stacked</h3> <h3>With Icons - Stacked</h3>
<mwc-tab-bar activeIndex="1"> <mwc-tab-bar activeIndex="1">
<mwc-tab label="one" icon="accessibility" stacked></mwc-tab> <mwc-tab label="one" icon="accessibility" stacked></mwc-tab>

View File

@ -43,6 +43,8 @@ export class TabBase extends BaseElement {
@property() icon = ''; @property() icon = '';
@property({type: Boolean}) hasImageIcon = false;
@property({type: Boolean}) isFadingIndicator = false; @property({type: Boolean}) isFadingIndicator = false;
@property({type: Boolean}) minWidth = false; @property({type: Boolean}) minWidth = false;
@ -97,6 +99,27 @@ export class TabBase extends BaseElement {
'mdc-tab--min-width': this.minWidth, 'mdc-tab--min-width': this.minWidth,
'mdc-tab--stacked': this.stacked, 'mdc-tab--stacked': this.stacked,
}; };
let iconTemplate = html``;
if (this.hasImageIcon || this.icon) {
// NOTE: MUST be on same line as spaces will cause vert alignment issues
// in IE
iconTemplate = html`
<span class="mdc-tab__icon material-icons"><slot>${
this.icon}</slot></span>`;
}
let labelTemplate = html``;
if (this.label) {
labelTemplate = html`
<span class="mdc-tab__text-label">${this.label}</span>`;
}
const rippleDirective = ripple({
interactionNode: this,
unbounded: false,
});
return html` return html`
<button <button
@click="${this._handleClick}" @click="${this._handleClick}"
@ -105,22 +128,12 @@ export class TabBase extends BaseElement {
aria-selected="false" aria-selected="false"
tabindex="-1"> tabindex="-1">
<span class="mdc-tab__content"> <span class="mdc-tab__content">
<slot></slot> ${iconTemplate}
${ ${labelTemplate}
this.icon ? html`
<span class="mdc-tab__icon material-icons">${this.icon}</span>` :
''}
${
this.label ? html`
<span class="mdc-tab__text-label">${this.label}</span>` :
''}
${this.isMinWidthIndicator ? this.renderIndicator() : ''} ${this.isMinWidthIndicator ? this.renderIndicator() : ''}
</span> </span>
${this.isMinWidthIndicator ? '' : this.renderIndicator()} ${this.isMinWidthIndicator ? '' : this.renderIndicator()}
<span class="mdc-tab__ripple" .ripple="${ripple({ <span class="mdc-tab__ripple" .ripple="${rippleDirective}"></span>
interactionNode: this,
unbounded: false
})}"></span>
</button>`; </button>`;
} }