Skip to content

Commit 69fee3d

Browse files
committedJul 24, 2020
fix my button
1 parent fe54565 commit 69fee3d

File tree

6 files changed

+55
-52
lines changed

6 files changed

+55
-52
lines changed
 

‎build/elements/my-button/my-button.d.ts

+1-4
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,8 @@ export declare class MyButton extends LitElement {
44
/**
55
* The name to say "Hello" to.
66
*/
7-
text: string;
8-
foo: string;
7+
isDark: boolean;
98
render(): import("lit-element").TemplateResult;
10-
update(changedProperties: any): void;
11-
updated(changedProperties: any): void;
129
private _onClick;
1310
}
1411
declare global {

‎build/elements/my-button/my-button.d.ts.map

+1-1
Original file line numberDiff line numberDiff line change

‎build/index.js

+26-14
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎build/index.js.map

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎src/elements/my-button/my-button.ts

+24-32
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11

2-
import { LitElement, html, customElement, property, css, internalProperty } from 'lit-element';
2+
import { LitElement, html, customElement, property, css } from 'lit-element';
33

44
@customElement('my-button')
55
export class MyButton extends LitElement {
@@ -9,51 +9,44 @@ export class MyButton extends LitElement {
99
}
1010
1111
button {
12-
padding: 5px;
13-
border-radius: 5px;
14-
background: green;
12+
height: 36px;
13+
border-radius: 18px;
14+
font-size: 14px;
15+
font-weight: 600;
16+
line-height: 20px;
17+
background: white;
18+
border: 1px solid red;
19+
color: red;
20+
outline:none;
21+
}
22+
23+
button.dark {
24+
background: #ccc;
1525
color: white;
26+
background: white;
27+
}
28+
29+
button:hover {
30+
cursor: pointer;
1631
}
1732
`;
1833

1934
/**
2035
* The name to say "Hello" to.
2136
*/
22-
@property()
23-
text = '';
24-
25-
@internalProperty()
26-
private _innerText = '';
37+
@property({
38+
type: Boolean
39+
})
40+
isDark = false;
2741

2842
render() {
2943
return html`
3044
<button @click=${this._onClick}>
31-
${this.text}
45+
Switch to ${this.isDark ? 'blue' : 'red'}
3246
</button>
33-
<span>
34-
${this._innerText}
35-
</span>
3647
`;
3748
}
3849

39-
attributeChangedCallback(changed: any) {
40-
41-
console.log('r', changed);
42-
43-
}
44-
45-
update(changedProperties: any) {
46-
47-
console.log('update', changedProperties);
48-
49-
}
50-
51-
updated(changedProperties: any) {
52-
53-
console.log('updated', changedProperties);
54-
55-
}
56-
5750
private _onClick() {
5851
let myEvent = new CustomEvent('that-click', {
5952
detail: { message: 'my-event happened.' },
@@ -64,7 +57,6 @@ export class MyButton extends LitElement {
6457
}
6558

6659
}
67-
6860
declare global {
6961
interface HTMLElementTagNameMap {
7062
'my-button': MyButton;

‎src/index.ts

+2
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,4 @@
11
import './elements/my-element/my-element';
22
import './elements/my-button/my-button';
3+
4+

0 commit comments

Comments
 (0)
Please sign in to comment.