feat(components): add missing button/a props to components that render them (#17883)

Adds the following properties to the components listed under them:

`rel`, `download`, `target`:
- anchor
- button
- card
- fab-button
- item-option
- item
- tab-button

`disabled`:
- back-button
- menu-button

`type`:
- back-button
- item-option
- menu-button
- segment-button

fixes #16848 closes #16889


Co-authored-by: bitflower <matthias.max@bitflower.net>
This commit is contained in:
Brandy Carney
2019-06-12 14:06:29 -04:00
committed by GitHub
parent 828eaaf3d3
commit eca4121dc6
36 changed files with 751 additions and 231 deletions

View File

@ -1,6 +1,7 @@
import { Component, ComponentInterface, Element, Event, EventEmitter, Listen, Prop } from '@stencil/core';
import { Color, Mode, RouterDirection } from '../../interface';
import { AnchorInterface, ButtonInterface } from '../../utils/element-interface';
import { hasShadowDom } from '../../utils/helpers';
import { createColorClasses, openURL } from '../../utils/theme';
@ -18,7 +19,7 @@ import { createColorClasses, openURL } from '../../utils/theme';
},
shadow: true,
})
export class Button implements ComponentInterface {
export class Button implements ComponentInterface, AnchorInterface, ButtonInterface {
private inToolbar = false;
private inItem = false;
@ -68,11 +69,25 @@ export class Button implements ComponentInterface {
*/
@Prop() routerDirection: RouterDirection = 'forward';
/**
* This attribute instructs browsers to download a URL instead of navigating to
* it, so the user will be prompted to save it as a local file. If the attribute
* has a value, it is used as the pre-filled file name in the Save prompt
* (the user can still change the file name if they want).
*/
@Prop() download: string | undefined;
/**
* Contains a URL or a URL fragment that the hyperlink points to.
* If this property is set, an anchor tag will be rendered.
*/
@Prop() href?: string;
@Prop() href: string | undefined;
/**
* Specifies the relationship of the target object to the link object.
* The value is a space-separated list of [link types](https://developer.mozilla.org/en-US/docs/Web/HTML/Link_types).
*/
@Prop() rel: string | undefined;
/**
* The button shape.
@ -89,6 +104,13 @@ export class Button implements ComponentInterface {
*/
@Prop() strong = false;
/**
* Specifies where to display the linked URL.
* Only applies when an `href` is provided.
* Special keywords: `"_blank"`, `"_self"`, `"_parent"`, `"_top"`.
*/
@Prop() target: string | undefined;
/**
* The type of the button.
*/
@ -187,7 +209,12 @@ export class Button implements ComponentInterface {
const TagType = this.href === undefined ? 'button' : 'a' as any;
const attrs = (TagType === 'button')
? { type: this.type }
: { href: this.href };
: {
download: this.download,
href: this.href,
rel: this.rel,
target: this.target
};
return (
<TagType