-
Notifications
You must be signed in to change notification settings - Fork 42
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
Conversation
|
Storybook demo3e1b92e56 | 91 komponenter | 144 stories |
@@ -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} |
There was a problem hiding this comment.
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
?
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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 😩 .
* @deprecated Prop will be removed and replaced by `size` in future versions. | ||
* @default "small" | ||
*/ | ||
headingSize?: "large" | "medium" | "small" | "xsmall"; |
There was a problem hiding this comment.
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).
There was a problem hiding this comment.
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; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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 😢
Should be ready for new review now 🤞
|
Description
Component Checklist 📝
@navikt/core/css/config/_mappings.js
)@navikt/core/css/tokens.json
)@navikt/aksel-stylelint/src/deprecations.ts
)@navikt/core/react/src/index.ts
and@navikt/core/react/package.json
)@navikt/core/css/index.css
)<Component>: <gitmoji?> <Text>.
E.g. "Button: ✨ Add feature xyz.")