material icon indicating copy to clipboard operation
material copied to clipboard

mdSpeedDial: Implement floating-action-button menu

Open marcysutton opened this issue 11 years ago • 41 comments

The "speed dial" component inspired by Google Inbox allows for a small number of items to animate out from a floating action button (FAB). In the Material Design spec although there isn't any detail for this specific component, there are a few patterns and requirements noted for items animating out of FABs:

  • The FAB should be attached/anchored to something and not in a random location
  • A FAB menu has to contain related items. Consider an overflow menu for unrelated items.

There are a few inspirations: Implementation: http://nobitagit.github.io/ng-material-floating-button/ (needs accessibility) Design: https://dribbble.com/shots/1788016-Inbox-Speed-Dial-Animation Google Inbox SpeedDial UX: MP4

speeddial

Similar to a Bottom Sheet, the speed dial component is a mobile-focused component, and should be noted in the docs.

h/t to https://github.com/angular/material/issues/1368.

marcysutton avatar Feb 06 '15 20:02 marcysutton

Looks great ...

m4cx avatar Feb 10 '15 12:02 m4cx

+10 would love to see this. I'll probably have to roll my own in the mean time. I'll share if it turns out good.

epelc avatar Mar 21 '15 01:03 epelc

:+1:

asm0dey avatar Mar 22 '15 06:03 asm0dey

If anyone has implemented this (using the md directives), please share!

Waiting for this and md-menu in 0.10, waiting for .9.0!

ghost avatar Mar 26 '15 16:03 ghost

These guys have it down pretty nice http://ui.lumapps.com/css/fab

imjoeybrennan avatar Apr 01 '15 20:04 imjoeybrennan

@imjoeybrennan unless you're using a keyboard or a screen reader.

marcysutton avatar Apr 01 '15 20:04 marcysutton

@marcysutton yas queen. angular material is boss.

imjoeybrennan avatar Apr 02 '15 01:04 imjoeybrennan

Awesome ++1

scriptsure avatar Apr 02 '15 02:04 scriptsure

please +1

klederson avatar Apr 06 '15 19:04 klederson

A start: http://codepen.io/ionic/pen/xbNrzV

ajoslin avatar Apr 06 '15 20:04 ajoslin

@ajoslin Looks good.

I don't know if it's going to a be a 1:1 with inbox but if it is they show the mini fabs whenever you hover anywhere in the blue box(basically the mini-fabs area + some margin). image

epelc avatar Apr 06 '15 20:04 epelc

Then fix it and open a PR :wink:

ajoslin avatar Apr 07 '15 16:04 ajoslin

Thanks for the Codepen @ajoslin!

@epelc although mdSpeedDial won't be an exact 1-1 with Inbox (which currently has limited keyboard support), a larger hover area would help usability of the menu. The demo shows the animation working pretty well though!

marcysutton avatar Apr 09 '15 01:04 marcysutton

Material Design Specifcation released for SpeedDial

Includes both FAB buttons and toolbar slideouts:

screen shot 2015-04-14 at 6 43 54 pm

screen shot 2015-04-14 at 6 43 47 pm

ThomasBurleson avatar Apr 14 '15 23:04 ThomasBurleson

Hi folks. I've just created a basic prototype using MD so that we can begin discussing some thoughts.

You can view the demo and get the code at http://profoundry-us.github.io/md-fab-test/

Of note, here are some of my thoughts:

  • Currently, this supports basic keyboard navigation via the tab and shift+tab keys. Ideally, we'll support the arrow keys too, but I ran into some difficulty getting that to work and wanted to share what I had before spending a significant amount of time on it.
  • All of the animation is currently done via CSS using scaling and the order property. This could very well need to change to support more functionality, but was a quick way to start.
  • Currently, the md-direction support is also CSS-only (which is kinda cool!) and this would probably need to change to be a proper attribute or scope object.
  • I've separated this into three components/directives:
    1. The main directive that wraps everything (md-fab)

    2. The trigger directive which wraps the always-visible element (the plus in this case: md-fab-trigger)

    3. The speed dial directive which wraps the popup (md-fab-speed-dial)

      This allows a decent level of separation and would allow us to add new presentation/behavior by adding a different nested component (for example: md-fab-toolbar).

  • Obviously, this is VERY prototype-code; I would start from scratch to create a proper component within the project; I just wanted something to play with and share :-)

So, the basic usage code looks something like this:

<md-fab md-direction="up">
    <md-fab-trigger>
        <md-button><md-icon path="/images/plus.svg"></md-icon></md-button>
    </md-fab-trigger>

    <md-fab-speed-dial>
        <md-button><md-icon path="/images/pencil.svg"></md-icon></md-button>
        <md-button><md-icon path="/images/user.svg"></md-icon></md-button>
        <md-button><md-icon path="/images/group.svg"></md-icon></md-button>
    </md-fab-speed-dial>
</md-fab>

In theory, this actually allows any HTML inside of the trigger or speed dial (perhaps a search box or other input field), but I haven't tried it since it seemed kinda silly.

In any case, I would love some feedback! I actually have today and tomorrow off so I could spend some time getting a basic component working if we think this approach is good.

topherfangio avatar Apr 16 '15 18:04 topherfangio

@topherfangio - This looks very interesting. Perhaps you could:

  • Support direction="left || right"
  • Support also a toolbar [with FABs] slideout [instead of floating FAB buttons].

ThomasBurleson avatar Apr 16 '15 18:04 ThomasBurleson

++1

victorsoliveira avatar Apr 16 '15 19:04 victorsoliveira

@ThomasBurleson I am definitely great with adding the additional suggestions you mentioned, however, I was hoping to get some feedback on the actual architectural choices (such has how I've broken out the directives, and whether to use CSS for the ordering, etc) before investing a significant amount of time in it.

As this is the first component I would be contributing, I'd like to hear some other people's thoughts on how to make sure it fits best with your existing ecosystem to make sure I'm not doing something really wonky :-)

Also, is there a document describing what browsers MD officially supports? I've only tested this with Chrome...

topherfangio avatar Apr 17 '15 00:04 topherfangio

Just a quick note, I am currently working on a PR for this. Code is available at https://github.com/profoundry-us/material/tree/contrib/md-fab-speed-dial if anyone is interested.

Right now, it supports the basic speed dial presentation. I am planning to submit the PR once I have added the toolbar presentation and signed the CLA.

topherfangio avatar Apr 21 '15 15:04 topherfangio

Just a quick update: I have added a basic toolbar presentation along with completely refactoring the code into two separate components (and fixing some issues with the speed dial while I was at it).

However, things took a bit longer than expected and there is still some work to be done:

  • Toolbar needs directional support (only comes from the left at the moment)
  • Some values are hard-coded in CSS for the demo; should be calculated by the directive
  • Speed dial SCSS is kinda complex; needs refactoring
  • Merge it with y'alls latest updates and make sure I didn't somehow break something else :-)

You can still keep up with the latest at https://github.com/profoundry-us/material/tree/contrib/md-fab-speed-dial. I'll try to finish it up this week if anyone happens to be waiting for it.

topherfangio avatar May 04 '15 06:05 topherfangio