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

flex menu item #2075

Merged
merged 10 commits into from
Feb 5, 2018
Merged

flex menu item #2075

merged 10 commits into from
Feb 5, 2018

Conversation

giladgray
Copy link
Contributor

@giladgray giladgray commented Feb 2, 2018

Fixes #984

Changes proposed in this pull request:

  • sweet pt-flex-container($dir, $margin, $inline, $fill) mixin does it all
  • menu-item() is a pt-flex-container(row) with margin between items
  • render MenuItem submenu caret in React (submenus are JS-only)
  • MenuItem applies ellipsis class automatically to text wrapper; can be disabled with new multiline={true} prop

I don't think there are any API breaks here!?

@blueprint-bot
Copy link

MenuExample demonstrates truncation

Preview: documentation | landing | table

@@ -42,9 +42,6 @@ span.pt-icon {
svg.pt-icon {
// respect dimensions exactly
flex: 0 0 auto;
// SVG and DOM elements don't align perfectly - this magic number seems to fix it.
// https://blog.prototypr.io/align-svg-icons-to-text-and-say-goodbye-to-font-icons-d44b3d7b26b4#6e0c
margin-top: -0.125em;
Copy link
Contributor Author

Choose a reason for hiding this comment

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

align-items is much better at alignment than humans, so this shouldn't be necessary. keep an eye out for SVG icons mixed with text to ensure they're centered.

@blueprint-bot
Copy link

navigator uses flex columnm, adjust releases min-width

Preview: documentation | landing | table

@blueprint-bot
Copy link

navigator uses flex columnm, adjust releases min-width

Preview: documentation | landing | table

* If `false`, text will be truncated with an ellipsis when it reaches `max-width`.
* @default false
*/
multiline?: boolean;
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 Author

@giladgray giladgray Feb 3, 2018

Choose a reason for hiding this comment

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

@llorca thoughts on the centered icon alignment when multiline? (see your screenshot in comment below)

Copy link
Contributor

Choose a reason for hiding this comment

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

good call, actually aligned at the top would be better in this case

@@ -76,8 +85,9 @@ export class MenuItem extends AbstractPureComponent<IMenuItemProps> {
target={this.props.target}
>
<Icon iconName={this.props.iconName} />
<span className={textClasses}>{this.props.text}</span>
Copy link
Contributor

@llorca llorca Feb 3, 2018

Choose a reason for hiding this comment

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

back to the topic of our public CSS API! this is very similar to what I had a few months ago--it was considered breaking then, so it's technically breaking now since you're adding a span. if you remove the span from this current PR, this is what it looks like:
image
image

reiterating that it's quite annoying, this sort of internal refactor should not be considered breaking, and we should be able to do these outside of major versions

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 implementation is not an API break, though! i added an element but only inside the React component. you can of course easily break the appearance by mucking in the console--that doesn't mean it's an API break.

you'll notice, most importantly, that all the CSS markup examples still look perfect, like before. I made no external changes to the CSS or React APIs.

folks who use only MenuItem and not .pt-menu-item will have a seamless upgrade experience (unless they have custom styles, of course).

Copy link
Contributor

@llorca llorca left a comment

Choose a reason for hiding this comment

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

looks great! nit on aligning the icon at the top when multiline

Copy link
Contributor

@adidahiya adidahiya left a comment

Choose a reason for hiding this comment

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

image

nice to have: can we add a browser native tooltip here for truncated content?

code lgtm; I agree with antoine about icon alignment for multiline menu items

@giladgray
Copy link
Contributor Author

@adidahiya browser tooltip would be nice. do you imagine it only appears when the text is ellipsized (requires measuring, though we do have the Text component) or appears always (super easy)?

@adidahiya
Copy link
Contributor

ideally it appears only when text is ellipsized (yes, requires measuring)

this seems like a regression (currently, text doesn't get cut off like this), so we should block this PR on adding the tooltip

@giladgray
Copy link
Contributor Author

giladgray commented Feb 5, 2018

Text component actually handles this perfectly 👌 (cc @ryanmcnamara 🎩 )

@giladgray
Copy link
Contributor Author

giladgray commented Feb 5, 2018

screen shot 2018-02-05 at 12 17 07 pm

@blueprint-bot
Copy link

use Text component for ellipsize + native tooltip behavior

Preview: documentation | landing | table

Copy link
Contributor

@adidahiya adidahiya left a comment

Choose a reason for hiding this comment

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

code changes lgtm

@giladgray giladgray changed the base branch from flex-containers to develop February 5, 2018 21:40
@blueprint-bot
Copy link

Merge branch 'develop' of github.com:palantir/blueprint into gg/flex-menu-item

Preview: documentation | landing | table

@giladgray giladgray merged commit d88e24a into develop Feb 5, 2018
@giladgray giladgray deleted the gg/flex-menu-item branch February 5, 2018 22:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants