mirror of
https://github.com/ionic-team/ionic-framework.git
synced 2025-11-09 08:09:32 +08:00
Issue number: Internal --------- <!-- Please do not submit updates to dependencies unless it fixes an issue. --> <!-- Please try to limit your pull request to one type (bugfix, feature, etc). Submit multiple pull requests if needed. --> ## What is the current behavior? <!-- Please describe the current behavior that you are modifying. --> ## What is the new behavior? <!-- Please describe the behavior or changes that are being added by this PR. --> Adds the base architecture to add a new theme configuration to Ionic Framework components. - Components can now specify an additional stylesheet for the `ionic` theme. - Developers can specify the `theme` and `mode` independently to control look and feel of a component. Test infrastructure has been updated to add support for testing the theme configuration with Playwright. - Existing `themes` test configuration has been renamed to `palettes` This PR is just the initial effort to decouple Ionic's architecture to separate look and feel and allow our dev team to start introducing the new component appearance to the UI. There will be additional changes required to completely add support for the Ionic theme. These changes are targeted against the `next` branch and are not expected to be used in a production environment at this time. ## Does this introduce a breaking change? - [ ] Yes - [x] No <!-- If this introduces a breaking change: 1. Describe the impact and migration path for existing applications below. 2. Update the BREAKING.md file with the breaking change. 3. Add "BREAKING CHANGE: [...]" to the commit description when merging. See https://github.com/ionic-team/ionic-framework/blob/main/.github/CONTRIBUTING.md#footer for more information. --> ## Other information <!-- Any other information that is important to this PR such as screenshots of how the component looks before and after the change. --> --------- Co-authored-by: Maria Hutt <thetaPC@users.noreply.github.com> Co-authored-by: Brandy Carney <brandyscarney@users.noreply.github.com>
89 lines
2.9 KiB
TypeScript
89 lines
2.9 KiB
TypeScript
import type { ComponentInterface } from '@stencil/core';
|
|
import { Component, Host, Prop, h } from '@stencil/core';
|
|
import { ENABLE_HTML_CONTENT_DEFAULT } from '@utils/config';
|
|
import { sanitizeDOMString } from '@utils/sanitization';
|
|
|
|
import { config } from '../../global/config';
|
|
import { getIonTheme } from '../../global/ionic-global';
|
|
import type { IonicSafeString } from '../../utils/sanitization';
|
|
import type { SpinnerTypes } from '../spinner/spinner-configs';
|
|
|
|
/**
|
|
* @virtualProp {"ios" | "md"} mode - The mode determines the platform behaviors of the component.
|
|
* @virtualProp {"ios" | "md" | "ionic"} theme - The theme determines the visual appearance of the component.
|
|
*/
|
|
@Component({
|
|
tag: 'ion-infinite-scroll-content',
|
|
styleUrls: {
|
|
ios: 'infinite-scroll-content.ios.scss',
|
|
md: 'infinite-scroll-content.md.scss',
|
|
ionic: 'infinite-scroll-content.md.scss',
|
|
},
|
|
})
|
|
export class InfiniteScrollContent implements ComponentInterface {
|
|
private customHTMLEnabled = config.get('innerHTMLTemplatesEnabled', ENABLE_HTML_CONTENT_DEFAULT);
|
|
|
|
/**
|
|
* An animated SVG spinner that shows while loading.
|
|
*/
|
|
@Prop({ mutable: true }) loadingSpinner?: SpinnerTypes | null;
|
|
|
|
/**
|
|
* Optional text to display while loading.
|
|
* `loadingText` can accept either plaintext or HTML as a string.
|
|
* To display characters normally reserved for HTML, they
|
|
* must be escaped. For example `<Ionic>` would become
|
|
* `<Ionic>`
|
|
*
|
|
* For more information: [Security Documentation](https://ionicframework.com/docs/faq/security)
|
|
*
|
|
* This property accepts custom HTML as a string.
|
|
* Content is parsed as plaintext by default.
|
|
* `innerHTMLTemplatesEnabled` must be set to `true` in the Ionic config
|
|
* before custom HTML can be used.
|
|
*/
|
|
@Prop() loadingText?: string | IonicSafeString;
|
|
|
|
componentDidLoad() {
|
|
if (this.loadingSpinner === undefined) {
|
|
const theme = getIonTheme(this);
|
|
this.loadingSpinner = config.get(
|
|
'infiniteLoadingSpinner',
|
|
config.get('spinner', theme === 'ios' ? 'lines' : 'crescent')
|
|
);
|
|
}
|
|
}
|
|
|
|
private renderLoadingText() {
|
|
const { customHTMLEnabled, loadingText } = this;
|
|
if (customHTMLEnabled) {
|
|
return <div class="infinite-loading-text" innerHTML={sanitizeDOMString(loadingText)}></div>;
|
|
}
|
|
|
|
return <div class="infinite-loading-text">{this.loadingText}</div>;
|
|
}
|
|
|
|
render() {
|
|
const theme = getIonTheme(this);
|
|
return (
|
|
<Host
|
|
class={{
|
|
[theme]: true,
|
|
|
|
// Used internally for styling
|
|
[`infinite-scroll-content-${theme}`]: true,
|
|
}}
|
|
>
|
|
<div class="infinite-loading">
|
|
{this.loadingSpinner && (
|
|
<div class="infinite-loading-spinner">
|
|
<ion-spinner name={this.loadingSpinner} />
|
|
</div>
|
|
)}
|
|
{this.loadingText !== undefined && this.renderLoadingText()}
|
|
</div>
|
|
</Host>
|
|
);
|
|
}
|
|
}
|