Skip to content

Commit

Permalink
fix(range): add correct margin in item (#28161)
Browse files Browse the repository at this point in the history
  • Loading branch information
liamdebeasi committed Sep 13, 2023
1 parent 8cb8786 commit 1d2b867
Show file tree
Hide file tree
Showing 6 changed files with 36 additions and 0 deletions.
9 changes: 9 additions & 0 deletions core/src/components/range/range.scss
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
@import "../../themes/ionic.globals";
@import "./range.vars.scss";

// Range
// --------------------------------------------------
Expand Down Expand Up @@ -338,3 +339,11 @@
*/
max-width: calc(100% / #{$form-control-label-stacked-scale});
}

:host(.in-item.range-label-placement-stacked) .label-text-wrapper {
@include margin($range-item-label-margin-top, null, $form-control-label-margin, null);
}

:host(.in-item.range-label-placement-stacked) .native-wrapper {
@include margin(null, null, $range-item-label-margin-bottom, null);
}
8 changes: 8 additions & 0 deletions core/src/components/range/range.vars.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
/// @prop - Top margin of range's label when in an item
$range-item-label-margin-top: 10px !default;

/// @prop - Bottom margin of range's label when in an item
// We don't add additional margin because the native container
// has additional white space. Otherwise there would be too
// much white space at the bottom of the item.
$range-item-label-margin-bottom: 0px !default;
19 changes: 19 additions & 0 deletions core/src/components/range/test/item/range.e2e.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,3 +50,22 @@ configs({ directions: ['ltr'] }).forEach(({ title, screenshot, config }) => {
});
});
});

configs({ modes: ['md'], directions: ['ltr'] }).forEach(({ title, config, screenshot }) => {
test.describe(title('range: stacked label in item'), () => {
test('should render margins correctly when using stacked label in item', async ({ page }) => {
await page.setContent(
`
<ion-list>
<ion-item>
<ion-range label="Temperature" label-placement="stacked"></ion-range>
</ion-item>
</ion-list>
`,
config
);
const list = page.locator('ion-list');
await expect(list).toHaveScreenshot(screenshot(`range-stacked-label-in-item`));
});
});
});
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 1d2b867

Please sign in to comment.