Skip to content

fix(range): add correct margin in item #28161

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 21 commits into from
Sep 13, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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.