feat(button): goback attribute

This commit is contained in:
Manu Mtz.-Almeida
2018-03-27 12:05:09 +02:00
parent a428fdc48c
commit 00fc460c4e
9 changed files with 51 additions and 10 deletions

View File

@@ -9,9 +9,13 @@ export class Anchor {
@Prop() href: string;
@Prop() goBack = false;
render() {
return <a
href={this.href}
onClick={(ev) => openURL(this.href, ev)}><slot/></a>;
onClick={(ev) => openURL(this.href, ev, this.goBack)}>
<slot/>
</a>;
}
}

View File

@@ -7,6 +7,11 @@
## Properties
#### goBack
boolean
#### href
string
@@ -14,6 +19,11 @@ string
## Attributes
#### go-back
boolean
#### href
string

View File

@@ -1,7 +1,6 @@
import { Component, Element, Prop } from '@stencil/core';
import { Config } from '../../index';
import { openURL } from '../../utils/theme';
import { RouterDirection } from '../router/utils/interfaces';
@Component({
tag: 'ion-back-button',
@@ -42,7 +41,7 @@ export class BackButton {
ev.preventDefault();
nav.pop();
} else if (this.defaultHref) {
openURL(this.defaultHref, ev, RouterDirection.Back);
openURL(this.defaultHref, ev, true);
}
}

View File

@@ -83,6 +83,7 @@ export class Button {
*/
@Prop() mode: 'ios' | 'md';
@Prop() goBack = false;
/**
* Emitted when the button has focus.
*/
@@ -148,7 +149,7 @@ export class Button {
disabled={this.disabled}
onFocus={this.onFocus.bind(this)}
onKeyUp={this.onKeyUp.bind(this)}
onClick={(ev) => openURL(this.href, ev)}
onClick={(ev) => openURL(this.href, ev, this.goBack)}
onBlur={this.onBlur.bind(this)}>
<span class='button-inner'>
<slot name='icon-only'></slot>

View File

@@ -119,6 +119,11 @@ button with a border, or to `"solid"`. The default style is `"solid"` except ins
a toolbar, where the default is `"clear"`.
#### goBack
boolean
#### href
string
@@ -210,6 +215,11 @@ button with a border, or to `"solid"`. The default style is `"solid"` except ins
a toolbar, where the default is `"clear"`.
#### go-back
boolean
#### href
string

View File

@@ -54,6 +54,9 @@ export class Item {
*/
@Prop() tappable = false;
@Prop() goBack = false;
@Listen('ionStyle')
itemStyle(ev: UIEvent) {
ev.stopPropagation();
@@ -122,7 +125,7 @@ export class Item {
<TagType
{...attrs}
class={themedClasses}
onClick={(ev) => openURL(this.href, ev)}>
onClick={(ev) => openURL(this.href, ev, this.goBack)}>
<slot name='start'></slot>
<div class='item-inner'>
<div class='input-wrapper'>

View File

@@ -31,6 +31,11 @@ boolean
If true, the user cannot interact with the item. Defaults to `false`.
#### goBack
boolean
#### href
string
@@ -82,6 +87,11 @@ boolean
If true, the user cannot interact with the item. Defaults to `false`.
#### go-back
boolean
#### href
string