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

feat(fab): Initial Implementation #4598

Merged
merged 1 commit into from
Aug 8, 2016
Merged

feat(fab): Initial Implementation #4598

merged 1 commit into from
Aug 8, 2016

Conversation

Garbee
Copy link
Collaborator

@Garbee Garbee commented Jul 26, 2016

No description provided.

@Garbee Garbee added this to the V2 Alpha milestone Jul 26, 2016
@traviskaufman traviskaufman self-assigned this Jul 26, 2016
@traviskaufman
Copy link
Contributor

#4469

}

fieldset .mdl-fab {
margin: 16px;
Copy link
Contributor

Choose a reason for hiding this comment

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

supernit: I think this is indented by one too many?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Yea, looks off by two spaces. We need linting in the demo files...

@Garbee Garbee force-pushed the garbee/fabs branch 2 times, most recently from b833a3e to b77fb33 Compare July 26, 2016 20:34
@traviskaufman traviskaufman changed the title chore(feat): Add FAB Component feat(fab): Initial Implementation Jul 26, 2016
<fieldset>
<legend>Normal FABs</legend>
<button class="mdl-fab">
<i class="material-icons mdl-fab__icon">favorite_border</i>
Copy link
Contributor

Choose a reason for hiding this comment

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

Do we need this wrapper element if we just put the material-icons class on the button and then using

.mdl-fab {
  align-items: center;
  justify-content: center;
}

to position the text?

Also, perhaps we should put an aria-label attribute on the button element for accessibility purposes, since the fab only displays an icon.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

The problem with making material-icons stuff forced is what if they are using another icon set? Whether or not it is "MD". We need to be able to let developers swap out anything icon-wise, like say you wanted to use an SVG version instead.

+1 to aria-label in the examples to help encourage using it.

Copy link
Contributor

Choose a reason for hiding this comment

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

what if they are using another icon set?

Then they could just swap out the class for that icon set right?

<button class="mdl-fab material-icons" aria-label="download">file_download</button>
<!-- OR -->
<button class="mdl-fab fa fa-download" aria-label="download">
  <span class="sr-only">download</span>
</button>

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Oh, you meant literally move it up. Yea, that can work.

I thought you meant like, implementing the font stack right within the fab class.

@Garbee Garbee force-pushed the garbee/fabs branch 2 times, most recently from 4ef64f3 to 2bc638b Compare July 29, 2016 17:41
@@ -0,0 +1,69 @@
<!DOCTYPE html>
Copy link
Contributor

@traviskaufman traviskaufman Jul 29, 2016

Choose a reason for hiding this comment

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

it may be good to have one example in the demo of a FAB positioned in the bottom-left corner, to show how easy it is to customize the behavior that way, and because it's such a common pattern in material

Copy link
Collaborator Author

@Garbee Garbee Jul 29, 2016

Choose a reason for hiding this comment

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

Done, added an "edit" icon that also uses SVG to test that out. Had to add fill: currentColor to the block to handle giving them the proper color. 😉

@traviskaufman
Copy link
Contributor

@Garbee did another pass on the styles. PTAL

overflow: hidden;
user-select: none;
box-sizing: border-box;
-webkit-appearance: none;
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 we also might want to add some font rules as well:

font-weight: 500;
font-size: 24px;

as per the spec's guidelines

screen shot 2016-07-29 at 15 47 38

@Garbee
Copy link
Collaborator Author

Garbee commented Jul 29, 2016

Codpen of the current state as well. Shadow update is already TODO'ed in the variable file, so I'm not going to duplicate the comment again.

With the typography stuff, let's also hold off just a bit until after the next sprint when we have the theme base done, as the typography should end up being more theme-bound then typography-bound. Unless we are now saying typography will be a big inter-linked dependency (which in this case would be a pretty needless one overall.)

I just need to add a README and this should be good for another pass.

@Garbee Garbee force-pushed the garbee/fabs branch 4 times, most recently from 0814b05 to 03b65f9 Compare August 1, 2016 16:27
Modify to fit your designs requirements.
-->
<style>
.app-fab--absolute.app-fab--absolute {
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 there's a repeated selector here...did you mean .mdl-fab.app-fab--absolute? And in that case, is the compound class needed? Or is it just there for demonstrative purposes?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Since the generated scripts will be injected after this, the double-class hack is to increase specificity to make sure these rules take place without !important. Otherwise the position would get overridden and it would never get moved.

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 I understand that exactly...but either way because this is documentation, that implicit knowledge might confuse some people. It may be more straightforward just to use an ID

#my-fab {
  position: absolute;
  bottom: 1rem;
  right: 1rem;
}

Copy link
Contributor

@sgomes sgomes Aug 8, 2016

Choose a reason for hiding this comment

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

Agree with @traviskaufman's suggestion.

@traviskaufman: for a bit of extra context, repeating the class name is a nice hack to increase specificity of a CSS rule, without having to use !important or hunt around for other things to append to the rule, like parent classes. Every repetition of the class name increments the specificity.

@traviskaufman
Copy link
Contributor

FABs are still missing box shadows:

Resting/default shadow (6dp):

box-shadow: 0px 3px 5px -1px rgba(0, 0, 0, 0.2),
              0px 6px 10px 0px rgba(0, 0, 0, 0.14),
              0px 1px 18px 0px rgba(0, 0, 0, 0.12);

Active shadow (12dp):

 box-shadow: 0px 7px 8px -4px rgba(0, 0, 0, 0.2),
              0px 12px 17px 2px rgba(0, 0, 0, 0.14),
              0px 5px 22px 4px rgba(0, 0, 0, 0.12);

@Garbee Garbee force-pushed the garbee/fabs branch 2 times, most recently from ed7b71b to 4fb9d7b Compare August 1, 2016 21:28
@Garbee
Copy link
Collaborator Author

Garbee commented Aug 1, 2016

Just pushed the updated code and the codepen is updated with its output.

Removed the ::before psueudo element and just made it all work on ::after. Not sure why we were using both when only one is required.

@Garbee Garbee added the PTAL label Aug 1, 2016
@traviskaufman
Copy link
Contributor

@Garbee you want to shift that back to ::before given #4628 ?

@traviskaufman traviskaufman removed the PTAL label Aug 2, 2016
@Garbee
Copy link
Collaborator Author

Garbee commented Aug 2, 2016

Waiting on that PR to land before updating this one, that way we are good on the direction. Yea, should have removed the PTAL tag.

<!-- You may also use SVG icons instead of an icon font. -->
<button class="mdl-fab app-fab--absolute" aria-label="Edit">
<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24">
<path d="M3 17.25V21h3.75L17.81 9.94l-3.75-3.75L3 17.25zM20.71 7.04c.39-.39.39-1.02 0-1.41l-2.34-2.34c-.39-.39-1.02-.39-1.41 0l-1.83 1.83 3.75 3.75 1.83-1.83z"/>
Copy link
Contributor

Choose a reason for hiding this comment

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

Does this default to currentColor or should that be added in?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

It does default. That is the fill CSS rule on the block.

@sgomes
Copy link
Contributor

sgomes commented Aug 8, 2016

LGTM other than the nits @traviskaufman and I pointed out. Thanks, @Garbee!

@traviskaufman traviskaufman removed the PTAL label Aug 8, 2016
@Garbee Garbee merged commit 1df786a into master Aug 8, 2016
@Garbee Garbee deleted the garbee/fabs branch August 8, 2016 14:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants