Skip to content

Commit ae78967

Browse files
feat(progress-bar): add styling for the ionic theme (#30185)
Issue number: internal --------- <!-- Please do not submit updates to dependencies unless it fixes an issue. --> <!-- Please try to limit your pull request to one type (bugfix, feature, etc). Submit multiple pull requests if needed. --> ## What is the current behavior? ion-progress-bar does not currently have any custom styling for the ionic theme. ## What is the new behavior? <!-- Please describe the behavior or changes that are being added by this PR. --> According to the design, the following styling changes were made: - Added a new shape prop which controls the shape of the progress bar - Changed the color of the unfilled part of the progress bar and the bar height to design token values - Adding a new testing page and screenshot tests ## Does this introduce a breaking change? - [ ] Yes - [x] No <!-- If this introduces a breaking change: 1. Describe the impact and migration path for existing applications below. 2. Update the BREAKING.md file with the breaking change. 3. Add "BREAKING CHANGE: [...]" to the commit description when merging. See https://github.com/ionic-team/ionic-framework/blob/main/docs/CONTRIBUTING.md#footer for more information. --> ## Other information <!-- Any other information that is important to this PR such as screenshots of how the component looks before and after the change. -->
1 parent 7be7c08 commit ae78967

22 files changed

+172
-7
lines changed

core/api.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1661,6 +1661,7 @@ ion-progress-bar,prop,buffer,number,1,false,false
16611661
ion-progress-bar,prop,color,"danger" | "dark" | "light" | "medium" | "primary" | "secondary" | "success" | "tertiary" | "warning" | string & Record<never, never> | undefined,undefined,false,true
16621662
ion-progress-bar,prop,mode,"ios" | "md",undefined,false,false
16631663
ion-progress-bar,prop,reversed,boolean,false,false,false
1664+
ion-progress-bar,prop,shape,"rectangular" | "round" | undefined,undefined,false,false
16641665
ion-progress-bar,prop,theme,"ios" | "md" | "ionic",undefined,false,false
16651666
ion-progress-bar,prop,type,"determinate" | "indeterminate",'determinate',false,false
16661667
ion-progress-bar,prop,value,number,0,false,false

core/src/components.d.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2609,6 +2609,10 @@ export namespace Components {
26092609
* If true, reverse the progress bar direction.
26102610
*/
26112611
"reversed": boolean;
2612+
/**
2613+
* 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.
2614+
*/
2615+
"shape"?: 'round' | 'rectangular';
26122616
/**
26132617
* The theme determines the visual appearance of the component.
26142618
*/
@@ -7959,6 +7963,10 @@ declare namespace LocalJSX {
79597963
* If true, reverse the progress bar direction.
79607964
*/
79617965
"reversed"?: boolean;
7966+
/**
7967+
* 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.
7968+
*/
7969+
"shape"?: 'round' | 'rectangular';
79627970
/**
79637971
* The theme determines the visual appearance of the component.
79647972
*/
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
@use "../../themes/ionic/ionic.globals.scss" as globals;
2+
@use "./progress-bar";
3+
4+
// Ionic Progress bar
5+
// --------------------------------------------------
6+
7+
:host {
8+
--background: #{globals.$ion-bg-neutral-subtle-default};
9+
10+
height: globals.$ion-scale-100;
11+
}
12+
13+
// Progress Bar Shapes
14+
// -------------------------------------------------------------------------------
15+
16+
:host(.progress-bar-shape-round) {
17+
@include globals.border-radius(globals.$ion-round-xs);
18+
}
19+
20+
:host(.progress-bar-shape-rectangular) {
21+
@include globals.border-radius(globals.$ion-rectangular-xs);
22+
}

core/src/components/progress-bar/progress-bar.tsx

Lines changed: 27 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ import type { Color } from '../../interface';
2121
styleUrls: {
2222
ios: 'progress-bar.ios.scss',
2323
md: 'progress-bar.md.scss',
24-
ionic: 'progress-bar.md.scss',
24+
ionic: 'progress-bar.ionic.scss',
2525
},
2626
shadow: true,
2727
})
@@ -57,10 +57,35 @@ export class ProgressBar implements ComponentInterface {
5757
*/
5858
@Prop({ reflect: true }) color?: Color;
5959

60+
/**
61+
* Set to `"round"` for a progress bar with rounded corners, or `"rectangular"`
62+
* for a progress bar without rounded corners.
63+
*
64+
* Defaults to `"round"` for the `ionic` theme, undefined for all other themes.
65+
*/
66+
@Prop() shape?: 'round' | 'rectangular';
67+
68+
private getShape(): string | undefined {
69+
const theme = getIonTheme(this);
70+
const { shape } = this;
71+
72+
// TODO(ROU-11638): Remove theme check when shapes are defined for all themes.
73+
if (theme !== 'ionic') {
74+
return undefined;
75+
}
76+
77+
if (shape === undefined) {
78+
return 'round';
79+
}
80+
81+
return shape;
82+
}
83+
6084
render() {
6185
const { color, type, reversed, value, buffer } = this;
6286
const paused = config.getBoolean('_testing');
6387
const theme = getIonTheme(this);
88+
const shape = this.getShape();
6489
// If the progress is displayed as a solid bar.
6590
const progressSolid = buffer === 1;
6691
return (
@@ -75,6 +100,7 @@ export class ProgressBar implements ComponentInterface {
75100
'progress-paused': paused,
76101
'progress-bar-reversed': document.dir === 'rtl' ? !reversed : reversed,
77102
'progress-bar-solid': progressSolid,
103+
[`progress-bar-shape-${shape}`]: shape !== undefined,
78104
})}
79105
>
80106
{type === 'indeterminate' ? renderIndeterminate() : renderProgress(value, buffer)}

core/src/components/progress-bar/test/basic/progress-bar.e2e.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { expect } from '@playwright/test';
22
import { configs, test } from '@utils/test/playwright';
33

4-
configs().forEach(({ title, screenshot, config }) => {
4+
configs({ modes: ['ios', 'md', 'ionic-md'] }).forEach(({ title, screenshot, config }) => {
55
test.describe(title('progress-bar: basic'), () => {
66
test('should not have visual regressions', async ({ page }) => {
77
await page.goto('/src/components/progress-bar/test/basic', config);
Loading
Loading
Loading
Loading
Loading

0 commit comments

Comments
 (0)