Skip to content
Merged
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
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion BREAKING.md
Original file line number Diff line number Diff line change
Expand Up @@ -360,7 +360,7 @@ The `default` value of the `fill` property is deprecated. It logs a warning and
- `IonChip.hue.bold.outline.activated.background` to `rgba(var(--ion-text-color-rgb, 0, 0, 0), 0.08)`
- `IonChip.hue.bold.solid.semantic.activated.background` and `IonChip.hue.bold.outline.semantic.activated.background` to `rgba(var(--ion-color-base-rgb), 0.16)`
- In the `md` theme, a disabled chip now has an opacity of `0.38` instead of `0.4`, in accordance with the Material Design 2 guidelines. To revert to the previous appearance, set `IonChip.state.disabled.opacity` to `0.4` for global styles, or `--ion-chip-state-disabled-opacity` for component-specific styles.
- In the `ios` theme, the chip is now `28px` tall instead of `32px`, with `4px` `10px` padding instead of `6px` `12px`, and its label is `15px` with a `20px` line height and `-0.016em` letter spacing instead of `14px` with inherited line height and letter spacing, in accordance with the iOS guidelines for small bezeled buttons. To revert to the previous appearance, set `IonChip.size.large.min.height` to `32px`, `IonChip.size.large.padding` to `6px` on the top and bottom and `12px` on the start and end, `IonChip.size.large.font.size` to `clamp(13px, 0.875rem, 22px)`, `IonChip.size.large.line.height` and `IonChip.size.large.letterSpacing` to `inherit`, `IonChip.icon.font.size` to `1.43em`, and `IonChip.avatar.width` and `IonChip.avatar.height` to `1.71em` for global styles, or the matching `--ion-chip-size-large-*`, `--ion-chip-icon-font-size` and `--ion-chip-avatar-*` variables for component-specific styles.
- In the `ios` theme, the chip is now `28px` tall instead of `32px`, with `4px` `10px` padding instead of `6px` `12px`, and its label is `15px` with a `20px` line height and `-0.016em` letter spacing instead of `14px` with inherited line height and letter spacing, in accordance with the iOS guidelines for small bezeled buttons. To revert to the previous appearance, set `IonChip.size.large.min.height` to `32px`, `IonChip.size.large.padding` to `6px` on the top and bottom and `12px` on the start and end, `IonChip.size.large.font.size` to `clamp(13px, 0.875rem, 22px)`, `IonChip.size.large.line.height` and `IonChip.size.large.letterSpacing` to `inherit`, `IonChip.size.large.icon.font.size` to `1.43em`, and `IonChip.avatar.width` and `IonChip.avatar.height` to `1.71em` for global styles, or the matching `--ion-chip-size-large-*` and `--ion-chip-avatar-*` variables for component-specific styles.
- In the `ios` theme, a slotted `ion-icon` now has `4px` of space between it and the label instead of `8px`, in accordance with the iOS guidelines for buttons with an icon and a label. To revert to the previous appearance, set `IonChip.icon.leading.margin.end` and `IonChip.icon.trailing.margin.start` to `8px` for global styles, or `--ion-chip-icon-leading-margin-end` and `--ion-chip-icon-trailing-margin-start` for component-specific styles.
- In the `ios` theme, a chip with a `color` now has a background of `15%` of the color instead of `8%`, in accordance with the iOS guidelines for bezeled buttons. Its hover and focus backgrounds are now `19%` instead of `12%`, and its pressed background `23%` instead of `16%`. To revert to the previous appearance, set `IonChip.hue.bold.solid.semantic.default.background`, `IonChip.hue.bold.solid.semantic.hover.background`, `IonChip.hue.bold.solid.semantic.focus.background` and `IonChip.hue.bold.solid.semantic.activated.background` for global styles, or the matching `--ion-chip-hue-bold-solid-semantic-*-background` variables for component-specific styles.
- In the `ios` theme, a disabled chip now has an opacity of `0.5` instead of `0.4`, to match the disabled `ios` button. To revert to the previous appearance, set `IonChip.state.disabled.opacity` to `0.4` for global styles, or `--ion-chip-state-disabled-opacity` for component-specific styles.
Expand Down
3 changes: 2 additions & 1 deletion core/api.txt
Original file line number Diff line number Diff line change
Expand Up @@ -1072,7 +1072,6 @@ ion-chip,css-prop,--ion-chip-hue-subtle-solid-semantic-default-color
ion-chip,css-prop,--ion-chip-hue-subtle-solid-semantic-focus-background
ion-chip,css-prop,--ion-chip-hue-subtle-solid-semantic-hover-background
ion-chip,css-prop,--ion-chip-icon-color
ion-chip,css-prop,--ion-chip-icon-font-size
ion-chip,css-prop,--ion-chip-icon-leading-margin-bottom
ion-chip,css-prop,--ion-chip-icon-leading-margin-end
ion-chip,css-prop,--ion-chip-icon-leading-margin-start
Expand All @@ -1097,6 +1096,7 @@ ion-chip,css-prop,--ion-chip-size-large-avatar-trailing-margin-end
ion-chip,css-prop,--ion-chip-size-large-avatar-trailing-margin-start
ion-chip,css-prop,--ion-chip-size-large-avatar-trailing-margin-top
ion-chip,css-prop,--ion-chip-size-large-font-size
ion-chip,css-prop,--ion-chip-size-large-icon-font-size
ion-chip,css-prop,--ion-chip-size-large-letter-spacing
ion-chip,css-prop,--ion-chip-size-large-line-height
ion-chip,css-prop,--ion-chip-size-large-min-height
Expand All @@ -1113,6 +1113,7 @@ ion-chip,css-prop,--ion-chip-size-small-avatar-trailing-margin-end
ion-chip,css-prop,--ion-chip-size-small-avatar-trailing-margin-start
ion-chip,css-prop,--ion-chip-size-small-avatar-trailing-margin-top
ion-chip,css-prop,--ion-chip-size-small-font-size
ion-chip,css-prop,--ion-chip-size-small-icon-font-size
ion-chip,css-prop,--ion-chip-size-small-letter-spacing
ion-chip,css-prop,--ion-chip-size-small-line-height
ion-chip,css-prop,--ion-chip-size-small-min-height
Expand Down
10 changes: 6 additions & 4 deletions core/src/components/chip/chip.interface.ts
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,12 @@ type IonChipSizeDefinition = {
height?: string | number;
};

icon?: {
font?: {
size?: string | number;
};
};

avatar?: IonChipMediaDefinition;
};

Expand All @@ -106,10 +112,6 @@ type IonChipMediaDefinition = {

type IonChipIconDefinition = IonChipMediaDefinition & {
color?: string;

font?: {
size?: string | number;
};
};

type IonChipAvatarDefinition = {
Expand Down
9 changes: 6 additions & 3 deletions core/src/components/chip/chip.scss
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
* @prop --ion-chip-size-small-min-height: Minimum height of the `small` chip size
* @prop --ion-chip-size-small-font-size: Font size of the `small` chip size
* @prop --ion-chip-size-small-line-height: Line height of the `small` chip size
* @prop --ion-chip-size-small-icon-font-size: Font size of the slotted `ion-icon` of the `small` chip size
* @prop --ion-chip-size-small-avatar-leading-margin-top: Top margin of the slotted `ion-avatar` when it is the first child of the `small` chip size
* @prop --ion-chip-size-small-avatar-leading-margin-end: Right margin if direction is left-to-right, and left margin if direction is right-to-left of the slotted `ion-avatar` when it is the first child of the `small` chip size
* @prop --ion-chip-size-small-avatar-leading-margin-bottom: Bottom margin of the slotted `ion-avatar` when it is the first child of the `small` chip size
Expand All @@ -38,6 +39,7 @@
* @prop --ion-chip-size-large-min-height: Minimum height of the `large` chip size
* @prop --ion-chip-size-large-font-size: Font size of the `large` chip size
* @prop --ion-chip-size-large-line-height: Line height of the `large` chip size
* @prop --ion-chip-size-large-icon-font-size: Font size of the slotted `ion-icon` of the `large` chip size
* @prop --ion-chip-size-large-avatar-leading-margin-top: Top margin of the slotted `ion-avatar` when it is the first child of the `large` chip size
* @prop --ion-chip-size-large-avatar-leading-margin-end: Right margin if direction is left-to-right, and left margin if direction is right-to-left of the slotted `ion-avatar` when it is the first child of the `large` chip size
* @prop --ion-chip-size-large-avatar-leading-margin-bottom: Bottom margin of the slotted `ion-avatar` when it is the first child of the `large` chip size
Expand Down Expand Up @@ -120,7 +122,6 @@
*
* Slotted Icon
* @prop --ion-chip-icon-color: Color of the slotted `ion-icon`
* @prop --ion-chip-icon-font-size: Font size of the slotted `ion-icon`
* @prop --ion-chip-icon-leading-margin-top: Top margin of the slotted `ion-icon` when it is the first child
* @prop --ion-chip-icon-leading-margin-end: Right margin if direction is left-to-right, and left margin if direction is right-to-left of the slotted `ion-icon` when it is the first child
* @prop --ion-chip-icon-leading-margin-bottom: Bottom margin of the slotted `ion-icon` when it is the first child
Expand Down Expand Up @@ -551,8 +552,10 @@
// ---------------------------------------------

// Icon
::slotted(ion-icon) {
font-size: var(--ion-chip-icon-font-size);
@each $size in (small, large) {
:host(.chip-size-#{$size}) ::slotted(ion-icon) {
font-size: var(--ion-chip-size-#{$size}-icon-font-size);
}
Comment thread
brandyscarney marked this conversation as resolved.
Resolved
}

:host(:not(.ion-color)) ::slotted(ion-icon) {
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.
43 changes: 43 additions & 0 deletions core/src/components/chip/test/size/chip.e2e.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,21 @@
import { expect } from '@playwright/test';
import { configs, test } from '@utils/test/playwright';

import type { IonChipSize } from '../../chip.interface';
import { ION_CHIP_SIZES } from '../../chip.interface';

const AVATAR_SRC =
'data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHZpZXdCb3g9IjAgMCA1MTIgNTEyIj48cGF0aCBmaWxsPSIjYzVkYmZmIiBkPSJNMCAwaDUxMnY1MTJIMHoiLz48cGF0aCBkPSJNMjU2IDMwNGM2MS42IDAgMTEyLTUwLjQgMTEyLTExMlMzMTcuNiA4MCAyNTYgODBzLTExMiA1MC40LTExMiAxMTIgNTAuNCAxMTIgMTEyIDExMnptMCA0MGMtNzQuMiAwLTIyNCAzNy44LTIyNCAxMTJ2NTZoNDQ4di01NmMwLTc0LjItMTQ5LjgtMTEyLTIyNC0xMTJ6IiBmaWxsPSIjODJhZWZmIi8+PC9zdmc+';

/**
* The avatar size that fits each chip size. Only the ionic theme
* lets the avatar's `size` prop set its size inside a chip.
*/
const AVATAR_SIZES: Record<IonChipSize, string> = {
small: 'xxsmall',
large: 'xsmall',
};

/**
* This behavior does not vary across directions.
*/
Expand All @@ -21,6 +34,36 @@ configs({ modes: ['ionic-md', 'md', 'ios'], directions: ['ltr'] }).forEach(({ ti

await expect(chip).toHaveScreenshot(screenshot(`chip-size-${size}`));
});

test(`should render ${size} chip with an icon`, async ({ page }) => {
await page.setContent(
`<ion-chip size="${size}">
<ion-icon name="calendar-outline"></ion-icon>
<ion-label>Icon</ion-label>
</ion-chip>`,
config
);

const chip = page.locator('ion-chip');

await expect(chip).toHaveScreenshot(screenshot(`chip-size-${size}-icon`));
});

test(`should render ${size} chip with an avatar`, async ({ page }) => {
await page.setContent(
`<ion-chip size="${size}">
<ion-avatar size="${AVATAR_SIZES[size]}">
<img src="${AVATAR_SRC}" />
</ion-avatar>
<ion-label>Avatar</ion-label>
</ion-chip>`,
config
);

const chip = page.locator('ion-chip');

await expect(chip).toHaveScreenshot(screenshot(`chip-size-${size}-avatar`));
});
});
});
});
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
130 changes: 104 additions & 26 deletions core/src/themes/ionic/default.tokens.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1319,9 +1319,9 @@ export const defaultTheme: DefaultTheme = {
size: {
small: {
padding: {
top: 'var(--ion-spacing-xs)',
top: 'var(--ion-spacing-0)',
end: 'var(--ion-spacing-sm)',
bottom: 'var(--ion-spacing-xs)',
bottom: 'var(--ion-spacing-0)',
start: 'var(--ion-spacing-sm)',
},

Expand All @@ -1334,14 +1334,40 @@ export const defaultTheme: DefaultTheme = {
size: 'var(--ion-font-size-xs)',
},
line: {
height: '100%',
height: dynamicFont(global.root, 20),
},

icon: {
font: {
size: 'var(--ion-scaling-xxxxs)',
},
},

avatar: {
leading: {
margin: {
top: 'var(--ion-spacing-0)',
end: 'var(--ion-spacing-0)',
bottom: 'var(--ion-spacing-0)',
start: '-4px',
},
},

trailing: {
margin: {
top: 'var(--ion-spacing-0)',
end: '-4px',
bottom: 'var(--ion-spacing-0)',
start: 'var(--ion-spacing-0)',
},
},
},
},
large: {
padding: {
top: 'var(--ion-spacing-xs)',
top: 'var(--ion-spacing-0)',
end: 'var(--ion-spacing-sm)',
bottom: 'var(--ion-spacing-xs)',
bottom: 'var(--ion-spacing-0)',
start: 'var(--ion-spacing-sm)',
},

Expand All @@ -1351,10 +1377,36 @@ export const defaultTheme: DefaultTheme = {
height: 'var(--ion-scaling-md)',
},
font: {
size: 'var(--ion-font-size-sm)',
size: 'var(--ion-font-size-xs)',
},
line: {
height: '100%',
height: dynamicFont(global.root, 20),
},

icon: {
font: {
size: 'var(--ion-scaling-xxxs)',
},
},

avatar: {
leading: {
margin: {
top: 'var(--ion-spacing-0)',
end: 'var(--ion-spacing-0)',
bottom: 'var(--ion-spacing-0)',
start: '-4px',
},
},

trailing: {
margin: {
top: 'var(--ion-spacing-0)',
end: '-4px',
bottom: 'var(--ion-spacing-0)',
start: 'var(--ion-spacing-0)',
},
},
},
},
},
Expand Down Expand Up @@ -1398,44 +1450,60 @@ export const defaultTheme: DefaultTheme = {
solid: {
// Default non-semantic states
default: {
background: '#3b3b3b',
background: '#383e45',
color: '#ffffff',
},

hover: {
Comment thread
brandyscarney marked this conversation as resolved.
Resolved
background: '#31373d',
},

// Any of the semantic colors like primary, secondary, etc.
semantic: {
default: {
background: currentColor('base'),
color: currentColor('contrast'),
},

hover: {
background: currentColor('shade'),
},
},
},

outline: {
// Default non-semantic states
default: {
background: '#3b3b3b',
color: '#ffffff',
background: 'transparent',
color: '#383e45',

border: {
color: '#242424',
color: '#383e45',
style: 'solid',
width: '1px',
},
},

hover: {
background: '#f6f7fa',
},

// Any of the semantic colors like primary, secondary, etc.
semantic: {
default: {
background: currentColor('base'),
color: currentColor('contrast'),
background: 'transparent',
color: currentColor('foreground'),

border: {
color: currentColor('shade'),
color: currentColor('base'),
style: 'solid',
width: '1px',
},
},

hover: {
background: currentColor('shade', { subtle: true }),
},
},
},
},
Expand All @@ -1444,8 +1512,12 @@ export const defaultTheme: DefaultTheme = {
solid: {
// Default non-semantic states
default: {
background: '#f3f3f3',
color: '#626262',
background: '#f6f7fa',
color: '#6c727a',
},

hover: {
background: '#e6eaee',
},

// Any of the semantic colors like primary, secondary, etc.
Expand All @@ -1454,14 +1526,18 @@ export const defaultTheme: DefaultTheme = {
background: currentColor('base', { subtle: true }),
color: currentColor('contrast', { subtle: true }),
},

hover: {
background: currentColor('shade', { subtle: true }),
},
},
},

outline: {
// Default non-semantic states
default: {
background: '#f3f3f3',
color: '#626262',
background: 'transparent',
color: '#6c727a',

border: {
color: '#e0e0e0',
Expand All @@ -1470,28 +1546,30 @@ export const defaultTheme: DefaultTheme = {
},
},

hover: {
background: '#f6f7fa',
},

// Any of the semantic colors like primary, secondary, etc.
semantic: {
default: {
background: currentColor('base', { subtle: true }),
color: currentColor('contrast', { subtle: true }),
background: 'transparent',
color: currentColor('foreground', { subtle: true }),

border: {
color: currentColor('shade', { subtle: true }),
style: 'solid',
width: '1px',
},
},

hover: {
background: currentColor('shade', { subtle: true }),
},
},
},
},
},

icon: {
font: {
size: 'var(--ion-scaling-xxxs)',
},
},
},

IonCol: {
Expand Down
Loading
Loading