Skip to content

Commit 1d2b867

Browse files
authored
fix(range): add correct margin in item (#28161)
1 parent 8cb8786 commit 1d2b867

File tree

6 files changed

+36
-0
lines changed

6 files changed

+36
-0
lines changed

core/src/components/range/range.scss

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
@import "../../themes/ionic.globals";
2+
@import "./range.vars.scss";
23

34
// Range
45
// --------------------------------------------------
@@ -338,3 +339,11 @@
338339
*/
339340
max-width: calc(100% / #{$form-control-label-stacked-scale});
340341
}
342+
343+
:host(.in-item.range-label-placement-stacked) .label-text-wrapper {
344+
@include margin($range-item-label-margin-top, null, $form-control-label-margin, null);
345+
}
346+
347+
:host(.in-item.range-label-placement-stacked) .native-wrapper {
348+
@include margin(null, null, $range-item-label-margin-bottom, null);
349+
}
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
/// @prop - Top margin of range's label when in an item
2+
$range-item-label-margin-top: 10px !default;
3+
4+
/// @prop - Bottom margin of range's label when in an item
5+
// We don't add additional margin because the native container
6+
// has additional white space. Otherwise there would be too
7+
// much white space at the bottom of the item.
8+
$range-item-label-margin-bottom: 0px !default;

core/src/components/range/test/item/range.e2e.ts

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,3 +50,22 @@ configs({ directions: ['ltr'] }).forEach(({ title, screenshot, config }) => {
5050
});
5151
});
5252
});
53+
54+
configs({ modes: ['md'], directions: ['ltr'] }).forEach(({ title, config, screenshot }) => {
55+
test.describe(title('range: stacked label in item'), () => {
56+
test('should render margins correctly when using stacked label in item', async ({ page }) => {
57+
await page.setContent(
58+
`
59+
<ion-list>
60+
<ion-item>
61+
<ion-range label="Temperature" label-placement="stacked"></ion-range>
62+
</ion-item>
63+
</ion-list>
64+
`,
65+
config
66+
);
67+
const list = page.locator('ion-list');
68+
await expect(list).toHaveScreenshot(screenshot(`range-stacked-label-in-item`));
69+
});
70+
});
71+
});

0 commit comments

Comments
 (0)