Skip to content
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

Add SizeControl component that allows negative values & customizable range #61180

Open
wants to merge 2 commits into
base: trunk
Choose a base branch
from

Conversation

protibimbok
Copy link

@protibimbok protibimbok commented Apr 28, 2024

What?

Addressing the issues #61179 & #60633
This component allows:

  1. Negative values
  2. Custom min, max & step per unit
  3. Option to allow adaptive min/max

Why?

While developing custom blocks, the use of negative values is often required. I myself have faced this issue many times. The current available option for managing custom size is HeightControl, which does not allow the negative values. And the range is pre-defined for all units.

How?

This new component is exactly same as the HeightControl except for two additional optional props: adaptiveRange: boolean & rangeConfig: Object.

  1. If adaptiveRange is true, the min/max range will adapt to the current value.
  2. And the rangeConfig prop allows to override the default min, max & step configuration.

Usage

<SizeControl
    label = "Your Label"
    adaptiveRange={true}
    rangeConfig={{
        px: {
            min: -500,
            max: 1000,
        },
        rem: {
            step: 0.5
        }
    }}
/>

Screenshots or screencast

2024-04-28.11-47-41.mp4

Copy link

The following accounts have interacted with this PR and/or linked issues. I will continue to update these lists as activity occurs. You can also manually ask me to refresh this list by adding the props-bot label.

If you're merging code through a pull request on GitHub, copy and paste the following into the bottom of the merge commit message.

Co-authored-by: protibimbok <protibimbok@git.wordpress.org>

To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook.

@github-actions github-actions bot added the First-time Contributor Pull request opened by a first-time contributor to Gutenberg repository label Apr 28, 2024
Copy link

👋 Thanks for your first Pull Request and for helping build the future of Gutenberg and WordPress, @protibimbok! In case you missed it, we'd love to have you join us in our Slack community.

If you want to learn more about WordPress development in general, check out the Core Handbook full of helpful information.

@mirka mirka added [Type] Enhancement A suggestion for improvement. [Package] Block editor /packages/block-editor labels May 7, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
First-time Contributor Pull request opened by a first-time contributor to Gutenberg repository [Package] Block editor /packages/block-editor [Type] Enhancement A suggestion for improvement.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants