@3mo/button 0.3.0 → 0.3.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +2 -2
- package/dist/Button.d.ts +1 -0
- package/dist/Button.d.ts.map +1 -1
- package/dist/Button.js +99 -98
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +33 -32
- package/dist/Button/Button.d.ts +0 -49
- package/dist/Button/Button.d.ts.map +0 -1
- package/dist/Button/index.d.ts +0 -2
- package/dist/Button/index.d.ts.map +0 -1
- package/dist/Icon/Icon.d.ts +0 -33
- package/dist/Icon/Icon.d.ts.map +0 -1
- package/dist/Icon/MaterialIcon.d.ts +0 -2
- package/dist/Icon/MaterialIcon.d.ts.map +0 -1
- package/dist/Icon/index.d.ts +0 -3
- package/dist/Icon/index.d.ts.map +0 -1
- package/dist/InstanceofAttributeController/InstanceofAttributeController.d.ts +0 -9
- package/dist/InstanceofAttributeController/InstanceofAttributeController.d.ts.map +0 -1
- package/dist/InstanceofAttributeController/index.d.ts +0 -2
- package/dist/InstanceofAttributeController/index.d.ts.map +0 -1
- package/dist/bundle.js +0 -1
- package/dist/disabledProperty/disabledProperty.d.ts +0 -6
- package/dist/disabledProperty/disabledProperty.d.ts.map +0 -1
- package/dist/disabledProperty/index.d.ts +0 -2
- package/dist/disabledProperty/index.d.ts.map +0 -1
package/README.md
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
# Button
|
|
2
|
-
|
|
1
|
+
# Button
|
|
2
|
+
|
|
3
3
|
A button web-component based on Material Web Components (MWC).
|
package/dist/Button.d.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { Component } from '@a11d/lit';
|
|
2
2
|
import { InstanceofAttributeController } from '@3mo/instanceof-attribute-controller';
|
|
3
3
|
import { type MaterialIcon } from '@3mo/icon';
|
|
4
|
+
import '@3mo/theme';
|
|
4
5
|
export declare const enum ButtonType {
|
|
5
6
|
Normal = "normal",
|
|
6
7
|
Outlined = "outlined",
|
package/dist/Button.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Button.d.ts","sourceRoot":"","sources":["../Button.ts"],"names":[],"mappings":"AAAA,OAAO,EAA4B,SAAS,EAAwB,MAAM,WAAW,CAAA;AACrF,OAAO,EAAE,6BAA6B,EAAE,MAAM,sCAAsC,CAAA;AACpF,OAAO,EAAE,KAAK,YAAY,EAAE,MAAM,WAAW,CAAA;
|
|
1
|
+
{"version":3,"file":"Button.d.ts","sourceRoot":"","sources":["../Button.ts"],"names":[],"mappings":"AAAA,OAAO,EAA4B,SAAS,EAAwB,MAAM,WAAW,CAAA;AACrF,OAAO,EAAE,6BAA6B,EAAE,MAAM,sCAAsC,CAAA;AACpF,OAAO,EAAE,KAAK,YAAY,EAAE,MAAM,WAAW,CAAA;AAG7C,OAAO,YAAY,CAAA;AAEnB,0BAAkB,UAAU;IAC3B,MAAM,WAAW;IACjB,QAAQ,aAAa;IACrB,MAAM,WAAW;IACjB,UAAU,eAAe;CACzB;AAED;;;;;;;;;;;;;;;;;GAiBG;AACH,qBACa,MAAO,SAAQ,SAAS;IACP,IAAI,aAAoB;IACjC,QAAQ,UAAQ;IAExB,WAAW,CAAC,EAAE,YAAY,CAAA;IAC1B,YAAY,CAAC,EAAE,YAAY,CAAA;IAEvC,WAAoB,MAAM,kCAwCzB;IAED,SAAS,CAAC,QAAQ,CAAC,6BAA6B,gCAA0C;IAE1F,cAAuB,QAAQ,yCAW9B;IAED,SAAS,KAAK,UAAU,YAEvB;IAED,SAAS,KAAK,eAAe,yCAM5B;IAED,SAAS,KAAK,mBAAmB,yCAMhC;IAED,SAAS,KAAK,mBAAmB,0CAEhC;IAED,SAAS,KAAK,YAAY,yCAEzB;IAED,SAAS,KAAK,oBAAoB,yCAMjC;IAED,SAAS,KAAK,oBAAoB,0CAEjC;CACD;AAqDD,OAAO,CAAC,MAAM,CAAC;IACd,UAAU,qBAAqB;QAC9B,WAAW,EAAE,MAAM,CAAA;KACnB;CACD"}
|
package/dist/Button.js
CHANGED
|
@@ -3,6 +3,7 @@ import { component, property, css, Component, html, nothing, style } from '@a11d
|
|
|
3
3
|
import { InstanceofAttributeController } from '@3mo/instanceof-attribute-controller';
|
|
4
4
|
import { Button as MwcButton } from '@material/mwc-button';
|
|
5
5
|
import { disabledProperty } from '@3mo/disabled-property';
|
|
6
|
+
import '@3mo/theme';
|
|
6
7
|
/**
|
|
7
8
|
* @attr type
|
|
8
9
|
* @attr disabled
|
|
@@ -29,73 +30,73 @@ let Button = class Button extends Component {
|
|
|
29
30
|
this.instanceofAttributeController = new InstanceofAttributeController(this);
|
|
30
31
|
}
|
|
31
32
|
static get styles() {
|
|
32
|
-
return css `
|
|
33
|
-
:host {
|
|
34
|
-
display: inline-block;
|
|
35
|
-
text-transform: uppercase;
|
|
36
|
-
text-align: center;
|
|
37
|
-
border-radius: var(--mo-border-radius
|
|
38
|
-
min-height: 36px;
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
:host([type=normal]) mwc-button {
|
|
42
|
-
--mo-button-default-horizontal-padding: 12px;
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
:host(:not([type=normal])) mwc-button {
|
|
46
|
-
--mo-button-default-horizontal-padding: 16px;
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
slot[name=leading] *, slot[name=leading]::slotted(*) {
|
|
50
|
-
margin-inline-end: calc(var(--mo-button-horizontal-padding, var(--mo-button-default-horizontal-padding)) * 0.5);
|
|
51
|
-
margin-inline-start: calc(var(--mo-button-horizontal-padding, var(--mo-button-default-horizontal-padding)) * -0.5);
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
slot[name=trailing] *, slot[name=trailing]::slotted(*) {
|
|
55
|
-
margin-inline-start: calc(var(--mo-button-horizontal-padding, var(--mo-button-default-horizontal-padding)) * 0.5);
|
|
56
|
-
margin-inline-end: calc(var(--mo-button-horizontal-padding, var(--mo-button-default-horizontal-padding)) * -0.5);
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
mwc-button {
|
|
60
|
-
min-height: inherit;
|
|
61
|
-
text-align: inherit;
|
|
62
|
-
--mdc-button-horizontal-padding: var(--mo-button-horizontal-padding, var(--mo-button-default-horizontal-padding));
|
|
63
|
-
--mdc-theme-primary: var(--mo-button-accent-color, var(--mo-color-accent
|
|
64
|
-
--mdc-button-outline-color: var(--mo-button-accent-color, var(--mo-color-accent
|
|
65
|
-
--mdc-button-disabled-fill-color: var(--mo-button-disabled-background-color);
|
|
66
|
-
--mdc-button-disabled-ink-color: var(--mo-button-disabled-color, var(--mo-color-gray-transparent));
|
|
67
|
-
--mdc-button-disabled-outline-color: var(--mo-button-disabled-color, var(--mo-color-gray-transparent));
|
|
68
|
-
--mdc-shape-small: inherit;
|
|
69
|
-
}
|
|
33
|
+
return css `
|
|
34
|
+
:host {
|
|
35
|
+
display: inline-block;
|
|
36
|
+
text-transform: uppercase;
|
|
37
|
+
text-align: center;
|
|
38
|
+
border-radius: var(--mo-border-radius);
|
|
39
|
+
min-height: 36px;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
:host([type=normal]) mwc-button {
|
|
43
|
+
--mo-button-default-horizontal-padding: 12px;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
:host(:not([type=normal])) mwc-button {
|
|
47
|
+
--mo-button-default-horizontal-padding: 16px;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
slot[name=leading] *, slot[name=leading]::slotted(*) {
|
|
51
|
+
margin-inline-end: calc(var(--mo-button-horizontal-padding, var(--mo-button-default-horizontal-padding)) * 0.5);
|
|
52
|
+
margin-inline-start: calc(var(--mo-button-horizontal-padding, var(--mo-button-default-horizontal-padding)) * -0.5);
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
slot[name=trailing] *, slot[name=trailing]::slotted(*) {
|
|
56
|
+
margin-inline-start: calc(var(--mo-button-horizontal-padding, var(--mo-button-default-horizontal-padding)) * 0.5);
|
|
57
|
+
margin-inline-end: calc(var(--mo-button-horizontal-padding, var(--mo-button-default-horizontal-padding)) * -0.5);
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
mwc-button {
|
|
61
|
+
min-height: inherit;
|
|
62
|
+
text-align: inherit;
|
|
63
|
+
--mdc-button-horizontal-padding: var(--mo-button-horizontal-padding, var(--mo-button-default-horizontal-padding));
|
|
64
|
+
--mdc-theme-primary: var(--mo-button-accent-color, var(--mo-color-accent));
|
|
65
|
+
--mdc-button-outline-color: var(--mo-button-accent-color, var(--mo-color-accent));
|
|
66
|
+
--mdc-button-disabled-fill-color: var(--mo-button-disabled-background-color);
|
|
67
|
+
--mdc-button-disabled-ink-color: var(--mo-button-disabled-color, var(--mo-color-gray-transparent));
|
|
68
|
+
--mdc-button-disabled-outline-color: var(--mo-button-disabled-color, var(--mo-color-gray-transparent));
|
|
69
|
+
--mdc-shape-small: inherit;
|
|
70
|
+
}
|
|
70
71
|
`;
|
|
71
72
|
}
|
|
72
73
|
get template() {
|
|
73
|
-
return html `
|
|
74
|
-
<mwc-button exportparts='button,ripple' expandContent
|
|
75
|
-
?raised=${this.type === "raised" /* ButtonType.Raised */}
|
|
76
|
-
?outlined=${this.type === "outlined" /* ButtonType.Outlined */}
|
|
77
|
-
?unelevated=${this.type === "unelevated" /* ButtonType.Unelevated */}
|
|
78
|
-
?disabled=${this.isDisabled}
|
|
79
|
-
>
|
|
80
|
-
${this.contentTemplate}
|
|
81
|
-
</mwc-button>
|
|
74
|
+
return html `
|
|
75
|
+
<mwc-button exportparts='button,ripple' expandContent
|
|
76
|
+
?raised=${this.type === "raised" /* ButtonType.Raised */}
|
|
77
|
+
?outlined=${this.type === "outlined" /* ButtonType.Outlined */}
|
|
78
|
+
?unelevated=${this.type === "unelevated" /* ButtonType.Unelevated */}
|
|
79
|
+
?disabled=${this.isDisabled}
|
|
80
|
+
>
|
|
81
|
+
${this.contentTemplate}
|
|
82
|
+
</mwc-button>
|
|
82
83
|
`;
|
|
83
84
|
}
|
|
84
85
|
get isDisabled() {
|
|
85
86
|
return this.disabled;
|
|
86
87
|
}
|
|
87
88
|
get contentTemplate() {
|
|
88
|
-
return html `
|
|
89
|
-
${this.leadingSlotTemplate}
|
|
90
|
-
${this.slotTemplate}
|
|
91
|
-
${this.trailingSlotTemplate}
|
|
89
|
+
return html `
|
|
90
|
+
${this.leadingSlotTemplate}
|
|
91
|
+
${this.slotTemplate}
|
|
92
|
+
${this.trailingSlotTemplate}
|
|
92
93
|
`;
|
|
93
94
|
}
|
|
94
95
|
get leadingSlotTemplate() {
|
|
95
|
-
return html `
|
|
96
|
-
<slot name='leading' slot='icon'>
|
|
97
|
-
${this.leadingIconTemplate}
|
|
98
|
-
</slot>
|
|
96
|
+
return html `
|
|
97
|
+
<slot name='leading' slot='icon'>
|
|
98
|
+
${this.leadingIconTemplate}
|
|
99
|
+
</slot>
|
|
99
100
|
`;
|
|
100
101
|
}
|
|
101
102
|
get leadingIconTemplate() {
|
|
@@ -105,10 +106,10 @@ let Button = class Button extends Component {
|
|
|
105
106
|
return html `<slot ${style({ width: '*' })}></slot>`;
|
|
106
107
|
}
|
|
107
108
|
get trailingSlotTemplate() {
|
|
108
|
-
return html `
|
|
109
|
-
<slot name='trailing' slot='trailingIcon'>
|
|
110
|
-
${this.trailingIconTemplate}
|
|
111
|
-
</slot>
|
|
109
|
+
return html `
|
|
110
|
+
<slot name='trailing' slot='trailingIcon'>
|
|
111
|
+
${this.trailingIconTemplate}
|
|
112
|
+
</slot>
|
|
112
113
|
`;
|
|
113
114
|
}
|
|
114
115
|
get trailingIconTemplate() {
|
|
@@ -140,43 +141,43 @@ MwcButton.addInitializer(element => {
|
|
|
140
141
|
}
|
|
141
142
|
});
|
|
142
143
|
});
|
|
143
|
-
MwcButton.elementStyles.push(css `
|
|
144
|
-
:host {
|
|
145
|
-
display: inline-grid !important;
|
|
146
|
-
width: 100% !important;
|
|
147
|
-
height: 100% !important;
|
|
148
|
-
border-radius: inherit !important;
|
|
149
|
-
}
|
|
150
|
-
|
|
151
|
-
button {
|
|
152
|
-
width: 100% !important;
|
|
153
|
-
height: 100% !important;
|
|
154
|
-
min-width: unset !important;
|
|
155
|
-
line-height: unset !important;
|
|
156
|
-
padding-top: 4px !important;
|
|
157
|
-
padding-bottom: 4px !important;
|
|
158
|
-
text-transform: unset !important;
|
|
159
|
-
border-radius: inherit !important;
|
|
160
|
-
text-align: inherit !important;
|
|
161
|
-
}
|
|
162
|
-
|
|
163
|
-
.mdc-button__label {
|
|
164
|
-
display: none;
|
|
165
|
-
}
|
|
166
|
-
|
|
167
|
-
.trailing-icon, .leading-icon {
|
|
168
|
-
display: inline-flex;
|
|
169
|
-
align-items: center;
|
|
170
|
-
}
|
|
171
|
-
|
|
172
|
-
.trailing-icon ::slotted(*), .leading-icon ::slotted(*) {
|
|
173
|
-
margin-inline-start: unset;
|
|
174
|
-
margin-inline-end: unset;
|
|
175
|
-
display: unset;
|
|
176
|
-
position: unset;
|
|
177
|
-
vertical-align: unset;
|
|
178
|
-
font-size: unset;
|
|
179
|
-
height: unset;
|
|
180
|
-
width: unset;
|
|
181
|
-
}
|
|
144
|
+
MwcButton.elementStyles.push(css `
|
|
145
|
+
:host {
|
|
146
|
+
display: inline-grid !important;
|
|
147
|
+
width: 100% !important;
|
|
148
|
+
height: 100% !important;
|
|
149
|
+
border-radius: inherit !important;
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
button {
|
|
153
|
+
width: 100% !important;
|
|
154
|
+
height: 100% !important;
|
|
155
|
+
min-width: unset !important;
|
|
156
|
+
line-height: unset !important;
|
|
157
|
+
padding-top: 4px !important;
|
|
158
|
+
padding-bottom: 4px !important;
|
|
159
|
+
text-transform: unset !important;
|
|
160
|
+
border-radius: inherit !important;
|
|
161
|
+
text-align: inherit !important;
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
.mdc-button__label {
|
|
165
|
+
display: none;
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
.trailing-icon, .leading-icon {
|
|
169
|
+
display: inline-flex;
|
|
170
|
+
align-items: center;
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
.trailing-icon ::slotted(*), .leading-icon ::slotted(*) {
|
|
174
|
+
margin-inline-start: unset;
|
|
175
|
+
margin-inline-end: unset;
|
|
176
|
+
display: unset;
|
|
177
|
+
position: unset;
|
|
178
|
+
vertical-align: unset;
|
|
179
|
+
font-size: unset;
|
|
180
|
+
height: unset;
|
|
181
|
+
width: unset;
|
|
182
|
+
}
|
|
182
183
|
`);
|