Skip to content

Conversation

matheushahnn
Copy link
Contributor

What does this PR do?

Add baseline as one of the alignSelf possible attribute

Where should the reviewer start?

What testing has been done on this PR?

How should this be manually tested?

Do Jest tests follow these best practices?

  • 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?

What are the relevant issues?

#6376

Screenshots (if appropriate)

Do the grommet docs need to be updated?

Yes

Should this PR be mentioned in the release notes?

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

Copy link
Collaborator

@jcfilben jcfilben left a comment

Choose a reason for hiding this comment

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

Nice work, just a few things...
Can you add a jest test to cover this enhancement? Also can you create a pull request on grommet-site to add 'baseline' to the docs?

@matheushahnn
Copy link
Contributor Author

Collaborator

Sure thing. What kind of test do you imagine? Just test snapshots?

@matheushahnn
Copy link
Contributor Author

Created the PR on grommet-site: grommet/grommet-site#428

@jcfilben
Copy link
Collaborator

Sure thing. What kind of test do you imagine? Just test snapshots?

Yeah i think we can just do a snapshot test to make sure the styling was correctly applied when we use alignSelf="baseline"

@matheushahnn
Copy link
Contributor Author

Idk why, but when I add a new Box inside Box/alignSelf test 2 tests fail when rendering, and also I see this message:

Uncaught 'Over 200 classes were generated for component StyledBox with the id of "StyledBox-sc-13pk1d4-0".\n' +
      'Consider using the attrs method, together with a style object for frequently changed styles.\n' +
      'Example:\n' +
      '  const Component = styled.div.attrs(props => ({\n' +
      '    style: {\n' +
      '      background: props.background,\n' +
      '    },\n' +
      '  }))`width: 100%;`\n' +
      '\n' +
      '  <Component />'

Have you already seen this?

NOTE If I remove one Box (e.g.: <Box alignSelf="stretch" /> the tests pass

@jcfilben
Copy link
Collaborator

Just checked and I am getting that same error on my end. I think it is related to how many versions of styled boxes we have in that test file. I think in this case it makes sense to suppress the error in this file because we know that the reason we are over limit is just because of how many test cases we have.

@matheushahnn
Copy link
Contributor Author

I am unsure how to suppress the error in this file, any suggestions?
If I move one test to another file it works, maybe we can split these tests into two files, what do you think?

@jcfilben
Copy link
Collaborator

jcfilben commented Oct 12, 2022

Hmm yeah I am not finding any good options for disabling the error for the test file. If possible I think we should avoid splitting this up into two test files. Ideally it would be nice to keep things organized under one file. I'll keep looking to see if I can find any other possible solutions...

@matheushahnn
Copy link
Contributor Author

matheushahnn commented Oct 14, 2022

I moved one style to attrs on StyledBox as the error suggested and now the tests are passing.
Please, take a look and let me know if it is one possible approach.

@halocline
Copy link
Collaborator

I mode one style to attrs on StyledBox as the error suggested and now the tests are passing. Please, take a look and let me know if it is one possible approach.

I think this ☝️ is the right direction. I believe @jcfilben was also exploring this approach.

@jcfilben
Copy link
Collaborator

Hey @matheushahnn I'm thinking this is probably the direction we will go. I'm going to look at it a bit more on Monday, I'm thinking about if we want to move additional items in styledBox within attrs not just wrap

@jcfilben
Copy link
Collaborator

Update: I chatted with some other members of the team and we are thinking that we do want to use attrs for styled box. However, these changes are going to happen in a separate pull request. For this PR I think we can remove the change to styled box, and comment out the test and just add a comment explaining that the test is being commented out until we change styled box to use attrs.

@matheushahnn
Copy link
Contributor Author

@jcfilben Followed your instructions 👍

Copy link
Collaborator

@jcfilben jcfilben left a comment

Choose a reason for hiding this comment

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

Looks good!

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.

4 participants