-
Notifications
You must be signed in to change notification settings - Fork 623
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
Conversation
…into feat/accordion
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.
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" }, |
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 the cva
utility?
"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" | ||
} |
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 would use cva
util.
); | ||
}; | ||
|
||
AccordionItemBase.displayName = "AccordionItem"; |
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.
Do we need this? Maybe not, since we are not using ref
); | ||
}; | ||
|
||
AccordionBase.displayName = "Accordion"; |
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.
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" |
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.
Shall we stick to a camelCase or kebab-case naming convention? The kebab-case looks good, but I would change skeletonPulse
🙏
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.
Done.
|
||
const AccordionContext = React.createContext<Pick<AccordionProps, "variant" | "background">>({}); | ||
|
||
const useAccordion = () => { |
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.
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?
packages/admin-ui/src/Icon/Icon.tsx
Outdated
@@ -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. |
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 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.
…into feat/accordion # Conflicts: # packages/cli/files/references.json
TODO
Changes
This PR creates the Accordion component.
Some screenshots.
Additional Changes
1. Icon Component -
label
Prop OptionalA 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:I removed these.
3. Reordered
keyframes
andanimation
Intailwind.config.js
I had to add
keyframes
/animation
intotailwind.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.