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

[Darkside] Accordion CSS-rewrite #3296

Merged
merged 28 commits into from
Nov 6, 2024
Merged

[Darkside] Accordion CSS-rewrite #3296

merged 28 commits into from
Nov 6, 2024

Conversation

KenAJoh
Copy link
Collaborator

@KenAJoh KenAJoh commented Oct 29, 2024

Description

  • discuss allow-discrete and starting-styles

Component Checklist 📝

  • JSDoc
  • Examples
  • Documentation / Decision Records
  • Storybook
  • Style mappings (@navikt/core/css/config/_mappings.js)
  • Component tokens (@navikt/core/css/tokens.json)
  • CSS class deprecations (@navikt/aksel-stylelint/src/deprecations.ts)
  • Exports (@navikt/core/react/src/index.ts and @navikt/core/react/package.json)
  • New component? CSS import (@navikt/core/css/index.css)
  • Breaking change? Update migration guide. Consider codemod.
  • Changeset (Format: <Component>: <gitmoji?> <Text>. E.g. "Button: ✨ Add feature xyz.")

Copy link

changeset-bot bot commented Oct 29, 2024

⚠️ No Changeset found

Latest commit: 842a042

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

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

Click here to learn what changesets are, and how to add one.

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

Copy link
Contributor

github-actions bot commented Oct 29, 2024

Storybook demo

3e1b92e56 | 91 komponenter | 144 stories

@KenAJoh KenAJoh marked this pull request as ready for review October 30, 2024 12:23
JulianNymark
JulianNymark previously approved these changes Oct 30, 2024
@navikt/core/css/darkside/accordion.darkside.css Outdated Show resolved Hide resolved
@navikt/core/css/darkside/accordion.darkside.css Outdated Show resolved Hide resolved
@navikt/core/css/darkside/accordion.darkside.css Outdated Show resolved Hide resolved
@@ -65,6 +65,7 @@ const AccordionItem = forwardRef<HTMLDivElement, AccordionItemProps>(
"navds-accordion__item--neutral": context?.variant === "neutral",
"navds-accordion__item--no-animation": !shouldAnimate.current,
})}
data-expanded={_open}
Copy link
Contributor

Choose a reason for hiding this comment

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

Why not use .navds-accordion__item--open?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I saw this pattern used a lot in Radix, and quite like what it achieves:

  • User can always see the current state in the dom
  • Using classes always ends with some instances being "positive" and some "negative", so --closed or --open. Using data-<state> removes that issue

This is mostly relevant for the cases where the component has styles applied for both states

Copy link
Contributor

@JulianNymark JulianNymark Nov 4, 2024

Choose a reason for hiding this comment

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

I super support this moving of state classes -> data-<state> attributes 🎉 . I don't like the "negative/positive" mix problem in css classes that inevitably happens 😩 .

Comment on lines 39 to 42
* @deprecated Prop will be removed and replaced by `size` in future versions.
* @default "small"
*/
headingSize?: "large" | "medium" | "small" | "xsmall";
Copy link
Contributor

@HalvorHaugan HalvorHaugan Nov 1, 2024

Choose a reason for hiding this comment

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

Should we delay deprecating headingSize until new design is launched? People will not be able to remove the prop until then anyways (without having to live with undesirable heading size temporarily).

Maybe we can do something clever and map headingSize to size temporarily? Edit: Probably a bad idea, just trying to think about how we can avoid any "breaking" design changes (to the extent you can call changed heading size a breaking change).

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Makes sense to delay it until release 👍

text-align: left;
background: var(--ac-accordion-header-bg, var(--a-surface-transparent));
cursor: pointer;
border: none;
position: relative;
Copy link
Contributor

Choose a reason for hiding this comment

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

you might want to add some sticky (and non alpha bg colors) to mirror the nav.no behaviour when you can't see the top of the accordion header anymore?

image

  position: sticky;
  top: 0;
  background-color: white;
  z-index: 1;

Copy link
Contributor

Choose a reason for hiding this comment

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

I think it's a good feature 🙌, so I vote for adding it.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Think this feature might need to be implemented by the teams themselves, because of the possible edgecases for where "top" is. If you dig down into how they handle it, they have a custom css-variable for "top" that changes based on decorator height

Copy link
Contributor

Choose a reason for hiding this comment

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

I think the top being 0 should work out as long as parent has position relative no? it seemed to work out great in my testing 🤔 The header is always inside an accordion item wrapper, so that can be the top: 0 position?

Copy link
Contributor

@JulianNymark JulianNymark Nov 4, 2024

Choose a reason for hiding this comment

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

nvm, it works badly after all 😅

They need to be sticky towards the same containing element with offsets 😢

@KenAJoh
Copy link
Collaborator Author

KenAJoh commented Nov 5, 2024

Should be ready for new review now 🤞

  • Removed position: relative used in Accordion.Content to avoid re-introducing datepicker bug
  • Implemented "new" size handling:
    • medium -> 20px font, spacing-3 padding-block in header
    • small -> 18px font, spacing-2 padding-block in header

@KenAJoh KenAJoh requested review from a team as code owners November 6, 2024 13:43
@KenAJoh KenAJoh merged commit 1fdb7c8 into main Nov 6, 2024
4 checks passed
@KenAJoh KenAJoh deleted the darkside-accordion-updated branch November 6, 2024 17:52
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