Skip to content
Merged
Show file tree
Hide file tree
Changes from 7 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
1 change: 1 addition & 0 deletions core/api.txt
Original file line number Diff line number Diff line change
Expand Up @@ -1661,6 +1661,7 @@ ion-progress-bar,prop,buffer,number,1,false,false
ion-progress-bar,prop,color,"danger" | "dark" | "light" | "medium" | "primary" | "secondary" | "success" | "tertiary" | "warning" | string & Record<never, never> | undefined,undefined,false,true
ion-progress-bar,prop,mode,"ios" | "md",undefined,false,false
ion-progress-bar,prop,reversed,boolean,false,false,false
ion-progress-bar,prop,shape,"rectangular" | "round" | undefined,undefined,false,false
ion-progress-bar,prop,theme,"ios" | "md" | "ionic",undefined,false,false
ion-progress-bar,prop,type,"determinate" | "indeterminate",'determinate',false,false
ion-progress-bar,prop,value,number,0,false,false
Expand Down
8 changes: 8 additions & 0 deletions core/src/components.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2609,6 +2609,10 @@ export namespace Components {
* If true, reverse the progress bar direction.
*/
"reversed": boolean;
/**
* Set to `"round"` for a progress bar with rounded corners, or `"rectangular"` for a progress bar without rounded corners. Defaults to `"round"` for the `ionic` theme, undefined for all other themes.
*/
"shape"?: 'round' | 'rectangular';
/**
* The theme determines the visual appearance of the component.
*/
Expand Down Expand Up @@ -7959,6 +7963,10 @@ declare namespace LocalJSX {
* If true, reverse the progress bar direction.
*/
"reversed"?: boolean;
/**
* Set to `"round"` for a progress bar with rounded corners, or `"rectangular"` for a progress bar without rounded corners. Defaults to `"round"` for the `ionic` theme, undefined for all other themes.
*/
"shape"?: 'round' | 'rectangular';
/**
* The theme determines the visual appearance of the component.
*/
Expand Down
22 changes: 22 additions & 0 deletions core/src/components/progress-bar/progress-bar.ionic.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
@use "../../themes/ionic/ionic.globals.scss" as globals;
@use "./progress-bar";

// Ionic Progress bar
// --------------------------------------------------

:host {
--background: #{globals.$ion-bg-neutral-subtle-default};

height: globals.$ion-scale-100;
}

// Progress Bar Shapes
// -------------------------------------------------------------------------------

:host(.progress-bar-shape-round) {
@include globals.border-radius(globals.$ion-border-radius-full);
}

:host(.progress-bar-shape-rectangular) {
@include globals.border-radius(globals.$ion-border-radius-0);
}
28 changes: 27 additions & 1 deletion core/src/components/progress-bar/progress-bar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ import type { Color } from '../../interface';
styleUrls: {
ios: 'progress-bar.ios.scss',
md: 'progress-bar.md.scss',
ionic: 'progress-bar.md.scss',
ionic: 'progress-bar.ionic.scss',
},
shadow: true,
})
Expand Down Expand Up @@ -57,10 +57,35 @@ export class ProgressBar implements ComponentInterface {
*/
@Prop({ reflect: true }) color?: Color;

/**
* Set to `"round"` for a progress bar with rounded corners, or `"rectangular"`
* for a progress bar without rounded corners.
*
* Defaults to `"round"` for the `ionic` theme, undefined for all other themes.
*/
@Prop() shape?: 'round' | 'rectangular';

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

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

if (shape === undefined) {
return 'round';
}

return shape;
}

render() {
const { color, type, reversed, value, buffer } = this;
const paused = config.getBoolean('_testing');
const theme = getIonTheme(this);
const shape = this.getShape();
// If the progress is displayed as a solid bar.
const progressSolid = buffer === 1;
return (
Expand All @@ -75,6 +100,7 @@ export class ProgressBar implements ComponentInterface {
'progress-paused': paused,
'progress-bar-reversed': document.dir === 'rtl' ? !reversed : reversed,
'progress-bar-solid': progressSolid,
[`progress-bar-shape-${shape}`]: shape !== undefined,
})}
>
{type === 'indeterminate' ? renderIndeterminate() : renderProgress(value, buffer)}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { expect } from '@playwright/test';
import { configs, test } from '@utils/test/playwright';

configs().forEach(({ title, screenshot, config }) => {
configs({ modes: ['ios', 'md', 'ionic-md'] }).forEach(({ title, screenshot, config }) => {
test.describe(title('progress-bar: basic'), () => {
test('should not have visual regressions', async ({ page }) => {
await page.goto('/src/components/progress-bar/test/basic', config);
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.
51 changes: 51 additions & 0 deletions core/src/components/progress-bar/test/shape/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
<!DOCTYPE html>
<html lang="en" dir="ltr">
<head>
<meta charset="UTF-8" />
<title>Progress Bar - 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>
</head>

<body>
<ion-app>
<ion-header>
<ion-toolbar>
<ion-title>Progress Bar - Shape</ion-title>
</ion-toolbar>
</ion-header>

<ion-content class="ion-padding">
<ion-list lines="none">
<ion-list-header>
<ion-label> Default </ion-label>
</ion-list-header>
<ion-item>
<ion-progress-bar value="0.50"></ion-progress-bar>
</ion-item>

<ion-list-header>
<ion-label> Round </ion-label>
</ion-list-header>
<ion-item>
<ion-progress-bar value="0.50" shape="round"></ion-progress-bar>
</ion-item>

<ion-list-header>
<ion-label> Rectangular </ion-label>
</ion-list-header>
<ion-item>
<ion-progress-bar value="0.50" shape="rectangular"></ion-progress-bar>
</ion-item>
</ion-list>
</ion-content>
</ion-app>
</body>
</html>
56 changes: 56 additions & 0 deletions core/src/components/progress-bar/test/shape/progress-bar.e2e.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
import { expect } from '@playwright/test';
import { configs, test } from '@utils/test/playwright';

configs({ directions: ['ltr'], modes: ['ionic-md'] }).forEach(({ title, screenshot, config }) => {
test.describe(title('progress-bar: shape'), () => {
test('round - should not have visual regressions', async ({ page }) => {
await page.setContent(
`
<style>
:root {
background: #ccc7c7;
}

.container {
padding: 10px;
}
</style>

<div class="container">
<ion-progress-bar value="0.50" shape="round"></ion-progress-bar>
</div>
`,
config
);

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

await expect(container).toHaveScreenshot(screenshot(`progress-bar-shape-round`));
});

test('rectangular - should not have visual regressions', async ({ page }) => {
await page.setContent(
`
<style>
:root {
background: #ccc7c7;
}

.container {
padding: 10px;
}
</style>

<div class="container">
<ion-progress-bar value="0.50" shape="rectangular"></ion-progress-bar>
</div>
`,
config
);

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

await expect(container).toHaveScreenshot(screenshot(`progress-bar-shape-rectangular`));
});
});
});
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Delete the shape snapshots and re-generate them. Playwright isn't able to detect the background change to buffer. That's why we need to force a re-generation. Background shouldn't be white, but neutral 100.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have regenerated the screenshots but no changes were made in the regeneration. I think the bar background looks white in comparison with #ccc7c7 colour we set to the container background, which is more gray-ish, but in reality it's not white.

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.
4 changes: 2 additions & 2 deletions packages/angular/src/directives/proxies.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1589,14 +1589,14 @@ Shorthand for ionPickerDidDismiss.


@ProxyCmp({
inputs: ['buffer', 'color', 'mode', 'reversed', 'theme', 'type', 'value']
inputs: ['buffer', 'color', 'mode', 'reversed', 'shape', 'theme', 'type', 'value']
})
@Component({
selector: 'ion-progress-bar',
changeDetection: ChangeDetectionStrategy.OnPush,
template: '<ng-content></ng-content>',
// eslint-disable-next-line @angular-eslint/no-inputs-metadata-property
inputs: ['buffer', 'color', 'mode', 'reversed', 'theme', 'type', 'value'],
inputs: ['buffer', 'color', 'mode', 'reversed', 'shape', 'theme', 'type', 'value'],
})
export class IonProgressBar {
protected el: HTMLElement;
Expand Down
4 changes: 2 additions & 2 deletions packages/angular/standalone/src/directives/proxies.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1593,14 +1593,14 @@ Shorthand for ionPickerDidDismiss.

@ProxyCmp({
defineCustomElementFn: defineIonProgressBar,
inputs: ['buffer', 'color', 'mode', 'reversed', 'theme', 'type', 'value']
inputs: ['buffer', 'color', 'mode', 'reversed', 'shape', 'theme', 'type', 'value']
})
@Component({
selector: 'ion-progress-bar',
changeDetection: ChangeDetectionStrategy.OnPush,
template: '<ng-content></ng-content>',
// eslint-disable-next-line @angular-eslint/no-inputs-metadata-property
inputs: ['buffer', 'color', 'mode', 'reversed', 'theme', 'type', 'value'],
inputs: ['buffer', 'color', 'mode', 'reversed', 'shape', 'theme', 'type', 'value'],
standalone: true
})
export class IonProgressBar {
Expand Down
3 changes: 2 additions & 1 deletion packages/vue/src/proxies.ts
Original file line number Diff line number Diff line change
Expand Up @@ -619,7 +619,8 @@ export const IonProgressBar = /*@__PURE__*/ defineContainer<JSX.IonProgressBar>(
'reversed',
'value',
'buffer',
'color'
'color',
'shape'
]);


Expand Down
Loading