Skip to content

Commit

Permalink
docs(omi): omi diff example
Browse files Browse the repository at this point in the history
  • Loading branch information
dntzhang committed Oct 25, 2023
1 parent a1903e2 commit 62703b0
Showing 1 changed file with 63 additions and 11 deletions.
74 changes: 63 additions & 11 deletions packages/omi/examples/base.tsx
Original file line number Diff line number Diff line change
@@ -1,28 +1,80 @@
import { render, signal, tag, Component, h } from '@/index'

const count = signal(0)

function add() {
count.value++

@tag('aa-demo')
class AADemo extends Component {
static css = 'span { color: red; }'

render() {
return (
<>

<slot name='bc'></slot>
<slot></slot>
</>
)
}
}

function sub() {
count.value--

@tag('my-el')
class myel extends Component {
static css = 'span { color: red; }'

render() {
return (
<>

<div>myel</div>
</>
)
}
}

@tag('counter-demo')
class CounterDemo extends Component {
@tag('my-el2')
class myel2 extends Component {
static css = 'span { color: red; }'

render() {
return (
<>
<button onClick={sub}>-</button>
<span>{count.value}</span>
<button onClick={add}>+</button>

<div>myel2</div>
</>
)
}
}

render(<counter-demo />, document.body)


@tag('my-app')
class CounterDemo extends Component {
static css = 'span { color: red; }'
tagName = 'div'
sub() {

this.show = true
this.update()
}

render() {
if (this.show) {
return (
<aa-demo>
<h2 slot='bc'>sfsdaf</h2>
<my-el2 onClick={() => this.sub()}>click me</my-el2>
</aa-demo>
)
}
return (
<aa-demo>
<my-el onClick={() => this.sub()}>click me!!!</my-el>
</aa-demo>
)
}
}



render(<my-app />, document.body)

0 comments on commit 62703b0

Please sign in to comment.