@material/mwc-button
Advanced tools
Comparing version 0.6.0 to 0.7.0
/** | ||
@license | ||
Copyright 2018 Google Inc. All Rights Reserved. | ||
Copyright 2019 Google Inc. All Rights Reserved. | ||
@@ -18,3 +18,2 @@ Licensed under the Apache License, Version 2.0 (the "License"); | ||
import { LitElement } from '@material/mwc-base/base-element'; | ||
import '@material/mwc-icon/mwc-icon-font.js'; | ||
export declare class ButtonBase extends LitElement { | ||
@@ -29,4 +28,4 @@ raised: boolean; | ||
label: string; | ||
createRenderRoot(): ShadowRoot; | ||
render(): import("lit-html/lib/template-result").TemplateResult; | ||
protected createRenderRoot(): ShadowRoot; | ||
protected render(): import("lit-html/lib/template-result").TemplateResult; | ||
} |
@@ -9,3 +9,3 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) { | ||
@license | ||
Copyright 2018 Google Inc. All Rights Reserved. | ||
Copyright 2019 Google Inc. All Rights Reserved. | ||
@@ -24,5 +24,4 @@ Licensed under the Apache License, Version 2.0 (the "License"); | ||
*/ | ||
import { LitElement, html, property, classMap } from '@material/mwc-base/base-element'; | ||
import { classMap, html, LitElement, property } from '@material/mwc-base/base-element'; | ||
import { ripple } from '@material/mwc-ripple/ripple-directive.js'; | ||
import '@material/mwc-icon/mwc-icon-font.js'; | ||
export class ButtonBase extends LitElement { | ||
@@ -52,4 +51,5 @@ constructor() { | ||
return html ` | ||
<button | ||
.ripple="${ripple({ unbounded: false })}" | ||
<button .ripple="${ripple({ | ||
unbounded: false | ||
})}" | ||
class="mdc-button ${classMap(classes)}" | ||
@@ -56,0 +56,0 @@ ?disabled="${this.disabled}" |
@@ -18,3 +18,3 @@ /** | ||
import { css } from '@material/mwc-base/base-element'; | ||
export const style = css `.mdc-button{font-family:Roboto,sans-serif;-moz-osx-font-smoothing:grayscale;-webkit-font-smoothing:antialiased;font-size:.875rem;line-height:2.25rem;font-weight:500;letter-spacing:.0892857143em;text-decoration:none;text-transform:uppercase;padding:0 8px 0 8px;display:inline-flex;position:relative;align-items:center;justify-content:center;box-sizing:border-box;min-width:64px;height:36px;border:none;outline:none;line-height:inherit;user-select:none;-webkit-appearance:none;overflow:hidden;vertical-align:middle;border-radius:4px}.mdc-button::-moz-focus-inner{padding:0;border:0}.mdc-button:active{outline:none}.mdc-button:hover{cursor:pointer}.mdc-button:disabled{background-color:transparent;color:rgba(0,0,0,.37);cursor:default;pointer-events:none}.mdc-button.mdc-button--dense{border-radius:4px}.mdc-button:not(:disabled){background-color:transparent}.mdc-button .mdc-button__icon{margin-left:0;margin-right:8px;display:inline-block;width:18px;height:18px;font-size:18px;vertical-align:top}[dir=rtl] .mdc-button .mdc-button__icon,.mdc-button .mdc-button__icon[dir=rtl]{margin-left:8px;margin-right:0}.mdc-button:not(:disabled){color:#6200ee;color:var(--mdc-theme-primary, #6200ee)}.mdc-button__label+.mdc-button__icon{margin-left:8px;margin-right:0}[dir=rtl] .mdc-button__label+.mdc-button__icon,.mdc-button__label+.mdc-button__icon[dir=rtl]{margin-left:0;margin-right:8px}svg.mdc-button__icon{fill:currentColor}.mdc-button--raised .mdc-button__icon,.mdc-button--unelevated .mdc-button__icon,.mdc-button--outlined .mdc-button__icon{margin-left:-4px;margin-right:8px}[dir=rtl] .mdc-button--raised .mdc-button__icon,.mdc-button--raised .mdc-button__icon[dir=rtl],[dir=rtl] .mdc-button--unelevated .mdc-button__icon,.mdc-button--unelevated .mdc-button__icon[dir=rtl],[dir=rtl] .mdc-button--outlined .mdc-button__icon,.mdc-button--outlined .mdc-button__icon[dir=rtl]{margin-left:8px;margin-right:-4px}.mdc-button--raised .mdc-button__label+.mdc-button__icon,.mdc-button--unelevated .mdc-button__label+.mdc-button__icon,.mdc-button--outlined .mdc-button__label+.mdc-button__icon{margin-left:8px;margin-right:-4px}[dir=rtl] .mdc-button--raised .mdc-button__label+.mdc-button__icon,.mdc-button--raised .mdc-button__label+.mdc-button__icon[dir=rtl],[dir=rtl] .mdc-button--unelevated .mdc-button__label+.mdc-button__icon,.mdc-button--unelevated .mdc-button__label+.mdc-button__icon[dir=rtl],[dir=rtl] .mdc-button--outlined .mdc-button__label+.mdc-button__icon,.mdc-button--outlined .mdc-button__label+.mdc-button__icon[dir=rtl]{margin-left:-4px;margin-right:8px}.mdc-button--raised,.mdc-button--unelevated{padding:0 16px 0 16px}.mdc-button--raised:disabled,.mdc-button--unelevated:disabled{background-color:rgba(0,0,0,.12);color:rgba(0,0,0,.37)}.mdc-button--raised:not(:disabled),.mdc-button--unelevated:not(:disabled){background-color:#6200ee}@supports not (-ms-ime-align: auto){.mdc-button--raised:not(:disabled),.mdc-button--unelevated:not(:disabled){background-color:var(--mdc-theme-primary, #6200ee)}}.mdc-button--raised:not(:disabled),.mdc-button--unelevated:not(:disabled){color:#fff;color:var(--mdc-theme-on-primary, #fff)}.mdc-button--raised{box-shadow:0px 3px 1px -2px rgba(0, 0, 0, 0.2),0px 2px 2px 0px rgba(0, 0, 0, 0.14),0px 1px 5px 0px rgba(0,0,0,.12);transition:box-shadow 280ms cubic-bezier(0.4, 0, 0.2, 1)}.mdc-button--raised:hover,.mdc-button--raised:focus{box-shadow:0px 2px 4px -1px rgba(0, 0, 0, 0.2),0px 4px 5px 0px rgba(0, 0, 0, 0.14),0px 1px 10px 0px rgba(0,0,0,.12)}.mdc-button--raised:active{box-shadow:0px 5px 5px -3px rgba(0, 0, 0, 0.2),0px 8px 10px 1px rgba(0, 0, 0, 0.14),0px 3px 14px 2px rgba(0,0,0,.12)}.mdc-button--raised:disabled{box-shadow:0px 0px 0px 0px rgba(0, 0, 0, 0.2),0px 0px 0px 0px rgba(0, 0, 0, 0.14),0px 0px 0px 0px rgba(0,0,0,.12)}.mdc-button--outlined{border-style:solid;padding:0 14px 0 14px;border-width:2px}.mdc-button--outlined:disabled{border-color:rgba(0,0,0,.37)}.mdc-button--outlined:not(:disabled){border-color:#6200ee;border-color:var(--mdc-theme-primary, #6200ee)}.mdc-button--dense{height:32px;font-size:.8125rem}@keyframes mdc-ripple-fg-radius-in{from{animation-timing-function:cubic-bezier(0.4, 0, 0.2, 1);transform:translate(var(--mdc-ripple-fg-translate-start, 0)) scale(1)}to{transform:translate(var(--mdc-ripple-fg-translate-end, 0)) scale(var(--mdc-ripple-fg-scale, 1))}}@keyframes mdc-ripple-fg-opacity-in{from{animation-timing-function:linear;opacity:0}to{opacity:var(--mdc-ripple-fg-opacity, 0)}}@keyframes mdc-ripple-fg-opacity-out{from{animation-timing-function:linear;opacity:var(--mdc-ripple-fg-opacity, 0)}to{opacity:0}}.mdc-ripple-surface--test-edge-var-bug{--mdc-ripple-surface-test-edge-var: 1px solid #000;visibility:hidden}.mdc-ripple-surface--test-edge-var-bug::before{border:var(--mdc-ripple-surface-test-edge-var)}.mdc-button{--mdc-ripple-fg-size: 0;--mdc-ripple-left: 0;--mdc-ripple-top: 0;--mdc-ripple-fg-scale: 1;--mdc-ripple-fg-translate-end: 0;--mdc-ripple-fg-translate-start: 0;-webkit-tap-highlight-color:rgba(0,0,0,0);will-change:transform,opacity}.mdc-button::before,.mdc-button::after{position:absolute;border-radius:50%;opacity:0;pointer-events:none;content:""}.mdc-button::before{transition:opacity 15ms linear,background-color 15ms linear;z-index:1}.mdc-button.mdc-ripple-upgraded::before{transform:scale(var(--mdc-ripple-fg-scale, 1))}.mdc-button.mdc-ripple-upgraded::after{top:0;left:0;transform:scale(0);transform-origin:center center}.mdc-button.mdc-ripple-upgraded--unbounded::after{top:var(--mdc-ripple-top, 0);left:var(--mdc-ripple-left, 0)}.mdc-button.mdc-ripple-upgraded--foreground-activation::after{animation:mdc-ripple-fg-radius-in 225ms forwards,mdc-ripple-fg-opacity-in 75ms forwards}.mdc-button.mdc-ripple-upgraded--foreground-deactivation::after{animation:mdc-ripple-fg-opacity-out 150ms;transform:translate(var(--mdc-ripple-fg-translate-end, 0)) scale(var(--mdc-ripple-fg-scale, 1))}.mdc-button::before,.mdc-button::after{top:calc(50% - 100%);left:calc(50% - 100%);width:200%;height:200%}.mdc-button.mdc-ripple-upgraded::after{width:var(--mdc-ripple-fg-size, 100%);height:var(--mdc-ripple-fg-size, 100%)}.mdc-button::before,.mdc-button::after{background-color:#6200ee}@supports not (-ms-ime-align: auto){.mdc-button::before,.mdc-button::after{background-color:var(--mdc-theme-primary, #6200ee)}}.mdc-button:hover::before{opacity:.04}.mdc-button:not(.mdc-ripple-upgraded):focus::before,.mdc-button.mdc-ripple-upgraded--background-focused::before{transition-duration:75ms;opacity:.12}.mdc-button:not(.mdc-ripple-upgraded)::after{transition:opacity 150ms linear}.mdc-button:not(.mdc-ripple-upgraded):active::after{transition-duration:75ms;opacity:.12}.mdc-button.mdc-ripple-upgraded{--mdc-ripple-fg-opacity: 0.12}.mdc-button--raised::before,.mdc-button--raised::after,.mdc-button--unelevated::before,.mdc-button--unelevated::after{background-color:#fff}@supports not (-ms-ime-align: auto){.mdc-button--raised::before,.mdc-button--raised::after,.mdc-button--unelevated::before,.mdc-button--unelevated::after{background-color:var(--mdc-theme-on-primary, #fff)}}.mdc-button--raised:hover::before,.mdc-button--unelevated:hover::before{opacity:.08}.mdc-button--raised:not(.mdc-ripple-upgraded):focus::before,.mdc-button--raised.mdc-ripple-upgraded--background-focused::before,.mdc-button--unelevated:not(.mdc-ripple-upgraded):focus::before,.mdc-button--unelevated.mdc-ripple-upgraded--background-focused::before{transition-duration:75ms;opacity:.24}.mdc-button--raised:not(.mdc-ripple-upgraded)::after,.mdc-button--unelevated:not(.mdc-ripple-upgraded)::after{transition:opacity 150ms linear}.mdc-button--raised:not(.mdc-ripple-upgraded):active::after,.mdc-button--unelevated:not(.mdc-ripple-upgraded):active::after{transition-duration:75ms;opacity:.24}.mdc-button--raised.mdc-ripple-upgraded,.mdc-button--unelevated.mdc-ripple-upgraded{--mdc-ripple-fg-opacity: 0.24}.material-icons{font-family:var(--mdc-icon-font, "Material Icons");font-weight:normal;font-style:normal;font-size:var(--mdc-icon-size, 24px);line-height:1;letter-spacing:normal;text-transform:none;display:inline-block;white-space:nowrap;word-wrap:normal;direction:ltr;-webkit-font-feature-settings:"liga";-webkit-font-smoothing:antialiased}:host{display:inline-flex;outline:none}:host([disabled]){pointer-events:none}.mdc-button{flex:1}`; | ||
export const style = css `.mdc-button{font-family:Roboto, sans-serif;-moz-osx-font-smoothing:grayscale;-webkit-font-smoothing:antialiased;font-size:.875rem;line-height:2.25rem;font-weight:500;letter-spacing:.0892857143em;text-decoration:none;text-transform:uppercase;padding:0 8px 0 8px;display:inline-flex;position:relative;align-items:center;justify-content:center;box-sizing:border-box;min-width:64px;height:36px;border:none;outline:none;line-height:inherit;user-select:none;-webkit-appearance:none;overflow:hidden;vertical-align:middle;border-radius:4px}.mdc-button::-moz-focus-inner{padding:0;border:0}.mdc-button:active{outline:none}.mdc-button:hover{cursor:pointer}.mdc-button:disabled{background-color:transparent;color:rgba(0,0,0,.37);cursor:default;pointer-events:none}.mdc-button.mdc-button--dense{border-radius:4px}.mdc-button:not(:disabled){background-color:transparent}.mdc-button .mdc-button__icon{margin-left:0;margin-right:8px;display:inline-block;width:18px;height:18px;font-size:18px;vertical-align:top}[dir=rtl] .mdc-button .mdc-button__icon,.mdc-button .mdc-button__icon[dir=rtl]{margin-left:8px;margin-right:0}.mdc-button:not(:disabled){color:#6200ee;color:var(--mdc-theme-primary, #6200ee)}.mdc-button__label+.mdc-button__icon{margin-left:8px;margin-right:0}[dir=rtl] .mdc-button__label+.mdc-button__icon,.mdc-button__label+.mdc-button__icon[dir=rtl]{margin-left:0;margin-right:8px}svg.mdc-button__icon{fill:currentColor}.mdc-button--raised .mdc-button__icon,.mdc-button--unelevated .mdc-button__icon,.mdc-button--outlined .mdc-button__icon{margin-left:-4px;margin-right:8px}[dir=rtl] .mdc-button--raised .mdc-button__icon,.mdc-button--raised .mdc-button__icon[dir=rtl],[dir=rtl] .mdc-button--unelevated .mdc-button__icon,.mdc-button--unelevated .mdc-button__icon[dir=rtl],[dir=rtl] .mdc-button--outlined .mdc-button__icon,.mdc-button--outlined .mdc-button__icon[dir=rtl]{margin-left:8px;margin-right:-4px}.mdc-button--raised .mdc-button__label+.mdc-button__icon,.mdc-button--unelevated .mdc-button__label+.mdc-button__icon,.mdc-button--outlined .mdc-button__label+.mdc-button__icon{margin-left:8px;margin-right:-4px}[dir=rtl] .mdc-button--raised .mdc-button__label+.mdc-button__icon,.mdc-button--raised .mdc-button__label+.mdc-button__icon[dir=rtl],[dir=rtl] .mdc-button--unelevated .mdc-button__label+.mdc-button__icon,.mdc-button--unelevated .mdc-button__label+.mdc-button__icon[dir=rtl],[dir=rtl] .mdc-button--outlined .mdc-button__label+.mdc-button__icon,.mdc-button--outlined .mdc-button__label+.mdc-button__icon[dir=rtl]{margin-left:-4px;margin-right:8px}.mdc-button--raised,.mdc-button--unelevated{padding:0 16px 0 16px}.mdc-button--raised:disabled,.mdc-button--unelevated:disabled{background-color:rgba(0,0,0,.12);color:rgba(0,0,0,.37)}.mdc-button--raised:not(:disabled),.mdc-button--unelevated:not(:disabled){background-color:#6200ee}@supports not (-ms-ime-align: auto){.mdc-button--raised:not(:disabled),.mdc-button--unelevated:not(:disabled){background-color:var(--mdc-theme-primary, #6200ee)}}.mdc-button--raised:not(:disabled),.mdc-button--unelevated:not(:disabled){color:#fff;color:var(--mdc-theme-on-primary, #fff)}.mdc-button--raised{box-shadow:0px 3px 1px -2px rgba(0, 0, 0, 0.2),0px 2px 2px 0px rgba(0, 0, 0, 0.14),0px 1px 5px 0px rgba(0,0,0,.12);transition:box-shadow 280ms cubic-bezier(0.4, 0, 0.2, 1)}.mdc-button--raised:hover,.mdc-button--raised:focus{box-shadow:0px 2px 4px -1px rgba(0, 0, 0, 0.2),0px 4px 5px 0px rgba(0, 0, 0, 0.14),0px 1px 10px 0px rgba(0,0,0,.12)}.mdc-button--raised:active{box-shadow:0px 5px 5px -3px rgba(0, 0, 0, 0.2),0px 8px 10px 1px rgba(0, 0, 0, 0.14),0px 3px 14px 2px rgba(0,0,0,.12)}.mdc-button--raised:disabled{box-shadow:0px 0px 0px 0px rgba(0, 0, 0, 0.2),0px 0px 0px 0px rgba(0, 0, 0, 0.14),0px 0px 0px 0px rgba(0,0,0,.12)}.mdc-button--outlined{border-style:solid;padding:0 15px 0 15px;border-width:1px}.mdc-button--outlined:disabled{border-color:rgba(0,0,0,.37)}.mdc-button--outlined:not(:disabled){border-color:#6200ee;border-color:var(--mdc-theme-primary, #6200ee)}.mdc-button--dense{height:32px;font-size:.8125rem}@keyframes mdc-ripple-fg-radius-in{from{animation-timing-function:cubic-bezier(0.4, 0, 0.2, 1);transform:translate(var(--mdc-ripple-fg-translate-start, 0)) scale(1)}to{transform:translate(var(--mdc-ripple-fg-translate-end, 0)) scale(var(--mdc-ripple-fg-scale, 1))}}@keyframes mdc-ripple-fg-opacity-in{from{animation-timing-function:linear;opacity:0}to{opacity:var(--mdc-ripple-fg-opacity, 0)}}@keyframes mdc-ripple-fg-opacity-out{from{animation-timing-function:linear;opacity:var(--mdc-ripple-fg-opacity, 0)}to{opacity:0}}.mdc-ripple-surface--test-edge-var-bug{--mdc-ripple-surface-test-edge-var: 1px solid #000;visibility:hidden}.mdc-ripple-surface--test-edge-var-bug::before{border:var(--mdc-ripple-surface-test-edge-var)}.mdc-button{--mdc-ripple-fg-size: 0;--mdc-ripple-left: 0;--mdc-ripple-top: 0;--mdc-ripple-fg-scale: 1;--mdc-ripple-fg-translate-end: 0;--mdc-ripple-fg-translate-start: 0;-webkit-tap-highlight-color:rgba(0,0,0,0)}.mdc-button::before,.mdc-button::after{position:absolute;border-radius:50%;opacity:0;pointer-events:none;content:""}.mdc-button::before{transition:opacity 15ms linear,background-color 15ms linear;z-index:1}.mdc-button.mdc-ripple-upgraded::before{transform:scale(var(--mdc-ripple-fg-scale, 1))}.mdc-button.mdc-ripple-upgraded::after{top:0;left:0;transform:scale(0);transform-origin:center center}.mdc-button.mdc-ripple-upgraded--unbounded::after{top:var(--mdc-ripple-top, 0);left:var(--mdc-ripple-left, 0)}.mdc-button.mdc-ripple-upgraded--foreground-activation::after{animation:mdc-ripple-fg-radius-in 225ms forwards,mdc-ripple-fg-opacity-in 75ms forwards}.mdc-button.mdc-ripple-upgraded--foreground-deactivation::after{animation:mdc-ripple-fg-opacity-out 150ms;transform:translate(var(--mdc-ripple-fg-translate-end, 0)) scale(var(--mdc-ripple-fg-scale, 1))}.mdc-button::before,.mdc-button::after{top:calc(50% - 100%);left:calc(50% - 100%);width:200%;height:200%}.mdc-button.mdc-ripple-upgraded::after{width:var(--mdc-ripple-fg-size, 100%);height:var(--mdc-ripple-fg-size, 100%)}.mdc-button::before,.mdc-button::after{background-color:#6200ee}@supports not (-ms-ime-align: auto){.mdc-button::before,.mdc-button::after{background-color:var(--mdc-theme-primary, #6200ee)}}.mdc-button:hover::before{opacity:.04}.mdc-button:not(.mdc-ripple-upgraded):focus::before,.mdc-button.mdc-ripple-upgraded--background-focused::before{transition-duration:75ms;opacity:.12}.mdc-button:not(.mdc-ripple-upgraded)::after{transition:opacity 150ms linear}.mdc-button:not(.mdc-ripple-upgraded):active::after{transition-duration:75ms;opacity:.12}.mdc-button.mdc-ripple-upgraded{--mdc-ripple-fg-opacity: 0.12}.mdc-button--raised::before,.mdc-button--raised::after,.mdc-button--unelevated::before,.mdc-button--unelevated::after{background-color:#fff}@supports not (-ms-ime-align: auto){.mdc-button--raised::before,.mdc-button--raised::after,.mdc-button--unelevated::before,.mdc-button--unelevated::after{background-color:var(--mdc-theme-on-primary, #fff)}}.mdc-button--raised:hover::before,.mdc-button--unelevated:hover::before{opacity:.08}.mdc-button--raised:not(.mdc-ripple-upgraded):focus::before,.mdc-button--raised.mdc-ripple-upgraded--background-focused::before,.mdc-button--unelevated:not(.mdc-ripple-upgraded):focus::before,.mdc-button--unelevated.mdc-ripple-upgraded--background-focused::before{transition-duration:75ms;opacity:.24}.mdc-button--raised:not(.mdc-ripple-upgraded)::after,.mdc-button--unelevated:not(.mdc-ripple-upgraded)::after{transition:opacity 150ms linear}.mdc-button--raised:not(.mdc-ripple-upgraded):active::after,.mdc-button--unelevated:not(.mdc-ripple-upgraded):active::after{transition-duration:75ms;opacity:.24}.mdc-button--raised.mdc-ripple-upgraded,.mdc-button--unelevated.mdc-ripple-upgraded{--mdc-ripple-fg-opacity: 0.24}.material-icons{font-family:var(--mdc-icon-font, "Material Icons");font-weight:normal;font-style:normal;font-size:var(--mdc-icon-size, 24px);line-height:1;letter-spacing:normal;text-transform:none;display:inline-block;white-space:nowrap;word-wrap:normal;direction:ltr;-webkit-font-smoothing:antialiased;text-rendering:optimizeLegibility;-moz-osx-font-smoothing:grayscale;font-feature-settings:"liga"}:host{display:inline-flex;outline:none}:host([disabled]){pointer-events:none}.mdc-button{flex:auto}`; | ||
//# sourceMappingURL=mwc-button-css.js.map |
@@ -1,31 +0,4 @@ | ||
/** | ||
@license | ||
Copyright 2018 Google Inc. All Rights Reserved. | ||
Licensed under the Apache License, Version 2.0 (the "License"); | ||
you may not use this file except in compliance with the License. | ||
You may obtain a copy of the License at | ||
http://www.apache.org/licenses/LICENSE-2.0 | ||
Unless required by applicable law or agreed to in writing, software | ||
distributed under the License is distributed on an "AS IS" BASIS, | ||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
See the License for the specific language governing permissions and | ||
limitations under the License. | ||
*/ | ||
import { LitElement } from '@material/mwc-base/base-element'; | ||
import '@material/mwc-icon/mwc-icon-font.js'; | ||
export declare class Button extends LitElement { | ||
raised: boolean; | ||
unelevated: boolean; | ||
outlined: boolean; | ||
dense: boolean; | ||
disabled: boolean; | ||
trailingIcon: boolean; | ||
icon: string; | ||
label: string; | ||
createRenderRoot(): ShadowRoot; | ||
import { ButtonBase } from './mwc-button-base.js'; | ||
export declare class Button extends ButtonBase { | ||
static styles: import("lit-element/lib/css-tag").CSSResult; | ||
render(): import("lit-html/lib/template-result").TemplateResult; | ||
} | ||
@@ -32,0 +5,0 @@ declare global { |
@@ -23,67 +23,8 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) { | ||
*/ | ||
import { LitElement, html, property, customElement, classMap } from '@material/mwc-base/base-element'; | ||
import { customElement } from '@material/mwc-base/base-element'; | ||
import { ButtonBase } from './mwc-button-base.js'; | ||
import { style } from './mwc-button-css.js'; | ||
import { ripple } from '@material/mwc-ripple/ripple-directive.js'; | ||
import '@material/mwc-icon/mwc-icon-font.js'; | ||
let Button = class Button extends LitElement { | ||
constructor() { | ||
super(...arguments); | ||
this.raised = false; | ||
this.unelevated = false; | ||
this.outlined = false; | ||
this.dense = false; | ||
this.disabled = false; | ||
this.trailingIcon = false; | ||
this.icon = ''; | ||
this.label = ''; | ||
} | ||
createRenderRoot() { | ||
return this.attachShadow({ mode: 'open', delegatesFocus: true }); | ||
} | ||
render() { | ||
const classes = { | ||
'mdc-button--raised': this.raised, | ||
'mdc-button--unelevated': this.unelevated, | ||
'mdc-button--outlined': this.outlined, | ||
'mdc-button--dense': this.dense, | ||
}; | ||
const mdcButtonIcon = html `<span class="material-icons mdc-button__icon">${this.icon}</span>`; | ||
return html ` | ||
<button | ||
.ripple="${ripple({ unbounded: false })}" | ||
class="mdc-button ${classMap(classes)}" | ||
?disabled="${this.disabled}" | ||
aria-label="${this.label || this.icon}"> | ||
${this.icon && !this.trailingIcon ? mdcButtonIcon : ''} | ||
<span class="mdc-button__label">${this.label}</span> | ||
${this.icon && this.trailingIcon ? mdcButtonIcon : ''} | ||
<slot></slot> | ||
</button>`; | ||
} | ||
let Button = class Button extends ButtonBase { | ||
}; | ||
Button.styles = style; | ||
__decorate([ | ||
property({ type: Boolean }) | ||
], Button.prototype, "raised", void 0); | ||
__decorate([ | ||
property({ type: Boolean }) | ||
], Button.prototype, "unelevated", void 0); | ||
__decorate([ | ||
property({ type: Boolean }) | ||
], Button.prototype, "outlined", void 0); | ||
__decorate([ | ||
property({ type: Boolean }) | ||
], Button.prototype, "dense", void 0); | ||
__decorate([ | ||
property({ type: Boolean, reflect: true }) | ||
], Button.prototype, "disabled", void 0); | ||
__decorate([ | ||
property({ type: Boolean }) | ||
], Button.prototype, "trailingIcon", void 0); | ||
__decorate([ | ||
property() | ||
], Button.prototype, "icon", void 0); | ||
__decorate([ | ||
property() | ||
], Button.prototype, "label", void 0); | ||
Button = __decorate([ | ||
@@ -90,0 +31,0 @@ customElement('mwc-button') |
{ | ||
"name": "@material/mwc-button", | ||
"version": "0.6.0", | ||
"version": "0.7.0", | ||
"description": "", | ||
@@ -8,3 +8,4 @@ "main": "mwc-button.js", | ||
"type": "git", | ||
"url": "https://github.com/material-components/material-components-web-components.git" | ||
"url": "https://github.com/material-components/material-components-web-components.git", | ||
"directory": "packages/button" | ||
}, | ||
@@ -17,6 +18,6 @@ "scripts": { | ||
"dependencies": { | ||
"@material/button": "^1.0.0", | ||
"@material/mwc-base": "^0.6.0", | ||
"@material/mwc-icon": "^0.6.0", | ||
"@material/mwc-ripple": "^0.6.0" | ||
"@material/button": "^3.0.0", | ||
"@material/mwc-base": "^0.7.0", | ||
"@material/mwc-icon": "^0.7.0", | ||
"@material/mwc-ripple": "^0.7.0" | ||
}, | ||
@@ -26,3 +27,3 @@ "publishConfig": { | ||
}, | ||
"gitHead": "1961a2530cc20bc020bba88f4da76d085ad1f1e0" | ||
"gitHead": "c8c5d01ad2103af63e3d7656b5d1acc5ccaa05db" | ||
} |
144
README.md
@@ -1,64 +0,138 @@ | ||
# mwc-button | ||
# `<mwc-button>` [![Published on npm](https://img.shields.io/npm/v/@material/mwc-button.svg)](https://www.npmjs.com/package/@material/mwc-button) | ||
> :warning: These components are a work in progress. They are pre-release and should be considered experimental, as they may undergo major changes before release. We are experimenting with alternate architectures and approaches with the goal of allowing us to bring the most correct and optimal implementation of Material components to the widest possible audiences. Visible progress may be slow, as this research is across teams and repositories so is not consistently reflected in commits to this codebase. :warning: | ||
> IMPORTANT: The Material Web Components are a work in progress and subject to | ||
> major changes until 1.0 release. | ||
A [Material Components](https://material.io/components/) icon implementation using [Web Components](https://www.webcomponents.org/introduction) | ||
Buttons allow users to take actions, and make choices, with a single tap. | ||
## Getting started | ||
[Material Design Guidelines: Button](https://material.io/design/components/buttons.html) | ||
* The easiest way to try out mwc-button is to use one of these online tools: | ||
## Installation | ||
* Runs in all [supported](#supported-browsers) browsers: [StackBlitz](https://stackblitz.com/edit/mwc-icon-example?file=index.js), [Glitch](https://glitch.com/edit/#!/mwc-icon-example?path=index.html) | ||
```sh | ||
npm install @material/mwc-button | ||
``` | ||
* Runs in browsers with [JavaScript Modules](https://caniuse.com/#search=modules): [JSBin](http://jsbin.com/qibisux/edit?html,output), | ||
[CodePen](https://codepen.io/azakus/pen/deZLja). | ||
> NOTE: The Material Web Components are distributed as ES2017 JavaScript | ||
> Modules, and use the Custom Elements API. They are compatible with all modern | ||
> browsers including Chrome, Firefox, Safari, Edge, and IE11, but an additional | ||
> tooling step is required to resolve *bare module specifiers*, as well as | ||
> transpilation and polyfills for Edge and IE11. See | ||
> [here](https://github.com/material-components/material-components-web-components#quick-start) | ||
> for detailed instructions. | ||
* You can also copy [this HTML file](https://gist.githubusercontent.com/azakus/f01e9fc2ed04e781ad5a52ded7b296e7/raw/266f2f4f91cbfe89b2acc6ec63957b1a3cfe9b39/index.html) into a local file and run it in any browser that supports [JavaScript Modules]((https://caniuse.com/#search=modules)). | ||
## Example Usage | ||
* When you're ready to use mwc-button in a project, install it via [npm](https://www.npmjs.com/). To run the project in the browser, a module-compatible toolctain is required. We recommend installing the [Polymer CLI](https://github.com/Polymer/polymer-cli) and using its development server as follows. | ||
### Standard | ||
1. Ensure the webcomponents polyfills are included in your HTML page | ||
![](https://raw.githubusercontent.com/material-components/material-components-web-components/c8c5d01ad2103af63e3d7656b5d1acc5ccaa05db/packages/button/images/standard.png) | ||
![](https://raw.githubusercontent.com/material-components/material-components-web-components/c8c5d01ad2103af63e3d7656b5d1acc5ccaa05db/packages/button/images/standard_with_icon.png) | ||
- Install webcomponents polyfills | ||
```html | ||
<mwc-button label="standard"></mwc-button> | ||
<mwc-button label="standard" icon="code"></mwc-button> | ||
``` | ||
```npm i @webcomponents/webcomponentsjs``` | ||
### Outlined | ||
- Add webcomponents polyfills to your HTML page | ||
![](https://raw.githubusercontent.com/material-components/material-components-web-components/c8c5d01ad2103af63e3d7656b5d1acc5ccaa05db/packages/button/images/outlined.png) | ||
![](https://raw.githubusercontent.com/material-components/material-components-web-components/c8c5d01ad2103af63e3d7656b5d1acc5ccaa05db/packages/button/images/outlined_with_icon.png) | ||
```<script src="@webcomponents/webcomponentsjs/webcomponents-loader.js"></script>``` | ||
```html | ||
<mwc-button outlined label="outlined"></mwc-button> | ||
<mwc-button outlined label="outlined" icon="code"></mwc-button> | ||
``` | ||
1. Add mwc-button to your project: | ||
### Raised | ||
```npm i @material/mwc-button``` | ||
![](https://raw.githubusercontent.com/material-components/material-components-web-components/c8c5d01ad2103af63e3d7656b5d1acc5ccaa05db/packages/button/images/raised.png) | ||
![](https://raw.githubusercontent.com/material-components/material-components-web-components/c8c5d01ad2103af63e3d7656b5d1acc5ccaa05db/packages/button/images/raised_with_icon.png) | ||
1. Import the mwc-button definition into your HTML page: | ||
```html | ||
<mwc-button raised label="raised"></mwc-button> | ||
<mwc-button raised label="raised" icon="code"></mwc-button> | ||
``` | ||
```<script type="module" src="@material/mwc-button/index.js"></script>``` | ||
### Unelevated | ||
Or into your module script: | ||
![](https://raw.githubusercontent.com/material-components/material-components-web-components/c8c5d01ad2103af63e3d7656b5d1acc5ccaa05db/packages/button/images/unelevated.png) | ||
![](https://raw.githubusercontent.com/material-components/material-components-web-components/c8c5d01ad2103af63e3d7656b5d1acc5ccaa05db/packages/button/images/unelevated_with_icon.png) | ||
```import {Button} from "@material/mwc-button"``` | ||
```html | ||
<mwc-button unelevated label="unelevated"></mwc-button> | ||
<mwc-button unelevated label="unelevated" icon="code"></mwc-button> | ||
``` | ||
1. Create an instance of mwc-button in your HTML page, or via any framework that [supports rendering Custom Elements](https://custom-elements-everywhere.com/): | ||
### Dense | ||
```<mwc-button>Click Here!</mwc-button>``` | ||
![](https://raw.githubusercontent.com/material-components/material-components-web-components/c8c5d01ad2103af63e3d7656b5d1acc5ccaa05db/packages/button/images/dense.png) | ||
![](https://raw.githubusercontent.com/material-components/material-components-web-components/c8c5d01ad2103af63e3d7656b5d1acc5ccaa05db/packages/button/images/dense_with_icon.png) | ||
1. Install the Polymer CLI: | ||
```html | ||
<mwc-button dense unelevated label="dense"></mwc-button> | ||
<mwc-button dense unelevated label="dense" icon="code"></mwc-button> | ||
``` | ||
```npm i -g polymer-cli``` | ||
### Trailing Icon | ||
1. Run the development server and open a browser pointing to its URL: | ||
![](https://raw.githubusercontent.com/material-components/material-components-web-components/c8c5d01ad2103af63e3d7656b5d1acc5ccaa05db/packages/button/images/trailing_icon.png) | ||
```polymer serve``` | ||
```html | ||
<mwc-button label="trailing icon" icon="code" trailingIcon></mwc-button> | ||
``` | ||
> mwc-button is published on [npm](https://www.npmjs.com/package/@material/mwc-button) using JavaScript Modules. | ||
This means it can take advantage of the standard native JavaScript module loader available in all current major browsers. | ||
> | ||
> However, since mwc-button uses npm convention to reference dependencies by name, a light transform to rewrite specifiers to URLs is required to get it to run in the browser. The polymer-cli's development server `polymer serve` automatically handles this transform. | ||
### Disabled | ||
Tools like [WebPack](https://webpack.js.org/) and [Rollup](https://rollupjs.org/) can also be used to serve and/or bundle mwc-button. | ||
![](https://raw.githubusercontent.com/material-components/material-components-web-components/c8c5d01ad2103af63e3d7656b5d1acc5ccaa05db/packages/button/images/disabled.png) | ||
![](https://raw.githubusercontent.com/material-components/material-components-web-components/c8c5d01ad2103af63e3d7656b5d1acc5ccaa05db/packages/button/images/disabled_with_icon.png) | ||
## Supported Browsers | ||
```html | ||
<mwc-button disabled label="disabled"></mwc-button> | ||
<mwc-button disabled label="disabled" icon="code"></mwc-button> | ||
``` | ||
The last 2 versions of all modern browsers are supported, including | ||
Chrome, Safari, Opera, Firefox, Edge. In addition, Internet Explorer 11 is also supported. | ||
### Customize Colors | ||
![](https://raw.githubusercontent.com/material-components/material-components-web-components/c8c5d01ad2103af63e3d7656b5d1acc5ccaa05db/packages/button/images/custom_color.png) | ||
```css | ||
mwc-button { | ||
--mdc-theme-primary: #e9437a; | ||
--mdc-theme-on-primary: white; | ||
} | ||
``` | ||
## API | ||
### Slots | ||
*None* | ||
### Properties/Attributes | ||
| Name | Type | Default | Description | ||
| ---- | ---- | ------- | ----------- | ||
| `icon` | `string` | `''` | Icon to display, and `aria-label` value when `label` is not defined. | ||
| `label` | `string` | `''` | Label to display for the button, and `aria-label` | ||
| `raised` | `boolean` | `false` | Creates a contained button that is elevated above the surface. | ||
| `unelevated` | `boolean` | `false` | Creates a contained button that is flush with the surface. | ||
| `outlined` | `boolean` | `false` | Creates an outlined button that is flush with the surface. | ||
| `dense` | `boolean` | `false` | Makes the button text and container slightly smaller. | ||
| `disabled` | `boolean` | `false` | Disabled buttons cannot be interacted with and have no visual interaction effect. | ||
| `trailingIcon` | `boolean` | `false` | When `true`, `icon` will be displayed _after_ `label` | ||
### Methods | ||
*None* | ||
### Events | ||
*None* | ||
### CSS Custom Properties | ||
| Name | Default | Description | ||
| ---- | ------- | ----------- | ||
| `--mdc-icon-font` | [`Material Icons`](https://google.github.io/material-design-icons/) | Font to use for the icon. | ||
| `--mdc-theme-primary` | ![](https://raw.githubusercontent.com/material-components/material-components-web-components/c8c5d01ad2103af63e3d7656b5d1acc5ccaa05db/packages/button/images/color_6200ee.png) `#6200ee` | Background color of the button | ||
| `--mdc-theme-on-primary` | ![](https://raw.githubusercontent.com/material-components/material-components-web-components/c8c5d01ad2103af63e3d7656b5d1acc5ccaa05db/packages/button/images/color_ffffff.png) `#ffffff` | Text color of the button | ||
## Additional references | ||
- [MDC Web: Button](https://material.io/develop/web/components/buttons/) |
@@ -19,2 +19,2 @@ /** | ||
export const style = css`.mdc-button{font-family:Roboto,sans-serif;-moz-osx-font-smoothing:grayscale;-webkit-font-smoothing:antialiased;font-size:.875rem;line-height:2.25rem;font-weight:500;letter-spacing:.0892857143em;text-decoration:none;text-transform:uppercase;padding:0 8px 0 8px;display:inline-flex;position:relative;align-items:center;justify-content:center;box-sizing:border-box;min-width:64px;height:36px;border:none;outline:none;line-height:inherit;user-select:none;-webkit-appearance:none;overflow:hidden;vertical-align:middle;border-radius:4px}.mdc-button::-moz-focus-inner{padding:0;border:0}.mdc-button:active{outline:none}.mdc-button:hover{cursor:pointer}.mdc-button:disabled{background-color:transparent;color:rgba(0,0,0,.37);cursor:default;pointer-events:none}.mdc-button.mdc-button--dense{border-radius:4px}.mdc-button:not(:disabled){background-color:transparent}.mdc-button .mdc-button__icon{margin-left:0;margin-right:8px;display:inline-block;width:18px;height:18px;font-size:18px;vertical-align:top}[dir=rtl] .mdc-button .mdc-button__icon,.mdc-button .mdc-button__icon[dir=rtl]{margin-left:8px;margin-right:0}.mdc-button:not(:disabled){color:#6200ee;color:var(--mdc-theme-primary, #6200ee)}.mdc-button__label+.mdc-button__icon{margin-left:8px;margin-right:0}[dir=rtl] .mdc-button__label+.mdc-button__icon,.mdc-button__label+.mdc-button__icon[dir=rtl]{margin-left:0;margin-right:8px}svg.mdc-button__icon{fill:currentColor}.mdc-button--raised .mdc-button__icon,.mdc-button--unelevated .mdc-button__icon,.mdc-button--outlined .mdc-button__icon{margin-left:-4px;margin-right:8px}[dir=rtl] .mdc-button--raised .mdc-button__icon,.mdc-button--raised .mdc-button__icon[dir=rtl],[dir=rtl] .mdc-button--unelevated .mdc-button__icon,.mdc-button--unelevated .mdc-button__icon[dir=rtl],[dir=rtl] .mdc-button--outlined .mdc-button__icon,.mdc-button--outlined .mdc-button__icon[dir=rtl]{margin-left:8px;margin-right:-4px}.mdc-button--raised .mdc-button__label+.mdc-button__icon,.mdc-button--unelevated .mdc-button__label+.mdc-button__icon,.mdc-button--outlined .mdc-button__label+.mdc-button__icon{margin-left:8px;margin-right:-4px}[dir=rtl] .mdc-button--raised .mdc-button__label+.mdc-button__icon,.mdc-button--raised .mdc-button__label+.mdc-button__icon[dir=rtl],[dir=rtl] .mdc-button--unelevated .mdc-button__label+.mdc-button__icon,.mdc-button--unelevated .mdc-button__label+.mdc-button__icon[dir=rtl],[dir=rtl] .mdc-button--outlined .mdc-button__label+.mdc-button__icon,.mdc-button--outlined .mdc-button__label+.mdc-button__icon[dir=rtl]{margin-left:-4px;margin-right:8px}.mdc-button--raised,.mdc-button--unelevated{padding:0 16px 0 16px}.mdc-button--raised:disabled,.mdc-button--unelevated:disabled{background-color:rgba(0,0,0,.12);color:rgba(0,0,0,.37)}.mdc-button--raised:not(:disabled),.mdc-button--unelevated:not(:disabled){background-color:#6200ee}@supports not (-ms-ime-align: auto){.mdc-button--raised:not(:disabled),.mdc-button--unelevated:not(:disabled){background-color:var(--mdc-theme-primary, #6200ee)}}.mdc-button--raised:not(:disabled),.mdc-button--unelevated:not(:disabled){color:#fff;color:var(--mdc-theme-on-primary, #fff)}.mdc-button--raised{box-shadow:0px 3px 1px -2px rgba(0, 0, 0, 0.2),0px 2px 2px 0px rgba(0, 0, 0, 0.14),0px 1px 5px 0px rgba(0,0,0,.12);transition:box-shadow 280ms cubic-bezier(0.4, 0, 0.2, 1)}.mdc-button--raised:hover,.mdc-button--raised:focus{box-shadow:0px 2px 4px -1px rgba(0, 0, 0, 0.2),0px 4px 5px 0px rgba(0, 0, 0, 0.14),0px 1px 10px 0px rgba(0,0,0,.12)}.mdc-button--raised:active{box-shadow:0px 5px 5px -3px rgba(0, 0, 0, 0.2),0px 8px 10px 1px rgba(0, 0, 0, 0.14),0px 3px 14px 2px rgba(0,0,0,.12)}.mdc-button--raised:disabled{box-shadow:0px 0px 0px 0px rgba(0, 0, 0, 0.2),0px 0px 0px 0px rgba(0, 0, 0, 0.14),0px 0px 0px 0px rgba(0,0,0,.12)}.mdc-button--outlined{border-style:solid;padding:0 14px 0 14px;border-width:2px}.mdc-button--outlined:disabled{border-color:rgba(0,0,0,.37)}.mdc-button--outlined:not(:disabled){border-color:#6200ee;border-color:var(--mdc-theme-primary, #6200ee)}.mdc-button--dense{height:32px;font-size:.8125rem}@keyframes mdc-ripple-fg-radius-in{from{animation-timing-function:cubic-bezier(0.4, 0, 0.2, 1);transform:translate(var(--mdc-ripple-fg-translate-start, 0)) scale(1)}to{transform:translate(var(--mdc-ripple-fg-translate-end, 0)) scale(var(--mdc-ripple-fg-scale, 1))}}@keyframes mdc-ripple-fg-opacity-in{from{animation-timing-function:linear;opacity:0}to{opacity:var(--mdc-ripple-fg-opacity, 0)}}@keyframes mdc-ripple-fg-opacity-out{from{animation-timing-function:linear;opacity:var(--mdc-ripple-fg-opacity, 0)}to{opacity:0}}.mdc-ripple-surface--test-edge-var-bug{--mdc-ripple-surface-test-edge-var: 1px solid #000;visibility:hidden}.mdc-ripple-surface--test-edge-var-bug::before{border:var(--mdc-ripple-surface-test-edge-var)}.mdc-button{--mdc-ripple-fg-size: 0;--mdc-ripple-left: 0;--mdc-ripple-top: 0;--mdc-ripple-fg-scale: 1;--mdc-ripple-fg-translate-end: 0;--mdc-ripple-fg-translate-start: 0;-webkit-tap-highlight-color:rgba(0,0,0,0);will-change:transform,opacity}.mdc-button::before,.mdc-button::after{position:absolute;border-radius:50%;opacity:0;pointer-events:none;content:""}.mdc-button::before{transition:opacity 15ms linear,background-color 15ms linear;z-index:1}.mdc-button.mdc-ripple-upgraded::before{transform:scale(var(--mdc-ripple-fg-scale, 1))}.mdc-button.mdc-ripple-upgraded::after{top:0;left:0;transform:scale(0);transform-origin:center center}.mdc-button.mdc-ripple-upgraded--unbounded::after{top:var(--mdc-ripple-top, 0);left:var(--mdc-ripple-left, 0)}.mdc-button.mdc-ripple-upgraded--foreground-activation::after{animation:mdc-ripple-fg-radius-in 225ms forwards,mdc-ripple-fg-opacity-in 75ms forwards}.mdc-button.mdc-ripple-upgraded--foreground-deactivation::after{animation:mdc-ripple-fg-opacity-out 150ms;transform:translate(var(--mdc-ripple-fg-translate-end, 0)) scale(var(--mdc-ripple-fg-scale, 1))}.mdc-button::before,.mdc-button::after{top:calc(50% - 100%);left:calc(50% - 100%);width:200%;height:200%}.mdc-button.mdc-ripple-upgraded::after{width:var(--mdc-ripple-fg-size, 100%);height:var(--mdc-ripple-fg-size, 100%)}.mdc-button::before,.mdc-button::after{background-color:#6200ee}@supports not (-ms-ime-align: auto){.mdc-button::before,.mdc-button::after{background-color:var(--mdc-theme-primary, #6200ee)}}.mdc-button:hover::before{opacity:.04}.mdc-button:not(.mdc-ripple-upgraded):focus::before,.mdc-button.mdc-ripple-upgraded--background-focused::before{transition-duration:75ms;opacity:.12}.mdc-button:not(.mdc-ripple-upgraded)::after{transition:opacity 150ms linear}.mdc-button:not(.mdc-ripple-upgraded):active::after{transition-duration:75ms;opacity:.12}.mdc-button.mdc-ripple-upgraded{--mdc-ripple-fg-opacity: 0.12}.mdc-button--raised::before,.mdc-button--raised::after,.mdc-button--unelevated::before,.mdc-button--unelevated::after{background-color:#fff}@supports not (-ms-ime-align: auto){.mdc-button--raised::before,.mdc-button--raised::after,.mdc-button--unelevated::before,.mdc-button--unelevated::after{background-color:var(--mdc-theme-on-primary, #fff)}}.mdc-button--raised:hover::before,.mdc-button--unelevated:hover::before{opacity:.08}.mdc-button--raised:not(.mdc-ripple-upgraded):focus::before,.mdc-button--raised.mdc-ripple-upgraded--background-focused::before,.mdc-button--unelevated:not(.mdc-ripple-upgraded):focus::before,.mdc-button--unelevated.mdc-ripple-upgraded--background-focused::before{transition-duration:75ms;opacity:.24}.mdc-button--raised:not(.mdc-ripple-upgraded)::after,.mdc-button--unelevated:not(.mdc-ripple-upgraded)::after{transition:opacity 150ms linear}.mdc-button--raised:not(.mdc-ripple-upgraded):active::after,.mdc-button--unelevated:not(.mdc-ripple-upgraded):active::after{transition-duration:75ms;opacity:.24}.mdc-button--raised.mdc-ripple-upgraded,.mdc-button--unelevated.mdc-ripple-upgraded{--mdc-ripple-fg-opacity: 0.24}.material-icons{font-family:var(--mdc-icon-font, "Material Icons");font-weight:normal;font-style:normal;font-size:var(--mdc-icon-size, 24px);line-height:1;letter-spacing:normal;text-transform:none;display:inline-block;white-space:nowrap;word-wrap:normal;direction:ltr;-webkit-font-feature-settings:"liga";-webkit-font-smoothing:antialiased}:host{display:inline-flex;outline:none}:host([disabled]){pointer-events:none}.mdc-button{flex:1}`; | ||
export const style = css`.mdc-button{font-family:Roboto, sans-serif;-moz-osx-font-smoothing:grayscale;-webkit-font-smoothing:antialiased;font-size:.875rem;line-height:2.25rem;font-weight:500;letter-spacing:.0892857143em;text-decoration:none;text-transform:uppercase;padding:0 8px 0 8px;display:inline-flex;position:relative;align-items:center;justify-content:center;box-sizing:border-box;min-width:64px;height:36px;border:none;outline:none;line-height:inherit;user-select:none;-webkit-appearance:none;overflow:hidden;vertical-align:middle;border-radius:4px}.mdc-button::-moz-focus-inner{padding:0;border:0}.mdc-button:active{outline:none}.mdc-button:hover{cursor:pointer}.mdc-button:disabled{background-color:transparent;color:rgba(0,0,0,.37);cursor:default;pointer-events:none}.mdc-button.mdc-button--dense{border-radius:4px}.mdc-button:not(:disabled){background-color:transparent}.mdc-button .mdc-button__icon{margin-left:0;margin-right:8px;display:inline-block;width:18px;height:18px;font-size:18px;vertical-align:top}[dir=rtl] .mdc-button .mdc-button__icon,.mdc-button .mdc-button__icon[dir=rtl]{margin-left:8px;margin-right:0}.mdc-button:not(:disabled){color:#6200ee;color:var(--mdc-theme-primary, #6200ee)}.mdc-button__label+.mdc-button__icon{margin-left:8px;margin-right:0}[dir=rtl] .mdc-button__label+.mdc-button__icon,.mdc-button__label+.mdc-button__icon[dir=rtl]{margin-left:0;margin-right:8px}svg.mdc-button__icon{fill:currentColor}.mdc-button--raised .mdc-button__icon,.mdc-button--unelevated .mdc-button__icon,.mdc-button--outlined .mdc-button__icon{margin-left:-4px;margin-right:8px}[dir=rtl] .mdc-button--raised .mdc-button__icon,.mdc-button--raised .mdc-button__icon[dir=rtl],[dir=rtl] .mdc-button--unelevated .mdc-button__icon,.mdc-button--unelevated .mdc-button__icon[dir=rtl],[dir=rtl] .mdc-button--outlined .mdc-button__icon,.mdc-button--outlined .mdc-button__icon[dir=rtl]{margin-left:8px;margin-right:-4px}.mdc-button--raised .mdc-button__label+.mdc-button__icon,.mdc-button--unelevated .mdc-button__label+.mdc-button__icon,.mdc-button--outlined .mdc-button__label+.mdc-button__icon{margin-left:8px;margin-right:-4px}[dir=rtl] .mdc-button--raised .mdc-button__label+.mdc-button__icon,.mdc-button--raised .mdc-button__label+.mdc-button__icon[dir=rtl],[dir=rtl] .mdc-button--unelevated .mdc-button__label+.mdc-button__icon,.mdc-button--unelevated .mdc-button__label+.mdc-button__icon[dir=rtl],[dir=rtl] .mdc-button--outlined .mdc-button__label+.mdc-button__icon,.mdc-button--outlined .mdc-button__label+.mdc-button__icon[dir=rtl]{margin-left:-4px;margin-right:8px}.mdc-button--raised,.mdc-button--unelevated{padding:0 16px 0 16px}.mdc-button--raised:disabled,.mdc-button--unelevated:disabled{background-color:rgba(0,0,0,.12);color:rgba(0,0,0,.37)}.mdc-button--raised:not(:disabled),.mdc-button--unelevated:not(:disabled){background-color:#6200ee}@supports not (-ms-ime-align: auto){.mdc-button--raised:not(:disabled),.mdc-button--unelevated:not(:disabled){background-color:var(--mdc-theme-primary, #6200ee)}}.mdc-button--raised:not(:disabled),.mdc-button--unelevated:not(:disabled){color:#fff;color:var(--mdc-theme-on-primary, #fff)}.mdc-button--raised{box-shadow:0px 3px 1px -2px rgba(0, 0, 0, 0.2),0px 2px 2px 0px rgba(0, 0, 0, 0.14),0px 1px 5px 0px rgba(0,0,0,.12);transition:box-shadow 280ms cubic-bezier(0.4, 0, 0.2, 1)}.mdc-button--raised:hover,.mdc-button--raised:focus{box-shadow:0px 2px 4px -1px rgba(0, 0, 0, 0.2),0px 4px 5px 0px rgba(0, 0, 0, 0.14),0px 1px 10px 0px rgba(0,0,0,.12)}.mdc-button--raised:active{box-shadow:0px 5px 5px -3px rgba(0, 0, 0, 0.2),0px 8px 10px 1px rgba(0, 0, 0, 0.14),0px 3px 14px 2px rgba(0,0,0,.12)}.mdc-button--raised:disabled{box-shadow:0px 0px 0px 0px rgba(0, 0, 0, 0.2),0px 0px 0px 0px rgba(0, 0, 0, 0.14),0px 0px 0px 0px rgba(0,0,0,.12)}.mdc-button--outlined{border-style:solid;padding:0 15px 0 15px;border-width:1px}.mdc-button--outlined:disabled{border-color:rgba(0,0,0,.37)}.mdc-button--outlined:not(:disabled){border-color:#6200ee;border-color:var(--mdc-theme-primary, #6200ee)}.mdc-button--dense{height:32px;font-size:.8125rem}@keyframes mdc-ripple-fg-radius-in{from{animation-timing-function:cubic-bezier(0.4, 0, 0.2, 1);transform:translate(var(--mdc-ripple-fg-translate-start, 0)) scale(1)}to{transform:translate(var(--mdc-ripple-fg-translate-end, 0)) scale(var(--mdc-ripple-fg-scale, 1))}}@keyframes mdc-ripple-fg-opacity-in{from{animation-timing-function:linear;opacity:0}to{opacity:var(--mdc-ripple-fg-opacity, 0)}}@keyframes mdc-ripple-fg-opacity-out{from{animation-timing-function:linear;opacity:var(--mdc-ripple-fg-opacity, 0)}to{opacity:0}}.mdc-ripple-surface--test-edge-var-bug{--mdc-ripple-surface-test-edge-var: 1px solid #000;visibility:hidden}.mdc-ripple-surface--test-edge-var-bug::before{border:var(--mdc-ripple-surface-test-edge-var)}.mdc-button{--mdc-ripple-fg-size: 0;--mdc-ripple-left: 0;--mdc-ripple-top: 0;--mdc-ripple-fg-scale: 1;--mdc-ripple-fg-translate-end: 0;--mdc-ripple-fg-translate-start: 0;-webkit-tap-highlight-color:rgba(0,0,0,0)}.mdc-button::before,.mdc-button::after{position:absolute;border-radius:50%;opacity:0;pointer-events:none;content:""}.mdc-button::before{transition:opacity 15ms linear,background-color 15ms linear;z-index:1}.mdc-button.mdc-ripple-upgraded::before{transform:scale(var(--mdc-ripple-fg-scale, 1))}.mdc-button.mdc-ripple-upgraded::after{top:0;left:0;transform:scale(0);transform-origin:center center}.mdc-button.mdc-ripple-upgraded--unbounded::after{top:var(--mdc-ripple-top, 0);left:var(--mdc-ripple-left, 0)}.mdc-button.mdc-ripple-upgraded--foreground-activation::after{animation:mdc-ripple-fg-radius-in 225ms forwards,mdc-ripple-fg-opacity-in 75ms forwards}.mdc-button.mdc-ripple-upgraded--foreground-deactivation::after{animation:mdc-ripple-fg-opacity-out 150ms;transform:translate(var(--mdc-ripple-fg-translate-end, 0)) scale(var(--mdc-ripple-fg-scale, 1))}.mdc-button::before,.mdc-button::after{top:calc(50% - 100%);left:calc(50% - 100%);width:200%;height:200%}.mdc-button.mdc-ripple-upgraded::after{width:var(--mdc-ripple-fg-size, 100%);height:var(--mdc-ripple-fg-size, 100%)}.mdc-button::before,.mdc-button::after{background-color:#6200ee}@supports not (-ms-ime-align: auto){.mdc-button::before,.mdc-button::after{background-color:var(--mdc-theme-primary, #6200ee)}}.mdc-button:hover::before{opacity:.04}.mdc-button:not(.mdc-ripple-upgraded):focus::before,.mdc-button.mdc-ripple-upgraded--background-focused::before{transition-duration:75ms;opacity:.12}.mdc-button:not(.mdc-ripple-upgraded)::after{transition:opacity 150ms linear}.mdc-button:not(.mdc-ripple-upgraded):active::after{transition-duration:75ms;opacity:.12}.mdc-button.mdc-ripple-upgraded{--mdc-ripple-fg-opacity: 0.12}.mdc-button--raised::before,.mdc-button--raised::after,.mdc-button--unelevated::before,.mdc-button--unelevated::after{background-color:#fff}@supports not (-ms-ime-align: auto){.mdc-button--raised::before,.mdc-button--raised::after,.mdc-button--unelevated::before,.mdc-button--unelevated::after{background-color:var(--mdc-theme-on-primary, #fff)}}.mdc-button--raised:hover::before,.mdc-button--unelevated:hover::before{opacity:.08}.mdc-button--raised:not(.mdc-ripple-upgraded):focus::before,.mdc-button--raised.mdc-ripple-upgraded--background-focused::before,.mdc-button--unelevated:not(.mdc-ripple-upgraded):focus::before,.mdc-button--unelevated.mdc-ripple-upgraded--background-focused::before{transition-duration:75ms;opacity:.24}.mdc-button--raised:not(.mdc-ripple-upgraded)::after,.mdc-button--unelevated:not(.mdc-ripple-upgraded)::after{transition:opacity 150ms linear}.mdc-button--raised:not(.mdc-ripple-upgraded):active::after,.mdc-button--unelevated:not(.mdc-ripple-upgraded):active::after{transition-duration:75ms;opacity:.24}.mdc-button--raised.mdc-ripple-upgraded,.mdc-button--unelevated.mdc-ripple-upgraded{--mdc-ripple-fg-opacity: 0.24}.material-icons{font-family:var(--mdc-icon-font, "Material Icons");font-weight:normal;font-style:normal;font-size:var(--mdc-icon-size, 24px);line-height:1;letter-spacing:normal;text-transform:none;display:inline-block;white-space:nowrap;word-wrap:normal;direction:ltr;-webkit-font-smoothing:antialiased;text-rendering:optimizeLegibility;-moz-osx-font-smoothing:grayscale;font-feature-settings:"liga"}:host{display:inline-flex;outline:none}:host([disabled]){pointer-events:none}.mdc-button{flex:auto}`; |
@@ -17,61 +17,10 @@ /** | ||
*/ | ||
import {LitElement, html, property, customElement, classMap} from '@material/mwc-base/base-element'; | ||
import {customElement} from '@material/mwc-base/base-element'; | ||
import {ButtonBase} from './mwc-button-base.js'; | ||
import {style} from './mwc-button-css.js'; | ||
import {ripple} from '@material/mwc-ripple/ripple-directive.js'; | ||
import '@material/mwc-icon/mwc-icon-font.js'; | ||
@customElement('mwc-button' as any) | ||
export class Button extends LitElement { | ||
@property({type: Boolean}) | ||
raised = false; | ||
@property({type: Boolean}) | ||
unelevated = false; | ||
@property({type: Boolean}) | ||
outlined = false; | ||
@property({type: Boolean}) | ||
dense = false; | ||
@property({type: Boolean, reflect: true}) | ||
disabled = false; | ||
@property({type: Boolean}) | ||
trailingIcon = false; | ||
@property() | ||
icon = ''; | ||
@property() | ||
label = ''; | ||
createRenderRoot() { | ||
return this.attachShadow({mode: 'open', delegatesFocus: true}); | ||
} | ||
@customElement('mwc-button') | ||
export class Button extends ButtonBase { | ||
static styles = style; | ||
render() { | ||
const classes = { | ||
'mdc-button--raised': this.raised, | ||
'mdc-button--unelevated': this.unelevated, | ||
'mdc-button--outlined': this.outlined, | ||
'mdc-button--dense': this.dense, | ||
}; | ||
const mdcButtonIcon = html`<span class="material-icons mdc-button__icon">${this.icon}</span>` | ||
return html` | ||
<button | ||
.ripple="${ripple({unbounded: false})}" | ||
class="mdc-button ${classMap(classes)}" | ||
?disabled="${this.disabled}" | ||
aria-label="${this.label || this.icon}"> | ||
${this.icon && !this.trailingIcon ? mdcButtonIcon : ''} | ||
<span class="mdc-button__label">${this.label}</span> | ||
${this.icon && this.trailingIcon ? mdcButtonIcon : ''} | ||
<slot></slot> | ||
</button>`; | ||
} | ||
} | ||
@@ -78,0 +27,0 @@ |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
Unidentified License
License(Experimental) Something that seems like a license was found, but its contents could not be matched with a known license.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
138
60835
16
2
314
2
+ Added@material/animation@3.1.0(transitive)
+ Added@material/base@3.1.0(transitive)
+ Added@material/button@3.2.0(transitive)
+ Added@material/dom@3.1.0(transitive)
+ Added@material/elevation@3.1.0(transitive)
+ Added@material/feature-targeting@3.1.0(transitive)
+ Added@material/mwc-base@0.7.0(transitive)
+ Added@material/mwc-icon@0.7.1(transitive)
+ Added@material/mwc-ripple@0.7.1(transitive)
+ Added@material/ripple@3.2.0(transitive)
+ Added@material/rtl@3.2.0(transitive)
+ Added@material/shape@3.1.0(transitive)
+ Added@material/theme@3.1.0(transitive)
+ Added@material/typography@3.1.0(transitive)
- Removed@material/animation@1.0.0(transitive)
- Removed@material/base@1.0.0(transitive)
- Removed@material/button@1.1.1(transitive)
- Removed@material/dom@1.1.0(transitive)
- Removed@material/elevation@1.1.0(transitive)
- Removed@material/feature-targeting@0.44.1(transitive)
- Removed@material/mwc-base@0.6.0(transitive)
- Removed@material/mwc-icon@0.6.0(transitive)
- Removed@material/mwc-ripple@0.6.0(transitive)
- Removed@material/ripple@1.1.0(transitive)
- Removed@material/rtl@0.42.0(transitive)
- Removed@material/shape@1.1.1(transitive)
- Removed@material/theme@1.1.0(transitive)
- Removed@material/typography@1.0.0(transitive)
Updated@material/button@^3.0.0
Updated@material/mwc-base@^0.7.0
Updated@material/mwc-icon@^0.7.0
Updated@material/mwc-ripple@^0.7.0