Components: better, modular slider-related controls #40507
Labels
[Feature] Component System
WordPress component system
[Package] Components
/packages/components
[Type] Enhancement
A suggestion for improvement.
What problem does this address?
The
RangeControl
component is a slider + (optional)NumberControl
and icons. Its monolithic approach has a few limitations — for example, it doesn't allow for aUnitControl
component to be used instead ofNumberControl
.The new approach aims at isolating the "slider" part to a separate component, so that we can more easily compose it with different components (e.g.
NumberControl
andUnitControl
)What is your proposed solution?
As initially discussed in #40462 (comment), the tentative plan is to:
Convert
RangeControl
to TypeScript. This is necessary to make sure we have the best understanding of the component and its public APIs (and that we can iron out any issues before proceding). RangeControl: Convert component to TypeScript #40535Create a new
SliderControl
component. This component would basically be only the slider part ofRangeControl
(ie. no number input field, no icons..). SliderControl: Create new control using imported G2 Slider component #42315RangeControl
, or instead use the approach from the g2Slider
. In both cases, we should then "adapt" the code to the current format recommended by the guidelines (e.g. TypeScript, Emotion, hooks/components..)SliderControl
should be written in TypeScript, styled with Emotion, connected to the context systemSliderControl
component be based offBaseControl
?SliderControl
have sifferentsize
s ?SliderControl
from the components packageCreate two new components that build on top of
SliderControl
:NumberControl
,UnitControl
,SliderControl
), which means that ideally, at this point theNumberControl
component will be fully typed (and we'll have an agreement on the type for thevalue
prop)SliderNumberControl
(name TBD), which internally usesNumberControl
andSliderControl
(plus support for icons?)SliderUnitControl
(names TBD), which internally usesUnitControl
andSliderControl
(plus support for icons?)Convert all internal usages of
RangeControl
toSliderNumberControl
orSliderUnitControl
as neededAlias
RangeControl
toSliderNumberControl
. In doing so, we should add a "compat layer" to translate fromRangeControl
's public APIs toSliderNumberControl
's new APIs (similarly to what done forColorPicker
)Mark
RangeControl
as deprecatedClean up or refactor any custom styling of RangeControls once they are aliased or replaced.
BorderRadiusControl
and theSpacingSizesControl
in the block editor included.The text was updated successfully, but these errors were encountered: