mirror of
https://github.com/ionic-team/ionic-framework.git
synced 2025-11-09 16:16:41 +08:00
chore(packages): move the packages to root
This commit is contained in:
41
core/src/components/back-button/back-button.ios.scss
Normal file
41
core/src/components/back-button/back-button.ios.scss
Normal file
@ -0,0 +1,41 @@
|
||||
@import "./back-button";
|
||||
@import "./back-button.ios.vars";
|
||||
|
||||
// iOS Back Button
|
||||
// --------------------------------------------------
|
||||
|
||||
.back-button-ios .back-button-inner {
|
||||
@include padding(0);
|
||||
@include margin(2px, 0, 0, 0);
|
||||
|
||||
z-index: $back-button-ios-button-z-index;
|
||||
overflow: visible;
|
||||
|
||||
min-height: 32px;
|
||||
|
||||
border: 0;
|
||||
font-size: 17px;
|
||||
line-height: 1;
|
||||
background-color: transparent;
|
||||
transform: translateZ(0);
|
||||
|
||||
&.activated {
|
||||
opacity: .4;
|
||||
}
|
||||
}
|
||||
|
||||
.back-button-ios ion-icon {
|
||||
@include padding(0);
|
||||
@include margin(0, -3px, 0, 0);
|
||||
|
||||
display: inherit;
|
||||
|
||||
font-size: 1.75em;
|
||||
|
||||
pointer-events: none;
|
||||
}
|
||||
|
||||
.back-button .button-text {
|
||||
letter-spacing: .01em;
|
||||
}
|
||||
|
||||
@ -0,0 +1,5 @@
|
||||
@import "../../themes/ionic.globals.ios";
|
||||
|
||||
|
||||
$back-button-ios-button-z-index: $z-index-toolbar-buttons !default;
|
||||
|
||||
32
core/src/components/back-button/back-button.md.scss
Normal file
32
core/src/components/back-button/back-button.md.scss
Normal file
@ -0,0 +1,32 @@
|
||||
@import "./back-button";
|
||||
|
||||
// MD Back Button
|
||||
// --------------------------------------------------
|
||||
.back-button-md .back-button-inner {
|
||||
@include margin(2px, 6px, 0, 0);
|
||||
@include padding(0, 5px);
|
||||
|
||||
min-width: 44px;
|
||||
height: 32px;
|
||||
border: 0;
|
||||
font-size: 14px;
|
||||
font-weight: 500;
|
||||
text-transform: uppercase;
|
||||
background-color: transparent;
|
||||
box-shadow: none;
|
||||
|
||||
&.activated {
|
||||
opacity: 0.4;
|
||||
}
|
||||
}
|
||||
|
||||
.back-button-md ion-icon {
|
||||
@include padding-horizontal(null, 0.3em);
|
||||
@include margin(0);
|
||||
@include padding(0, 6px);
|
||||
@include text-align(start);
|
||||
font-size: 24px;
|
||||
font-weight: normal;
|
||||
line-height: 0.67;
|
||||
pointer-events: none;
|
||||
}
|
||||
70
core/src/components/back-button/back-button.scss
Normal file
70
core/src/components/back-button/back-button.scss
Normal file
@ -0,0 +1,70 @@
|
||||
@import "../../themes/ionic.globals";
|
||||
|
||||
// Back Button
|
||||
// --------------------------------------------------
|
||||
|
||||
.back-button {
|
||||
display: none;
|
||||
}
|
||||
|
||||
.back-button.can-back-back,
|
||||
.back-button.show-back-button {
|
||||
display: inline-block;
|
||||
}
|
||||
|
||||
.back-button button {
|
||||
@include text-align(center);
|
||||
@include appearance(none);
|
||||
|
||||
position: relative;
|
||||
z-index: 0;
|
||||
display: inline-block;
|
||||
|
||||
border: 0;
|
||||
outline: none;
|
||||
|
||||
line-height: 1;
|
||||
|
||||
text-decoration: none;
|
||||
text-overflow: ellipsis;
|
||||
text-transform: none;
|
||||
|
||||
white-space: nowrap;
|
||||
cursor: pointer;
|
||||
vertical-align: top; // the better option for most scenarios
|
||||
vertical-align: -webkit-baseline-middle; // the best for those that support it
|
||||
|
||||
transition: background-color, opacity 100ms linear;
|
||||
|
||||
font-kerning: none;
|
||||
user-select: none;
|
||||
|
||||
font-smoothing: antialiased;
|
||||
-webkit-font-smoothing: antialiased;
|
||||
|
||||
display: flex;
|
||||
|
||||
flex-flow: row nowrap;
|
||||
flex-shrink: 0;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
|
||||
}
|
||||
|
||||
.back-button .button-inner {
|
||||
display: flex;
|
||||
|
||||
flex-flow: row nowrap;
|
||||
flex-shrink: 0;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
}
|
||||
|
||||
.back-button-text {
|
||||
display: flex;
|
||||
|
||||
align-items: center;
|
||||
}
|
||||
71
core/src/components/back-button/back-button.tsx
Normal file
71
core/src/components/back-button/back-button.tsx
Normal file
@ -0,0 +1,71 @@
|
||||
import { Component, Element, Prop } from '@stencil/core';
|
||||
import { Config } from '../../index';
|
||||
import { openURL } from '../../utils/theme';
|
||||
|
||||
@Component({
|
||||
tag: 'ion-back-button',
|
||||
styleUrls: {
|
||||
ios: 'back-button.ios.scss',
|
||||
md: 'back-button.md.scss'
|
||||
},
|
||||
host: {
|
||||
theme: 'back-button'
|
||||
}
|
||||
})
|
||||
export class BackButton {
|
||||
|
||||
/**
|
||||
* The mode determines which platform styles to use.
|
||||
* Possible values are: `"ios"` or `"md"`.
|
||||
* For more information, see [Platform Styles](/docs/theming/platform-specific-styles).
|
||||
*/
|
||||
@Prop() mode: 'ios' | 'md';
|
||||
|
||||
/**
|
||||
* The text property is used to provide custom text for the back button while using the
|
||||
* default look-and-feel
|
||||
*/
|
||||
@Prop() text: string|undefined;
|
||||
|
||||
@Prop() icon: string;
|
||||
|
||||
@Prop() defaultHref: string;
|
||||
|
||||
@Prop({ context: 'config' }) config: Config;
|
||||
|
||||
@Element() el: HTMLElement;
|
||||
|
||||
|
||||
hostData() {
|
||||
return {
|
||||
class: {
|
||||
'show-back-button': !!this.defaultHref
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
private onClick(ev: Event) {
|
||||
const nav = this.el.closest('ion-nav');
|
||||
if (nav && nav.canGoBack()) {
|
||||
ev.preventDefault();
|
||||
nav.pop();
|
||||
} else if (this.defaultHref) {
|
||||
openURL(this.defaultHref, ev, true);
|
||||
}
|
||||
}
|
||||
|
||||
render() {
|
||||
const backButtonIcon = this.icon || this.config.get('backButtonIcon', 'arrow-back');
|
||||
const backButtonText = this.text || this.config.get('backButtonText', this.mode === 'ios' ? 'Back' : '');
|
||||
|
||||
return (
|
||||
<button
|
||||
class='back-button-inner'
|
||||
onClick={(ev) => this.onClick(ev)}>
|
||||
{ backButtonIcon && <ion-icon name={backButtonIcon}/> }
|
||||
{ backButtonText && <span class='button-text'>{backButtonText}</span> }
|
||||
{ this.mode === 'md' && <ion-ripple-effect/> }
|
||||
</button>
|
||||
);
|
||||
}
|
||||
}
|
||||
109
core/src/components/back-button/readme.md
Normal file
109
core/src/components/back-button/readme.md
Normal file
@ -0,0 +1,109 @@
|
||||
# ion-back-button
|
||||
|
||||
A back button is a component that allows you navigate back into app history. To
|
||||
add a back button to your view, all you need is:
|
||||
|
||||
```html
|
||||
<ion-header>
|
||||
<ion-toolbar>
|
||||
<ion-buttons slot="start">
|
||||
<ion-back-button></ion-back-button>
|
||||
</ion-buttons>
|
||||
</ion-toolbar>
|
||||
</ion-header>
|
||||
```
|
||||
|
||||
The back button component is smart enough to know what to render and what content to show.
|
||||
|
||||
If, however, you want more control over what is shown in the back button, you use the
|
||||
`text` and `icon` properties.
|
||||
|
||||
```html
|
||||
<ion-header>
|
||||
<ion-toolbar>
|
||||
<ion-buttons slot="start">
|
||||
<ion-back-button text="Volver" icon="add"></ion-back-button>
|
||||
</ion-buttons>
|
||||
</ion-toolbar>
|
||||
</ion-header>
|
||||
```
|
||||
|
||||
Or no button text at all:
|
||||
|
||||
|
||||
```html
|
||||
<ion-header>
|
||||
<ion-toolbar>
|
||||
<ion-buttons slot="start">
|
||||
<ion-back-button text="" icon="add"></ion-back-button>
|
||||
</ion-buttons>
|
||||
</ion-toolbar>
|
||||
</ion-header>
|
||||
```
|
||||
|
||||
|
||||
<!-- Auto Generated Below -->
|
||||
|
||||
|
||||
## Properties
|
||||
|
||||
#### defaultHref
|
||||
|
||||
string
|
||||
|
||||
|
||||
#### icon
|
||||
|
||||
string
|
||||
|
||||
|
||||
#### mode
|
||||
|
||||
|
||||
|
||||
The mode determines which platform styles to use.
|
||||
Possible values are: `"ios"` or `"md"`.
|
||||
For more information, see [Platform Styles](/docs/theming/platform-specific-styles).
|
||||
|
||||
|
||||
#### text
|
||||
|
||||
|
||||
|
||||
The text property is used to provide custom text for the back button while using the
|
||||
default look-and-feel
|
||||
|
||||
|
||||
## Attributes
|
||||
|
||||
#### default-href
|
||||
|
||||
string
|
||||
|
||||
|
||||
#### icon
|
||||
|
||||
string
|
||||
|
||||
|
||||
#### mode
|
||||
|
||||
|
||||
|
||||
The mode determines which platform styles to use.
|
||||
Possible values are: `"ios"` or `"md"`.
|
||||
For more information, see [Platform Styles](/docs/theming/platform-specific-styles).
|
||||
|
||||
|
||||
#### text
|
||||
|
||||
|
||||
|
||||
The text property is used to provide custom text for the back button while using the
|
||||
default look-and-feel
|
||||
|
||||
|
||||
|
||||
----------------------------------------------
|
||||
|
||||
*Built with [StencilJS](https://stenciljs.com/)*
|
||||
96
core/src/components/back-button/test/basic/index.html
Normal file
96
core/src/components/back-button/test/basic/index.html
Normal file
@ -0,0 +1,96 @@
|
||||
<!DOCTYPE html>
|
||||
<html dir="ltr">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<title>Back Button</title>
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=no">
|
||||
<script src="/dist/ionic.js"></script>
|
||||
</head>
|
||||
<body onload="loadFirstPage()">
|
||||
<ion-app>
|
||||
<ion-nav></ion-nav>
|
||||
</ion-app>
|
||||
</body>
|
||||
|
||||
<script>
|
||||
|
||||
async function loadFirstPage() {
|
||||
const nav = document.querySelector('ion-nav');
|
||||
await nav.componentOnReady();
|
||||
const firstPage = document.createElement('div');
|
||||
firstPage.classList.add('first-page');
|
||||
firstPage.innerHTML = `
|
||||
<ion-header>
|
||||
<ion-toolbar>
|
||||
<ion-buttons slot="start">
|
||||
<ion-back-button></ion-back-button>
|
||||
</ion-buttons>
|
||||
<ion-title>Page One</ion-title>
|
||||
</ion-toolbar>
|
||||
</ion-header>
|
||||
<ion-content padding>
|
||||
<h1>Page One</h1>
|
||||
<ion-button class="next">Go to Page Two</ion-button>
|
||||
</ion-content>
|
||||
`;
|
||||
|
||||
await nav.setRoot(firstPage);
|
||||
|
||||
// okay cool, we're in the DOM now
|
||||
const button = firstPage.querySelector('.next');
|
||||
button.addEventListener('click', async () => {
|
||||
await goToPageTwo(nav);
|
||||
});
|
||||
}
|
||||
|
||||
async function goToPageTwo(nav) {
|
||||
const secondPage = document.createElement('div');
|
||||
secondPage.classList.add('second-page');
|
||||
secondPage.innerHTML = `
|
||||
<ion-header>
|
||||
<ion-toolbar color="secondary">
|
||||
<ion-buttons slot="start">
|
||||
<ion-back-button></ion-back-button>
|
||||
</ion-buttons>
|
||||
<ion-title>Page Two</ion-title>
|
||||
</ion-toolbar>
|
||||
</ion-header>
|
||||
<ion-content padding>
|
||||
<h1>Page Two</h1>
|
||||
<p>Just an empty <code>ion-back-button</code></p>
|
||||
<ion-button class="next">Go to Page Three</ion-button>
|
||||
</ion-content>
|
||||
`;
|
||||
|
||||
// okay cool, we're in the DOM now
|
||||
await nav.push(secondPage);
|
||||
|
||||
const nextButton = secondPage.querySelector('ion-button .next');
|
||||
nextButton.addEventListener('click', async () => {
|
||||
await goToPageThree(nav);
|
||||
});
|
||||
}
|
||||
|
||||
async function goToPageThree(nav) {
|
||||
const thirdPage = document.createElement('div');
|
||||
thirdPage.classList.add('third-page');
|
||||
thirdPage.innerHTML = `
|
||||
<ion-header>
|
||||
<ion-toolbar>
|
||||
<ion-buttons slot="start">
|
||||
<ion-back-button color="danger" text="Text!" icon="add"></ion-back-button>
|
||||
</ion-buttons>
|
||||
<ion-title>Page Three</ion-title>
|
||||
</ion-toolbar>
|
||||
</ion-header>
|
||||
<ion-content padding>
|
||||
<h1>Page Three</h1>
|
||||
<p>Custom back button</p>
|
||||
</ion-content>
|
||||
`;
|
||||
|
||||
// okay cool, we're in the DOM now
|
||||
await nav.push(thirdPage);
|
||||
}
|
||||
</script>
|
||||
</html>
|
||||
111
core/src/components/back-button/test/host-element/index.html
Normal file
111
core/src/components/back-button/test/host-element/index.html
Normal file
@ -0,0 +1,111 @@
|
||||
<!DOCTYPE html>
|
||||
<html dir="ltr">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<title>Back Button</title>
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=no">
|
||||
<script src="/dist/ionic.js"></script>
|
||||
<script>
|
||||
class PageOne extends HTMLElement {
|
||||
connectedCallback() {
|
||||
this.innerHTML = `
|
||||
|
||||
<ion-header>
|
||||
<ion-toolbar>
|
||||
<ion-buttons slot="start">
|
||||
<ion-back-button></ion-back-button>
|
||||
</ion-buttons>
|
||||
<ion-title>Page One</ion-title>
|
||||
</ion-toolbar>
|
||||
</ion-header>
|
||||
<ion-content padding>
|
||||
<h1>Page One</h1>
|
||||
<ion-nav-push component="page-two">
|
||||
<ion-button class="next">Go to Page Two</ion-button>
|
||||
</ion-nav-push>
|
||||
</ion-content>
|
||||
`;
|
||||
}
|
||||
}
|
||||
|
||||
class PageTwo extends HTMLElement {
|
||||
connectedCallback() {
|
||||
this.innerHTML = `
|
||||
|
||||
<ion-header>
|
||||
<ion-toolbar>
|
||||
<ion-buttons slot="start">
|
||||
<ion-back-button></ion-back-button>
|
||||
</ion-buttons>
|
||||
<ion-title>Page Two</ion-title>
|
||||
</ion-toolbar>
|
||||
</ion-header>
|
||||
<ion-content padding>
|
||||
<h1>Page Two</h1>
|
||||
<div>
|
||||
<ion-nav-push component="page-three">
|
||||
<ion-button class="next">Go to Page Three</ion-button>
|
||||
</ion-nav-push>
|
||||
</div>
|
||||
</ion-content>
|
||||
`;
|
||||
}
|
||||
}
|
||||
|
||||
class PageThree extends HTMLElement {
|
||||
connectedCallback() {
|
||||
this.innerHTML = `
|
||||
|
||||
<ion-header>
|
||||
<ion-toolbar>
|
||||
<ion-buttons slot="start">
|
||||
<ion-back-button text='Page Two'></ion-back-button>
|
||||
</ion-buttons>
|
||||
<ion-title>Page Three</ion-title>
|
||||
</ion-toolbar>
|
||||
</ion-header>
|
||||
<ion-content padding>
|
||||
<h1>Page Three</h1>
|
||||
<div>
|
||||
<ion-nav-push component="page-four">
|
||||
<ion-button class="next">Go to Page Four</ion-button>
|
||||
</ion-nav-push>
|
||||
</div>
|
||||
</ion-content>
|
||||
`;
|
||||
}
|
||||
}
|
||||
|
||||
class PageFour extends HTMLElement {
|
||||
connectedCallback() {
|
||||
this.innerHTML = `
|
||||
|
||||
<ion-header>
|
||||
<ion-toolbar>
|
||||
<ion-buttons slot="start">
|
||||
<ion-back-button text='Page Three'></ion-back-button>
|
||||
</ion-buttons>
|
||||
<ion-title>Page Four</ion-title>
|
||||
</ion-toolbar>
|
||||
</ion-header>
|
||||
<ion-content padding>
|
||||
<h1>Page Four</h1>
|
||||
</ion-content>
|
||||
`;
|
||||
}
|
||||
}
|
||||
|
||||
customElements.define('page-one', PageOne);
|
||||
customElements.define('page-two', PageTwo);
|
||||
customElements.define('page-three', PageThree);
|
||||
customElements.define('page-four', PageFour);
|
||||
|
||||
</script>
|
||||
</head>
|
||||
<body>
|
||||
<ion-app>
|
||||
<ion-nav root="page-one"></ion-nav>
|
||||
</ion-app>
|
||||
</body>
|
||||
|
||||
</html>
|
||||
16
core/src/components/back-button/test/standalone/index.html
Normal file
16
core/src/components/back-button/test/standalone/index.html
Normal file
@ -0,0 +1,16 @@
|
||||
<!DOCTYPE html>
|
||||
<html dir="ltr">
|
||||
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<title>Back Button</title>
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=no">
|
||||
<script src="/dist/ionic.js"></script>
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<ion-back-button class="show-back-button"></ion-back-button>
|
||||
</body>
|
||||
|
||||
|
||||
</html>
|
||||
Reference in New Issue
Block a user