feat(range): add class and expose parts for dual knobs for custom styling#30941
feat(range): add class and expose parts for dual knobs for custom styling#30941brandyscarney wants to merge 16 commits intofeature-8.8from
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
There was a problem hiding this comment.
This change is required otherwise it won't match knob when it has knob knob-a.
There was a problem hiding this comment.
I renamed the classes assigned to knob-handle from range-knob-a to range-knob-handle-a to match what they are actually applied to.
| configs({ directions: ['ltr'] }).forEach(({ title, screenshot, config }) => { | ||
| test.describe(title('range: customization'), () => { | ||
| test('should be customizable', async ({ page }) => { | ||
| await page.goto(`/src/components/range/test/custom`, config); |
There was a problem hiding this comment.
I removed the screenshots here in favor of checking that the styles are applied to the right element when the part is styled.
| * @part pressed - Added to the knob-handle, knob, and pin that is currently being pressed to drag. Only one set has this part at a time when `dualKnobs` is `true`. | ||
| * @part focused - Added to the knob-handle, knob, and pin that currently has focus. Only one set has this part at a time when `dualKnobs` is `true`. | ||
| * @part hover - Added to the knob-handle, knob, and pin when the knob has hover. Only one set has this part at a time. |
There was a problem hiding this comment.
I added these parts for the different range states which is used like this:
ion-range::part(knob hover),
ion-range::part(knob focused),
ion-range::part(knob pressed) {
background: var(--color-blue-primary);
}However, I could also see an argument for adding these as classes to the main range like this (or similarly named classes):
<ion-range class="knob-focused knob-a-focused knob-lower-focused">Then users could style them like this:
ion-range.knob-hover::part(knob),
ion-range.knob-focused::part(knob),
ion-range.knob-pressed::part(knob) {
background: var(--color-blue-primary);
}
Issue number: resolves #29862
What is the current behavior?
Range exposes a single part for both knobs & pins. This makes it impossible to style the knobs/pins differently when dual knobs is enabled.
What is the new behavior?
range-dual-knobsto the host element whendualKnobsis enabledknob-handle-a- The container element for the first knob. Only available whendualKnobsistrue.knob-handle-b- The container element for the second knob. Only available whendualKnobsistrue.knob-handle-lower- The container element for the lower knob. Only available whendualKnobsistrue.knob-handle-upper- The container element for the upper knob. Only available whendualKnobsistrue.pin-a- The counter that appears above the first knob. Only available whendualKnobsistrue.pin-b- The counter that appears above the second knob. Only available whendualKnobsistrue.pin-lower- The counter that appears above the lower knob. Only available whendualKnobsistrue.pin-upper- The counter that appears above the upper knob. Only available whendualKnobsistrue.knob-a- The visual knob element for the first knob. Only available whendualKnobsistrue.knob-b- The visual knob element for the second knob. Only available whendualKnobsistrue.knob-lower- The visual knob element for the lower knob. Only available whendualKnobsistrue.knob-upper- The visual knob element for the upper knob. Only available whendualKnobsistrue.pressed- Added to the knob-handle, knob, and pin that is currently being pressed to drag. Only one set has this part at a time.focused- Added to the knob-handle, knob, and pin that currently has focus. Only one set has this part at a time.hover- Added to the knob-handle, knob, and pin when the knob has hover. Only one set has this part at a time.Does this introduce a breaking change?
Other information
Dev build:
8.7.17-dev.11770147425.1bfcd5e5