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

New Admin UI - Accordion Component #4505

Merged
merged 60 commits into from
Feb 10, 2025
Merged

Conversation

adrians5j
Copy link
Member

@adrians5j adrians5j commented Jan 26, 2025

TODO

Changes

This PR creates the Accordion component.

Some screenshots.

image
image
image

Additional Changes

1. Icon Component - label Prop Optional

A lot of times, I needed to use the Icon component, without the need to provide the label for the icon. So, I made the label prop optional.

2. Removed Redundant Comments

While working on the wby- prefix, code generation left comments in a couple of places. For example:

// No Tailwind classes to modify in this file

I removed these.

3. Reordered keyframes and animation In tailwind.config.js

I had to add keyframes / animation into tailwind.config.js, and then I noticed these already got here via the Skeleton PR. All good, but I still just alphabetically ordered the properties.

4. Form Builder - Minor Tweaks

Had to do a bit of tweaking there. Nothing special. But it is included in this PR.

@adrians5j adrians5j changed the base branch from next to feat/new-admin-ui January 26, 2025 06:55
@adrians5j adrians5j marked this pull request as ready for review February 6, 2025 08:05
Copy link
Contributor

@leopuleo leopuleo left a comment

Choose a reason for hiding this comment

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

Thank you Adrian, I left some comments here and there but the overall PR looks good!

{...rootProps}
className={cn(
"w-full",
{ "wby-gap-xs wby-flex wby-flex-col": variant === "container" },
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 the cva utility?

Comment on lines 49 to 54
"wby-border-b-sm wby-border-b-neutral-dimmed data-[state=open]:wby-rounded-bl-lg data-[state=open]:wby-rounded-br-lg",
{
"wby-rounded-lg": variant === "container",
"wby-bg-neutral-base": background === "base",
"wby-bg-neutral-light": background === "light"
}
Copy link
Contributor

Choose a reason for hiding this comment

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

I would use cva util.

);
};

AccordionItemBase.displayName = "AccordionItem";
Copy link
Contributor

@leopuleo leopuleo Feb 6, 2025

Choose a reason for hiding this comment

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

Do we need this? Maybe not, since we are not using ref

);
};

AccordionBase.displayName = "Accordion";
Copy link
Contributor

@leopuleo leopuleo Feb 6, 2025

Choose a reason for hiding this comment

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

Do we need this? Maybe not, since we are not using ref

animation: {
"accordion-down": "accordion-down 0.2s ease-out",
"accordion-up": "accordion-up 0.2s ease-out",
skeletonPulse: "skeletonPulse 1400ms ease-in-out infinite"
Copy link
Contributor

Choose a reason for hiding this comment

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

Shall we stick to a camelCase or kebab-case naming convention? The kebab-case looks good, but I would change skeletonPulse 🙏

Copy link
Member Author

Choose a reason for hiding this comment

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

Done.


const AccordionContext = React.createContext<Pick<AccordionProps, "variant" | "background">>({});

const useAccordion = () => {
Copy link
Contributor

@leopuleo leopuleo Feb 6, 2025

Choose a reason for hiding this comment

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

The AccordionContext holds variant and background values accessible to inner components.

I had a similar situation with the Toast component, and I managed to style the inner components by adding wby-group and the variation class names to the root component -> https://github.com/webiny/webiny-js/blob/feat/new-admin-ui/packages/admin-ui/src/Toast/components/Root.tsx#L12-L15

Then, I can target the parent class name from the inner component and style it differently based on the variation class name -> https://github.com/webiny/webiny-js/blob/feat/new-admin-ui/packages/admin-ui/src/Toast/components/Title.tsx#L15

What do you think?

@@ -29,12 +29,12 @@ const iconVariants = cva("", {
interface IconProps
extends Omit<React.HTMLAttributes<HTMLOrSVGElement>, "color">,
VariantProps<typeof iconVariants> {
label: string;
label?: string; // We don't want to force the label to be required.
Copy link
Contributor

@leopuleo leopuleo Feb 6, 2025

Choose a reason for hiding this comment

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

I understand we don't want to force this property, but it's actually quite useful if we aim to have an accessible application. It's okay to make it optional, but providing a label should be encouraged as a best practice.

@webiny webiny deleted a comment from leopuleo Feb 7, 2025
@adrians5j adrians5j merged commit 0093c96 into feat/new-admin-ui Feb 10, 2025
17 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants