Skip to content

Commit e5b00af

Browse files
Add new styles
1 parent 839969e commit e5b00af

21 files changed

+180
-6
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 tab-button with rounded corners, or `"rectangular"` for a tab-button 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 tab-button with rounded corners, or `"rectangular"` for a tab-button 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: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
@use "../../themes/ionic/ionic.globals.scss" as globals;
2+
3+
@import "./progress-bar";
4+
5+
// iOS Progress bar
6+
// --------------------------------------------------
7+
8+
:host {
9+
height: globals.$ion-scale-100;
10+
}
11+
12+
:host(.progress-bar-solid) {
13+
/**
14+
* On the ionic theme the unfilled portion of the progress
15+
* bar is always a consistent background color. We
16+
* only apply this style when the progress bar is
17+
* solid (with a buffer value of 1). This maintains
18+
* the custom Ionic appearance for a buffered progress bar.
19+
*/
20+
--background: #{globals.$ion-primitives-neutral-100};
21+
}
22+
23+
// Progress Bar Shapes
24+
// -------------------------------------------------------------------------------
25+
26+
:host(.progress-bar-shape-round) {
27+
@include globals.border-radius(globals.$ion-border-radius-full);
28+
}
29+
30+
:host(.progress-bar-shape-rectangular) {
31+
@include globals.border-radius(globals.$ion-border-radius-0);
32+
}

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 tab-button with rounded corners, or `"rectangular"`
62+
* for a tab-button 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-11436): 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)}
Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
<!DOCTYPE html>
2+
<html lang="en" dir="ltr">
3+
<head>
4+
<meta charset="UTF-8" />
5+
<title>Progress Bar - Shape</title>
6+
<meta
7+
name="viewport"
8+
content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=no"
9+
/>
10+
<link href="../../../../../css/ionic.bundle.css" rel="stylesheet" />
11+
<link href="../../../../../scripts/testing/styles.css" rel="stylesheet" />
12+
<script src="../../../../../scripts/testing/scripts.js"></script>
13+
<script nomodule src="../../../../../dist/ionic/ionic.js"></script>
14+
<script type="module" src="../../../../../dist/ionic/ionic.esm.js"></script>
15+
16+
<style>
17+
ion-content::part(scroll) {
18+
display: flex;
19+
flex-direction: column;
20+
align-items: center;
21+
}
22+
23+
ion-content ion-progress-bar {
24+
margin: 10px 0;
25+
width: 70%;
26+
}
27+
</style>
28+
</head>
29+
30+
<body>
31+
<ion-app>
32+
<ion-header>
33+
<ion-toolbar>
34+
<ion-title>Progress Bar - Shape</ion-title>
35+
</ion-toolbar>
36+
</ion-header>
37+
38+
<ion-content class="outer-content">
39+
<ion-label> Default </ion-label>
40+
<ion-progress-bar value="0.50"></ion-progress-bar>
41+
42+
<ion-label> Round </ion-label>
43+
<ion-progress-bar value="0.50" shape="round"></ion-progress-bar>
44+
45+
<ion-label> Default </ion-label>
46+
<ion-progress-bar value="0.50" shape="rectangular"></ion-progress-bar>
47+
</ion-content>
48+
</ion-app>
49+
</body>
50+
</html>
Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
import { expect } from '@playwright/test';
2+
import { configs, test } from '@utils/test/playwright';
3+
4+
configs({ modes: ['ionic-md'] }).forEach(({ title, screenshot, config }) => {
5+
test.describe(title('progress-bar: shape'), () => {
6+
test('should render a round progress bar', async ({ page }) => {
7+
await page.setContent(
8+
`
9+
<style>
10+
:root {
11+
background: #ccc7c7;
12+
}
13+
14+
.container {
15+
padding: 10px;
16+
}
17+
</style>
18+
19+
<div class="container">
20+
<ion-progress-bar value="0.50" shape="round"></ion-progress-bar>
21+
</div>
22+
`,
23+
config
24+
);
25+
26+
const tabBar = page.locator('.container');
27+
28+
await expect(tabBar).toHaveScreenshot(screenshot(`progress-bar-shape-round`));
29+
});
30+
31+
test('should render a rectangular progress bar', async ({ page }) => {
32+
await page.setContent(
33+
`
34+
<style>
35+
:root {
36+
background: #ccc7c7;
37+
}
38+
39+
.container {
40+
padding: 10px;
41+
}
42+
</style>
43+
44+
<div class="container">
45+
<ion-progress-bar value="0.50" shape="rectangular"></ion-progress-bar>
46+
</div>
47+
`,
48+
config
49+
);
50+
51+
const tabBar = page.locator('.container');
52+
53+
await expect(tabBar).toHaveScreenshot(screenshot(`progress-bar-shape-rectangular`));
54+
});
55+
});
56+
});
Loading
Loading
Loading
Loading

0 commit comments

Comments
 (0)