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

[ShadCN] Migrate Modal component to ShadCN/Tailwind #14163

Draft
wants to merge 3 commits into
base: dev
Choose a base branch
from

Conversation

TylerAPfledderer
Copy link
Contributor

Description

Related Issue

Copy link

netlify bot commented Oct 14, 2024

Deploy Preview for ethereumorg ready!

Name Link
🔨 Latest commit 3c246ef
🔍 Latest deploy log https://app.netlify.com/sites/ethereumorg/deploys/671088214ebc9c0008294d02
😎 Deploy Preview https://deploy-preview-14163--ethereumorg.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.
Lighthouse
Lighthouse
7 paths audited
Performance: 48 (🔴 down 5 from production)
Accessibility: 93 (no change from production)
Best Practices: 89 (🔴 down 9 from production)
SEO: 92 (no change from production)
PWA: -
View the detailed breakdown and full score reports

To edit notification comments on pull requests, go to your Netlify site configuration.

@TylerAPfledderer
Copy link
Contributor Author

Currently trying to leverage tailwind-variants to come up with a good approach to make the Modal styling a priority, and the other styles as variants. particularly with the placement of the close button.

@pettinarip
Copy link
Member

Currently trying to leverage tailwind-variants to come up with a good approach to make the Modal styling a priority, and the other styles as variants. particularly with the placement of the close button.

Great! thanks for the update @TylerAPfledderer. I'll have a closer look tomorrow.

@TylerAPfledderer
Copy link
Contributor Author

TylerAPfledderer commented Oct 17, 2024

@pettinarip I've noticed an error in my approach that I'll have corrected soon.

I should allow disclosure control to come purely from a parent of the modal, and consider including the dialog trigger in the renders if they aren't being used already.

Comment on lines +112 to +117
<Center className="absolute end-0 top-0" asChild>
<DialogPrimitive.Close className={close()}>
<MdClose />
<span className="sr-only">Close</span>
</DialogPrimitive.Close>
</Center>
Copy link
Member

Choose a reason for hiding this comment

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

To give full control, perhaps we could avoid forcing this and declare it as part of the DialogClose button.

Then, we could be more opinionated in the Modal structure and declare it as part of the header.

<DialogHeader>
  <DialogTitle>{title}</DialogTitle>
  <Center className="absolute end-0 top-0" asChild>
    <DialogClose />
  </Center>
</DialogHeader>

Copy link
Member

Choose a reason for hiding this comment

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

We could use our Button to wrap the close button to inherit the styles, right?

<DialogPrimitive.Close asChild>
  <Button ...>...
</DialogPrimitive.Close>

Copy link
Contributor Author

Choose a reason for hiding this comment

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

To give full control, perhaps we could avoid forcing this and declare it as part of the DialogClose button.

Can you clarify what you mean here? Are you referring specifically to DialogTitle?

Hmmm I'm not sure either way about the use of Button component. Best would be

<Button variant="ghost" isSecondary size="sm">

though here the size might be too small, but size="md" is too tall compared to the figma file, and you would have to force overrides in the size.

contentProps?: DialogContentProps
}

const Modal = ({
Copy link
Member

Choose a reason for hiding this comment

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

Nice. So, this export is to be backwards compatible with the previous instances, right?

Anyway, I think this abstraction makes sense to avoid repeating this code and have more consistency.

Copy link
Member

Choose a reason for hiding this comment

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

Was thinking if this was the correct place to put it or in src/components/Modal.tsx.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yea. Prop naming has changed slightly.

I currently have it here just to keep this isolated from the existing Modal file along with having all of this isolated from the existing dialog file while I try to figure out how all of it should be merged together.

const dialogVariant = tv({
slots: {
content:
"data-[state=open]:animate-contentShow w-full fixed left-1/2 top-1/2 grid -translate-x-1/2 -translate-y-1/2 gap-4 rounded-md bg-white p-8 shadow-[hsl(206_22%_7%_/_35%)_0px_10px_38px_-10px,_hsl(206_22%_7%_/_20%)_0px_10px_20px_-15px] focus:outline-none",
Copy link
Member

Choose a reason for hiding this comment

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

contentShow? is that a built-in animation in TW?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

That is a utility that came from Radix as I was copy/pasting some default code. I'll review this.

@TylerAPfledderer
Copy link
Contributor Author

TylerAPfledderer commented Oct 19, 2024

@pettinarip Not sure what should be done here using this new modal for the wallet simulators. Per how logic works in radix between DialogTrigger and the dialog itself, it would require rebuilding the code structure of the simulator content to retain this internal logic and avoid the need for a controlled state from the parent (but maintain the path querying to render the modal content).

I could try and keep the current way the simulator modals are triggered, but could be become async with the intended approach in using this modal in other areas.

Would at least keep this temporary dialog-modal file for now, while doing incremental transitioning, and ignore the simulator area for now.

At the time of this comment, I have not viewed other renders that are currently using the existing Modal.

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.

2 participants