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

feat(components): add dialog component #68

Draft
wants to merge 4 commits into
base: main
Choose a base branch
from

Conversation

sonnyt
Copy link
Contributor

@sonnyt sonnyt commented May 8, 2024

Started to add a dialog component. This is a still work in progress.

Am I heading the right direction @brankoconjic ? 😃

image

Copy link

changeset-bot bot commented May 8, 2024

⚠️ No Changeset found

Latest commit: e59612c

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

vercel bot commented May 8, 2024

@sonnyt is attempting to deploy a commit to the Lemon Squeezy Team on Vercel.

A member of the Team first needs to authorize it.

@brankoconjic brankoconjic self-requested a review May 8, 2024 17:21
@brankoconjic
Copy link
Collaborator

Hey @sonnyt,

Thank you for your contribution. It seems like you're headed in the right direction! Here are a few comments:

You've used some Tailwind utilities that do not exist. These animation classes are available through the Wedges Tailwind CSS plugin:

  • "wg-fade-in-up"
  • "wg-fade-in-down"
  • "wg-fade-in-left"
  • "wg-fade-in-right"
  • "wg-fade-out"
  • "wg-line-spinner"

We don't provide these: animate-in, animate-out...

Also, text-wedges-gray-900, you probably meant text-wg-gray-900.

Close button

I'd use the Wedges Button component for the Dialog Close component to maintain consistency with the design.

DialogContent.displayName = "DialogContent";
DialogOverlay.displayName = "DialogOverlay";

const Dialog = Object.assign(DialogPrimitive.Root, {
Copy link
Collaborator

@brankoconjic brankoconjic May 12, 2024

Choose a reason for hiding this comment

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

The idea behind Wedges components is to provide a versatile yet easy to use component for common use cases, equipped with the most useful props. Also, there is an option to enhance and personalize these components through the composition of additional components.

For instance, the Dialog component can be used as follows:

<Dialog title="Title" isOpen={true}>
  Content
</Dialog>

For more advanced use cases, the component can be composed with other components:

<Dialog.Root>
  <Dialog.Title>Title</Dialog.Title>
  <Dialog.Content>
    Content
  </Dialog.Content>
 ...
</Dialog.Root>

This flexibility allows for both easy implementation in straightforward scenarios and customizable complexity when needed.
```suggestion
const Dialog = Object.assign(DialogPrimitive.Root, {

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Perfect!

I will work on it next week :)

@sonnyt
Copy link
Contributor Author

sonnyt commented Jun 3, 2024

@brankoconjic I haven't forgotten about this PR. Been a little busy with job interviews. I will get back to it this week! 😊


export default function Example() {
// You most likely don't need to use `containerRef` in your implementation. This is just for preview.
const containerRef = useRef<HTMLDivElement>(null);
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Mounting the dialog into a container rather than the document.body so we can apply the dark and light themes during previews.

Comment on lines +141 to +155
const transformDefaults = {
translateX: "var(--tw-translate-x)",
translateY: "var(--tw-translate-y)",
rotate: "var(--tw-rotate)",
skewX: "var(--tw-skew-x)",
skewY: "var(--tw-skew-y)",
scaleX: "var(--tw-scale-x)",
scaleY: "var(--tw-scale-y)",
};

const animateTransform = (transforms: Partial<typeof transformDefaults> = {}) => {
return Object.entries({ ...transformDefaults, ...transforms })
.map(([key, value]) => `${key}(${value})`)
.join(" ");
};
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I noticed that currently, animations are overriding all transform functions. Ideally we only want to animate the functions we need and inherit the rest. This small utility function basically does that.

},
"100%": {
opacity: "1",
transform: "translateY(0px) scale(1)",
transform: animateTransform({ translateY: "0", scaleX: "1", scaleY: "1" }),
Copy link
Contributor Author

Choose a reason for hiding this comment

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

So currently we are hardcoding the final state of the animations which basically is the initial state (translateY(0), scaleX(1)).

I was thinking, what if we just remove them and fallback to default variables? Because currently animations override functions defined on the element classes.

For example:

<div className="translate-y-1/2 animate-wg-fade-in-up"></div>

The animation overrides the translate-y with 0 due to the final keyframe.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Comment on lines +276 to +285
fadeIn: {
"0%": {
opacity: "0",
transform: animateTransform({ scaleX: ".97", scaleY: ".97" }),
},
"100%": {
opacity: "1",
transform: animateTransform({ scaleX: "1", scaleY: "1" }),
},
},
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Added basic fadeIn animation

@sonnyt sonnyt requested a review from brankoconjic July 18, 2024 00:36
@ammarmbe
Copy link

ammarmbe commented Aug 9, 2024

Any updates on this? @brankoconjic

@brankoconjic
Copy link
Collaborator

brankoconjic commented Aug 16, 2024

Sorry, I haven't had a chance to take a look into this yet. Still need to wait for the official Wedges design for this component before we can release it.

I'm hoping to review the code next week.

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