Skip to content

Commit

Permalink
feat(badge): add round to the ionic theme (#29574)
Browse files Browse the repository at this point in the history
  • Loading branch information
thetaPC committed May 31, 2024
1 parent 777521f commit 8ac3ae5
Show file tree
Hide file tree
Showing 48 changed files with 42 additions and 6 deletions.
2 changes: 1 addition & 1 deletion core/api.txt
Original file line number Diff line number Diff line change
Expand Up @@ -312,7 +312,7 @@ ion-backdrop,event,ionBackdropTap,void,true
ion-badge,shadow
ion-badge,prop,color,"danger" | "dark" | "light" | "medium" | "primary" | "secondary" | "success" | "tertiary" | "warning" | string & Record<never, never> | undefined,undefined,false,true
ion-badge,prop,mode,"ios" | "md",undefined,false,false
ion-badge,prop,shape,"soft" | undefined,undefined,false,false
ion-badge,prop,shape,"round" | "soft" | undefined,undefined,false,false
ion-badge,prop,size,"large" | "medium" | "small" | "xlarge" | "xsmall" | "xxsmall" | undefined,undefined,false,false
ion-badge,prop,theme,"ios" | "md" | "ionic",undefined,false,false
ion-badge,css-prop,--background,ionic
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 @@ -418,9 +418,9 @@ export namespace Components {
*/
"mode"?: "ios" | "md";
/**
* Set to `"soft"` for slightly rounded corners. Defaults to `"round"` for the `ionic` theme, undefined for all other themes.
* Set to `"soft"` for slightly rounded corners. Set to `"round"` for fully rounded corners. Defaults to `"round"` for the `ionic` theme, undefined for all other themes.
*/
"shape"?: 'soft';
"shape"?: 'soft' | 'round';
/**
* Set to `"xxsmall"` for the smallest badge. Set to "xsmall" for a very small badge. Set to `"small"` for a small badge. Set to "medium" for a medium badge. Set to "large" for a large badge. Set to `"xlarge"` for the largest badge. Defaults to `"small"` for the `ionic` theme, undefined for all other themes.
*/
Expand Down Expand Up @@ -5666,9 +5666,9 @@ declare namespace LocalJSX {
*/
"mode"?: "ios" | "md";
/**
* Set to `"soft"` for slightly rounded corners. Defaults to `"round"` for the `ionic` theme, undefined for all other themes.
* Set to `"soft"` for slightly rounded corners. Set to `"round"` for fully rounded corners. Defaults to `"round"` for the `ionic` theme, undefined for all other themes.
*/
"shape"?: 'soft';
"shape"?: 'soft' | 'round';
/**
* Set to `"xxsmall"` for the smallest badge. Set to "xsmall" for a very small badge. Set to `"small"` for a small badge. Set to "medium" for a medium badge. Set to "large" for a large badge. Set to `"xlarge"` for the largest badge. Defaults to `"small"` for the `ionic` theme, undefined for all other themes.
*/
Expand Down
4 changes: 4 additions & 0 deletions core/src/components/badge/badge.ionic.scss
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,10 @@
@include border-radius(globals.$ionic-border-radius-100);
}

:host(.badge-round) {
@include border-radius(globals.$ionic-border-radius-full);
}

// Badge Sizes
// --------------------------------------------------

Expand Down
3 changes: 2 additions & 1 deletion core/src/components/badge/badge.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,11 @@ export class Badge implements ComponentInterface {

/**
* Set to `"soft"` for slightly rounded corners.
* Set to `"round"` for fully rounded corners.
*
* Defaults to `"round"` for the `ionic` theme, undefined for all other themes.
*/
@Prop() shape?: 'soft';
@Prop() shape?: 'soft' | 'round';

/**
* Set to `"xxsmall"` for the smallest badge.
Expand Down
26 changes: 26 additions & 0 deletions core/src/components/badge/test/shape/badge.e2e.ts
Original file line number Diff line number Diff line change
Expand Up @@ -73,5 +73,31 @@ configs({ directions: ['ltr'], modes: ['ionic-md'] }).forEach(({ config, screens

await expect(container).toHaveScreenshot(screenshot(`badge-shape-soft-larger-sizes-long-text`));
});

test('should render round badges', async ({ page }) => {
await page.setContent(
`
<ion-badge shape="round">1</ion-badge>
`,
config
);

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

await expect(badge).toHaveScreenshot(screenshot(`badge-shape-round`));
});

test('should render round badges with long text', async ({ page }) => {
await page.setContent(
`
<ion-badge shape="round">99+</ion-badge>
`,
config
);

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

await expect(badge).toHaveScreenshot(screenshot(`badge-shape-round-long-text`));
});
});
});
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.
5 changes: 5 additions & 0 deletions core/src/components/badge/test/shape/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,11 @@
<ion-badge slot="end" shape="soft">1</ion-badge>
<ion-badge slot="end" shape="soft">99+</ion-badge>
</ion-item>
<ion-item>
<ion-label>Round</ion-label>
<ion-badge slot="end" shape="round">1</ion-badge>
<ion-badge slot="end" shape="round">99+</ion-badge>
</ion-item>
</ion-list>
</ion-content>
</ion-app>
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.

0 comments on commit 8ac3ae5

Please sign in to comment.