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: Update Text and Heading Themes for New DS #10606

Merged

Conversation

TylerAPfledderer
Copy link
Contributor

Description

Update theming of the Heading and Text components with stories.

Related Issue

Part of the Implentation of the DS v1 #9548

@TylerAPfledderer TylerAPfledderer changed the title feat(theme/Heading): add new theme for DS feat: Update Text and Heading themes for New DS Jul 4, 2023
@TylerAPfledderer TylerAPfledderer changed the title feat: Update Text and Heading themes for New DS feat: Update Text and Heading Themes for New DS Jul 4, 2023
@gatsby-cloud
Copy link

gatsby-cloud bot commented Jul 4, 2023

✅ ethereum-org-website-dev deploy preview ready

@TylerAPfledderer TylerAPfledderer force-pushed the feat/heading-text-theme-new-ds branch from 051c112 to 97ce437 Compare July 6, 2023 18:39
@TylerAPfledderer TylerAPfledderer marked this pull request as ready for review July 7, 2023 01:10
@TylerAPfledderer
Copy link
Contributor Author

TylerAPfledderer commented Jul 7, 2023

@nloureiro Please view the Chromatic UI Tests check and storybook. Of course, this is considered a priority to be able to properly work on other components that need it.

One thing outstanding on here: should a margin bottom be a part of the Heading styling -- to be specified for each size in the theme -- or be kept separate and only be added as the Heading is used?

@TylerAPfledderer TylerAPfledderer force-pushed the feat/heading-text-theme-new-ds branch from bf889e7 to adf11e6 Compare July 7, 2023 03:31
@pettinarip
Copy link
Member

@nloureiro Please view the Chromatic UI Tests check and storybook. Of course, this is considered a priority to be able to properly work on other components that need it.

One thing outstanding on here: should a margin bottom be a part of the Heading styling -- to be specified for each size in the theme -- or be kept separate and only be added as the Heading is used?

Interesting point @TylerAPfledderer. IMO for this first iteration we should not add those margins to the Heading component.

Later, as we migrate the different layouts or pages (previously defined in the DS), we are going to start detecting patterns with these margins, and we should decide then if we add them to the Headings or if we do something else, like using textStyles (I'd go with adding them to the Headings and then overriding the other cases were we are not using the default margins).

},
a: {
color: "primary.base",
textDecoration: "underline",
},
// should be replace with https://chakra-ui.com/docs/components/text
p: {
margin: "0px 0px 1.45rem",
Copy link
Member

Choose a reason for hiding this comment

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

Now, looking at the preview deploy, I see that we kind of depend on this margin to avoid having to refactor all the codebase. I'd say that for the Text component we add this button margin. What do you think @nloureiro and @TylerAPfledderer?

Note for context for @nloureiro. This Text component represents the p tag, the paragraphs in html.

Copy link
Contributor Author

@TylerAPfledderer TylerAPfledderer Jul 31, 2023

Choose a reason for hiding this comment

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

@pettinarip fair point!

So for example, with the Homepage hero where this margin would be used against the CTA button "Explore Ethereum", when working on the new heroes I took a different approach, whereby I structured the Header and text under one flex stack, and then that grouping with the button at a higher level stack, and used the gap or spacing prop to define the "margin" between the different texts and between the paragraph and the button.

// Something to this effect
<VStack spacing='4'>
  <VStack spacing='2'>
    <Heading />
    <Text />
  </VStack>
  <Button />
</VStack>

I should ask then what would best practice be here? In my description above, this approach using the Flexbox gap property to define the margins between content instead of using the margin prop.

And I would consider in addition to the above the idea of using margin only when we are stacking paragraphs, with a defined :first- or :last-of-type selector so that only margin is defined between the paragraphs, but not added above the first or below the last of the stacked siblings.

So:

"p:not(:last-of-type)": {
  mb: "2" // or some other token value
}

However, I also understand that margin has to be well defined for the mdx file parsing because you have no ability to isolate groups of text elements into neatly packaged boxes. So I would want to figure out what the best practice should be to keep usage in MDX pages inline with the page layouts that do not use MDX.

Copy link
Member

Choose a reason for hiding this comment

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

Using gap and spacing is correct and expected as the best way to go looking ahead.

Now, talking about the current problem and thinking about how to support the old margins, I think that the best way to go is by leaving the Text component as it is and creating a new temporary one called OldText that would have the old margins.

Following this idea

  • the Text component would be used in all new implementation
  • the OldText would be marked as deprecated and would be used in the rest of the old/current implementations.

The OldText component might be something as simple as this

function OldText(props) {
  return <Text margin={oldDefaultMargins} {...props} />
}

With that new component in place, I could go and refactor the entire codebase by importing the OldText and adding those changes to this PR.

Then, as you migrate the new components as the Hero, you can start using and importing the native Text.

Does it make sense?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@pettinarip Ok! So using the OldText component for the MDX files too, correct?

Copy link
Member

Choose a reason for hiding this comment

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

Correct.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@pettinarip I've pushed this new component here.

Copy link
Member

Choose a reason for hiding this comment

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

Thanks. I'll refactor the code to use that component instead of the Text.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Sounds good!

@@ -0,0 +1,48 @@
import { defineStyle, defineStyleConfig } from "@chakra-ui/react"

const sizes = {
Copy link
Member

Choose a reason for hiding this comment

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

@TylerAPfledderer we discussed with Nuno about these sizes and we've updated them to match the same sizes than Chakra https://chakra-ui.com/docs/styled-system/theme#typography

Now, md should be the same md as in Chakra (1 rem). Same with the rest.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@pettinarip to clarify, this is just regarding the Text component? It looks like the sizes for the Heading component have not changed (which is to be expected since they are currently inline with the Chakra defaults)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Also need clarification regarding the body copy with this update. Marked a question in the figma file as I found a discrepancy.

Copy link
Member

Choose a reason for hiding this comment

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

Correct @TylerAPfledderer. The Heading has not suffered any update.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@pettinarip this is now updated in the PR

@nloureiro
Copy link
Contributor

Maybe late to this one. Where should I look to review?

here?
Screen Shot 2023-08-14 03 35 43 PM

@TylerAPfledderer
Copy link
Contributor Author

Maybe late to this one. Where should I look to review?

here? Screen Shot 2023-08-14 03 35 43 PM

@pettinarip looks like Chromatic wasn't triggered with the new stories.

@nloureiro yes to this one as well as Atoms / Typography / Text

@TylerAPfledderer
Copy link
Contributor Author

TylerAPfledderer commented Aug 21, 2023

@pettinarip @nloureiro I updated the branch recently, and now the chromatic test and review checks are now available!

NOTE

I've failed the UI Tests check due to regressions showing from the Card and Slider stories. (Glad they were available!)

Therefore, this PR should not merge until those at least can be fixed and shown as properly laid out (i.e. keep to the original spacing and sizing... or close to it). Then approve the UI Tests again and the UI review itself.

And this is why we have Chromatic! 🤣

Side Note: if both of you think that it would be simpler to only need the UI Tests check instead of also having the UI Reviews check, you should be able to disable it in the "Manage Page" section of the Chromatic Dashboard.
This means you would only prefer just approving/deny UI changes, and not doing overview approval like you would you request for any other stake-holders.

@TylerAPfledderer
Copy link
Contributor Author

@nloureiro @pettinarip this should be good for a review again!

@github-actions github-actions bot added the content 🖋️ This involves copy additions or edits label Aug 30, 2023

const headingScale: Array<HeadingProps> = [
{
as: "h1",
Copy link
Contributor

Choose a reason for hiding this comment

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

@TylerAPfledderer @pettinarip maybe this is normal, but having 3 times as="h1" is correct?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@nloureiro I could only assume that the three largest sizes would be reserved for the h1 heading. If that is true, then I would make sure that the story reflected that preference.

Copy link
Member

@pettinarip pettinarip left a comment

Choose a reason for hiding this comment

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

🚢

@pettinarip pettinarip merged commit 4e89821 into ethereum:dev Sep 11, 2023
@TylerAPfledderer TylerAPfledderer deleted the feat/heading-text-theme-new-ds branch September 11, 2023 18:13
This was referenced Sep 13, 2023
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
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants