Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
22 changes: 22 additions & 0 deletions BREAKING.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ This is a comprehensive list of the breaking changes introduced in the major ver
- [Browser and Platform Support](#version-10x-browser-platform-support)
- [Global Styles](#version-10x-global-styles)
- [Components](#version-10x-components)
- [Accordion](#version-10x-accordion)
- [Backdrop](#version-10x-backdrop)
- [Button](#version-10x-button)
- [Card](#version-10x-card)
Expand All @@ -29,6 +30,7 @@ This is a comprehensive list of the breaking changes introduced in the major ver
- [Grid](#version-10x-grid)
- [Image](#version-10x-image)
- [Input Otp](#version-10x-input-otp)
- [Item](#version-10x-item)
- [Item Divider](#version-10x-item-divider)
- [Label](#version-10x-label)
- [Menu Toggle](#version-10x-menu-toggle)
Expand Down Expand Up @@ -76,6 +78,11 @@ This section details the desktop browser and mobile platform versions that are s

<h2 id="version-10x-components">Components</h2>

<h4 id="version-10x-accordion">Accordion</h4>

- In the ios theme, the line above the header of an accordion that follows an expanded one is drawn by the accordion instead of a border on the header item. It uses `--ion-item-border-color`, or `--ion-border-color` when that isn't set, and the shade of the header item's `color` when it has one. `--border-color` on the header item no longer changes its color.
- While an accordion is expanded, a header item with `lines="full"` has `lines` set to `"none"`, and back to `"full"` when the accordion collapses.

<h4 id="version-10x-backdrop">Backdrop</h4>

The following breaking changes apply to `ion-backdrop`:
Expand Down Expand Up @@ -651,6 +658,21 @@ Converted `ion-input-otp` to use [Shadow DOM](https://developer.mozilla.org/en-U

If you were targeting the internals of `ion-input-otp` in your CSS, you will need to target the `group`, `container`, `native`, `separator` or `description` [Shadow Parts](https://ionicframework.com/docs/theming/css-shadow-parts) instead, or use the provided CSS Variables.

<h4 id="version-10x-item">Item</h4>

The lines between items are drawn with an element instead of a border, so `--border-width` and `--inner-border-width` no longer show, hide or resize them. `--border-color` still sets their color.

The lines no longer add to the item's height, so an item with a line is slightly shorter: 1px in the md and ionic themes, and half a pixel on most iOS devices in the ios theme.

- To hide a line, set `lines="none"` on the item or the list.
- To style a line, target the `line` (full width) or `inner-line` (inset) [Shadow Part](https://ionicframework.com/docs/theming/css-shadow-parts):

```css
ion-item::part(inner-line) {
display: none;
}
```

<h4 id="version-10x-item-divider">Item Divider</h4>

- Component CSS variables have been removed. The component now utilizes the centralized Ionic Theming system. Global updates should be managed via the theme tokens file, while component-specific overrides are handled through localized CSS variables.
Expand Down
2 changes: 2 additions & 0 deletions core/api.txt
Original file line number Diff line number Diff line change
Expand Up @@ -1839,6 +1839,8 @@ ion-item,css-prop,--transition,md
ion-item,part,container
ion-item,part,detail-icon
ion-item,part,inner
ion-item,part,inner-line
ion-item,part,line
ion-item,part,native

ion-item-divider,shadow
Expand Down
15 changes: 10 additions & 5 deletions core/scripts/testing/scripts.js
Original file line number Diff line number Diff line change
Expand Up @@ -139,8 +139,11 @@ const DEFAULT_PALETTE = 'light';
// Store existing theme set from the app initialization
const customTheme = window.Ionic?.config?.customTheme;
// Load the default tokens for the theme
const themeLoaded = import(`/themes/${themeName}/default.tokens.js`).then((defaultTokens) =>
buildTheme(defaultTokens.defaultTheme, customTheme, paletteName)
const themeLoaded = Promise.all([
import(`/themes/${themeName}/default.tokens.js`),
import('/themes/utils/theme.js'),
]).then(([defaultTokens, themeUtils]) =>
buildTheme(defaultTokens.defaultTheme, customTheme, paletteName, themeUtils)
);

/*
Expand Down Expand Up @@ -224,11 +227,13 @@ const DEFAULT_PALETTE = 'light';
}

// TODO(FW-6750): Determine if this function can be removed once the theme tokens can be imported directly into the test pages
function buildTheme(tokensTheme, customTheme, paletteName) {
function buildTheme(tokensTheme, customTheme, paletteName, themeUtils) {
let theme = tokensTheme;
// Merge with existing theme to preserve any customizations
// Merge with existing theme to preserve any customizations. A custom
// value replaces the theme's media query values for the same key, as
// it does in the app (refer to `mergeTheme`).
if (customTheme) {
theme = deepMerge(theme, customTheme);
theme = themeUtils.mergeTheme(theme, customTheme);
}

// If a specific palette is requested, modify the palette structure
Expand Down
6 changes: 3 additions & 3 deletions core/src/components/accordion/accordion.common.scss
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,9 @@
z-index: 0;
}

:host(.accordion-expanding) ::slotted(ion-item[slot="header"]),
:host(.accordion-expanded) ::slotted(ion-item[slot="header"]) {
--border-width: 0px;
// Hidden unless the theme's stylesheet shows it
.accordion-next-line {
display: none;
}

#content {
Expand Down
6 changes: 2 additions & 4 deletions core/src/components/accordion/accordion.ionic.scss
Original file line number Diff line number Diff line change
Expand Up @@ -44,13 +44,11 @@
// Accordion Header
// --------------------------------------------------

// The border is removed from the item in the header because
// we are adding a border to the ::after element of the accordion.
// The header item's lines are hidden in core.ionic.scss because the
// accordion draws its own line with the ::after element.
::slotted(ion-item[slot="header"]) {
--border-radius: inherit;
--color: #{globals.$ion-text-default};
--border-width: #{globals.$ion-border-size-0};
--inner-border-width: #{globals.$ion-scale-0};
--min-height: #{globals.$ion-scale-700};
--padding-top: #{globals.$ion-space-300};
--padding-end: #{globals.$ion-space-400};
Expand Down
16 changes: 14 additions & 2 deletions core/src/components/accordion/accordion.ios.scss
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,18 @@
// iOS Accordion
// --------------------------------------------------

:host(.accordion-next) ::slotted(ion-item[slot="header"]) {
--border-width: #{$item-ios-border-bottom-width 0px $item-ios-border-bottom-width 0px};
// Drawn as a filled box instead of a border on the header item
// (refer to the `hairline` mixin)
.accordion-next-line {
@include hairline(top);

color: $item-ios-border-bottom-color;

// Above the header item's background
z-index: 1;
}

// The last accordion's header has no lines (refer to core.scss), so it has no top line either
:host(.accordion-next:not(.accordion-last)) .accordion-next-line {
display: block;
}
46 changes: 46 additions & 0 deletions core/src/components/accordion/accordion.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@ export class Accordion implements ComponentInterface {
private contentEl: HTMLDivElement | undefined;
private contentElWrapper: HTMLDivElement | undefined;
private headerEl: HTMLDivElement | undefined;
private nextLineEl: HTMLDivElement | undefined;

private currentRaf: number | undefined;

Expand Down Expand Up @@ -159,6 +160,8 @@ export class Accordion implements ComponentInterface {
componentDidLoad() {
this.setItemDefaults();
this.slotToggleIcon();
this.updateHeaderLine(this.state === AccordionState.Expanded || this.state === AccordionState.Expanding);
this.updateNextLineColor();

/**
* We need to wait a tick because we
Expand Down Expand Up @@ -201,6 +204,46 @@ export class Accordion implements ComponentInterface {
}
};

/**
* Whether the accordion switched its header item's `lines` from `"full"`
* to `"none"` while expanded, so it knows to switch it back.
*/
private headerLineHidden = false;

/**
* Hides the header item's full line while the accordion is expanded. Some
* themes draw item lines inside the item, where the accordion's styles
* can't reach, so the accordion switches `lines` instead.
*/
private updateHeaderLine = (expanded: boolean) => {
const ionItem = this.getSlottedHeaderIonItem();
if (!ionItem) {
return;
}

if (expanded && ionItem.lines === 'full') {
ionItem.lines = 'none';
this.headerLineHidden = true;
} else if (!expanded && this.headerLineHidden) {
ionItem.lines = 'full';
this.headerLineHidden = false;
}
};

/**
* Colors the top line with the shade of the header item's color, matching
* the item's own lines. The accordion's styles can't read the item's color,
* so the shade is set here. The names follow `generateColorClasses`.
*/
private updateNextLineColor = () => {
const color = this.getSlottedHeaderIonItem()?.color;
if (!this.nextLineEl || color === undefined) {
return;
}

this.nextLineEl.style.color = `var(--ion-color-${color}-shade, var(--ion-color-${color}-bold-shade))`;
};

private getSlottedHeaderIonItem = () => {
const { headerEl } = this;
if (!headerEl) {
Expand Down Expand Up @@ -509,6 +552,7 @@ export class Accordion implements ComponentInterface {
const contentPart = expanded ? 'content expanded' : 'content';

this.setAria(expanded);
this.updateHeaderLine(expanded);

return (
<Host
Expand Down Expand Up @@ -542,6 +586,8 @@ export class Accordion implements ComponentInterface {
<slot name="header"></slot>
</div>

<div class="accordion-next-line" ref={(nextLineEl) => (this.nextLineEl = nextLineEl)}></div>

<div
id="content"
part={contentPart}
Expand Down
53 changes: 52 additions & 1 deletion core/src/components/accordion/test/basic/accordion.e2e.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
import { expect } from '@playwright/test';
import { configs, test } from '@utils/test/playwright';
import { configs, keepSafariHairlines, test } from '@utils/test/playwright';

configs().forEach(({ config, screenshot, title }) => {
test.describe(title('accordion: basic'), () => {
keepSafariHairlines(config);

test('should not have visual regressions', async ({ page }) => {
await page.goto(`/src/components/accordion/test/basic`, config);

Expand Down Expand Up @@ -95,3 +97,52 @@ configs({ modes: ['ionic-md'] }).forEach(({ config, screenshot, title }) => {
});
});
});

/**
* Snapshots shrink the page to CSS pixels, which can drop a one-device-pixel
* ios line in Safari when an accordion sits at a fractional position. This
* test keeps every device pixel, so a missing, thicker or misplaced line above
* a header fails in every browser. Only the ios theme draws that line.
* This behavior does not vary across directions.
*/
configs({ modes: ['ios'], directions: ['ltr'] }).forEach(({ config, screenshot, title }) => {
test.describe(title('accordion: line at device resolution'), () => {
test('should not have visual regressions', async ({ page }) => {
// The groups start 0, 1/3 and 2/3 of a pixel down the page
const group = (offset: string, color = '') => `
<ion-accordion-group value="first" style="padding-top: ${offset}">
<ion-accordion value="first">
<ion-item slot="header" ${color}><ion-label>First</ion-label></ion-item>
<div slot="content">Content</div>
</ion-accordion>
<ion-accordion value="second">
<ion-item slot="header" ${color}><ion-label>Second</ion-label></ion-item>
<div slot="content">Content</div>
</ion-accordion>
<ion-accordion value="third">
<ion-item slot="header" ${color}><ion-label>Third</ion-label></ion-item>
<div slot="content">Content</div>
</ion-accordion>
</ion-accordion-group>
`;

await page.setContent(
`
<style>
#container {
width: 120px;
}
</style>
<div id="container">
${group('0px')}${group('0.33px')}${group('0.34px')}${group('0px', 'color="warning"')}
</div>
`,
config
);

const container = page.locator('#container');

await expect(container).toHaveScreenshot(screenshot(`accordion-line-device`), { scale: 'device' });
});
});
});
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
import { expect } from '@playwright/test';
import { configs, test } from '@utils/test/playwright';
import { configs, keepSafariHairlines, test } from '@utils/test/playwright';

configs({ directions: ['ltr'], modes: ['ionic-md', 'md', 'ios'] }).forEach(({ config, screenshot, title }) => {
test.describe(title('accordion: multiple'), () => {
keepSafariHairlines(config);

test('should update value and visually expand items', async ({ page }) => {
await page.goto(`/src/components/accordion/test/multiple`, config);
const accordionGroup = page.locator('ion-accordion-group');
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
import { expect } from '@playwright/test';
import { configs, test } from '@utils/test/playwright';
import { configs, keepSafariHairlines, test } from '@utils/test/playwright';

configs({ directions: ['ltr'], modes: ['md', 'ios', 'ionic-md'] }).forEach(({ config, screenshot, title }) => {
test.describe(title('accordion: nested'), () => {
keepSafariHairlines(config);

test('parent and child should not be disabled', async ({ page }) => {
await page.goto(`/src/components/accordion/test/nested`, config);

Expand Down
2 changes: 1 addition & 1 deletion core/src/components/divider/_divider.docs.scss
Original file line number Diff line number Diff line change
Expand Up @@ -14,5 +14,5 @@
* @prop --ion-divider-spacing-xlarge-margin-bottom: Bottom margin of the `xlarge` divider spacing
* @prop --ion-divider-spacing-xxlarge-margin-top: Top margin of the `xxlarge` divider spacing
* @prop --ion-divider-spacing-xxlarge-margin-bottom: Bottom margin of the `xxlarge` divider spacing
* @prop --ion-divider-thickness: Thickness of the divider line
* @prop --ion-divider-thickness: Thickness of the divider line. The ios theme changes it with screen density, so the line stays one screen pixel thick.
*/
9 changes: 8 additions & 1 deletion core/src/components/divider/divider.interface.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,16 @@
import type { IonMargin } from '../../themes/themes.interfaces';
import type { IonMargin, IonMediaQuery } from '../../themes/themes.interfaces';

export type IonDividerRecipe = {
/** Color of the divider line. */
color?: string;

/**
* Thickness used inside media queries, such as a thinner line on denser screens.
* A `thickness` that a custom theme sets outside this key replaces the base
* theme's values here, so it applies on every screen.
*/
mediaQuery?: IonMediaQuery<Pick<IonDividerRecipe, 'thickness'>>;

/** Applies for each value of the `spacing` property, except `"none"`, which is always 0. */
spacing?: {
[K in Exclude<IonDividerSpacing, 'none'>]?: {
Expand Down
16 changes: 13 additions & 3 deletions core/src/components/divider/divider.scss
Original file line number Diff line number Diff line change
Expand Up @@ -27,12 +27,22 @@ $spacings: xxsmall, xsmall, small, medium, large, xlarge, xxlarge;
:host hr {
display: block;

position: relative;

width: 100%;
height: var(--ion-divider-thickness);

border: none;
border-top-width: var(--ion-divider-thickness);
border-top-style: solid;
border-top-color: var(--ion-divider-color);

// Lets the pseudo-element reach above the line
overflow: visible;
}

// Drawn as a filled box instead of a border (refer to the `hairline` mixin)
:host hr::after {
@include mixins.hairline(bottom, var(--ion-divider-color), var(--ion-divider-thickness));

content: "";
}

// Divider Spacing
Expand Down
Loading
Loading