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-1884: new template component #1711

Merged

Conversation

oliviawongnyc
Copy link
Collaborator

@oliviawongnyc oliviawongnyc commented Dec 5, 2024

Fixes JIRA ticket DSD-1884 and DSD-1885

This PR does the following:

  • Updates Template wrapper component and children components
  • Adds concept of narrow main content for long text
  • Updates styles to make responsive gaps and sidebar in grid

How has this been tested?

  • In Storybook

Accessibility concerns or updates

  • Documentation not complete

Accessibility Checklist

  • Checked Storybook's "Accessibility" tab for color contrast and other issues.
  • The feature works with keyboard inputs including tabbing back and forward and pressing space, enter, arrow, and esc keys.
  • For hidden text or when aria-live is used, a screenreader was used to verify the text is read.
  • For features that involve UI updates and focusing on DOM refs, focus management was reviewed.
  • The feature works when the page is zoomed in to 200% and 400%.

Open Questions

Checklist:

  • I have updated the Storybook documentation and changelog 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 Dec 5, 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 Dec 20, 2024 3:49pm

@oliviawongnyc oliviawongnyc added DON’T MERGE YET When somethign has been approved, but should not be merged just yet. Needs Review Pull requests that are ready for peer review. labels Dec 5, 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.

You can remove "new" from the component and file names since this is a breaking change update.

CHANGELOG.md Outdated Show resolved Hide resolved
src/components/Template/Template.mdx Outdated Show resolved Hide resolved
src/components/Template/Template.mdx Show resolved Hide resolved
src/components/Template/Template.mdx Outdated Show resolved Hide resolved
src/components/Template/Template.mdx Outdated Show resolved Hide resolved
<TemplateFooter>{footer}</TemplateFooter>
</Template>
);
const { container } = render(<>{templateChildren}</>);
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 it'd be good to make templateChildren a function and pass in the value of the sidebar, either left or right. Then you can have two accessibility tests and verify both sidebar variants (and the default without a sidebar) are all accessible.

<TemplateContentPrimary>{contentPrimary}</TemplateContentPrimary>
</TemplateContent>
<TemplateFooter>{footer}</TemplateFooter>
<Template sidebar={sidebar}>
Copy link
Member

Choose a reason for hiding this comment

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

Similar comment here, this is a snapshot for the left sidebar but have snapshots for other variants.

src/components/Template/Template.test.tsx Show resolved Hide resolved
src/components/Template/Template.test.tsx Show resolved Hide resolved
src/components/Template/templateChangelogData.ts Outdated Show resolved Hide resolved
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.

The update looks good! Some minor things including fixing the story:
Screenshot 2024-12-06 at 5 15 42 PM

I will do a closer test next week by trying to add different components and layouts in my local set up.

CHANGELOG.md Outdated Show resolved Hide resolved
src/components/Template/Template.stories.tsx Outdated Show resolved Hide resolved
src/components/Template/Template.test.tsx Outdated Show resolved Hide resolved
src/components/Template/Template.test.tsx Show resolved Hide resolved
src/components/Template/Template.test.tsx Outdated Show resolved Hide resolved
src/components/Template/templateChangelogData.ts Outdated Show resolved Hide resolved
m: "0 auto",
p: "s",
gridTemplateAreas: `"breakout" "top" "main" "bottom"`,
gridTemplateColumns: "repeat(1, minmax(100px, 1fr))",
Copy link
Member

Choose a reason for hiding this comment

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

How did you get 100px for the first value in minmax?

Copy link
Collaborator Author

@oliviawongnyc oliviawongnyc Dec 9, 2024

Choose a reason for hiding this comment

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

Arbitrarily, though I think it looks good.... it should probably be decided on by @bigfishdesign13.

Copy link
Collaborator

Choose a reason for hiding this comment

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

The smallest screen width that designers consider (in theory) is 320px, so I'd suggest changing the min here to 320px.

Why use repeat when it's not repeating?

Copy link
Collaborator

Choose a reason for hiding this comment

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

Actually, I'd argue that minmax should be removed altogether from the column styles and instead apply minWidth: "320px" to the full grid.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

If the smallest screen width is 320, then the minWidth of the grid should be smaller than that, no?

Copy link
Collaborator

Choose a reason for hiding this comment

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

@oliviawongnyc Yes. That is what I was referring to during our call earlier. It should be 320 minus the value of the padding. For the mobile viewport the padding on either side is 16px, so the minWidth for the grid should be set to "288px".

320px - (16px x 2) = 288px

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.

Minor comments. I will approve once others get a chance to review the PR (I think I've been looking so often that at this point I will miss things).

Important: make a feature branch and point this PR into that branch. This should not accidentally be merged into development and this feature won't go out until 4.0 is released.

src/components/Template/Template.mdx Outdated Show resolved Hide resolved
src/components/Template/Template.test.tsx Outdated Show resolved Hide resolved
<Template sidebar={sidebar}>
<TemplateBreakout>{breakout}</TemplateBreakout>
<TemplateTop>{contentTop}</TemplateTop>
{sidebar !== "none" && !useMainNarrow && (
Copy link
Member

Choose a reason for hiding this comment

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

Not too big of a deal since this is a test, but if "sidebar" is "right", the DOM will not be in the right order.

@EdwinGuzman
Copy link
Member

@jackiequach @7emansell @bigfishdesign13 if you get a chance to review, please try to before 12/11.

Copy link
Collaborator

@jackiequach jackiequach left a comment

Choose a reason for hiding this comment

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

The "Template Full Example" is very cramped at 600px screen width. Otherwise, this looks great!

src/components/Template/Template.mdx Outdated Show resolved Hide resolved
src/components/Template/Template.stories.tsx Show resolved Hide resolved
src/theme/components/template.ts Outdated Show resolved Hide resolved
@oliviawongnyc oliviawongnyc changed the base branch from development to new-template-feature-branch December 10, 2024 17:30
*/

export const responsiveGap = { base: "1rem", md: "1.5rem", xl: "1rem" };
export const responsivePadding = { base: "1rem", md: "1.5rem", xl: "2rem" };
Copy link
Collaborator

Choose a reason for hiding this comment

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

To keep proper alignment in the UI, this same type of responsive padding will be used in a number of other components. The responsive gaps could also be used in some places. Do you think it would make sense to move these into global.ts?

Copy link
Member

Choose a reason for hiding this comment

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

Yes, could this also be a general "DS gap" and "DS padding" set of values that can be used elsewhere? Perhaps exported as design tokens if consuming apps need them.

Copy link
Collaborator

Choose a reason for hiding this comment

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

I was thinking about this a bit more. Design tokens are static, while this object is responsive. From what I recall, the only other design tokens that are setup with reference to screen size are the form input height values. There's one for default (anything other than mobile) and one for mobile. If we do setup tokens for these gap values, I would like to do it using the naming conventions of the new breakpoints (small mobile, large mobile, etc.).

src/components/Template/Template.stories.tsx Show resolved Hide resolved
Copy link
Collaborator

@bigfishdesign13 bigfishdesign13 left a comment

Choose a reason for hiding this comment

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

Some suggestions.

baseStyle: defineStyle({
gridColumn: { base: "1", md: "1 / span 2" },
paddingX: "s",
maxWidth: { lg: "720px" },
Copy link
Collaborator

Choose a reason for hiding this comment

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

Let's see if we can bring this into alignment with the 12-column grid. When using a 12-column grid at 1280px with appropriate padding and gaps, an eight column span is 822px. And interestingly, DC is using 820px max width on the About page.

The underlying grid for desktop would use:

gridTemplateColumns: "1fr 4fr 1fr"

And the content area would be the 4fr column.

For tablet, maybe something like this:

gridTemplateColumns: "1fr 10fr 1fr"

And the next jump would just be "1fr" (full width).

Thoughts?

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 won't be able to work on this myself, but I think we can achieve this in TemplateMainNarrow by adding display: grid and something like gridTemplateColumns: "2fr minmax(800, 8fr) 2fr". This second value would need to be fiddled with.

Then, the component needs to have another div wrapper like so:

const TemplateMainNarrow: React.FC<React.PropsWithChildren<TemplateMainProps>> =
  ({ children, id = "mainContent" }) => {
    const styles = useStyleConfig("TemplateMainNarrow");

    return (
      <Box as="main" id={id} gridArea="main" __css={styles}>
        <div style={{ gridColumn: 2 }}>{children}</div>
      </Box>
    );
  };

Copy link
Member

Choose a reason for hiding this comment

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

src/components/Template/Template.mdx Outdated Show resolved Hide resolved
`}
language="jsx"
/>
TBD.
Copy link
Collaborator

Choose a reason for hiding this comment

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

I will work on this.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

TY!

src/components/Template/Template.mdx Outdated Show resolved Hide resolved
src/components/Template/Template.mdx Show resolved Hide resolved
@bigfishdesign13 bigfishdesign13 added the v4 Updates for the v4.0 feature branch label Dec 16, 2024
@bigfishdesign13 bigfishdesign13 changed the title DSD-1884/new template component DSD-1884: new template component Dec 16, 2024
@EdwinGuzman
Copy link
Member

I'm going to merge this PR in and we can work on subsequent fixes in future PRs as planned.

@bigfishdesign13 bigfishdesign13 merged commit ab8e0ab into new-template-feature-branch Dec 20, 2024
5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
DON’T MERGE YET When somethign has been approved, but should not be merged just yet. Needs Review Pull requests that are ready for peer review. v4 Updates for the v4.0 feature branch
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants