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

Add ProductMenu, ProductMenuDropdown components. Add ProductMenuItems data. #14

Merged
merged 7 commits into from
Jul 17, 2018

Conversation

danswick
Copy link
Contributor

@danswick danswick commented Jul 13, 2018

closes #3

image

image

After chatting with @colleenmcginnis yesterday about the data that populates the ProductMenu, it seems clear that frontend-documentation would make a good home for the truth about which products should be in the menu. I included the most recent product list I could find in a new data 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.

}

renderMenu() {
return <ProductMenuDropdown categories={ProductMenuItems} />;
Copy link
Contributor Author

@danswick danswick Jul 13, 2018

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"

Copy link
Contributor

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.

Copy link
Contributor Author

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?

image

Copy link
Contributor

Choose a reason for hiding this comment

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

👍

Copy link
Contributor

@davidtheclark davidtheclark left a comment

Choose a reason for hiding this comment

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

🥇 @danswick

@@ -0,0 +1,15 @@
import { ProductMenuDropdown } from '../product-menu-dropdown';
Copy link
Contributor

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.

Copy link
Contributor Author

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'
};
Copy link
Contributor

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
Copy link
Contributor

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,
Copy link
Contributor

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"
Copy link
Contributor

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}?

Copy link
Contributor Author

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:

<Icon
name="caret-down"
inline={true}
className="flex-child fr icon h30 w30"
Copy link
Contributor

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.

Copy link
Contributor

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?

Copy link
Contributor Author

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?

Copy link
Contributor

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">
Copy link
Contributor

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">
Copy link
Contributor

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">
Copy link
Contributor

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
Copy link
Contributor

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?

Copy link
Contributor

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.

Copy link
Contributor

@colleenmcginnis colleenmcginnis left a 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?

image

@danswick
Copy link
Contributor Author

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.

@danswick danswick merged commit 88e3e7e into master Jul 17, 2018
@danswick danswick deleted the product-menu branch July 17, 2018 22:19
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.

Add ProductMenu and ProductMenuDropdown component
3 participants