-
Notifications
You must be signed in to change notification settings - Fork 1.3k
feat: accordion header tag (#4999) #5424
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
base: main
Are you sure you want to change the base?
feat: accordion header tag (#4999) #5424
Conversation
| type Props = ComponentPropsWithoutRef<typeof Header> & { tag?: Tag }; | ||
| export const AccordionHeader = forwardRef<HTMLHeadingElement, Props>( | ||
| ({ tag: legacyTag, ...props }, ref) => { | ||
| const tag = getTagFromProps(props) ?? legacyTag ?? defaultTag; |
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.
Call variable in pascal case "Heading" and you can use it in jsx without createElement which is considered legacy.
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.
Alright, I will resolve this. Thank you.
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.
Hello @TrySound , I’ve made the necessary updates based on your earlier comments.
| style: { | ||
| ...(props.style || {}), | ||
| marginTop: 0, | ||
| marginBottom: 0, | ||
| }, |
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.
Builder does not support "style" property. So please remove it. Otherwise it will override user preferences from tokens.
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.
Alright, I will resolve this too. There is a margin-top: 0 and margin-bottom: 0 applied to the H3 Item Header in accordion.ws.ts, which is why I applied the style here. I wanted to ask, do we still need these styles?
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.
Yes, I think they still needed. At least to not break existing projects.
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.
And just to confirm, do we need this margin-top: 0 and margin-bottom: 0 for all heading levels or just for H3? I am planning to apply it to all heading levels in accordion.ws.ts.
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.
@TrySound the PR was updated last week, I just didn’t drop a message here.
179b2b1 to
fd35c7f
Compare
fd35c7f to
398a540
Compare
| type Tag = "h1" | "h2" | "h3" | "h4" | "h5" | "h6"; | ||
| type Props = ComponentProps<typeof Header> & { tag?: Tag }; | ||
| export const AccordionHeader = forwardRef<HTMLHeadingElement, Props>( | ||
| ({ tag: legacyTag, ...props }, ref) => { |
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.
Since this component never accepted tag property there is no need to handle legacy version. tag property you added in meta will add control which will write directly into this call getTagFromProps(props). So just remove "tag" property from here and all will continue to work.
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.
@TrySound The tag property has been removed, and defaultTag is now set to h1 to ensure the rendered tag stays in sync with properties like data-ws-editable-placeholder from the moment the component is added.
398a540 to
51d10c8
Compare
TrySound
left a comment
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.
Great work! Thanks
Description
This pull request introduces a new feature that allows changing the heading tag of an Accordion Item Header.
Related issue: #4999
Changes
metaAccordionHeaderinaccordion.ws.tsto includeh1–h6options, enabling users to select the heading level in the Item Header settings.AccordionHeaderinaccordion.tsxto accept and renderh1–h6tags dynamically.margin-topandmargin-bottomstyles frommetaAccordionHeadertoAccordionHeaderto ensure consistent spacing across all heading levels.How to Test