mirror of
https://github.com/ionic-team/ionic-framework.git
synced 2025-11-10 00:27:41 +08:00
refactor(components): update to use shadow DOM and work with css variables
- updates components to use shadow DOM or scoped if they require css variables - moves global styles to an external stylesheet that needs to be imported - adds support for additional colors and removes the Sass loops to generate colors for each component - several property renames, bug fixes, and test updates Co-authored-by: Manu Mtz.-Almeida <manu.mtza@gmail.com> Co-authored-by: Adam Bradley <adambradley25@gmail.com> Co-authored-by: Cam Wiegert <cam@camwiegert.com>
This commit is contained in:
@ -1,7 +1,7 @@
|
||||
@import "../../themes/ionic.globals.ios";
|
||||
|
||||
/// @prop - Color of the refresher icon
|
||||
$refresher-ios-icon-color: $text-ios-color !default;
|
||||
$refresher-ios-icon-color: $text-color !default;
|
||||
|
||||
/// @prop - Text color of the refresher content
|
||||
$refresher-ios-text-color: $text-ios-color !default;
|
||||
$refresher-ios-text-color: $text-color !default;
|
||||
|
||||
@ -1,7 +1,7 @@
|
||||
@import "../../themes/ionic.globals.md";
|
||||
|
||||
/// @prop - Color of the refresher icon
|
||||
$refresher-md-icon-color: $text-md-color !default;
|
||||
$refresher-md-icon-color: $text-color !default;
|
||||
|
||||
/// @prop - Text color of the refresher content
|
||||
$refresher-md-text-color: $text-md-color !default;
|
||||
$refresher-md-text-color: $text-color !default;
|
||||
|
||||
@ -39,7 +39,7 @@ ion-refresher-content {
|
||||
|
||||
.refresher-pulling-icon,
|
||||
.refresher-refreshing-icon {
|
||||
@include text-align(center);
|
||||
text-align: center;
|
||||
@include transform-origin(center);
|
||||
|
||||
font-size: $refresher-icon-font-size;
|
||||
@ -48,7 +48,7 @@ ion-refresher-content {
|
||||
|
||||
.refresher-pulling-text,
|
||||
.refresher-refreshing-text {
|
||||
@include text-align(center);
|
||||
text-align: center;
|
||||
|
||||
font-size: $refresher-text-font-size;
|
||||
}
|
||||
|
||||
@ -1,5 +1,6 @@
|
||||
import { Component, Element, Event, EventEmitter, Method, Prop, State } from '@stencil/core';
|
||||
import { GestureDetail, QueueController } from '../../interface';
|
||||
import { Component, Element, Event, EventEmitter, Method, Prop, QueueApi, State } from '@stencil/core';
|
||||
import { GestureDetail, Mode } from '../../interface';
|
||||
import { createThemedClasses } from '../../utils/theme';
|
||||
|
||||
const enum RefresherState {
|
||||
Inactive = 1 << 0,
|
||||
@ -17,9 +18,6 @@ const enum RefresherState {
|
||||
styleUrls: {
|
||||
ios: 'refresher.ios.scss',
|
||||
md: 'refresher.md.scss'
|
||||
},
|
||||
host: {
|
||||
theme: 'refresher'
|
||||
}
|
||||
})
|
||||
export class Refresher {
|
||||
@ -27,9 +25,11 @@ export class Refresher {
|
||||
private appliedStyles = false;
|
||||
private didStart = false;
|
||||
private progress = 0;
|
||||
private scrollEl: HTMLElement | null = null;
|
||||
private scrollEl?: HTMLIonScrollElement;
|
||||
|
||||
@Prop({ context: 'queue' }) queue!: QueueController;
|
||||
mode!: Mode;
|
||||
|
||||
@Prop({ context: 'queue' }) queue!: QueueApi;
|
||||
|
||||
/**
|
||||
* The current state which the refresher is in. The refresher's states include:
|
||||
@ -93,7 +93,7 @@ export class Refresher {
|
||||
*/
|
||||
@Event() ionStart!: EventEmitter<void>;
|
||||
|
||||
componentDidLoad() {
|
||||
async componentDidLoad() {
|
||||
if (this.el.getAttribute('slot') !== 'fixed') {
|
||||
console.error('Make sure you use: <ion-refresher slot="fixed">');
|
||||
return;
|
||||
@ -103,14 +103,17 @@ export class Refresher {
|
||||
console.error('ion-refresher is not attached');
|
||||
return;
|
||||
}
|
||||
this.scrollEl = parentElement.querySelector('ion-scroll') as HTMLElement;
|
||||
if (!this.scrollEl) {
|
||||
const contentEl = parentElement.querySelector('ion-content');
|
||||
if (contentEl) {
|
||||
await contentEl.componentOnReady();
|
||||
this.scrollEl = contentEl.getScrollElement();
|
||||
} else {
|
||||
console.error('ion-refresher didn\'t attached, make sure if parent is a ion-content');
|
||||
}
|
||||
}
|
||||
|
||||
componentDidUnload() {
|
||||
this.scrollEl = null;
|
||||
this.scrollEl = undefined;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -333,6 +336,8 @@ export class Refresher {
|
||||
hostData() {
|
||||
return {
|
||||
class: {
|
||||
...createThemedClasses(this.mode, 'refresher'),
|
||||
|
||||
'refresher-active': this.state !== RefresherState.Inactive,
|
||||
'refresher-pulling': this.state === RefresherState.Pulling,
|
||||
'refresher-ready': this.state === RefresherState.Ready,
|
||||
|
||||
@ -6,30 +6,28 @@
|
||||
<title>Refresher - Basic</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>
|
||||
<link rel="stylesheet" type="text/css" href="/css/ionic.min.css">
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<ion-app>
|
||||
|
||||
|
||||
<ion-header>
|
||||
<ion-toolbar>
|
||||
<ion-title>Pull To Refresh</ion-title>
|
||||
</ion-toolbar>
|
||||
</ion-header>
|
||||
<ion-header>
|
||||
<ion-toolbar>
|
||||
<ion-title>Pull To Refresh</ion-title>
|
||||
</ion-toolbar>
|
||||
</ion-header>
|
||||
|
||||
<ion-content>
|
||||
<ion-refresher id="refresher" disabled="false" slot="fixed">
|
||||
<ion-refresher-content
|
||||
pulling-text="Pull to refresh..."
|
||||
refreshing-spinner="bubbles"
|
||||
refreshing-text="Refreshing...">
|
||||
</ion-refresher-content>
|
||||
</ion-refresher>
|
||||
<ion-content>
|
||||
<ion-refresher id="refresher" disabled="false" slot="fixed">
|
||||
<ion-refresher-content pulling-text="Pull to refresh..." refreshing-spinner="bubbles" refreshing-text="Refreshing...">
|
||||
</ion-refresher-content>
|
||||
</ion-refresher>
|
||||
|
||||
<ion-list id="list"></ion-list>
|
||||
<ion-list id="list"></ion-list>
|
||||
|
||||
</ion-content>
|
||||
</ion-content>
|
||||
|
||||
|
||||
|
||||
@ -39,11 +37,11 @@
|
||||
<script>
|
||||
let items = [];
|
||||
for (var i = 0; i < 30; i++) {
|
||||
items.push( i+1 );
|
||||
items.push(i + 1);
|
||||
}
|
||||
const list = document.getElementById('list');
|
||||
const refresher = document.getElementById('refresher');
|
||||
refresher.addEventListener('ionRefresh', async function() {
|
||||
refresher.addEventListener('ionRefresh', async function () {
|
||||
console.log('Loading data...');
|
||||
const data = await getAsyncData();
|
||||
items = items.concat(data);
|
||||
@ -53,7 +51,7 @@
|
||||
});
|
||||
function render() {
|
||||
let html = '';
|
||||
for(let item of items) {
|
||||
for (let item of items) {
|
||||
html += `<ion-item button>${item}</ion-item>`;
|
||||
}
|
||||
list.innerHTML = html;
|
||||
@ -73,4 +71,5 @@
|
||||
render();
|
||||
</script>
|
||||
</body>
|
||||
|
||||
</html>
|
||||
|
||||
@ -6,30 +6,28 @@
|
||||
<title>Refresher</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>
|
||||
<link rel="stylesheet" type="text/css" href="/css/ionic.min.css">
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<ion-app>
|
||||
|
||||
|
||||
<ion-header>
|
||||
<ion-toolbar>
|
||||
<ion-title>Pull To Refresh</ion-title>
|
||||
</ion-toolbar>
|
||||
</ion-header>
|
||||
<ion-header>
|
||||
<ion-toolbar>
|
||||
<ion-title>Pull To Refresh</ion-title>
|
||||
</ion-toolbar>
|
||||
</ion-header>
|
||||
|
||||
<ion-content>
|
||||
<ion-refresher id="refresher" disabled="false" slot="fixed">
|
||||
<ion-refresher-content
|
||||
pulling-text="Pull to refresh..."
|
||||
refreshing-spinner="bubbles"
|
||||
refreshing-text="Refreshing...">
|
||||
</ion-refresher-content>
|
||||
</ion-refresher>
|
||||
<ion-content>
|
||||
<ion-refresher id="refresher" disabled="false" slot="fixed">
|
||||
<ion-refresher-content pulling-text="Pull to refresh..." refreshing-spinner="bubbles" refreshing-text="Refreshing...">
|
||||
</ion-refresher-content>
|
||||
</ion-refresher>
|
||||
|
||||
<ion-list id="list"></ion-list>
|
||||
<ion-list id="list"></ion-list>
|
||||
|
||||
</ion-content>
|
||||
</ion-content>
|
||||
|
||||
|
||||
|
||||
@ -39,11 +37,11 @@
|
||||
<script>
|
||||
let items = [];
|
||||
for (var i = 0; i < 30; i++) {
|
||||
items.push( i+1 );
|
||||
items.push(i + 1);
|
||||
}
|
||||
const list = document.getElementById('list');
|
||||
const refresher = document.getElementById('refresher');
|
||||
refresher.addEventListener('ionRefresh', async function() {
|
||||
refresher.addEventListener('ionRefresh', async function () {
|
||||
console.log('Loading data...');
|
||||
const data = await getAsyncData();
|
||||
items = items.concat(data);
|
||||
@ -53,7 +51,7 @@
|
||||
});
|
||||
function render() {
|
||||
let html = '';
|
||||
for(let item of items) {
|
||||
for (let item of items) {
|
||||
html += `<ion-item>${item}</ion-item>`;
|
||||
}
|
||||
list.innerHTML = html;
|
||||
@ -73,4 +71,5 @@
|
||||
render();
|
||||
</script>
|
||||
</body>
|
||||
|
||||
</html>
|
||||
|
||||
Reference in New Issue
Block a user