fix(range): range matches iOS design specification (#25873)

Resolves #25872
This commit is contained in:
Sean Perkins
2022-09-09 12:25:06 -04:00
committed by GitHub
parent cb265d6cc6
commit da05ffe462
24 changed files with 101 additions and 62 deletions

View File

@ -12,43 +12,16 @@ This is a comprehensive list of the breaking changes introduced in the major ver
## Version 7.x ## Version 7.x
- [Browser and Platform Support](#version-7x-browser-platform-support)
- [Components](#version-7x-components) - [Components](#version-7x-components)
- [Overlays](#version-7x-overlays) - [Overlays](#version-7x-overlays)
- [Virtual Scroll](#version-7x-virtual-scroll) - [Range](#version-7x-range)
- [Slides](#version-7x-slides) - [Slides](#version-7x-slides)
- [Browser and Platform Support](#version-7x-browser-platform-support) - [Virtual Scroll](#version-7x-virtual-scroll)
- [Utilities](#version-7x-utilities) - [Utilities](#version-7x-utilities)
- [hidden attribute](#version-7x-hidden-attribute) - [hidden attribute](#version-7x-hidden-attribute)
<h2 id="version-7x-components">Components</h2> <h2 id="version-7x-browser-platform-support">Browser and Platform Support</h2>
<h4 id="version-7x-overlays">Overlays</h4>
Ionic now listens on the `keydown` event instead of the `keyup` event when determining when to dismiss overlays via the "Escape" key. Any applications that were listening on `keyup` to suppress this behavior should listen on `keydown` instead.
<h4 id="version-7x-virtual-scroll">Virtual Scroll</h4>
`ion-virtual-scroll` has been removed from Ionic.
Developers using the component will need to migrate to a virtual scroll solution provided by their framework:
- [Angular](https://ionicframework.com/docs/angular/virtual-scroll)
- [React](https://ionicframework.com/docs/react/virtual-scroll)
- [Vue](https://ionicframework.com/docs/vue/virtual-scroll)
Any references to the virtual scroll types from `@ionic/core` have been removed. Please remove or replace these types: `Cell`, `VirtualNode`, `CellType`, `NodeChange`, `HeaderFn`, `ItemHeightFn`, `FooterHeightFn`, `ItemRenderFn` and `DomRenderFn`.
<h4 id="version-7x-slides">Slides</h4>
`ion-slides`, `ion-slide`, and the `IonicSwiper` plugin have been removed from Ionic.
Developers using these components will need to migrate to using Swiper.js directly, optionally using the `IonicSlides` plugin. Guides for migration and usage are linked below:
- [Angular](https://ionicframework.com/docs/angular/slides)
- [React](https://ionicframework.com/docs/react/slides)
- [Vue](https://ionicframework.com/docs/vue/slides)
<h4 id="version-7x-browser-platform-support">Browser and Platform Support</h4>
This section details the desktop browser, JavaScript framework, and mobile platform versions that are supported by Ionic 7. This section details the desktop browser, JavaScript framework, and mobile platform versions that are supported by Ionic 7.
@ -75,6 +48,53 @@ This section details the desktop browser, JavaScript framework, and mobile platf
| iOS | 14+ | | iOS | 14+ |
| Android | 5.1+ with Chromium 79+ | | Android | 5.1+ with Chromium 79+ |
<h2 id="version-7x-components">Components</h2>
<h4 id="version-7x-overlays">Overlays</h4>
Ionic now listens on the `keydown` event instead of the `keyup` event when determining when to dismiss overlays via the "Escape" key. Any applications that were listening on `keyup` to suppress this behavior should listen on `keydown` instead.
<h4 id="version-7x-range">Range</h4>
Range is updated to align with the design specification for supported modes.
**Design tokens**
iOS:
|Token|Previous Value|New Value|
|-----|--------------|---------|
|`--bar-border-radius`|`0px`|`$range-ios-bar-border-radius` (`2px` default)|
|`--knob-size`|`28px`|`$range-ios-knob-width` (`26px` default)|
|`$range-ios-bar-height`|`2px`|`4px`|
|`$range-ios-bar-background-color`|`rgba(var(--ion-text-color-rgb, 0, 0, 0), .1)`|`var(--ion-color-step-900, #e6e6e6)`|
|`$range-ios-knob-box-shadow`|`0 3px 1px rgba(0, 0, 0, .1), 0 4px 8px rgba(0, 0, 0, .13), 0 0 0 1px rgba(0, 0, 0, .02)`|`0px 0.5px 4px rgba(0, 0, 0, 0.12), 0px 6px 13px rgba(0, 0, 0, 0.12)`|
|`$range-ios-knob-width`|`28px`|`26px`|
<h4 id="version-7x-slides">Slides</h4>
`ion-slides`, `ion-slide`, and the `IonicSwiper` plugin have been removed from Ionic.
Developers using these components will need to migrate to using Swiper.js directly, optionally using the `IonicSlides` plugin. Guides for migration and usage are linked below:
- [Angular](https://ionicframework.com/docs/angular/slides)
- [React](https://ionicframework.com/docs/react/slides)
- [Vue](https://ionicframework.com/docs/vue/slides)
<h4 id="version-7x-virtual-scroll">Virtual Scroll</h4>
`ion-virtual-scroll` has been removed from Ionic.
Developers using the component will need to migrate to a virtual scroll solution provided by their framework:
- [Angular](https://ionicframework.com/docs/angular/virtual-scroll)
- [React](https://ionicframework.com/docs/react/virtual-scroll)
- [Vue](https://ionicframework.com/docs/vue/virtual-scroll)
Any references to the virtual scroll types from `@ionic/core` have been removed. Please remove or replace these types: `Cell`, `VirtualNode`, `CellType`, `NodeChange`, `HeaderFn`, `ItemHeightFn`, `FooterHeightFn`, `ItemRenderFn` and `DomRenderFn`.
<h2 id="version-7x-utilities">Utilities</h2> <h2 id="version-7x-utilities">Utilities</h2>
<h4 id="version-7x-hidden-attribute">`hidden` attribute</h4> <h4 id="version-7x-hidden-attribute">`hidden` attribute</h4>

Binary file not shown.

Before

Width:  |  Height:  |  Size: 79 KiB

After

Width:  |  Height:  |  Size: 77 KiB

View File

@ -8,11 +8,11 @@
--knob-border-radius: 50%; --knob-border-radius: 50%;
--knob-background: #{$range-ios-knob-background-color}; --knob-background: #{$range-ios-knob-background-color};
--knob-box-shadow: #{$range-ios-knob-box-shadow}; --knob-box-shadow: #{$range-ios-knob-box-shadow};
--knob-size: 28px; --knob-size: #{$range-ios-knob-width};
--bar-height: #{$range-ios-bar-height}; --bar-height: #{$range-ios-bar-height};
--bar-background: #{$range-ios-bar-background-color}; --bar-background: #{$range-ios-bar-background-color};
--bar-background-active: #{ion-color(primary, base)}; --bar-background-active: #{ion-color(primary, base)};
--bar-border-radius: 0; --bar-border-radius: #{$range-ios-bar-border-radius};
--height: #{$range-ios-slider-height}; --height: #{$range-ios-slider-height};
@include padding($range-ios-padding-vertical, $range-ios-padding-horizontal); @include padding($range-ios-padding-vertical, $range-ios-padding-horizontal);
@ -36,6 +36,9 @@
} }
.range-bar-active { .range-bar-active {
@include border-radius(0);
@include margin(null, calc(-1 * $range-ios-tick-width * 0.5), null, calc(-1 * $range-ios-tick-width * 0.5));
bottom: 0; bottom: 0;
width: auto; width: auto;
@ -48,7 +51,7 @@
@include border-radius($range-ios-tick-border-radius); @include border-radius($range-ios-tick-border-radius);
position: absolute; position: absolute;
top: ($range-ios-hit-height * 0.5) - ($range-ios-tick-height * 0.5) + ($range-ios-bar-height * 0.5); top: ($range-ios-hit-height * 0.5) - ($range-ios-tick-height * 0.5);
width: $range-ios-tick-width; width: $range-ios-tick-width;
height: $range-ios-tick-height; height: $range-ios-tick-height;

View File

@ -19,22 +19,25 @@ $range-ios-hit-width: 42px !default;
$range-ios-hit-height: $range-ios-slider-height !default; $range-ios-hit-height: $range-ios-slider-height !default;
/// @prop - Height of the range bar /// @prop - Height of the range bar
$range-ios-bar-height: 2px !default; $range-ios-bar-height: 4px !default;
/// @prop - Background of the range bar /// @prop - Background of the range bar
$range-ios-bar-background-color: rgba(var(--ion-text-color-rgb, 0, 0, 0), .1) !default; $range-ios-bar-background-color: var(--ion-color-step-900, #e6e6e6) !default;
/// @prop - Background of the active range bar /// @prop - Background of the active range bar
$range-ios-bar-active-background-color: current-color(base) !default; $range-ios-bar-active-background-color: current-color(base) !default;
/// @prop - Border radius of the range bar
$range-ios-bar-border-radius: 2px !default;
/// @prop - Width of the range knob /// @prop - Width of the range knob
$range-ios-knob-width: 28px !default; $range-ios-knob-width: 26px !default;
/// @prop - Height of the range knob /// @prop - Height of the range knob
$range-ios-knob-height: $range-ios-knob-width !default; $range-ios-knob-height: $range-ios-knob-width !default;
/// @prop - Box shadow of the range knob /// @prop - Box shadow of the range knob
$range-ios-knob-box-shadow: 0 3px 1px rgba(0, 0, 0, .1), 0 4px 8px rgba(0, 0, 0, .13), 0 0 0 1px rgba(0, 0, 0, .02) !default; $range-ios-knob-box-shadow: 0px 0.5px 4px rgba(0, 0, 0, 0.12), 0px 6px 13px rgba(0, 0, 0, 0.12) !default;
/// @prop - Border radius of the range knob /// @prop - Border radius of the range knob
$range-ios-knob-border-radius: 50% !default; $range-ios-knob-border-radius: 50% !default;

View File

@ -93,7 +93,7 @@
} }
} }
.range-bar { .range-bar-container {
@include border-radius(var(--bar-border-radius)); @include border-radius(var(--bar-border-radius));
@include position(calc((var(--height) - var(--bar-height)) / 2), null, null, 0); @include position(calc((var(--height) - var(--bar-height)) / 2), null, null, 0);
@ -107,6 +107,17 @@
width: 100%; width: 100%;
height: var(--bar-height); height: var(--bar-height);
overflow: hidden;
}
.range-bar {
@include border-radius(var(--bar-border-radius));
position: absolute;
width: 100%;
height: var(--bar-height);
background: var(--bar-background); background: var(--bar-background);
pointer-events: none; pointer-events: none;

View File

@ -613,8 +613,10 @@ export class Range implements ComponentInterface {
/> />
))} ))}
<div class="range-bar-container">
<div class="range-bar" role="presentation" part="bar" /> <div class="range-bar" role="presentation" part="bar" />
<div class="range-bar range-bar-active" role="presentation" style={barStyle} part="bar-active" /> <div class="range-bar range-bar-active" role="presentation" style={barStyle} part="bar-active" />
</div>
{renderKnob(rtl, { {renderKnob(rtl, {
knob: 'A', knob: 'A',

Binary file not shown.

Before

Width:  |  Height:  |  Size: 181 KiB

After

Width:  |  Height:  |  Size: 154 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 57 KiB

After

Width:  |  Height:  |  Size: 58 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 143 KiB

After

Width:  |  Height:  |  Size: 143 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 181 KiB

After

Width:  |  Height:  |  Size: 154 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 57 KiB

After

Width:  |  Height:  |  Size: 58 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 142 KiB

After

Width:  |  Height:  |  Size: 143 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 214 KiB

After

Width:  |  Height:  |  Size: 215 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 76 KiB

After

Width:  |  Height:  |  Size: 78 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 196 KiB

After

Width:  |  Height:  |  Size: 201 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 215 KiB

After

Width:  |  Height:  |  Size: 214 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 76 KiB

After

Width:  |  Height:  |  Size: 78 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 196 KiB

After

Width:  |  Height:  |  Size: 201 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 50 KiB

After

Width:  |  Height:  |  Size: 51 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 19 KiB

After

Width:  |  Height:  |  Size: 20 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 47 KiB

After

Width:  |  Height:  |  Size: 48 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 50 KiB

After

Width:  |  Height:  |  Size: 51 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 19 KiB

After

Width:  |  Height:  |  Size: 20 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 47 KiB

After

Width:  |  Height:  |  Size: 48 KiB