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 slider component #40

Closed
jaaydenh opened this issue Mar 14, 2025 · 5 comments
Closed

Add slider component #40

jaaydenh opened this issue Mar 14, 2025 · 5 comments
Assignees
Labels
early-access candidate for an early-access, or experimental, release

Comments

@jaaydenh
Copy link
Contributor

Image
@jaaydenh jaaydenh self-assigned this Mar 14, 2025
@bpmct
Copy link
Member

bpmct commented Mar 14, 2025

This will be awesome for stuff like tolerance!! Could we also support sliding between several pre-defined "string" options in a specific order. For example

Edit: fixed image

Image

@jaaydenh
Copy link
Contributor Author

Yes definitely possible. btw I use this site for inspiration and to save time with implementing new components, https://originui.com/slider

@Emyrk
Copy link
Member

Emyrk commented Mar 17, 2025

@bpmct We are quite limited on the syntax to represent this.

Here is the current hcl syntax for a slider

data "coder_parameter" "temperature" {
  name = "temperature"
  display_name = "AI Temperature"
  type = "number"
  form_type = "slider"
  default = 50
  count = 1

  validation {
    min = 0
    max = 100
  }
}

How do you propose we best represent the metadata for the slider? We are currently limited by the terraform provider to a completely static schema. So we could add something like:

data "coder_parameter" "temperature" {
  name = "temperature"
  // ...
  slider_metadata = {
    tick_labels = {
      "Cold" = 0
      "Balanced" = 50
      "Creative" = 100
    }
  }
}

This would mean we would have <type>_metdata for every form type that we want to add custom styling too. These blocks would obviously grow and grow, requiring bumping the terraform provider for each change. Now our terraform provider version is basically tracking form_metadata changes. Which.... is not ideal imo.

Arbitrary metadata field

The alternative is to place arbitrary data into a shared metadata block. This is currently impossible without these changes @johnstcn looked into: coder/terraform-provider-coder#354

data "coder_parameter" "temperature" {
  name = "temperature"
  // ...
  form_type_metadata = {
    // Literally put anything you want in here
    // An example:
    tick_labels = {
      "Cold" = 0
      "Balanced" = 50
      "Creative" = 100
    }
  }
}

Today to accomplish this, we would have to do this:

data "coder_parameter" "temperature" {
  name = "temperature"
  // ...
  form_type_metadata = jsonencode({
    // Literally put anything you want in here
    // An example:
    tick_labels = {
      "Cold" = 0
      "Balanced" = 50
      "Creative" = 100
    }
  })
}

@bpmct
Copy link
Member

bpmct commented Mar 19, 2025

This would mean we would have _metdata for every form type that we want to add custom styling too. These blocks would obviously grow and grow, requiring bumping the terraform provider for each change. Now our terraform provider version is basically tracking form_metadata changes. Which.... is not ideal imo.

This feels a bit safer than arbitrary an metadata that we have to read for each field, so it is my slight preference. I know both are not ideal. WIll honestly defer to y'all here.

@jaaydenh
Copy link
Contributor Author

Going to create another issue to handle custom styling on form controls such as sliders as there is still some decisions to make.

For actually implementing this on the frontend. I would push for either arbitrary metadata or styling defined outside terraform.

One issue I can anticipate is edge case in the display of the forms because of the limitations on how to express the styling. These will feel like bugs and it will be more difficult to make the UI responsive to all possible form states.

@Kira-Pilot Kira-Pilot added the early-access candidate for an early-access, or experimental, release label Apr 4, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
early-access candidate for an early-access, or experimental, release
Projects
None yet
Development

No branches or pull requests

4 participants