| 1 |
/** |
| 2 |
* @license |
| 3 |
* Copyright 2022 Google LLC |
| 4 |
* SPDX-License-Identifier: BSD-3-Clause |
| 5 |
*/ |
| 6 |
|
| 7 |
import {LitElement, html, css} from 'lit'; |
| 8 |
import {customElement, property} from 'lit/decorators.js'; |
| 9 |
import type React from 'react'; |
| 10 |
import './count-display'; |
| 11 |
|
| 12 |
@customElement('simple-greeter') |
| 13 |
export class SimpleGreeter extends LitElement { |
| 14 |
static styles = css` |
| 15 |
div { |
| 16 |
border: 1px solid black; |
| 17 |
padding: 1rem; |
| 18 |
display: flex; |
| 19 |
flex-direction: column; |
| 20 |
align-items: center; |
| 21 |
} |
| 22 |
|
| 23 |
@media (prefers-color-scheme: dark) { |
| 24 |
div { |
| 25 |
border-color: white; |
| 26 |
} |
| 27 |
} |
| 28 |
|
| 29 |
span { |
| 30 |
color: rebeccapurple; |
| 31 |
} |
| 32 |
|
| 33 |
p { |
| 34 |
font-family: sans-serif; |
| 35 |
} |
| 36 |
`; |
| 37 |
|
| 38 |
@property() |
| 39 |
name = 'Somebody'; |
| 40 |
|
| 41 |
@property({type: Number}) |
| 42 |
count = 0; |
| 43 |
|
| 44 |
render() { |
| 45 |
return html` |
| 46 |
<div> |
| 47 |
<h1>Hello, <span>${this.name}</span>!</h1> |
| 48 |
<count-display .count=${this.count}></count-display> |
| 49 |
<button @click=${() => this.count++}>++</button> |
| 50 |
</div> |
| 51 |
`; |
| 52 |
} |
| 53 |
} |
| 54 |
|
| 55 |
declare global { |
| 56 |
interface HTMLElementTagNameMap { |
| 57 |
'simple-greeter': SimpleGreeter; |
| 58 |
} |
| 59 |
|
| 60 |
namespace JSX { |
| 61 |
interface IntrinsicElements { |
| 62 |
'simple-greeter': |
| 63 |
| React.DetailedHTMLProps< |
| 64 |
React.HTMLAttributes<SimpleGreeter>, |
| 65 |
SimpleGreeter |
| 66 |
> |
| 67 |
| Partial<SimpleGreeter>; |
| 68 |
} |
| 69 |
} |
| 70 |
} |