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

Adding Input #252

Closed
tleperou opened this issue Mar 24, 2023 · 0 comments
Closed

Adding Input #252

tleperou opened this issue Mar 24, 2023 · 0 comments

Comments

@tleperou
Copy link
Contributor

tleperou commented Mar 24, 2023

🙌

Summary

Input component aims at providing support for user input

  • aria compliant (eg. semantic, state)
  • key control (eg. focus, navigate fields)
  • good practices (eg. label, hints, errors)

It doesn't intend to provide validations support (yet).

Implementation

I could get the above working, with

  • semantic and aria attributes
  • automatic for attribute
const Input = component$(() => {
  return (
    <Input.Root>
    <Input.Label>On/Off</Input.Label>
    <Input.Switch
      checked={checkedSignal.value}
      onChange$={(_, { checked }) => {
          checkedSignal.value = checked;
        }}
      />
      <Input.Hint>Choose if it's on or off</Input.Hint>
      <Input.Message>Can't be turned off at the moment</Input.Message>
    </Input.Root>
  )
});

Style

In order to pass scoped styles down to the child nodes when using useScopedStyles

const { scopeId } = useStylesScoped$(styles);

// .. then

<Input.Label class={[scopeId, 'control']}></Input.Label>

Works as usual with any other patterns (eg. styled of vanilla extract css)

@gioboa gioboa closed this as completed Apr 3, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Archived in project
Development

No branches or pull requests

2 participants