mirror of
https://github.com/toeverything/AFFiNE.git
synced 2026-02-27 02:42:25 +08:00
chore: move client folders (#948)
This commit is contained in:
59
apps/web/src/components/simple-counter/index.ts
Normal file
59
apps/web/src/components/simple-counter/index.ts
Normal file
@@ -0,0 +1,59 @@
|
||||
import { LitElement, css, html } from 'lit';
|
||||
import { customElement, property, state } from 'lit/decorators.js';
|
||||
import * as React from 'react';
|
||||
|
||||
export const tagName = 'simple-counter';
|
||||
|
||||
// Adapt React in order to be able to use custom tags properly
|
||||
declare global {
|
||||
// eslint-disable-next-line @typescript-eslint/no-namespace
|
||||
namespace JSX {
|
||||
interface IntrinsicElements {
|
||||
[tagName]: PersonInfoProps;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
interface PersonInfoProps
|
||||
extends React.DetailedHTMLProps<
|
||||
React.HTMLAttributes<HTMLElement>,
|
||||
HTMLElement
|
||||
> {
|
||||
name?: string;
|
||||
}
|
||||
// ===================== Adapt end ====================
|
||||
|
||||
@customElement(tagName)
|
||||
export class Counter extends LitElement {
|
||||
static styles = css`
|
||||
.counter-container {
|
||||
display: flex;
|
||||
color: var(--affine-text-color);
|
||||
}
|
||||
button {
|
||||
margin: 0 5px;
|
||||
}
|
||||
`;
|
||||
|
||||
@property()
|
||||
name?: string = '';
|
||||
|
||||
@state()
|
||||
count = 0;
|
||||
// Render the UI as a function of component state
|
||||
render() {
|
||||
return html`<div class="counter-container">
|
||||
<div class="name">${this.name}</div>
|
||||
<button @click=${this._subtract}>-</button>
|
||||
<div>${this.count}</div>
|
||||
<button @click="${this._increment}">+</button>
|
||||
</div>`;
|
||||
}
|
||||
|
||||
private _increment() {
|
||||
this.count++;
|
||||
}
|
||||
private _subtract() {
|
||||
this.count--;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user