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

Enhancement: Custom labels for slider handles and ticks #4004

Closed
paulcpederson opened this issue Jan 25, 2022 · 5 comments
Closed

Enhancement: Custom labels for slider handles and ticks #4004

paulcpederson opened this issue Jan 25, 2022 · 5 comments
Assignees
Labels
4 - verified Issues that have been released and confirmed resolved. ArcGIS Online Issues logged by ArcGIS Online team members. c-slider Issues that pertain to the calcite-slider component enhancement Issues tied to a new feature or request. estimate - 8 Requires input from team, consider smaller steps. low risk Issues with low risk for consideration in low risk milestones p - high Issue should be addressed in the current milestone, impacts component or core functionality

Comments

@paulcpederson
Copy link
Member

Description

Currently the slider supports a labelHandles prop which shows the numeric value of each handle above the slider. There are many cases where the numeric value is not user friendly, and we'd like the ability to set a custom handle text.

Acceptance Criteria

API should allow for dynamically updating the custom handle text in response to changes. We propose adding this via an additional prop formatLabels which accepts a function:

<calcite-slider formatLabels={(value: number) => string} />

This function returns a string and must be synchronous. Each time we render a tick label or a handle label, we call this function if available and render the resulting string instead. If this function is not defined or doesn't return a string, the original value is used.

Relevant Info

I can work on a solution to this for review as we need this for the current release.

This is a more abstract solution to #557 (closed due to inactivity) and is semi related to #2584 as it's the same concept for for handles rather than ticks.

Please respond with thoughts on the API and especially naming as this is a rather esoteric prop concept.

Which Component

calcite-slider

Example Use Case

There are lots of applications of this capability:

  • Cleanly displaying current value if slider is stepless and shows long decimals (Slider: round handle labels and event values? #557)
  • Locale specific number formatting
  • Slider representing currencies having particular formatting requirements
  • Slider representing configurable memory or hard drive size (in bytes, kilobytes, megabytes, gigabytes, etc)
  • Level of detail selection (ie 0 = "World" and 12 = "Street")
  • Non regular interval sliders (logarithmic, exponential, etc)
@paulcpederson paulcpederson added enhancement Issues tied to a new feature or request. 0 - new New issues that need assignment. needs triage Planning workflow - pending design/dev review. labels Jan 25, 2022
@paulcpederson paulcpederson self-assigned this Jan 25, 2022
@benelan benelan added p - high Issue should be addressed in the current milestone, impacts component or core functionality and removed needs triage Planning workflow - pending design/dev review. labels Jan 25, 2022
@benelan benelan added this to the Sprint 01/31 - 02/11 milestone Jan 25, 2022
@benelan
Copy link
Member

benelan commented May 16, 2022

This came up in a Community question as well.

@benelan benelan changed the title Enhancement: Custom labels for slider handles Enhancement: Custom labels for slider handles and ticks May 16, 2022
@eriklharper eriklharper added the i18n-l10n issues dealing with internationalization/localization label May 17, 2022
@jcfranco jcfranco removed the i18n-l10n issues dealing with internationalization/localization label May 24, 2022
@geospatialem geospatialem added the low risk Issues with low risk for consideration in low risk milestones label Sep 28, 2023
@brittneytewks brittneytewks added the estimate - 8 Requires input from team, consider smaller steps. label Jan 29, 2024
@jcfranco jcfranco self-assigned this Apr 23, 2024
@jcfranco jcfranco added 2 - in development Issues that are actively being worked on. and removed 0 - new New issues that need assignment. labels Apr 23, 2024
jcfranco added a commit that referenced this issue Apr 24, 2024
**Related Issue:** #4004

## Summary

Adds `labelFormatter` prop to allow customization of handle and tick
labels.

```ts
interface CalciteSlider {

  /** 
    * Formatter for custom handle/ticks labels.
    * 
    * If the returned value is a string, it will get used in the label, 
    * and if it is `undefined`, it will use the default, formatted label.
    */
  labelFormatter(

    // the associated label value
    value: number, 

    // the label type
    type: "min" | "max" | "value" | "tick" 

    // the default formatter (configured with corresponding locale, numbering system and group separator
    defaultFormatter: (value: number): string;

  ): string | undefined;
}
```
@jcfranco jcfranco added 3 - installed Issues that have been merged to master branch and are ready for final confirmation. and removed 2 - in development Issues that are actively being worked on. labels Apr 24, 2024
@github-actions github-actions bot assigned geospatialem and DitwanP and unassigned jcfranco Apr 24, 2024
Copy link
Contributor

Installed and assigned for verification.

@DitwanP
Copy link
Contributor

DitwanP commented Apr 24, 2024

🚀 Verified on 2.8.0-next.9
Screenshot 2024-04-24 at 3 30 23 PM

@DitwanP DitwanP closed this as completed Apr 24, 2024
@DitwanP DitwanP added 4 - verified Issues that have been released and confirmed resolved. and removed 3 - installed Issues that have been merged to master branch and are ready for final confirmation. labels Apr 24, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
4 - verified Issues that have been released and confirmed resolved. ArcGIS Online Issues logged by ArcGIS Online team members. c-slider Issues that pertain to the calcite-slider component enhancement Issues tied to a new feature or request. estimate - 8 Requires input from team, consider smaller steps. low risk Issues with low risk for consideration in low risk milestones p - high Issue should be addressed in the current milestone, impacts component or core functionality
Projects
None yet
Development

No branches or pull requests

8 participants