-
Notifications
You must be signed in to change notification settings - Fork 6.8k
prototype(button): create prototype button based on MDC Web #15887
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
Merged
Merged
Changes from 8 commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
ff8960e
prototype(button): create prototype button based on MDC Web
andrewseguin 19ce08e
fix BUILD
andrewseguin 2ed16ac
add focus method to button base
andrewseguin d9e86ef
build: rename lib to material
andrewseguin e5a242f
add comments to ripple styles; remove position relative; merge mixins
andrewseguin f21fbda
put button HTML into file
andrewseguin 81604b3
fix lint
andrewseguin c24e7d3
move sass rules out of theme; cleanup typography styles
andrewseguin ca90399
build fix
andrewseguin e20359d
build fix
andrewseguin File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,147 @@ | ||
<!-- TODO: copy in demo template from existing mat-button demo. --> | ||
Not yet implemented. | ||
<div class="demo-button"> | ||
<h4 class="demo-section-header">Buttons</h4> | ||
<section> | ||
<button mat-button>normal</button> | ||
<button mat-raised-button>raised</button> | ||
<button mat-stroked-button>stroked</button> | ||
<button mat-flat-button>flat</button> | ||
<button mat-fab> | ||
<mat-icon>check</mat-icon> | ||
</button> | ||
<button mat-mini-fab> | ||
<mat-icon>check</mat-icon> | ||
</button> | ||
</section> | ||
|
||
<h4 class="demo-section-header">Anchors</h4> | ||
<section> | ||
<a href="//www.google.com" mat-button color="primary">SEARCH</a> | ||
<a href="//www.google.com" mat-raised-button>SEARCH</a> | ||
<a href="//www.google.com" mat-stroked-button color="primary">SEARCH</a> | ||
<a href="//www.google.com" mat-flat-button>SEARCH</a> | ||
<a href="//www.google.com" mat-fab> | ||
<mat-icon>check</mat-icon> | ||
</a> | ||
<a href="//www.google.com" mat-mini-fab> | ||
<mat-icon>check</mat-icon> | ||
</a> | ||
</section> | ||
|
||
<h4 class="demo-section-header">Text Buttons [mat-button]</h4> | ||
<section> | ||
<button mat-button color="primary">primary</button> | ||
<button mat-button color="accent">accent</button> | ||
<button mat-button color="warn">warn</button> | ||
<button mat-button disabled>disabled</button> | ||
</section> | ||
|
||
<h4 class="demo-section-header">Raised Buttons [mat-raised-button]</h4> | ||
<section> | ||
<button mat-raised-button color="primary">primary</button> | ||
<button mat-raised-button color="accent">accent</button> | ||
<button mat-raised-button color="warn">warn</button> | ||
<button mat-raised-button disabled>disabled</button> | ||
</section> | ||
|
||
<h4 class="demo-section-header">Stroked Buttons [mat-stroked-button]</h4> | ||
<section> | ||
<button mat-stroked-button color="primary">primary</button> | ||
<button mat-stroked-button color="accent">accent</button> | ||
<button mat-stroked-button color="warn">warn</button> | ||
<button mat-stroked-button disabled>disabled</button> | ||
</section> | ||
|
||
<h4 class="demo-section-header">Flat Buttons [mat-flat-button]</h4> | ||
<section> | ||
<button mat-flat-button color="primary">primary</button> | ||
<button mat-flat-button color="accent">accent</button> | ||
<button mat-flat-button color="warn">warn</button> | ||
<button mat-flat-button disabled>disabled</button> | ||
</section> | ||
|
||
<h4 class="demo-section-header"> Icon Buttons [mat-icon-button]</h4> | ||
<section> | ||
<button mat-icon-button color="primary"> | ||
<mat-icon>cached</mat-icon> | ||
</button> | ||
<button mat-icon-button color="accent"> | ||
<mat-icon>backup</mat-icon> | ||
</button> | ||
<button mat-icon-button color="warn"> | ||
<mat-icon>trending_up</mat-icon> | ||
</button> | ||
<button mat-icon-button disabled> | ||
<mat-icon>visibility</mat-icon> | ||
</button> | ||
</section> | ||
|
||
<h4 class="demo-section-header">Fab Buttons [mat-fab]</h4> | ||
<section> | ||
<button mat-fab color="primary"> | ||
<mat-icon>delete</mat-icon> | ||
</button> | ||
<button mat-fab color="accent"> | ||
<mat-icon>bookmark</mat-icon> | ||
</button> | ||
<button mat-fab color="warn"> | ||
<mat-icon>home</mat-icon> | ||
</button> | ||
<button mat-fab disabled> | ||
<mat-icon>favorite</mat-icon> | ||
</button> | ||
</section> | ||
|
||
<h4 class="demo-section-header"> Mini Fab Buttons [mat-mini-fab]</h4> | ||
<section> | ||
<button mat-mini-fab color="primary"> | ||
<mat-icon>menu</mat-icon> | ||
</button> | ||
<button mat-mini-fab color="accent"> | ||
<mat-icon>plus_one</mat-icon> | ||
</button> | ||
<button mat-mini-fab color="warn"> | ||
<mat-icon>filter_list</mat-icon> | ||
</button> | ||
<button mat-mini-fab disabled> | ||
<mat-icon>home</mat-icon> | ||
</button> | ||
</section> | ||
|
||
<h4 class="demo-section-header">Interaction/State</h4> | ||
<section class="demo-no-flex"> | ||
<div> | ||
<p>isDisabled: {{isDisabled}}</p> | ||
<p>Button 1 as been clicked {{clickCounter}} times</p> | ||
<button mat-flat-button (click)="isDisabled=!isDisabled"> | ||
{{isDisabled ? 'Enable All' : 'Disable All'}} | ||
</button> | ||
<button mat-flat-button (click)="button1.focus()">Focus 1</button> | ||
<button mat-flat-button (click)="button2.focus()">Focus 2</button> | ||
<button mat-flat-button (click)="button3.focus()">Focus 3</button> | ||
<button mat-flat-button (click)="button4.focus()">Focus 4</button> | ||
</div> | ||
<div> | ||
<button mat-button #button1 [disabled]="isDisabled" | ||
(click)="clickCounter=clickCounter+1"> | ||
Button 1 | ||
</button> | ||
<button mat-button #button2 color="primary" [disabled]="isDisabled"> | ||
Button 2 | ||
</button> | ||
<a href="//www.google.com" #button3 mat-button color="accent" | ||
[disabled]="isDisabled"> | ||
Button 3 | ||
</a> | ||
<button mat-raised-button #button4 color="primary" | ||
[disabled]="isDisabled"> | ||
Button 4 | ||
</button> | ||
<button mat-mini-fab [disabled]="isDisabled"> | ||
<mat-icon>check</mat-icon> | ||
</button> | ||
<button mat-icon-button color="accent" [disabled]="isDisabled"> | ||
<mat-icon>favorite</mat-icon> | ||
</button> | ||
</div> | ||
</section> | ||
</div> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,24 @@ | ||
// TODO: copy in demo styles from existing mat-button demo. | ||
button, | ||
a { | ||
margin: 8px; | ||
text-transform: uppercase; | ||
} | ||
|
||
section { | ||
display: flex; | ||
align-items: center; | ||
margin: 8px; | ||
} | ||
|
||
p { | ||
padding: 5px 15px; | ||
} | ||
|
||
.demo-section-header { | ||
font-weight: 500; | ||
margin: 0; | ||
} | ||
|
||
.demo-no-flex { | ||
display: block; | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,29 +1,65 @@ | ||
package(default_visibility=["//visibility:public"]) | ||
package(default_visibility = ["//visibility:public"]) | ||
|
||
load("@io_bazel_rules_sass//:defs.bzl", "sass_library", "sass_binary") | ||
load("@io_bazel_rules_sass//:defs.bzl", "sass_binary", "sass_library") | ||
load("//tools:defaults.bzl", "ng_module") | ||
load("//:packages.bzl", "CDK_TARGETS", "MATERIAL_TARGETS") | ||
|
||
ng_module( | ||
name = "mdc-button", | ||
srcs = glob(["**/*.ts"], exclude=["**/*.spec.ts"]), | ||
module_name = "@angular/material-experimental/mdc-button", | ||
assets = [":button_scss"] + glob(["**/*.html"]), | ||
deps = [ | ||
"@npm//material-components-web", | ||
] + CDK_TARGETS + MATERIAL_TARGETS, | ||
name = "mdc-button", | ||
srcs = glob(["**/*.ts"], exclude = ["**/*.spec.ts"]), | ||
module_name = "@angular/material-experimental/mdc-button", | ||
assets = [":button_scss", ":fab_scss", ":icon-button_scss"] + glob(["**/*.html"]), | ||
deps = [ | ||
"@npm//@angular/animations", | ||
"@npm//material-components-web", | ||
] + CDK_TARGETS + MATERIAL_TARGETS, | ||
) | ||
|
||
sass_library( | ||
name = "button_scss_lib", | ||
srcs = glob(["**/_*.scss"]), | ||
deps = [ | ||
"//src/material/core:core_scss_lib", | ||
"//src/material-experimental/mdc-helpers:mdc_helpers_scss_lib", | ||
], | ||
name = "button_scss_lib", | ||
srcs = glob(["**/_*.scss"]), | ||
deps = [ | ||
"//src/material/core:core_scss_lib", | ||
"//src/material-experimental/mdc-helpers:mdc_helpers_scss_lib", | ||
"//src/material-experimental/mdc-helpers:mdc_scss_deps_lib", | ||
], | ||
) | ||
|
||
sass_binary( | ||
name = "button_scss", | ||
src = "button.scss", | ||
name = "button_scss", | ||
src = "button.scss", | ||
include_paths = [ | ||
"external/npm/node_modules", | ||
], | ||
deps = [ | ||
":button_scss_lib", | ||
"//src/material/core:all_themes", | ||
"//src/material-experimental/mdc-helpers:mdc_scss_deps_lib", | ||
], | ||
) | ||
|
||
sass_binary( | ||
name = "fab_scss", | ||
src = "fab.scss", | ||
include_paths = [ | ||
"external/npm/node_modules", | ||
], | ||
deps = [ | ||
":fab_scss_lib", | ||
"//src/material/core:all_themes", | ||
"//src/material-experimental/mdc-helpers:mdc_scss_deps_lib", | ||
], | ||
) | ||
|
||
sass_binary( | ||
name = "icon-button_scss", | ||
src = "icon-button.scss", | ||
include_paths = [ | ||
"external/npm/node_modules", | ||
], | ||
deps = [ | ||
":icon-button_scss_lib", | ||
"//src/material/core:all_themes", | ||
"//src/material-experimental/mdc-helpers:mdc_scss_deps_lib", | ||
], | ||
) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,15 @@ | ||
This is a placeholder for the MDC-based implementation of button. | ||
### Open Issues | ||
|
||
- Disabled FAB does not look disabled | ||
- Anchor button does not look disabled | ||
- No focused state | ||
- Icon buttons are not colored by theme | ||
|
||
### TODO | ||
- Write README - looks like lot of overlap with checkbox README. Create common readme for setup | ||
- Move tests over (both unit and e2e) | ||
- JSDoc comments on all classes, consts | ||
- Consider supporting button[mat-outlined-button] | ||
- Add to universal app | ||
- Should each button type have a unique top level class? e.g. mdc-mat-icon-button | ||
- Consider if we want to add a "appearance/type" input to button, similar to form field (outline/stroked, flat, raised) |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.