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 <SInputSegments> #357

Closed
kiaking opened this issue Oct 20, 2023 · 3 comments · Fixed by #362
Closed

Add <SInputSegments> #357

kiaking opened this issue Oct 20, 2023 · 3 comments · Fixed by #362
Assignees
Labels
enhancement New feature or request

Comments

@kiaking
Copy link
Member

kiaking commented Oct 20, 2023

<SInputSegments> is a select switch or tab panel that works as radio button. In GitHub Primer, this is called Segmented control.

Screenshot 2023-10-20 at 9 30 19

Props

It's input component so it should inherit basic input props. Would it be possible to use component generics for value? It should be the same type as Option.value 👀

import { type Validatable } from 'sefirot/composables/Validation'

interface Props {
  // Base props to be passed down to `<SInputBase>`.
  size?: Size
  label?: string
  info?: string
  note?: string
  help?: string
  hideError?: boolean
  validation?: Validatable

  options: Option[]

  disabled?: boolean // Default: false

  // The selected file. Same as other input,
  // `modelValue` takes precedence over `value`.
  value?: string | number | boolean
  modelValue?: string | number | boolean
}

type Size = 'mini' | 'small' | 'medium'

interface Option {
  label: string

  // Default: 'default'
  mode?: 'default' | 'info' | 'warning' | 'success' | 'danger'

  value: string | number | boolean
}

Events

interface Events {
  change: [value: string | number | boolean]
  'update:model-value': [value: string | number | boolean]
}

Slots

  • #info
    • Same as :info. When info prop and this slot are defined at the same time, this slot will take precedence.
@kiaking kiaking added the enhancement New feature or request label Oct 20, 2023
@cuebit
Copy link
Member

cuebit commented Oct 20, 2023

SInputTab gives me tab vibes and these are not tabs per-se nor do they function alike. Segmented controls are unique in their UI/UX usage, so when you read the word “segment” you can disambiguate it from all other forms of input controls given it is consistent with established patterns. For the sake of simplicity, perhaps SInputSegments is a reasonable compromise?

@kiaking
Copy link
Member Author

kiaking commented Oct 23, 2023

Good point 👀 Yeah let's make it SInputSegments 👍

@kiaking kiaking changed the title Add <SInputTab> Add <SInputSegments> Oct 23, 2023
@kiaking kiaking self-assigned this Oct 26, 2023
@kiaking
Copy link
Member Author

kiaking commented Oct 26, 2023

I'll take this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants