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

fix: Implement DS styles and unify modals #11212

Merged
merged 67 commits into from
May 29, 2024
Merged

Conversation

ashiskumar-1999
Copy link
Contributor

@ashiskumar-1999 ashiskumar-1999 commented Sep 19, 2023

Description

Implemented the styles from the DS to the Modal theme file & component. Replaced the existing modal implementation with the current Modal.

  • Added the DS styles from Figma in the theme file(@chakra-ui/gatsby-plugin/components/Modal.ts) & removed styles from the ModalContent in the Component file(components/Modal.tsx).
  • Replaced the current QuizessModal implementation with the current Modal Component.
  • Implemented the current Modal component in the index.tsx file instead of CodeModal component.

Preview link

Related Issue

ashiskumar-1999 and others added 2 commits September 19, 2023 22:33
Added the styles to the theme file aligned with the DS styles & replaced the QuizzesModal with the current customized modal component.
@github-actions github-actions bot added content 🖋️ This involves copy additions or edits review needed 👀 labels Sep 19, 2023
@gatsby-cloud
Copy link

gatsby-cloud bot commented Sep 20, 2023

✅ ethereum-org-website-dev deploy preview ready

@ashiskumar-1999 ashiskumar-1999 marked this pull request as ready for review September 21, 2023 06:35
@ashiskumar-1999 ashiskumar-1999 changed the title fix: Implement DS styles and unify modals #10749 fix: Implement DS styles and unify modals [ Closes issue #10749 ] Sep 21, 2023
@TylerAPfledderer
Copy link
Contributor

Taking a quick moment to mention that Closes #10749 should be added to the description so this PR is automatically tied to that issue.

@ashiskumar-1999
Copy link
Contributor Author

Thanks @TylerAPfledderer
Added it.

@ashiskumar-1999 ashiskumar-1999 changed the title fix: Implement DS styles and unify modals [ Closes issue #10749 ] fix: Implement DS styles and unify modals Sep 30, 2023
@TylerAPfledderer
Copy link
Contributor

TylerAPfledderer commented Oct 1, 2023

@ashiskumar-1999 hmmm, I believe there are two things that should be done first before this can get a proper review:

  1. All the styling under variantCode in the component theming is related to the CodeModal component that can be seen on the home page. Head to the Site preview deploy of this PR, scroll down to the section called "A new frontier for development" and select one of the options in that list to see the modal.

Screen Shot 2023-09-30 at 23 21 39

Since the CodeModal is likely to be using this same general styling, I would take all of the styling from variantCode and move it to baseStyle and address the compressed width of CodeModal from there. (I'd recommend simply removing the maxWidth from the dialog part for now and use size="2xl" instead)

This would mean Modal should have no variant, and CodeModal is basically redundant against the custom Modal that has been added.

  1. All components related to the Design System need to be added to Storybook with a stories file. So Modal.tsx needs to be converted to Modal/index.tsx and add the stories file in this new folder as Modal.stories.tsx. For the directory title the new story is housed in, it should be Molecules / Overlay Content / Modal.

For further guidance on creating this stories file and using it for visual testing, there is a doc in the project repo to view. However, I just recognized that it is a bit out-of-date. Therefore, I would view the file via a PR I just opened. Though subject to change, this would be more accurate documentation. See this commit of the file from that PR and we'll go from there.

@ashiskumar-1999
Copy link
Contributor Author

Hi @TylerAPfledderer,
Addressed the above comments. Review this once in your available time.

Copy link
Contributor

@TylerAPfledderer TylerAPfledderer left a comment

Choose a reason for hiding this comment

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

I have provided suggestions to the most recent changes.

With the Storybook file, we want to favor Single-story hoisting, since there only one story expected to be used for the modal at this time. This means updating namings to import alias of the component, the story title and the single story itself.

@@ -0,0 +1,20 @@
import { Meta, StoryObj } from "@storybook/react"
import Modal from "."
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
import Modal from "."
import ModalComponent from "."

Comment on lines 4 to 7
const meta = {
title: "Molecules/Overlay Content/Modal/BaseModal",
component: Modal,
} satisfies Meta<typeof Modal>
Copy link
Contributor

Choose a reason for hiding this comment

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

In addition to import alias name change.

The title should only account for the name of the component, whether or not there is just one story.

Suggested change
const meta = {
title: "Molecules/Overlay Content/Modal/BaseModal",
component: Modal,
} satisfies Meta<typeof Modal>
const meta = {
title: "Molecules/Overlay Content/Modal",
component: ModalComponent,
} satisfies Meta<typeof ModalComponent>


export default meta
type Story = StoryObj<typeof meta>
export const BaseModal: Story = {
Copy link
Contributor

Choose a reason for hiding this comment

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

Because the alias import of the component is renamed to ModalComponent and the directory path of this story file (The title in the meta object) ends with Modal, then we can give this story the same name, and Storybook will just generate the story and not a folder for it to be housed in. This tidies up the directory structure with only one story being rendered for the component.

Suggested change
export const BaseModal: Story = {
export const Modal: Story = {

You can read more here about Single-Story Hoisting

Suggested change
export const BaseModal: Story = {
export const Modal: Story = {

@@ -95,14 +96,14 @@ const QuizzesHubPage = ({ data }: PageProps<Queries.QuizzesHubPageQuery>) => {
</Box>

<QuizzesHubContext.Provider value={contextState}>
<QuizzesModal isOpen={isOpen} onClose={onClose}>
<Modal isOpen={isOpen} setIsOpen={onClose}>
Copy link
Contributor

Choose a reason for hiding this comment

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

Do not replace QuizzesModal here. Rather, update that component instead to use the custom Modal over the one imported directly from Chakra.

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 think we should use directly the Modal component instead of updating the QuizzesModal. Because we have set another prop for the isOpen & setIsOpen prop of the custom Modal & we can add the value where the QuizzesModal component is being rendered. What do you think?

Copy link
Contributor

Choose a reason for hiding this comment

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

@ashiskumar-1999 it's more about the custom styling that is added to this instance of the modal and keeping that styling in isolation. In particular, there is conditional rendering of the background color and the use of the size prop based on screen size.

Also it would be easier to continue handling the background style in QuizzesModal than trying to do the logic in a variant for something primitive. That's not how a theme variant should be applied.

/* borderTop: "1px solid",
borderBottom: "1px solid", */
padding: 0,
textTransform: "uppercase",
Copy link
Contributor

Choose a reason for hiding this comment

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

Not a part of the DS

Suggested change
textTransform: "uppercase",

fontSize: "md",
fontFamily: "Inter",
},
footer: {
Copy link
Contributor

Choose a reason for hiding this comment

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

The footer part needs it's padding updated. Currently, the ModalFooter component renders it's own padding.

Add:

px: 0,
pt: "8",
pb: 0,

This will create the necessary overrides here and match the DS is the extended spacing above the buttons.

@pettinarip
Copy link
Member

@nloureiro PR ready for review (once the build finishes).

As discussed, we have:

  • on mobile, used the same styles used in the Simulator modal
  • unified the sizes of the modals
  • the close button is not absolute positioned, now it is part of the header structure
  • the modal padding is 32px

The affected modals and pages where you can see them are:

@pettinarip pettinarip marked this pull request as draft April 26, 2024 14:33
@pettinarip pettinarip self-assigned this Apr 26, 2024
@nloureiro
Copy link
Contributor

@pettinarip looks great! great work

I found one tiny, tiny detail that it's not a blocker. I will create an issue later on.

@pettinarip pettinarip marked this pull request as ready for review May 21, 2024 16:45
@wackerow
Copy link
Member

@pettinarip This look ready from your perspective?

I'm noticing the content of the Quiz modal

Production (left aligned text, full width content):
image

PR (center aligned text, fits-to-content)
image

@nloureiro
Copy link
Contributor

@pettinarip This look ready from your perspective?

I'm noticing the content of the Quiz modal

Production (left aligned text, full width content): image

PR (center aligned text, fits-to-content) image

From my side, it's better centered.
On the original Figma it's centered, too.

Screen Shot 2024-05-25 11 12 43 AM

@pettinarip pettinarip merged commit 7039220 into ethereum:dev May 29, 2024
10 checks passed
Copy link

gitpoap-bot bot commented May 29, 2024

Congrats, your important contribution to this open-source project has earned you a GitPOAP!

Be sure to join the Ethereum.org discord if you are interested in contributing further to the project or have any questions for the team.

GitPOAP: 2024 Ethereum.org Contributor:

GitPOAP: 2024 Ethereum.org Contributor GitPOAP Badge

Head to gitpoap.io & connect your GitHub account to mint!

Learn more about GitPOAPs here.

This was referenced Jun 19, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
content 🖋️ This involves copy additions or edits needs design approval 🧑‍🎨 Approval from a designer is needed before merging needs dev approval 🧑‍💻 Approval from a developer is needed before merging refactor ♻️ Changes which don't affect functionality tooling 🔧 Changes related to tooling of the project
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Modal - implement DS styles and unify modals
6 participants