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

DSD-1702: responsive grid system #1591

Open
wants to merge 8 commits into
base: breakpoints-grid-feature-branch
Choose a base branch
from

Conversation

bigfishdesign13
Copy link
Collaborator

@bigfishdesign13 bigfishdesign13 commented May 6, 2024

Fixes JIRA ticket DSD-1702

This PR does the following:

  • Updates the Template component to implement a new responsive grid system.
  • Updates the docs for the Template component to explain how the new responsive grid system will work and how to use the legacy "grid" layout.
  • Adds and exports the responsiveGutters and responsiveSpacing data objects to make available to consuming apps.
  • Adds the Responsive Grid page to the Style Guide.

How has this been tested?

  • local Storybook

Accessibility concerns or updates

  • n/a

Checklist:

  • I have updated the Storybook documentation accordingly.
  • I have added relevant accessibility documentation for this pull request.
  • All new and existing tests passed.

Front End Review:

  • Review the Vercel preview deployment once it is ready.

Copy link

vercel bot commented May 6, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
nypl-design-system ✅ Ready (Inspect) Visit Preview 💬 Add feedback May 16, 2024 11:02pm

@bigfishdesign13 bigfishdesign13 marked this pull request as draft May 6, 2024 20:52
@bigfishdesign13 bigfishdesign13 marked this pull request as ready for review May 6, 2024 20:52
@bigfishdesign13 bigfishdesign13 changed the title DSD-1702: responsive grid system [WIP] DSD-1702: responsive grid system May 6, 2024
@bigfishdesign13 bigfishdesign13 added the In Progress Tickets or PRs that are being worked on. PRs marked as In Progress should not be merged. label May 9, 2024
@bigfishdesign13 bigfishdesign13 changed the title [WIP] DSD-1702: responsive grid system DSD-1702: responsive grid system May 14, 2024
@bigfishdesign13 bigfishdesign13 added Needs Review Pull requests that are ready for peer review. x2 This PR needs at least two approvals. and removed In Progress Tickets or PRs that are being worked on. PRs marked as In Progress should not be merged. labels May 14, 2024
Copy link
Member

@EdwinGuzman EdwinGuzman left a comment

Choose a reason for hiding this comment

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

I did a first pass of reading the documentation and code. I don't fully understand everything so I will do another pass soon.

Inspect responsive displays in between each breakpoint for how content responds
across the fluid spectrum

## Figma Reference
Copy link
Member

Choose a reason for hiding this comment

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

This should go in the TOC

The following terms are used through the documentation, so it is important to
understand what they mean.

### Breakpoints & Breakpoint Ranges
Copy link
Member

Choose a reason for hiding this comment

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

Should this go in the TOC as a subpoint under "Terminology"?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I originally had a lot of items as sub-bullets in the list, but I opted to remove them to streamline the TOC. Let's see how others feel.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Ha! I did leave everything in there. See, I flip-flopped so much that I can't remember where I landed. But I will make some changes to try to simplify the TOC. Looking at it now, I am not happy with all those links in there.

that in mind, the NYPL Reservoir Design System will designate four actual
breakpoints and from that we will define five breakpoint ranges:

#### Breakpoints
Copy link
Member

Choose a reason for hiding this comment

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

This and the rest in this section are in the TOC directly under the "Terminology" heading, but they are all marked with four #s. They should be three for consistent hierarchy.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Yes, I just caught that myself.


#### Breakpoint Ranges

- Small mobile (base): less than 480px (see Appendix Section I: Small Mobile)
Copy link
Member

Choose a reason for hiding this comment

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

I think you are using "base" in reference to Chakra, right? If so, then the other values in parenthesis should also be the chakra value. So "sm" instead of "s", "md" instead of "m", etc.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Yes, I did want to mirror the Chakra syntax. I can easily fix the labels, but do you think I should even include that here?

<Image src="/img/grid-gutters.png" alt="Grid gutters" mb="l" />
</div>
<div>
#### Margins
Copy link
Member

Choose a reason for hiding this comment

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

Oddly, this is not indented like the examples above.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

VS Code was doing some weird things with the formatting when I was originally working on it, but I was now able to normalized the formatting.

@@ -188,7 +204,10 @@ const TemplateContent: React.FC<any> = (
const TemplateContentTop: React.FC<any> = (
props: React.PropsWithChildren<TemplateProps>
) => {
const styles = useStyleConfig("TemplateContentTopBottom", {});
const { useLegacyGrid } = props;
Copy link
Member

Choose a reason for hiding this comment

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

Also destructure children to update line 211.

@@ -15,6 +15,12 @@
--nypl-breakpoint-medium: 768px;
--nypl-breakpoint-large: 1024px;
--nypl-breakpoint-xl: 1280px;

// Safe Area Environment Vars
Copy link
Member

Choose a reason for hiding this comment

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

Can you include that this is mostly for mobile ios?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Actually, I will just remove those. We are are not going to them. Not yet, at least.

@@ -310,22 +332,31 @@ export const TemplateAppContainer: ChakraComponent<
renderFooterElement = true,
renderHeaderElement = true,
renderSkipNavigation = false,
useLegacyGrid = true,
Copy link
Member

Choose a reason for hiding this comment

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

Should this be set to false by default? We want consumers to use the new grid and only explicitly set the legacy if they need to?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Yes, good catch. I missed this when I flipped the logic at the end of my dev.

Comment on lines 57 to 60
left: ({ useLegacyGrid = false }) => ({
gridTemplateColumns: useLegacyGrid ? { md: "255px 1fr" } : undefined,
}),
right: ({ useLegacyGrid = false }) => ({
Copy link
Member

Choose a reason for hiding this comment

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

Wrap the functions in defineStyle

* - Small tablet: 2/3 width
* - Large tablet & desktop: 3/4 width
* */
left: ({ useLegacyGrid = false }) => ({
Copy link
Member

Choose a reason for hiding this comment

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

Wrap the functions in defineStyle

gridColumn: "1 / -1",
}),
});
const TemplateContent = defineStyleConfig({
baseStyle: defineStyle({
// Set this element to start on the second 1280px grid column.
baseStyle: defineStyle(({ useLegacyGrid = false }) => ({
Copy link
Collaborator

Choose a reason for hiding this comment

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

Is there a reason why the checks have to happen in every style definition separately, rather than once up top (eg: switch vs if-else)

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

The conditions are used to set specific values for various style attributes and we've found it is easier to see the condition right on the attribute rather than abstracting the condition into a separate function elsewhere in the file.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Is it easier because Chakra favors using one pattern over the other? Or is this an argument that an if-else ladder is an easier pattern to read in general? Or an if-else ladder is easier to read in this specific situation because ... ?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

We've continued to use patterns that Chakra shows in their docs. That being said, I am curious about the solution you are suggesting. There are a number of styles for separate elements that are dependent on the useLegacyGrid prop. What type of design pattern would you suggest to consolidate the conditions based on that prop value?

Copy link
Collaborator

Choose a reason for hiding this comment

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

This just comes from the principle that, if we're having a switch that we expect to remove in the future, it's easier to read and easier to remove if we define the entire legacy grid style in one place, and the entire new grid style in another place. Now, if the tools we use don't allow that (I know Storybook doesn't, but I didn't know if Chakra didn't) then we don't have much of a choice.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Needs Review Pull requests that are ready for peer review. x2 This PR needs at least two approvals.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants