SIGN IN SIGN UP

A powerful cross-platform UI toolkit for building native-quality iOS, Android, and Progressive Web Apps with HTML, CSS, and JavaScript.

52437 0 2 TypeScript
/**
* This script is loaded in testing environments to set up the
* document based on URL parameters.
*
* Test pages (e.g., `chip/test/basic/index.html`) are set to use
* URL query parameters.
*
* Playwright test environments (e.g., `chip/test/basic/chip.e2e.ts`)
* are set based on whether `setContent` or `goto` has been used:
* - `setContent` uses URL hash parameters. Tests will break if
* query parameters are used.
* - `goto` uses URL query parameters.
*
* The following URL parameters are supported:
* - `rtl`: Set to `true` to enable right-to-left directionality.
* - `ionic:_testing`: Set to `true` to identify testing environments.
* - `ionic:mode`: Set to `ios` or `md` to load a specific mode.
* Defaults to `md`.
* - `palette`: Set to `light`, `dark`, `high-contrast`, or
* `high-contrast-dark` to load a specific palette. Defaults to `light`.
*/
(function() {
/**
* The `rtl` param is used to set the directionality of the
* document. This can be `true` or `false`.
*/
const isRTL = window.location.search.indexOf('rtl=true') > -1 || window.location.hash.indexOf('rtl=true') > -1;
if (isRTL) {
document.documentElement.setAttribute('dir', 'rtl');
}
/**
* The `ionic:_testing` param is used to identify testing
* environments.
*/
const isTestEnv = window.location.search.indexOf('ionic:_testing=true') > -1 || window.location.hash.indexOf('ionic:_testing=true') > -1;
if (isTestEnv) {
2019-09-25 18:12:57 +02:00
const style = document.createElement('style');
style.innerHTML = `
* {
caret-color: transparent !important;
}
`;
2019-09-25 18:12:57 +02:00
document.head.appendChild(style);
}
refactor(dark): use palettes through url queries in test pages (#29238) Issue number: N/A --------- <!-- 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. --> If a dev wants to view a test page in dark mode, they have to manually add the styles. This can lead to a slowdown. Plus they can't use Playwright's `goto` to test both light and dark. In order to test dark mode with Playwright, the dev would need to use `setContent` instead of `goto`. ## What is the new behavior? <!-- Please describe the behavior or changes that are being added by this PR. --> Dark mode can be added to any page by appending `palette=dark` to the URL. - The param will be used to add a link tag with the correct palette file. - Playwright will load the correct palette file when a dev uses `goto` and `{ themes: ['dark'] }` ## 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. --> I recommend using badge to try this out. It already has a `goto` in the basic tests.
2024-04-19 11:48:29 -07:00
/**
* The `palette` param is used to load a specific palette
* for the theme.
* The dark class will load the dark palette automatically
* if no palette is specified through the URL.
*
* Values can be `light`, `dark`, `high-contrast`,
* or `high-contrast-dark`. Default to `light` for tests.
refactor(dark): use palettes through url queries in test pages (#29238) Issue number: N/A --------- <!-- 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. --> If a dev wants to view a test page in dark mode, they have to manually add the styles. This can lead to a slowdown. Plus they can't use Playwright's `goto` to test both light and dark. In order to test dark mode with Playwright, the dev would need to use `setContent` instead of `goto`. ## What is the new behavior? <!-- Please describe the behavior or changes that are being added by this PR. --> Dark mode can be added to any page by appending `palette=dark` to the URL. - The param will be used to add a link tag with the correct palette file. - Playwright will load the correct palette file when a dev uses `goto` and `{ themes: ['dark'] }` ## 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. --> I recommend using badge to try this out. It already has a `goto` in the basic tests.
2024-04-19 11:48:29 -07:00
*/
const paletteQuery = window.location.search.match(/palette=([a-z]+)/);
const paletteHash = window.location.hash.match(/palette=([a-z]+)/);
const darkClass = document.body?.classList.contains('ion-palette-dark') ? 'dark' : null;
const paletteName = paletteQuery?.[1] || paletteHash?.[1] || darkClass || 'light';
if (paletteName !== 'light') {
refactor(dark): use palettes through url queries in test pages (#29238) Issue number: N/A --------- <!-- 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. --> If a dev wants to view a test page in dark mode, they have to manually add the styles. This can lead to a slowdown. Plus they can't use Playwright's `goto` to test both light and dark. In order to test dark mode with Playwright, the dev would need to use `setContent` instead of `goto`. ## What is the new behavior? <!-- Please describe the behavior or changes that are being added by this PR. --> Dark mode can be added to any page by appending `palette=dark` to the URL. - The param will be used to add a link tag with the correct palette file. - Playwright will load the correct palette file when a dev uses `goto` and `{ themes: ['dark'] }` ## 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. --> I recommend using badge to try this out. It already has a `goto` in the basic tests.
2024-04-19 11:48:29 -07:00
const linkTag = document.createElement('link');
linkTag.setAttribute('rel', 'stylesheet');
linkTag.setAttribute('type', 'text/css');
linkTag.setAttribute('href', `/css/palettes/${paletteName}.always.css`);
refactor(dark): use palettes through url queries in test pages (#29238) Issue number: N/A --------- <!-- 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. --> If a dev wants to view a test page in dark mode, they have to manually add the styles. This can lead to a slowdown. Plus they can't use Playwright's `goto` to test both light and dark. In order to test dark mode with Playwright, the dev would need to use `setContent` instead of `goto`. ## What is the new behavior? <!-- Please describe the behavior or changes that are being added by this PR. --> Dark mode can be added to any page by appending `palette=dark` to the URL. - The param will be used to add a link tag with the correct palette file. - Playwright will load the correct palette file when a dev uses `goto` and `{ themes: ['dark'] }` ## 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. --> I recommend using badge to try this out. It already has a `goto` in the basic tests.
2024-04-19 11:48:29 -07:00
document.head.appendChild(linkTag);
}
fix(colors): change ionic colors scss imports for ionic dist (#29791) 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. --> When consuming the Ionic Framework and using the Ionic Theme, the color attribute was still not working as the color css was not present. ## What is the new behavior? <!-- Please describe the behavior or changes that are being added by this PR. --> - Now the ion-color maps are correctly imported on the Ionic `dist` related folder and not the on the `md/ios` ones. - Changed the usage of `map.get` to `map-get` to avoid issues with the usage of `@use` and `@forward`. This seems to have no impact on the compilation and I believe its a better code convention, as map-gets are a native scss function that doesn't need to be imported. ## 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/docs/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: ionitron <hi@ionicframework.com> Co-authored-by: Maria Hutt <maria@ionic.io>
2024-08-27 08:42:46 +01:00
/**
* The `ionic` theme uses a different stylesheet than the `iOS` and `md` themes.
* This is to ensure that the `ionic` theme is loaded when the `ionic:theme=ionic`
* or when the HTML tag has the `theme="ionic"` attribute. This is useful for
* the snapshot tests, where the `ionic` theme is not loaded by default.
*/
const themeQuery = window.location.search.match(/ionic:theme=([a-z]+)/);
const themeAttr = document.documentElement.getAttribute('theme');
if ((themeQuery && themeQuery[1] === 'ionic') || themeAttr === 'ionic') {
const ionicThemeLinkTag = document.querySelector('link[href*="css/ionic/bundle.ionic.css"]');
if (!ionicThemeLinkTag) {
const linkTag = document.createElement('link');
linkTag.setAttribute('rel', 'stylesheet');
linkTag.setAttribute('type', 'text/css');
linkTag.setAttribute('href', '/css/ionic/bundle.ionic.css');
document.head.appendChild(linkTag);
}
fix(tokens): remove style dictionary scripts and reuse os tokens logic (#30786) 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 new behavior? <!-- Please describe the behavior or changes that are being added by this PR. --> This pull request updates the design token build system and its dependencies, simplifying the process and removing custom scripts in favor of using the latest features of the `outsystems-design-tokens` package. The changes modernize how design tokens are generated and maintained, reducing custom code and leveraging upstream improvements. Key changes include: **Build Process Simplification:** - The custom design token generation scripts (`core/scripts/tokens/index.mjs` and `core/scripts/tokens/utils.mjs`) have been removed. Token generation is now handled directly via the `outsystems-design-tokens` package using an `npx` command in the `build.tokens` script. This reduces maintenance overhead and keeps the build process aligned with upstream best practices. [[1]](diffhunk://#diff-0b9870c62ff80af860467e2541bba0b9ba5e7280b12bea6eeb124b1d174efbcfL1-L188) [[2]](diffhunk://#diff-8b5c339d9dd13300954577213f84a443321a0d6477acd7553787fbcc00ce8cabL1-L320) [[3]](diffhunk://#diff-7f67769260741e2563407af949f7e54fbf0431d1c607933f6e8a8094e3219e26L83-R82) **Dependency Updates:** - Updated `outsystems-design-tokens` to version `1.3.3` and `style-dictionary` to version `5.1.1` in both `package.json` and `package-lock.json`. This ensures compatibility with the latest features and bug fixes and removes the need to specify `style-dictionary` directly as a dependency. [[1]](diffhunk://#diff-4ff996db8bece1eded512c3b97a6bde33622f94bb387634ef32496d832d57744L47-L52) [[2]](diffhunk://#diff-4ff996db8bece1eded512c3b97a6bde33622f94bb387634ef32496d832d57744L9592-R9598) [[3]](diffhunk://#diff-4ff996db8bece1eded512c3b97a6bde33622f94bb387634ef32496d832d57744L11137-R11138) [[4]](diffhunk://#diff-7f67769260741e2563407af949f7e54fbf0431d1c607933f6e8a8094e3219e26L69-L74) **SCSS Utility Import:** - The `@forward "../../foundations/ionic.utility";` statement was removed from `core/src/css/ionic/utils.bundle.ionic.scss`, likely because the utility SCSS is now generated and managed by the new token build process. Removed CSS tests for Ionic theme, as they relied heavily on testing the effect of the utility-classes, that are no longer created on the ionic scope. ## 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/docs/CONTRIBUTING.md#footer for more information. --> --------- Co-authored-by: ionitron <hi@ionicframework.com>
2025-11-20 18:02:37 +00:00
const utilsBundleLinkTag = document.querySelector('link[href*="css/utils.bundle.css"]');
if (!utilsBundleLinkTag) {
const linkTag = document.createElement('link');
linkTag.setAttribute('rel', 'stylesheet');
linkTag.setAttribute('type', 'text/css');
linkTag.setAttribute('href', '/css/utils.bundle.css');
document.head.appendChild(linkTag);
}
const defaultThemeLinkTag = document.querySelector('link[href*="css/ionic.bundle.css"]');
if (defaultThemeLinkTag) {
defaultThemeLinkTag.remove();
}
fix(colors): change ionic colors scss imports for ionic dist (#29791) 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. --> When consuming the Ionic Framework and using the Ionic Theme, the color attribute was still not working as the color css was not present. ## What is the new behavior? <!-- Please describe the behavior or changes that are being added by this PR. --> - Now the ion-color maps are correctly imported on the Ionic `dist` related folder and not the on the `md/ios` ones. - Changed the usage of `map.get` to `map-get` to avoid issues with the usage of `@use` and `@forward`. This seems to have no impact on the compilation and I believe its a better code convention, as map-gets are a native scss function that doesn't need to be imported. ## 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/docs/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: ionitron <hi@ionicframework.com> Co-authored-by: Maria Hutt <maria@ionic.io>
2024-08-27 08:42:46 +01:00
}
window.Ionic = window.Ionic || {};
window.Ionic.config = window.Ionic.config || {};
window.addEventListener('appload', () => {
window.testAppLoaded = true;
})
})();