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

feat(elements): Adjust FieldState and Field #3017

Merged
merged 4 commits into from
Mar 21, 2024

Conversation

LekoArts
Copy link
Member

@LekoArts LekoArts commented Mar 20, 2024

Description

  • Adjust <FieldState> to return its state directly in the function param, not nested inside an object
  • Adjust <Field> to allow for a function prop that gives back the field state
<Field name="email">
  <FieldState>
    {(state) => (
      <pre>Field state: {state}</pre>
    )}
  </FieldState>
</Field>
<Field name="emailAddress">
  {(fieldState) => (
    <span>{fieldState === "invalid" ? "Error" : "All fine!"}</span>
  )}
</Field>

Fixes SDK-1524
Fixes SDK-1525

Checklist

  • npm test runs as expected.
  • npm run build runs as expected.
  • (If applicable) JSDoc comments have been added or updated for any package exports
  • (If applicable) Documentation has been updated

Type of change

  • 🐛 Bug fix
  • 🌟 New feature
  • 🔨 Breaking change
  • 📖 Refactoring / dependency upgrade / documentation
  • other:

Copy link

changeset-bot bot commented Mar 20, 2024

🦋 Changeset detected

Latest commit: bd2c9f0

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 0 packages

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@LekoArts LekoArts requested a review from brkalow March 20, 2024 15:10
@LekoArts LekoArts marked this pull request as ready for review March 20, 2024 15:10
Copy link
Member

@brkalow brkalow left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm!

<Label className='sr-only'>Email</Label>
<Input
className={`bg-[rgb(12,12,12)] border-[rgb(37,37,37)] border rounded w-full placeholder-[rgb(100,100,100)] px-4 py-2 ${
fieldState === 'invalid' && 'border-red-500'
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[nit] Just an observation, I would actually consider this not the proper usage of accessing field state. Given that we have the data attribute for styling purposes, that's probably how we would want to educate folks for basic styling.

For more advanced use cases, like animation, then we have the render prop for programmatic access.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, agree. One should use the data attribute - but since this is our Playground and I needed a way to test it + have it used somewhere to see possible future regressions I opted to do that 👍

@LekoArts LekoArts merged commit aef024e into main Mar 21, 2024
9 checks passed
@LekoArts LekoArts deleted the lekoarts/sdk-1525-support-render-prop-for-field branch March 21, 2024 08:24
@LekoArts LekoArts added this to the @clerk/elements (Beta) milestone Mar 21, 2024
brkalow pushed a commit that referenced this pull request Mar 22, 2024
* fix(elements): Update FieldState function prop signature

* feat(elements): Add state children function to Field

* chore(elements): Bump version
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants