sourcegraph / sourcegraph-public-snapshot

Code AI platform with Code Search & Cody
https://sourcegraph.com
Other
10.11k stars 1.29k forks source link

Wildcard: `Form` implementation #32127

Open umpox opened 2 years ago

umpox commented 2 years ago

Context

We have a variety of usage of <form> in the Sourcegraph codebase:

We should align these to use a new Wildcard <Form> element.

Implementation

TODO Update with details after further investigation.

This was originally discussed as part of Wildcard V2, but we didn't have time/capacity to work on this.

We should ensure that all our forms support:

Note:

umpox commented 2 years ago

Comment from @vovakulikov: https://github.com/sourcegraph/sourcegraph/pull/31977#issuecomment-1055343564

About form field base component. I'm not sure it still has a root wrapper because this component provides more than just a native input/textarea/checkbox. I think this could be more flexible if we split this UI into two components

<Field.Root isValid="true" ariaLabel=""> 
  <Field.Input type="" />
  or 
  <Field.FlextTextArea />
  or 
  <Field.Checkbox />
</Label>

These components still have our styles and UI guidance (in case if Field.Root got isValid false we could share it info through React Context with Field.Input and set a right CSS class to enforce validation styles over input element) but it allows to you more control over styles of label (root element) and input component itself (input, textarea, checkbox ...)