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(Field): start implementing field api #2502

Merged
merged 32 commits into from
Oct 18, 2024
Merged

feat(Field): start implementing field api #2502

merged 32 commits into from
Oct 18, 2024

Conversation

eirikbacker
Copy link
Contributor

@eirikbacker eirikbacker commented Sep 24, 2024

Fixes #1943
For now just testing creating a <Field> component, which uses a utility that works with the real DOM, making it possible to use in a future custom element <ds-field> as well. This also allows injecting any form element - not just made by us, but any native form element, any form associated custom element or third party components.

By using native DOM, there is no Context that needs to run on server, and all the wire-up is only for assistive technology - it does not effect the visual representation, meaning it can be done under the hood on the client without causing any layout shift or similar issues.

API:

<Field>
  <Label>Label text</Label>
  <Field.Description>Description</Field.Description> // Should be without Field.? :)
  <Input />
  <ValidationMessage>Validation message</ValidationMessage> // Should be Field.Validation.? :)
</Field>
  • More tests are needed, and moving Affix and Counter into Field is needed, but keeping this PR small so we can divide the task between us :)

@eirikbacker eirikbacker self-assigned this Sep 24, 2024
Copy link

changeset-bot bot commented Sep 24, 2024

🦋 Changeset detected

Latest commit: c339c1b

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

This PR includes changesets to release 4 packages
Name Type
@digdir/designsystemet-css Patch
@digdir/designsystemet-react Patch
@digdir/designsystemet Patch
@digdir/designsystemet-theme Patch

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

Copy link
Contributor

github-actions bot commented Sep 24, 2024

Preview deployments for this pull request:

Storybook - 18. Oct 2024 - 14:01

Copy link
Contributor

github-actions bot commented Sep 24, 2024

Coverage Report

Status Category Percentage Covered / Total
🔵 Lines 57.83% 3624 / 6266
🔵 Statements 57.83% 3624 / 6266
🔵 Functions 83.91% 167 / 199
🔵 Branches 75.69% 514 / 679
File Coverage
File Stmts % Branch % Funcs % Lines Uncovered Lines
Changed Files
packages/react/src/components/ValidationMessage/ValidationMessage.tsx 100% 100% 100% 100%
packages/react/src/components/form/Field/Field.tsx 35.71% 100% 0% 35.71% 9-14, 16-17, 19
packages/react/src/components/form/Field/FieldDescription.tsx 66.66% 100% 0% 66.66% 10-11
packages/react/src/components/form/Field/fieldObserver.ts 84.28% 60% 87.5% 84.28% 30, 32-37, 87-90
Generated in workflow #434 for commit c339c1b by the Vitest Coverage Report Action

@eirikbacker eirikbacker marked this pull request as ready for review October 18, 2024 09:59
@Barsnes
Copy link
Member

Barsnes commented Oct 18, 2024

We should probably have a changeset for this

packages/css/index.css Outdated Show resolved Hide resolved
packages/react/src/components/form/Field/Field.stories.tsx Outdated Show resolved Hide resolved
packages/react/src/components/form/Field/fieldA11Y.ts Outdated Show resolved Hide resolved
packages/react/src/components/form/Field/fieldA11Y.ts Outdated Show resolved Hide resolved
Copy link
Collaborator

@mimarz mimarz left a comment

Choose a reason for hiding this comment

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

Just some small stuff on code readability.

This is a good starting point for us to start using, and we'll just tweak going forward.

I also updated #2311 CharacterCounter so we don't forget we need to figure out how to solve that.

@eirikbacker eirikbacker merged commit 50efed2 into next Oct 18, 2024
9 checks passed
@eirikbacker eirikbacker deleted the fix/field-api branch October 18, 2024 12:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

POC: Field component
3 participants