Skip to content
Draft
  •  
  •  
  •  
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>

In the ios theme, 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: half a pixel on most iOS devices.

- 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
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
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.
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.
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
9 changes: 9 additions & 0 deletions core/src/components/item/item.common.scss
Original file line number Diff line number Diff line change
Expand Up @@ -286,6 +286,15 @@ a {
opacity: var(--detail-icon-opacity);
}

// Item Lines
// --------------------------------------------------

// Hidden unless the theme's stylesheet shows them
.item-line,
.item-inner-line {
display: none;
}

// Item Slots
// --------------------------------------------------

Expand Down
34 changes: 17 additions & 17 deletions core/src/components/item/item.ios.scss
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
--transition: background-color 200ms linear, opacity 200ms linear;
--padding-start: #{$item-ios-padding-start};
--inner-padding-end: #{$item-ios-padding-end};
--inner-border-width: #{0px 0px $item-ios-border-bottom-width 0px};
--background: #{$item-ios-background};
/**
* The active/focus states need
Expand Down Expand Up @@ -57,27 +56,28 @@
// iOS Item Lines
// --------------------------------------------------

// Full lines - apply the border to the item
// Inset lines - apply the border to the item inner
:host(.item-lines-full) {
--border-width: #{0px 0px $item-ios-border-bottom-width 0px};
}
// Drawn as filled boxes instead of borders (refer to the `hairline` mixin)
.item-line,
.item-inner-line {
@include hairline(bottom);

color: var(--border-color);

:host(.item-lines-inset) {
--inner-border-width: #{0px 0px $item-ios-border-bottom-width 0px};
// Painted like a border: above the native element's background,
// below the item's content
z-index: -1;
}

// Full lines - remove the border from the item inner (inset list items)
// Inset lines - remove the border on the item (full list items)
// No lines - remove the border on both (full / inset list items)
:host(.item-lines-inset),
:host(.item-lines-none) {
--border-width: 0px;
:host(.ion-color) .item-line,
:host(.ion-color) .item-inner-line {
color: current-color(shade);
}

:host(.item-lines-full),
:host(.item-lines-none) {
--inner-border-width: 0px;
// The inset line is the default, and `lines` picks the full line or neither.
:host(.item-lines-default) .item-inner-line,
:host(.item-lines-inset) .item-inner-line,
:host(.item-lines-full) .item-line {
display: block;
}

// iOS Item Slots
Expand Down
10 changes: 10 additions & 0 deletions core/src/components/item/item.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@ const INDICATOR_CONTROL_SELECTOR = 'ion-checkbox, ion-radio, ion-toggle';
* @part inner - The inner wrapper element that arranges the item content.
* @part container - The wrapper element that contains the default slot.
* @part detail-icon - The chevron icon for the item. Only applies when `detail="true"`.
* @part line - The full-width line at the bottom of the item. Only applies to the ios theme.
* @part inner-line - The inset line at the bottom of the item content. Only applies to the ios theme.
*/
@Component({
tag: 'ion-item',
Expand Down Expand Up @@ -504,6 +506,12 @@ export class Item implements ComponentInterface, AnchorInterface, ButtonInterfac
}

const showDetail = detail !== undefined ? detail : theme === 'ios' && clickable;
/**
* Without `lines`, both render so a parent list's `lines` can pick one.
* The theme's stylesheet decides whether they show.
*/
const showLine = lines === undefined || lines === 'full';
const showInnerLine = lines === undefined || lines === 'inset';
this.itemStyles.forEach((value) => {
Object.assign(childStyles, value);
});
Expand Down Expand Up @@ -572,7 +580,9 @@ export class Item implements ComponentInterface, AnchorInterface, ButtonInterfac
flip-rtl={shouldFlipIcon}
></ion-icon>
)}
{showInnerLine && <div class="item-inner-line" part="inner-line"></div>}
</div>
{showLine && <div class="item-line" part="line"></div>}
{canActivate && theme === 'md' && <ion-ripple-effect></ion-ripple-effect>}
</TagType>
</Host>
Expand Down
Loading