Skip to content
This repository has been archived by the owner on Feb 28, 2024. It is now read-only.

Menu bar #47

Merged
merged 21 commits into from
Dec 30, 2017
Merged

Menu bar #47

merged 21 commits into from
Dec 30, 2017

Conversation

mateoclarke
Copy link
Contributor

@mateoclarke mateoclarke commented Dec 21, 2017

Closes #32 & Closes #21

menu

I think this gets us most of the way there. We'll def have to refactor code around the navigation hierarchy. For example, what happens when you click a Service Type? We currently don't have an index of services by type. I think we should create an endpoint that gives us the data in a good format, but I made due with an existing endpoint.

Other things we may to add would be an event lister on the esc key and on a click on the overlay area to trigger a state change and close the menu.

We may also need to check this for accessibility. Do we want tab indexing to skip this when its not visible?

@mateoclarke mateoclarke changed the base branch from master to header December 21, 2017 08:03
@mateoclarke mateoclarke removed the wip label Dec 23, 2017
@@ -22,11 +23,17 @@ class App extends Component {
return (
<Router>
<div>
<Banner />
<I18nBanner />
<Route path="/" render={props => (
Copy link
Contributor Author

Choose a reason for hiding this comment

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

in order to give the Header component props.location, I had to wrap it in a Route component. We'll see how this may need to change in an SSR world.

const endpoint = [
`${process.env.REACT_APP_CMS_ENDPOINT}/pages/`,
`?format=json&type=base.ServicePage&fields=topic(text)`,
].join('')
Copy link
Contributor Author

Choose a reason for hiding this comment

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

do y'all know if there a better syntax for a mutli-line string?

parentTitle: title,
children: getChildrenNavItemsByParent(title),
}
})
Copy link
Contributor Author

Choose a reason for hiding this comment

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

All this nonsense (lines 33-46) could be removed if we had a better endpoint.

return (
<li>
<a className={this.getMenuItemClassName(`/service/${child.id}`)}
href={`/service/${child.id}`}
Copy link
Contributor Author

Choose a reason for hiding this comment

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

this will need to change if when we switch to slugs instead of ids in the routing

@mateoclarke mateoclarke mentioned this pull request Dec 23, 2017
3 tasks
Copy link
Contributor

@ifsimicoded ifsimicoded left a comment

Choose a reason for hiding this comment

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

SOOOOOOO, I don’t know a whole lot about React Routing, but here’s some feedback (UX, CSS, other stuff) that you can take or leave. I plan on doing more reading tonight/this week. Please don't feel like you need my approval to merge this. Go crazy. Thoughts on my feedback are always appreciated if you have time.
Thanks for your patience with my lengthy reviews. Here’s a GIPHt (see what I did there???)

giphy 6

some dude on the internet did some stuff with child routes as a nav menu pattern here which seemed pretty clean: https://scotch.io/tutorials/routing-react-apps-the-complete-guide

UX STUFF
can the menu persist in an open state, while the content below is repainted so the experience is less jarring?

Can we create links via names, so that if routes change, we only have to make updates to links in one place? I have a feeling we'll be changing these.

Some more comments inline


menuClassName = () => {
const baseClassName = `coa-Navmenu`;
return this.props.isOpen ? `${baseClassName}--open` : baseClassName;
Copy link
Contributor

Choose a reason for hiding this comment

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

For css convention — I was going with BEM class stacking (http://getbem.com/introduction/). So className=“base_class base_class—modifier”. NOT just className=“base_class—modifier”
Honestly, I haven’t spent a lot of time thinking/reading about what’s better here, just leaning on the folks who came up with BEM stuff to have done that heavy lifting.

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, I don't really have a strong opinion here. I updated for this case, but unless there is a clear benefit, i'd leave it to chef's choice.

})}
</ul>
</nav>
<div className={`coa-Navmenu__overlay${this.props.isOpen ? '' : '--hide'}`}></div>
Copy link
Contributor

Choose a reason for hiding this comment

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

I used the outline: 9999px solid rgba(0,0,0,0.5); trick on my modal overlay so I wouldn’t have to have multiple elements to create an overlay. Maybe this could work? Haven’t browser tested beyond chrome & safari desktop tested tho. Either way, maybe we can make generic overlay classes. Like coa-overlay, coa-overlay--center coa-overlay--left coa-overlay--right that can be used all over.

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, i just tried mimic what I saw the USWDS usa-overlay does. I was assuming it had good accessibility and browser coverage.

I'm open to refactoring this to for more holistic use.

<div className="row">
<div className="col-xs-6 coa-Header__menu">
<span onClick={this.toggleMenu} tabIndex="0">MENU</span>
<span className="coa-Header__text-spacer">|</span>
Copy link
Contributor

Choose a reason for hiding this comment

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

Can the separator ‘|’ be a part of a :after content property so it’s not read as content? Or do we want it to be read as content?
Can we also make this more generic -- coa-text_spacer_vertical -- so we can use these all over? I have a feeling we'll have links listed like this in other places.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

sounds good, putting this in helpers.scss. Is that a good place for this type of thing?

{ parent.children.map((child) => {
return (
<li>
<a className={this.getMenuItemClassName(`/service/${child.id}`)}
Copy link
Contributor

Choose a reason for hiding this comment

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

Cursor pointer on the menu links plZZZZZ

Copy link
Contributor Author

Choose a reason for hiding this comment

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

i'm pretty sure we have that. it was missing on the "Menu" text so I added it there. Maybe that's what you meant.

<Route path="/" render={props => (
<section>
<Banner />
<I18nBanner />
Copy link
Contributor

Choose a reason for hiding this comment

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

Looks like the translation bar should always be fixed over the menu. This way the menu slide is also consistently positioned over where a user initially clicked to reveal the menu. Can we throw some CSS at this?

Copy link
Contributor Author

@mateoclarke mateoclarke Dec 29, 2017

Choose a reason for hiding this comment

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

Looks like the translation bar should always be fixed over the menu.

Are you referring to the mockups? Because I saw inconsistencies in how sidebars get displayed in them. I don't see a good reason functionally (or visually) to always show the language bar. Ok if we ask @cthibaultatx for clarification on this one?

}

componentDidMount () {
const endpoint = [
Copy link
Contributor

Choose a reason for hiding this comment

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

thinking we should start defining our endpoint urls in one place, since these will likely be changing and we’ll likely only want to update these urls in one place.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

cool, i'll create a file at src/constants/endpoints and import the string from there.

@mateoclarke mateoclarke changed the base branch from header to master December 29, 2017 22:20
# Conflicts:
#	src/App.js
#	src/components/I18nBanner.js
#	src/css/App.scss
#	src/css/components/Footer.scss
#	src/css/components/_Footer.scss
#	src/css/layout/_Footer.scss
@mateoclarke
Copy link
Contributor Author

mateoclarke commented Dec 30, 2017

@ifsimicoded, thanks for the feedback!

At first I was just going to leave the suboptimal jarring redirects until we land on what routing library we use with SSR. But when I looked into it, it wasn't too much to add. You can see what I did in the last commit.
fa27bca

dec-30-2017 00-10-14

I wasn't sure what you meant by...

Can we create links via names, so that if routes change, we only have to make updates to links in one place? I have a feeling we'll be changing these.

@mateoclarke mateoclarke merged commit e866817 into master Dec 30, 2017
@mateoclarke mateoclarke deleted the menu_bar branch December 30, 2017 06:08
@ifsimicoded
Copy link
Contributor

Hey when I said named routes, I meant like this: https://www.npmjs.com/package/react-router-named-routes
This way if we ever change the route for say the services page from /service/:id ... we could do it in one place, instead of updating links everywhere. Just something to think about it.

@mateoclarke
Copy link
Contributor Author

ah, gotcha. yeah, I think in an ideal world, we get back slugs/paths instead of (or in addition to) ids to use for these links.

I'll think we'll have to refactor this nav code regardless once the information architecture gets more solidified. This came up yesterday briefly in a chat with @benweatherman & @cthibaultatx around page hierarchy. sounds like it'll be 3-4 levels of nesting.

Maybe we should anticipate having a Nav/menu content model in the CMS. What does Wagtail already give us there @benweatherman?

@benweatherman
Copy link
Contributor

we get back slugs/paths instead of (or in addition to) ids to use for these links.

I think this is implementing cityofaustin/joplin#26

You can do this now via graphql (though it might change slightly)

{
  pages(slug:"dropoff") {
    edges {
      node {
        id
        content
      }
    }
  }
}

Maybe we should anticipate having a Nav/menu content model in the CMS. What does Wagtail already give us there @benweatherman?

We'd just need to develop a content model to allow authors to create the hierarchy. If we're not ready for authors to do that yet, we could generate the data via the API like the client is currently doing without allowing authors to change it until we get around to developing the model. Filed cityofaustin/joplin#49 as a placeholder. It's not currently set for MVP, but let me know if that's not right.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Menu Header/Footer
3 participants