-
Notifications
You must be signed in to change notification settings - Fork 11
Add ProductMenu, ProductMenuDropdown components. Add ProductMenuItems data. #14
Conversation
} | ||
|
||
renderMenu() { | ||
return <ProductMenuDropdown categories={ProductMenuItems} />; |
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.
Could we generalize this component a bit more by rendering ProductMenu
's children instead of ProductMenuDropdown
specifically?
edit: turns out "yes"
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'm not sure it needs to be generalized, really, unless we decide at some point that we want to repeat the button style with different content. For now, these components are coupled immediately with the product names themselves, and I think that's ok.
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.
@davidtheclark 🙈 you're so fast! whelp, I rearranged the furniture a bit and I think I like it better this way. I don't know that we'll have an immediate use case for this style of button with other stuff inside of it, but I can see it being useful in the future.
Would you and @colleenmcginnis mind taking a peek at the new arrangement and let me know if you think it's worse?
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.
@@ -0,0 +1,15 @@ | |||
import { ProductMenuDropdown } from '../product-menu-dropdown'; |
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 decide whether to favor default or named exports by default in the repo and stick with that. I'm fine with either way.
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.
Per chat, we're going to stick with always named
for now.
position: 'absolute', | ||
margin: '10px 0 0 -12px', | ||
display: '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.
Since this object doesn't get affected by the props, it could be declared outside the component's render
method, which means we don't have to re-create the object on every render.
const allCategories = this.props.categories.map((category, index) => { | ||
const allProducts = category.products.map((product, index) => { | ||
const liClasses = classnames('mt6 relative ', { | ||
'txt-bold': product.url && location.pathname.indexOf(product.url) > -1 |
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.
window.location
won't be available when pages are rendered in Node, so there's a chance the current logic will break things during static HTML rendering.
'txt-bold': product.url && location.pathname.indexOf(product.url) > -1 | ||
}); | ||
const dotClasses = classnames({ | ||
'inline-block': location.pathname.indexOf(product.url) > -1, |
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 could consolidate this logic into a single variable: isActive
. Then you only have to figure it out once and can reapply it in these various contexts.
<Icon | ||
name={category.icon} | ||
inline={true} | ||
className="icon mb-neg6 mr6 h20 w20 color-gray inline" |
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 inline
necessary? Or is it covered by inline={true}
?
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.
@davidtheclark looks like they're both needed:
.inline
setsdisplay: inline !important
inline={true}
does some math to position the icon vertically: https://github.com/mapbox/mapbox-react-components/blob/master/packages/react-icon/src/icon.js#L19-L28
<Icon | ||
name="caret-down" | ||
inline={true} | ||
className="flex-child fr icon h30 w30" |
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 IE11 has problem with flex display on SVGs, so a wrapping div should take care of the layout instead of the Icon itself.
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.
Why is this floating right?
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.
Why is this floating right?
Similar to above, I'm not totally sure. Would you mind hopping in here, @colleenmcginnis?
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.
🔪
onPopoverClose={this.onPopoverClose} | ||
> | ||
<div className="fl wmax240-ml wmax180-mm flex-parent flex-parent--space-between-main flex-parent--center-cross"> | ||
<div className="flex-child inline-block txt-fancy txt-l cursor-pointer border-b border-b--2 border--white border--blue-on-hover txt-truncate"> |
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.
flex-child and inline-block cancel each other out.
onPopoverClose={this.onPopoverClose} | ||
> | ||
<div className="fl wmax240-ml wmax180-mm flex-parent flex-parent--space-between-main flex-parent--center-cross"> | ||
<div className="flex-child inline-block txt-fancy txt-l cursor-pointer border-b border-b--2 border--white border--blue-on-hover txt-truncate"> |
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.
Curious why this div has a pointer cursor, instead of the higher-level container? I notice on the live site that if you hover over the caret icon you don't see the cursor, but you can click — probably we could improve on that.
onPopoverClose={this.onPopoverClose} | ||
> | ||
<div className="fl wmax240-ml wmax180-mm flex-parent flex-parent--space-between-main flex-parent--center-cross"> | ||
<div className="flex-child inline-block txt-fancy txt-l cursor-pointer border-b border-b--2 border--white border--blue-on-hover txt-truncate"> |
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.
border-transparent
could be the default (non-hover), in case we ever put this on a non-white background.
|
||
ProductMenu.propTypes = { | ||
platform: PropTypes.string.isRequired, | ||
product: PropTypes.string.isRequired |
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.
@colleenmcginnis Is there any chance that this menu might contain non "SDK"s at some point? If so, maybe we want to remove the logic that forces an x SDK for y
format, and instead allow products to be freeform strings?
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. We should change that — it will break for GL JS. @danswick let's just use a prop like productName
to pass a string with the exact name we want to display.
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.
@danswick I left a couple lil comments in response to David's comments.
I also noticed that this is going beyond the bottom of the page. Is this something that will only be fixed with the custom CSS that you're going to add in a follow-up PR?
Thanks for 👀 @colleenmcginnis. Updated per your comments. Regarding the menu overrunning the bottom of the page, yes, I believe this will be resolved once our custom docs classes are added. |
closes #3
After chatting with @colleenmcginnis yesterday about the data that populates the ProductMenu, it seems clear that
frontend-documentation
would make a good home for thetruth
about which products should be in the menu. I included the most recent product list I could find in a newdata
directory. I'm not sure if that's the most sensible way to do it!I'm also unsure whether it would be better to refactor
ProductMenuDropdown
a bit so it accepts a prop with all of the product data.