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

[Feature] Page Designer Layout Components WIP #993

Merged
merged 19 commits into from
Feb 23, 2023

Conversation

bendvc
Copy link
Collaborator

@bendvc bendvc commented Feb 17, 2023

Overview

This PR implements the below layout components for page designer.

  • MobileGrid1r1c
  • MobileGird2r1c
  • MobileGrid2r2c
  • MobileGrid2r3c
  • MobileGrid3r1c
  • MobileGrid3r2c

Internally all these components use Charkra's SimpleGrid component with varying column props. Additionally we take advantage of Chakra's responsive props to ensure that the column layout is appropriate for the screen size. E.g. Mobile2r1c displays its children in a 2 row x 1 column grid on mobile and a 1 row x 2 column grid on desktop.

Testing

Because we are using the SimpleGrid to do the heavy lifting with respect to the gird layout and it's responsiveness there isn't really much to test. I however have included a basic test for each component to ensure that it renders.

To test this work, checkout this branch and view the sample page:

> git checkout experience-layout-components
> npm ci
> npm start

Followed by visiting http://localhost:3000/page-viewer, here you can see a sample page using all the layout components created in this PR. Play with your browser width to see the layout change in response to the change.

TODO's

  • Before merging, remove the test page (PageViewer).

@bendvc bendvc requested a review from a team as a code owner February 17, 2023 16:34
@bendvc bendvc added the ready for review PR is ready to be reviewed label Feb 22, 2023
Copy link
Collaborator

@adamraya adamraya 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. I only left minor comments.
We could simplify code by dynamically generating all layouts in one file, but it makes sense also to create multiple files if the idea is to mimic what SFRA does.

]}
/>
)
expect(document.querySelector('.mobile-1r-1c')).toBeDefined()
Copy link
Collaborator

Choose a reason for hiding this comment

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

It looks like the test should be failing and instead the test should be looking for the class .mobile-2r-1c defined inside the <MobileGrid2r1c />. component.

The same assertion needs to be updated for the rest of the layouts components test files.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Thanks .. I've addressed these and those false positives as well

@@ -21,7 +21,7 @@ export const Region = (props) => {
const {id, components} = region

return (
<div id={id} className={`region ${className}`} {...rest}>
<div id={id} className={`region ${className}`} style={{marginBottom: 15}} {...rest}>
Copy link
Collaborator

Choose a reason for hiding this comment

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

small nit: I think we shouldn't need to add the extra style here since region will be living in the SDK package.
Also, on Mobile the vertical space between rows accumulates the margin-bottom defined here with the spacingY defined in the layout component:

<SimpleGrid className="mobile-2r-2c" columns={{base: 2, md: 4}} spacingX={15} spacingY={15}>

spacingY

We may want to conditionally add the rows spacingY or remove the margin-bottom to not show extra vertical space between rows on Mobile.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

That grid spacing is jsut something that I added because it was easy to do with ChakraUI. I don't want to be opinionated to much with styling and I was hoping to loop back on a clean up ticket to address any styling questions. So I've removed the space between forthe moment.


import * as Layouts from '../../components/experience/layouts'

const withTitle = (Component) => {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Nice hint to get a visual of the layout during the review.

@bendvc bendvc merged commit 043c7a9 into develop Feb 23, 2023
bfeister added a commit that referenced this pull request Feb 28, 2023
* develop:
  Support Node 16 (#965)
  [W-12450361] Introduce short-circuit method for bypassing auth in Commerce Provider by passing in a fetchedToken (#1010)
  remove jest-silent-reporter (#1009)
  Clean up Page Designer Code (#1004)
  [Shopper Experience] `ImageWithText` component (#991)
  Feature: Page Designer Carousel Component (#977)
  [Feature] Page Designer Layout Components WIP (#993)
  remove updatePw from not implemented list (#996)
  Back-port Shopper Experience Base Components into Retail Template (#992)

# Conflicts:
#	packages/commerce-sdk-react/package-lock.json
#	packages/commerce-sdk-react/package.json
#	packages/pwa-kit-dev/package-lock.json
#	packages/pwa-kit-dev/src/configs/webpack/config.js
#	packages/template-retail-react-app/package-lock.json
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
ready for review PR is ready to be reviewed
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants