Skip to content

feat!: refactor field component API #1713

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

Merged
merged 2 commits into from
May 7, 2024
Merged

Conversation

joshuaellis
Copy link
Contributor

What does it do?

  • refactors the Field API to be a composite component
  • uses a default value so you can use our inputs in and out of the Field component

Related issue(s)/PR(s)

  • resolves DX-1386

@joshuaellis joshuaellis added pr: enhancement This PR adds or updates some part of the codebase or features flag: 💥 Breaking change This PR contains breaking changes and should not be merged source: design-system relates to design-system package labels May 3, 2024
@joshuaellis joshuaellis self-assigned this May 3, 2024
Copy link

changeset-bot bot commented May 3, 2024

🦋 Changeset detected

Latest commit: e54aaa9

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

This PR includes changesets to release 3 packages
Name Type
@strapi/design-system Major
@strapi/icons Major
@strapi/ui-primitives Major

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

vercel bot commented May 3, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
design_system_v2 ✅ Ready (Inspect) Visit Preview 💬 Add feedback May 3, 2024 2:49pm
design-system ✅ Ready (Inspect) Visit Preview 💬 Add feedback May 3, 2024 2:49pm
design-system-website ❌ Failed (Inspect) May 3, 2024 2:49pm

Copy link
Contributor

github-actions bot commented May 3, 2024

Size Change: +1.16 kB (0%)

Total Size: 297 kB

Filename Size Change
packages/design-system/dist/index.js 98.9 kB +639 B (+1%)
packages/design-system/dist/index.mjs 97.5 kB +516 B (+1%)
ℹ️ View Unchanged
Filename Size
packages/icons/dist/index.js 22.1 kB
packages/icons/dist/index.mjs 21.7 kB
packages/icons/dist/symbols-index.js 11.9 kB
packages/icons/dist/symbols-index.mjs 11.8 kB
packages/primitives/dist/index.js 16.6 kB
packages/primitives/dist/index.mjs 16.1 kB

compressed-size-action

@@ -8,5 +8,6 @@
// TODO: re-enable this rules
"react/display-name": "off",
"@typescript-eslint/no-explicit-any": "warn",
"import/export": "off",
Copy link
Contributor

Choose a reason for hiding this comment

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

Why did you add this?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

typescript manages this for us, and there were weird errors where eslint thought there was an issue with dual exports but it wasn't an issue since we use TS namespacing 🤔

Copy link
Contributor

@simotae14 simotae14 left a comment

Choose a reason for hiding this comment

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

Great work as always

I saw there are part of code repeated in some input fields

const hasError = Boolean(error) || hasErrorProp;
    const id = field.id ?? idProp;
    const required = field.required || requiredProp;

    let ariaDescription: string | undefined;
    if (error) {
      ariaDescription = `${id}-error`;
    } else if (field.hint) {
      ariaDescription = `${id}-hint`;
    }

but to be honest I can find a better way to do it.

@joshuaellis
Copy link
Contributor Author

Great work as always

I saw there are part of code repeated in some input fields

const hasError = Boolean(error) || hasErrorProp;
    const id = field.id ?? idProp;
    const required = field.required || requiredProp;

    let ariaDescription: string | undefined;
    if (error) {
      ariaDescription = `${id}-error`;
    } else if (field.hint) {
      ariaDescription = `${id}-hint`;
    }

but to be honest I can find a better way to do it.

Yeah I agree, I'll keep it mind when working on other bits, it might be that the API could be made better again 🤔

@joshuaellis joshuaellis merged commit 1613d94 into releases/2.0.0 May 7, 2024
@joshuaellis joshuaellis deleted the feat/field-api branch May 7, 2024 08:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
flag: 💥 Breaking change This PR contains breaking changes and should not be merged pr: enhancement This PR adds or updates some part of the codebase or features source: design-system relates to design-system package
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants