Skip to content

Commit e5ae45d

Browse files
fix(spinner): allow resizing of dots, bubbles, and circles (#27424)
Issue number: Resolves #18115 --------- <!-- 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? <!-- Please describe the current behavior that you are modifying. --> Resizing the `ion-spinner` by setting the width & height using CSS works for most spinner variants, but not for `dots`, `bubbles`, and `circles`. The spacing between the circles on these spinner variants is not scaling with the spinner. ## What is the new behavior? <!-- Please describe the behavior or changes that are being added by this PR. --> - `ion-spinner` may now be resized by setting the width & height using CSS for all variants. ## Does this introduce a breaking change? - [ ] Yes - [x] No <!-- If this introduces a breaking change, please describe the impact and migration path for existing applications below. --> ## Other information <!-- Any other information that is important to this PR such as screenshots of how the component looks before and after the change. --> ### Before <img width="371" alt="Screenshot 2023-05-08 at 5 17 59 PM" src="https://user-images.githubusercontent.com/14926794/236937361-b8139bb3-192d-4fbf-839c-f9262b7c112a.png"> ### After <img width="373" alt="Screenshot 2023-05-08 at 5 18 45 PM" src="https://user-images.githubusercontent.com/14926794/236937508-9a8fa74e-60c8-47d9-9d56-c287da03a33f.png"> --------- Co-authored-by: ionitron <[email protected]>
1 parent 3f07297 commit e5ae45d

13 files changed

+44
-8
lines changed

core/src/components/spinner/spinner-configs.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,8 @@ const spinners = {
1010
return {
1111
r: 5,
1212
style: {
13-
top: `${9 * Math.sin(angle)}px`,
14-
left: `${9 * Math.cos(angle)}px`,
13+
top: `${32 * Math.sin(angle)}%`,
14+
left: `${32 * Math.cos(angle)}%`,
1515
'animation-delay': animationDelay,
1616
},
1717
};
@@ -28,8 +28,8 @@ const spinners = {
2828
return {
2929
r: 5,
3030
style: {
31-
top: `${9 * Math.sin(angle)}px`,
32-
left: `${9 * Math.cos(angle)}px`,
31+
top: `${32 * Math.sin(angle)}%`,
32+
left: `${32 * Math.cos(angle)}%`,
3333
'animation-delay': animationDelay,
3434
},
3535
};
@@ -72,7 +72,7 @@ const spinners = {
7272
return {
7373
r: 6,
7474
style: {
75-
left: `${9 - 9 * index}px`,
75+
left: `${32 - 32 * index}%`,
7676
'animation-delay': animationDelay,
7777
},
7878
};

core/src/components/spinner/test/color/index.html

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@
2424

2525
<ion-content id="content">
2626
<ion-list>
27-
<ion-item><ion-spinner slot="start"></ion-spinner>Platform Default Spinner</ion-item>
2827
<ion-item
2928
><ion-spinner color="primary" slot="start" name="lines"></ion-spinner><code>lines</code> (primary)</ion-item
3029
>

core/src/components/spinner/test/color/spinner.e2e.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@ import { expect } from '@playwright/test';
22
import { configs, test } from '@utils/test/playwright';
33

44
/**
5-
* This behavior does not vary across directions.
5+
* This behavior does not vary across directions or modes.
66
*/
7-
configs({ directions: ['ltr'] }).forEach(({ title, screenshot, config }) => {
7+
configs({ directions: ['ltr'], modes: ['md'] }).forEach(({ title, screenshot, config }) => {
88
test.describe(title('spinner: color'), () => {
99
test.beforeEach(async ({ page }) => {
1010
await page.goto('/src/components/spinner/test/color', config);
-3.16 KB
Loading
-3.17 KB
Loading
-2.77 KB
Loading
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
import { expect } from '@playwright/test';
2+
import { configs, test } from '@utils/test/playwright';
3+
4+
/**
5+
* The resize behavior does not vary across directions or modes.
6+
*/
7+
configs({ directions: ['ltr'], modes: ['md'] }).forEach(({ title, screenshot, config }) => {
8+
test.describe(title('spinner: resize'), () => {
9+
test.beforeEach(async ({ page }) => {
10+
await page.setViewportSize({ width: 320, height: 340 });
11+
});
12+
test('should not have visual regressions', async ({ page }) => {
13+
await page.setContent(
14+
`
15+
<style>
16+
ion-spinner {
17+
width: 100px;
18+
height: 100px;
19+
}
20+
</style>
21+
<ion-spinner name="lines"></ion-spinner>
22+
<ion-spinner name="lines-small"></ion-spinner>
23+
<ion-spinner name="lines-sharp"></ion-spinner>
24+
<ion-spinner name="lines-sharp-small"></ion-spinner>
25+
<ion-spinner name="circular"></ion-spinner>
26+
<ion-spinner name="dots"></ion-spinner>
27+
<ion-spinner name="bubbles"></ion-spinner>
28+
<ion-spinner name="circles"></ion-spinner>
29+
<ion-spinner name="crescent"></ion-spinner>
30+
`,
31+
config
32+
);
33+
34+
await expect(page).toHaveScreenshot(screenshot(`spinner-resize-diff`));
35+
});
36+
});
37+
});

0 commit comments

Comments
 (0)