Skip to content

Commit

Permalink
Merge branch 'main' of https://github.com/dy/sprae
Browse files Browse the repository at this point in the history
  • Loading branch information
dy committed Sep 3, 2024
2 parents f5fa70b + 53a0086 commit bbe9dc1
Showing 1 changed file with 8 additions and 6 deletions.
14 changes: 8 additions & 6 deletions readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -105,13 +105,13 @@ Set style value.

```html
<!-- extends style -->
<div style="foo: bar" :style="'baz-baz: qux'">
<div style="foo: bar" :style="'bar-baz: qux'">

<!-- object -->
<div :style="{bazBaz: 'qux'}"></div>
<div :style="{barBaz: 'qux'}"></div>

<!-- CSS variable -->
<div :style="{'--baz-baz': qux}"></div>
<div :style="{'--bar-baz': qux}"></div>
```

#### `:value="value"`
Expand Down Expand Up @@ -163,8 +163,8 @@ Expose element with `name`.
<textarea :ref="text" placeholder="Enter text..."></textarea>

<!-- iterable items -->
<li :each="item in items" :ref="item">
<input :onfocus..onblur="e => (item.classList.add('editing'), e => item.classList.remove('editing'))"/>
<li :each="item in items" :ref="li">
<input :onfocus..onblur="e => (li.classList.add('editing'), e => li.classList.remove('editing'))"/>
</li>
```

Expand All @@ -176,7 +176,7 @@ Run effect, not changing any attribute.
<div :fx="a.value ? foo() : bar()" />

<!-- cleanup function -->
<div :fx="id = setInterval(tick, interval), () => clearInterval(tick)" />
<div :fx="id = setInterval(tick, 1000), () => clearInterval(id)" />
```

#### `:on<event>="handler"`, `:on<in>..on<out>="handler"`
Expand Down Expand Up @@ -375,6 +375,8 @@ sprae.use({ compile })
* State getters/setters work as computed effects, eg. `sprae(el, { x:1, get x2(){ return this.x * 2} })`.
* `this` keyword is not used, to get access to current element use `<input :ref="el" :text="el.value"/>`.
* Async/await is not supported in attributes, it's a strong indicator you need to put these methods into state.
* `:each` doesn't need `key` since it uses direct mapping, see [#44](https://github.com/dy/sprae/issues/44).
* Event attributes always expect a function value `:onevt="event => handle()"`, see [#46](https://github.com/dy/sprae/issues/46).

## Justification

Expand Down

0 comments on commit bbe9dc1

Please sign in to comment.