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

Update Nav #22

Merged
merged 3 commits into from
Sep 15, 2021
Merged

Update Nav #22

merged 3 commits into from
Sep 15, 2021

Conversation

zachmargolis
Copy link
Contributor

we only have one page...so some of this may be overkill 😬

before after
Screen Shot 2021-09-15 at 12 32 41 PM Screen Shot 2021-09-15 at 12 32 26 PM

And mobile too

closed expanded
Screen Shot 2021-09-15 at 12 38 24 PM Screen Shot 2021-09-15 at 12 38 33 PM

@zachmargolis zachmargolis requested a review from aduth September 15, 2021 19:40
</button>
<ul className="usa-nav__primary usa-accordion">
<li className="usa-nav__primary-item">
<Link href="/" activeClassName="usa-current">
Copy link
Contributor Author

Choose a reason for hiding this comment

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

activeClassName as documented in preact-router doesn't seem to work? It just gets splatted into the dom as activeclassname="usa-current"... but the react types say that it should exist?

https://github.com/preactjs/preact-router/blob/24ffb40c8df2a455bc9518aa0ffdb7c5a1878968/index.d.ts#L75-L77

🤷

Copy link
Member

Choose a reason for hiding this comment

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

Looks familiar: preactjs/preact-router#379

Copy link
Member

Choose a reason for hiding this comment

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

Maybe we can recreate it like <Link className={path === '/' ? 'usa-current' : null }>

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Since this is top level render we don't have access to path? But we wouldn't be able to get that directly from a component either?

Copy link
Member

Choose a reason for hiding this comment

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

Hm, that's frustrating 😕

I'd wonder if we could create our own context to hold the path, using the Router onChange prop:

https://github.com/preactjs/preact-router/blob/61671b38fd5e371e886a6b33db2c66df7a6444db/src/index.js#L235

At a glance, I'm not sure the best way to meaningfully tie that to a specific "path" or route component.

We could also defer this for now and handle it later.

Aside: I also realize looking at the internal implementation: The way we're using path to build a new path fragment may not always work if path is actually the path pattern and could be something like /d/:optional?/:params?.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yeah we may need to come back to this --- Also I noticed routing to / does not change the path... but it does change the display, unsure how to fix that right now

Copy link
Member

Choose a reason for hiding this comment

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

Also I noticed routing to / does not change the path... but it does change the display, unsure how to fix that right now

If I follow correctly, I think this is fixed in #26 by introducing the route handler for a "Home" route.

Copy link
Member

@aduth aduth left a comment

Choose a reason for hiding this comment

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

We could publish new version of identity-style-guide if you want 18F/identity-design-system#249 ?

src/main.tsx Outdated Show resolved Hide resolved
</button>
<ul className="usa-nav__primary usa-accordion">
<li className="usa-nav__primary-item">
<Link href="/" activeClassName="usa-current">
Copy link
Member

Choose a reason for hiding this comment

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

Looks familiar: preactjs/preact-router#379

</button>
<ul className="usa-nav__primary usa-accordion">
<li className="usa-nav__primary-item">
<Link href="/" activeClassName="usa-current">
Copy link
Member

Choose a reason for hiding this comment

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

Maybe we can recreate it like <Link className={path === '/' ? 'usa-current' : null }>

<nav>
<div>
<Link href="/">Home</Link>
<header className="usa-header usa-header--extended">
Copy link
Member

Choose a reason for hiding this comment

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

Worth moving into a component?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

🤷 it's only used once and doesn't contain any logic? Happy to move if you feel strongly, will leave in place for now

@zachmargolis
Copy link
Contributor Author

We could publish new version of identity-style-guide if you want 18F/identity-style-guide#249 ?

No need to rush a release just for this? It'll get here eventually

@aduth
Copy link
Member

aduth commented Sep 15, 2021

We could publish new version of identity-style-guide if you want 18F/identity-style-guide#249 ?

No need to rush a release just for this? It'll get here eventually

I don't mind either way. If you're not worried about it, it can wait 👍

@zachmargolis zachmargolis merged commit 8011c46 into main Sep 15, 2021
@zachmargolis zachmargolis deleted the margolis-update-nav branch September 15, 2021 21:31
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.

2 participants