-
Notifications
You must be signed in to change notification settings - Fork 6
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
base: new-template-feature-branch
Are you sure you want to change the base?
DSD-1884: new template component #1711
Conversation
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
There was a problem hiding this 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.
language="jsx" | ||
/> | ||
The `TemplateMain` and `TemplateMainNarrow` components render the content as a | ||
`<main>` element with a default "id" of `"mainContent"`. This should be used as |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Because of the same shared id value, I think it's fine to explicitly say to use either one but not both.
<TemplateFooter>{footer}</TemplateFooter> | ||
</Template> | ||
); | ||
const { container } = render(<>{templateChildren}</>); |
There was a problem hiding this comment.
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}> |
There was a problem hiding this comment.
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.
/> | ||
) | ||
.toJSON(); | ||
const withChakraProps = renderer |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is still applicable.
/> | ||
) | ||
.toJSON(); | ||
const withOtherProps = renderer |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This and the ref test below are still applicable.
type: "Update", | ||
affects: ["Functionality", "Styles"], | ||
notes: [ | ||
"Major update to component and styles based on the [Template TAD](https://docs.google.com/document/d/1vZJX7Y-DnEM44-iWw5qoXGdxqavHEN6prhr-YDTNr0o/edit?pli=1&tab=t.0).", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This doesn't render as a link in storybook since it can't parse mdx strings. You can leave out the link.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
CHANGELOG.md
Outdated
@@ -8,6 +8,10 @@ Currently, this repo is in Prerelease. When it is released, this project will ad | |||
|
|||
## Prerelease | |||
|
|||
### Updates | |||
|
|||
- [Updates `Template` component(s)](<(https://newyorkpubliclibrary.atlassian.net/browse/DSD-1884)>) and styles per TAD. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Did you mean to have the internal <(
and )>
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Don't think so!
type="informative" | ||
/> | ||
</TemplateTop> | ||
<TemplateSidebar> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You need to add a case for when "sidebar" is set to "none"
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actually, this also displays correctly when sidebar is either "left" or "right", but we do want to recommend that the DOM follows the styles as well. So if sidebar="right"
, the DOM should be set in the same manner.
// The `<header>` HTML element has the same meaning as `role="banner"`. | ||
expect(screen.getAllByRole("banner")).toHaveLength(1); | ||
}); | ||
it("renders each section with left sidebar", () => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: this should say right
}); | ||
const contentBottom = <Placeholder variant="short">Content Bottom</Placeholder>; | ||
|
||
const templateComponents = ( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍
const { container } = render(templateComponents("left")); | ||
expect(await axe(container)).toHaveNoViolations(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Add two similar tests for the default and "right".
version: "Prerelease", | ||
type: "Update", | ||
affects: ["Functionality", "Styles"], | ||
notes: ["Major update to component and styles based on the Template TAD."], |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's ok to be more descriptive here! Maybe not all the details but definitely the major ones.
src/theme/components/template.ts
Outdated
m: "0 auto", | ||
p: "s", | ||
gridTemplateAreas: `"breakout" "top" "main" "bottom"`, | ||
gridTemplateColumns: "repeat(1, minmax(100px, 1fr))", |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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
There was a problem hiding this 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
@@ -2,499 +2,121 @@ import { ArgTypes, Canvas, Description, Meta, Source } from "@storybook/blocks"; | |||
import ComponentChangelogTable from "../../utils/ComponentChangelogTable"; | |||
import { changelogData } from "./templateChangelogData"; | |||
|
|||
import * as TemplateStories from "./Template.stories"; | |||
import * as TemplateNewStories from "./Template.stories"; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: remove "new" where necessary.
expect(await axe(container)).toHaveNoViolations(); | ||
}); | ||
|
||
it("passes axe accessibility test", async () => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These four tests have the same description. Update this so they are all descriptive to the test.
<Template sidebar={sidebar}> | ||
<TemplateBreakout>{breakout}</TemplateBreakout> | ||
<TemplateTop>{contentTop}</TemplateTop> | ||
{sidebar !== "none" && !useMainNarrow && ( |
There was a problem hiding this comment.
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.
@jackiequach @7emansell @bigfishdesign13 if you get a chance to review, please try to before 12/11. |
There was a problem hiding this 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
should be wrapped in a `<div>` element or a `<Box>` component. | ||
|
||
Basic "template" components structure: | ||
### Using the `Template` with the `Header` and `Footer` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Add a short description here for better clarity
<Button id="submit">Submit</Button> | ||
</FormField> | ||
</Form> | ||
<Table |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Unrelated issue: this table does not scroll properly at 600px screen width
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmm, for me, the table scrolls at 600px, but you're right that it doesn't look great.
@bigfishdesign13 & @EdwinGuzman, will this be resolved with the new md breakpoint? I believe it's 768px, meaning this would be one column up until then.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Container queries would resolve this issue. The Table
will not use a fixed first column for mobile viewports, but what you are seeing can happen when it is dropped in a narrow space. The new mobile breakpoint of 768px will help, but it will still not be ideal.
Another way to improve the UX here would be to turn off the row headers on the Table
when the viewport width drops below 960px
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, good points. Won't do anything about it here though.
src/theme/components/template.ts
Outdated
* Grid layout based on https://www.joshwcomeau.com/css/full-bleed/ | ||
*/ | ||
|
||
export const responsiveGap = { base: "1rem", md: "1.5rem", xl: "1rem" }; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
is xl supposed to be 2rem?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't believe so, but @bigfishdesign13, could you please confirm?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It looks like the values for responsiveGap
and responsivePadding
were flip-flopped. For responsiveGap
, the xl
value should be "2rem"
. And for responsivePadding
, the xl
value should be "1rem"
.
src/theme/components/template.ts
Outdated
*/ | ||
|
||
export const responsiveGap = { base: "1rem", md: "1.5rem", xl: "1rem" }; | ||
export const responsivePadding = { base: "1rem", md: "1.5rem", xl: "2rem" }; |
There was a problem hiding this comment.
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
?
There was a problem hiding this comment.
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.
<Button id="submit">Submit</Button> | ||
</FormField> | ||
</Form> | ||
<Table |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Container queries would resolve this issue. The Table
will not use a fixed first column for mobile viewports, but what you are seeing can happen when it is dropped in a narrow space. The new mobile breakpoint of 768px will help, but it will still not be ideal.
Another way to improve the UX here would be to turn off the row headers on the Table
when the viewport width drops below 960px
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Some suggestions.
src/theme/components/template.ts
Outdated
baseStyle: defineStyle({ | ||
gridColumn: { base: "1", md: "1 / span 2" }, | ||
paddingX: "s", | ||
maxWidth: { lg: "720px" }, |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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>
);
};
There was a problem hiding this comment.
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
Wide lines of text are difficult to read and are proven to make it harder for | ||
people to focus, while short lines of text force the eye to travel back too often, | ||
breaking a reader's rhythm. The `TemplateMain` component has a max width of 1280px, | ||
which is too wide for text. If your content includes long chunks of text, you | ||
should use the `TemplateMainNarrow` component instead. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We need to mention that this type of scenario is only applicable when the sidebar is not used.
`} | ||
language="jsx" | ||
/> | ||
TBD. |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
TY!
`} | ||
language="jsx" | ||
/> | ||
## Template Sidebar Configuration |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should either expand this section to detail the placement and function of all of the grid regions or we should add a section for each region. I am leaning toward adding separate sections to describe each region.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Okay, I think that makes sense! Will leave this work for the documentation ticket.
I'm going to merge this PR in and we can work on subsequent fixes in future PRs as planned. |
Fixes JIRA ticket DSD-1884 and DSD-1885
This PR does the following:
Template
wrapper component and children componentsHow has this been tested?
Accessibility concerns or updates
Accessibility Checklist
aria-live
is used, a screenreader was used to verify the text is read.ref
s, focus management was reviewed.Open Questions
Checklist:
Front End Review: