Skip to content

Commit abb781f

Browse files
committed
docs: what is jwc
1 parent 078384d commit abb781f

File tree

1 file changed

+22
-7
lines changed

1 file changed

+22
-7
lines changed

docs/guide/what-is-jwc.md

Lines changed: 22 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -27,13 +27,13 @@ You have two choices for writing web components: **Class-based** or **function-b
2727

2828
::: code-group
2929

30-
```js [Class Based]
30+
```tsx [Class Based]
3131
@Component({ name: "app-element", css: styles })
3232
export class App extends JwcComponent {
33-
constructor() { super(); }
33+
constructor() { super(); }
3434

35-
@Prop({ default: 0, attr: "count" }) count = 0;
36-
public onClick = () => { this.count++; }}
35+
@Prop({ default: 0, attr: "count" }) count = 0;
36+
public onClick = () => { this.count++ }}
3737

3838
override render() {
3939
return (
@@ -48,13 +48,28 @@ export class App extends JwcComponent {
4848

4949
```
5050

51-
```js [Function Based <Badge text="Not yet implemented" type="danger"/>]
52-
// no yet implemented
51+
```tsx [Function Based <Badge text="Not yet implemented" type="danger"/>]
52+
// no yet implemented // [!code focus]
53+
54+
export function App() {
55+
const [count, setCount] = useProp<number>(0);
56+
const onClick = () => {
57+
setCount(count + 1);
58+
};
59+
60+
return (
61+
<div class={"card"}>
62+
<button onClick={onClick}>count is {String(count)}</button>
63+
</div>
64+
);
65+
}
66+
67+
registerComponent("app-element", App, styles);
5368
```
5469

5570
:::
5671

57-
With the example code and css style, you can create your own web component, like this: *(If you can't see this component, refresh it and try again)*
72+
With the example code and css style, you can create your own web component, like this: _(If you can't see this component, refresh it and try again)_
5873

5974
<app-element count="2022"></app-element>
6075

0 commit comments

Comments
 (0)