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

fix(react): add missing data-size & data-color props to Details #2930

Open
wants to merge 1 commit into
base: next
Choose a base branch
from

Conversation

unekinn
Copy link
Contributor

@unekinn unekinn commented Dec 20, 2024

No description provided.

Copy link

changeset-bot bot commented Dec 20, 2024

🦋 Changeset detected

Latest commit: 8f54ec9

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-react Patch
@digdir/designsystemet Patch
@digdir/designsystemet-css 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 Dec 20, 2024

Preview deployments for this pull request:

Storybook - 20. Dec 2024 - 17:41

Copy link
Contributor

github-actions bot commented Dec 20, 2024

Coverage Report

Status Category Percentage Covered / Total
🔵 Lines 55.2% 3198 / 5793
🔵 Statements 55.2% 3198 / 5793
🔵 Functions 86.6% 181 / 209
🔵 Branches 76.96% 518 / 673
File Coverage
File Stmts Branches Functions Lines Uncovered Lines
Changed Files
packages/react/src/components/Details/Details.tsx 100% 80% 100% 100%
Generated in workflow #1389 for commit 8f54ec9 by the Vitest Coverage Report Action

Comment on lines 10 to 15
DefaultProps & HTMLAttributes<HTMLDetailsElement>,
{
/**
* Specify which color palette to use.
*/
'data-color'?: DefaultProps['data-color'];
Copy link
Member

@Barsnes Barsnes Dec 20, 2024

Choose a reason for hiding this comment

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

DefaultProps comes with data-color, do we need to specify it again?

Copy link
Collaborator

Choose a reason for hiding this comment

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

Something with MergeRight or how react-docgen parses types not working as intended?

Copy link
Contributor Author

@unekinn unekinn Dec 20, 2024

Choose a reason for hiding this comment

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

The only reason I'm repeating it, is to make the documentation make sense. The DefaultProps['data-color'] doc comment says (emphasis mine):

Sets a color palette which may be used by descendants. Does not affect this component. If left unspecified, the color is inherited from the nearest ancestor with data-color.

When I implemented the new color system I landed on this as the best default documentation, since it would be confusing for components that don't change color based on this prop to have "Specify which color palette to use". But if you have any ideas or suggestions on how to do this more clearly, I'm all ears 😊

However, looking at Details' implementation, both the type and doc comment should actually be different. It should be something like this:

    /**
     * Specify which color palette to use.
     * If left unspecified, the color is inherited from the nearest ancestor with data-color.
     */
    'data-color'?: 'subtle' | Color;

@unekinn unekinn force-pushed the fix/details-missing-props branch from 90d2d3e to 8f54ec9 Compare December 20, 2024 16:38
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.

3 participants