Skip to content

Commit

Permalink
Merge branch 'next' of github.com:ionic-team/ionic-framework into ROU…
Browse files Browse the repository at this point in the history
…-11318
  • Loading branch information
thetaPC committed Nov 14, 2024
2 parents c5cf023 + bc3d30c commit fe821e2
Show file tree
Hide file tree
Showing 40 changed files with 187 additions and 48 deletions.
2 changes: 1 addition & 1 deletion core/api.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2064,7 +2064,7 @@ ion-select,prop,name,string,this.inputId,false,false
ion-select,prop,okText,string,'OK',false,false
ion-select,prop,placeholder,string | undefined,undefined,false,false
ion-select,prop,selectedText,null | string | undefined,undefined,false,false
ion-select,prop,shape,"round" | undefined,undefined,false,false
ion-select,prop,shape,"rectangular" | "round" | "soft" | undefined,undefined,false,false
ion-select,prop,size,"large" | "medium" | "small" | undefined,undefined,false,false
ion-select,prop,theme,"ios" | "md" | "ionic",undefined,false,false
ion-select,prop,toggleIcon,string | undefined,undefined,false,false
Expand Down
8 changes: 4 additions & 4 deletions core/src/components.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3280,9 +3280,9 @@ export namespace Components {
*/
"selectedText"?: string | null;
/**
* The shape of the select. If "round" it will have an increased border radius.
* Set to `"soft"` for a select with slightly rounded corners, `"round"` for a select with fully rounded corners, or `"rectangular"` for a select without rounded corners. Defaults to `"round"` for the `"ionic"` theme, undefined for all other themes.
*/
"shape"?: 'round';
"shape"?: 'soft' | 'round' | 'rectangular';
/**
* Set to `"small"` for a select with less height, `"medium"` for the default select height, or `"large"` for a select with more height. Defaults to `"medium"` for the ionic theme, and undefined for all other themes.
*/
Expand Down Expand Up @@ -8708,9 +8708,9 @@ declare namespace LocalJSX {
*/
"selectedText"?: string | null;
/**
* The shape of the select. If "round" it will have an increased border radius.
* Set to `"soft"` for a select with slightly rounded corners, `"round"` for a select with fully rounded corners, or `"rectangular"` for a select without rounded corners. Defaults to `"round"` for the `"ionic"` theme, undefined for all other themes.
*/
"shape"?: 'round';
"shape"?: 'soft' | 'round' | 'rectangular';
/**
* Set to `"small"` for a select with less height, `"medium"` for the default select height, or `"large"` for a select with more height. Defaults to `"medium"` for the ionic theme, and undefined for all other themes.
*/
Expand Down
19 changes: 17 additions & 2 deletions core/src/components/select/select.ionic.scss
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
// TODO(ROU-10778, ROU-10875): Sync the color names to the design system of
// ios and md. This will allow us to have a single color map.
--border-color: #{globals.current-color(neutral)};
--border-radius: #{globals.$ion-border-radius-400};
--border-width: #{globals.$ion-border-size-025};
--padding-start: #{globals.$ion-space-400};
--padding-end: #{globals.$ion-space-400};
Expand Down Expand Up @@ -168,7 +167,7 @@
// ----------------------------------------------------------------

// Disabled
// ----------------------------------------------------------------
// ---------------------------------------------

:host(.select-disabled) {
--background: #{globals.$ion-primitives-neutral-100};
Expand All @@ -182,6 +181,21 @@
color: globals.$ion-primitives-neutral-500;
}

// Shapes
// ----------------------------------------------------------------

:host(.select-shape-soft) {
--border-radius: #{globals.$ion-border-radius-200};
}

:host(.select-shape-round) {
--border-radius: #{globals.$ion-border-radius-400};
}

:host(.select-shape-rectangular) {
--border-radius: #{globals.$ion-border-radius-0};
}

// Sizes
// ----------------------------------------------------------------

Expand All @@ -196,3 +210,4 @@
:host(.select-size-large) .select-wrapper-inner {
height: globals.$ion-scale-1400;
}

24 changes: 20 additions & 4 deletions core/src/components/select/select.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -191,9 +191,13 @@ export class Select implements ComponentInterface {
@Prop() expandedIcon?: string;

/**
* The shape of the select. If "round" it will have an increased border radius.
* Set to `"soft"` for a select with slightly rounded corners,
* `"round"` for a select with fully rounded corners,
* or `"rectangular"` for a select without rounded corners.
*
* Defaults to `"round"` for the `"ionic"` theme, undefined for all other themes.
*/
@Prop() shape?: 'round';
@Prop() shape?: 'soft' | 'round' | 'rectangular';

/**
* The value of the select.
Expand Down Expand Up @@ -1015,6 +1019,18 @@ export class Select implements ComponentInterface {
);
}

private getShape(): string | undefined {
const theme = getIonTheme(this);
const { shape } = this;

// TODO(ROU-11366): Remove theme check when shapes are defined for all themes.
if (theme === 'ionic' && shape === undefined) {
return 'round';
}

return shape;
}

/**
* Get the icon to use for the expand icon.
* If an icon is set on the component, use that.
Expand Down Expand Up @@ -1071,9 +1087,9 @@ export class Select implements ComponentInterface {
}

render() {
const { disabled, el, isExpanded, expandedIcon, labelPlacement, justify, placeholder, fill, shape, name, value } =
this;
const { disabled, el, isExpanded, expandedIcon, labelPlacement, justify, placeholder, fill, name, value } = this;
const theme = getIonTheme(this);
const shape = this.getShape();
const hasFloatingOrStackedLabel = labelPlacement === 'floating' || labelPlacement === 'stacked';
const shouldRenderOuterIcon = theme !== 'ionic' && hasFloatingOrStackedLabel;
const shouldRenderInnerIcon = theme === 'ionic' || !hasFloatingOrStackedLabel;
Expand Down
37 changes: 0 additions & 37 deletions core/src/components/select/test/fill/select.e2e.ts
Original file line number Diff line number Diff line change
Expand Up @@ -89,24 +89,6 @@ configs({ modes: ['md'] }).forEach(({ title, screenshot, config }) => {
const select = page.locator('ion-select');
await expect(select).toHaveScreenshot(screenshot(`select-fill-solid-label-floating`));
});
test('should not have visual regressions with shaped solid', async ({ page }) => {
await page.setContent(
`
<ion-select
shape="round"
fill="solid"
label="Fruit"
value="apple"
>
<ion-select-option value="apple">Apple</ion-select-option>
</ion-select>
`,
config
);

const select = page.locator('ion-select');
await expect(select).toHaveScreenshot(screenshot(`select-fill-shaped-solid`));
});
test('padding and border radius should be customizable', async ({ page }) => {
await page.setContent(
`
Expand Down Expand Up @@ -153,25 +135,6 @@ configs({ modes: ['md'] }).forEach(({ title, screenshot, config }) => {
const select = page.locator('ion-select');
await expect(select).toHaveScreenshot(screenshot(`select-fill-outline-label-floating`));
});

test('should not have visual regressions with shaped outline', async ({ page }) => {
await page.setContent(
`
<ion-select
shape="round"
fill="outline"
label="Fruit"
value="apple"
>
<ion-select-option value="apple">Apple</ion-select-option>
</ion-select>
`,
config
);

const select = page.locator('ion-select');
await expect(select).toHaveScreenshot(screenshot(`select-fill-shaped-outline`));
});
});
});
});
Expand Down
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
69 changes: 69 additions & 0 deletions core/src/components/select/test/shape/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
<!DOCTYPE html>
<html lang="en" dir="ltr">
<head>
<meta charset="UTF-8" />
<title>Select - Shape</title>
<meta
name="viewport"
content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=no"
/>
<link href="../../../../../css/ionic.bundle.css" rel="stylesheet" />
<link href="../../../../../scripts/testing/styles.css" rel="stylesheet" />
<script src="../../../../../scripts/testing/scripts.js"></script>
<script nomodule src="../../../../../dist/ionic/ionic.js"></script>
<script type="module" src="../../../../../dist/ionic/ionic.esm.js"></script>

<style>
h2 {
font-size: 12px;
font-weight: normal;

color: #6f7378;

margin-top: 10px;
}
</style>
</head>

<body>
<ion-app>
<ion-header>
<ion-toolbar>
<ion-title>Select - Shape</ion-title>
</ion-toolbar>
</ion-header>

<ion-content class="ion-padding">
<div class="grid">
<div class="grid-item">
<h2>Default</h2>
<ion-select shape="round" fill="outline" label="Label" label-placement="stacked" value="filledText">
<ion-select-option value="filledText">Filled text</ion-select-option>
</ion-select>
</div>

<div class="grid-item">
<h2>Soft</h2>
<ion-select shape="soft" fill="outline" label="Label" label-placement="stacked" value="filledText">
<ion-select-option value="filledText">Filled text</ion-select-option>
</ion-select>
</div>

<div class="grid-item">
<h2>Round</h2>
<ion-select shape="round" fill="outline" label="Label" label-placement="stacked" value="filledText">
<ion-select-option value="filledText">Filled text</ion-select-option>
</ion-select>
</div>

<div class="grid-item">
<h2>Rectangular</h2>
<ion-select shape="rectangular" fill="outline" label="Label" label-placement="stacked" value="filledText">
<ion-select-option value="filledText">Filled text</ion-select-option>
</ion-select>
</div>
</div>
</ion-content>
</ion-app>
</body>
</html>
76 changes: 76 additions & 0 deletions core/src/components/select/test/shape/select.e2e.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
import { expect } from '@playwright/test';
import { configs, test } from '@utils/test/playwright';

/**
* This behavior does not vary across directions.
*/
configs({ modes: ['ionic-md'], directions: ['ltr'] }).forEach(({ config, screenshot, title }) => {
test.describe(title('select: shape'), () => {
['soft', 'round', 'rectangular'].forEach((shape) => {
test(`${shape} - should not have visual regressions with outline fill`, async ({ page }) => {
await page.setContent(
`
<ion-select
shape="${shape}"
fill="outline"
label="Label"
label-placement="stacked"
value="filledText"
>
<ion-select-option value="filledText">Filled text</ion-select-option>
</ion-select>
`,
config
);

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

await expect(select).toHaveScreenshot(screenshot(`select-shape-${shape}-fill-outline`));
});
});
});
});

configs({ modes: ['md'] }).forEach(({ config, screenshot, title }) => {
test.describe(title('select: shape'), () => {
test('round - should not have visual regressions with outline fill', async ({ page }) => {
await page.setContent(
`
<ion-select
shape="round"
fill="outline"
label="Label"
label-placement="stacked"
value="filledText"
>
<ion-select-option value="filledText">Filled text</ion-select-option>
</ion-select>
`,
config
);

const select = page.locator('ion-select');
await expect(select).toHaveScreenshot(screenshot(`select-shape-round-fill-outline`));
});

test('round - should not have visual regressions with solid fill', async ({ page }) => {
await page.setContent(
`
<ion-select
shape="round"
fill="solid"
label="Label"
label-placement="stacked"
value="filledText"
>
<ion-select-option value="filledText">Filled text</ion-select-option>
</ion-select>
`,
config
);

const select = page.locator('ion-select');
await expect(select).toHaveScreenshot(screenshot(`select-shape-round-fill-solid`));
});
});
});
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.

0 comments on commit fe821e2

Please sign in to comment.