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

Enhancement - #6175: Added option for responsive Paragraph and Text text #6451

Open
wants to merge 4 commits into
base: master
Choose a base branch
from

Conversation

georgiabains
Copy link

What does this PR do?

This PR mainly modifies the Paragraph and Text schemas and components to add a responsiveBreakpoint that is used to scale down font sizes for resolutions under that breakpoint. The method follows that of Heading quite closely, however I did have to change the schema to group the font sizes within one object, in order to create an ordered array to loop through to determine the appropriate smaller size.

Where should the reviewer start?

Looking at base.js, StyledParagraph.js and StyledText.js.

What testing has been done on this PR?

I ran yarn test-update and yarn test before each commit and created Paragraph and Text components in my local host, set up with responsive={true} and tested the different possible sizes. I also tried inputting sizes that didn't exist, to confirm that text still displayed.

How should this be manually tested?

In a localhost, set up a Paragraph and Text component with the property responsive={true}. Confirm that resolutions under 768px have a smaller font size. Further testing can be done by changing the size property.

Do Jest tests follow these best practices?

N/A

  • screen is used for querying.
  • The correct query is used. (Refer to this list of queries)
  • userEvent is used in place of fireEvent.
  • asFragment() is used for snapshot testing.

Any background context you want to provide?

I followed the existing coding structure that the Heading component uses.

What are the relevant issues?

Link to github issue (6175)

Screenshots (if appropriate)

N/A

Do the grommet docs need to be updated?

No

Should this PR be mentioned in the release notes?

I'm afraid I might be a little unfamiliar with Grommet, do users have the ability to directly target theme props? If so then it should be, so that users can update any references to props.theme.paragraph and props.theme.text.

Is this change backwards compatible or is it a breaking change?

I believe its a breaking change, as modifying the schema for Text resulted in modifying references to props.theme.text, which are used in other components.

@jcfilben
Copy link
Collaborator

jcfilben commented Oct 25, 2022

Just wanted to give a quick update on the review status of this pull request. I have been looking into it, the problem is changing the theme structure to include fontSize will cause backwards compatibility issues. However I realize we need the sizes to be grouped together so we can move up/down a size. I'm trying to think of other ways we could do this that won't cause backwards compatibility issues.

@jcfilben
Copy link
Collaborator

Hey @georgiabains thanks for your patience on this! I chatted with some other members of the team this morning and we came to a solution. We are thinking instead of changing the theme for paragraph and text to have fontSize we could change paragraph.responsiveBreakpoint and text.responsiveBreakpoint to accept an object. paragraph.small, text.small, etc would be unchanged.

The responsive breakpoint object would look something like this for Text and Paragraph:

text: {
  ...
  responsiveBreakpoint: {
    small: { // here small refers to the screen size breakpoint 
      small: 'xsmall', // here small refers to text size small and says when we are in a small breakpoint and the text size is small use the xsmall size defined by text.xsmall in the theme
      medium: 'small',
      large: 'medium',
    },
    medium: { 
       ...
    }
    ...
}

For backwards compatibility base.js will leave text.responsiveBreakpoint and paragraph.responsiveBreakpoint undefined. People will be able to opt into this change by adjusting their theme and defining text.responsiveBreakpoint and paragraph.responsiveBreakpoint.

Let me know if this makes sense or if there are any questions. I appreciate your work on this and happy to help out or clarify in any way needed!

@georgiabains
Copy link
Author

Hey @jcfilben thanks for responding! That solution makes way more sense rather than forcing countless users to update their codebases 😅

I can work on making this update this week 👍

@jcfilben
Copy link
Collaborator

Hey @jcfilben thanks for responding! That solution makes way more sense rather than forcing countless users to update their codebases 😅

I can work on making this update this week 👍

Perfect!

@jcfilben jcfilben added the waiting Awaiting response to latest comments label Nov 8, 2022
@jcfilben jcfilben added needs attention To alert grommet team that a PR has been waiting for the author for a while and removed waiting Awaiting response to latest comments labels Mar 29, 2023
@halocline halocline self-assigned this Mar 30, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
needs attention To alert grommet team that a PR has been waiting for the author for a while
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants