Skip to content

Commit

Permalink
docs(preaction): fix code exmple
Browse files Browse the repository at this point in the history
  • Loading branch information
vnphanquang committed Jul 4, 2024
1 parent c7dbd7c commit c4f7cd3
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 2 deletions.
12 changes: 12 additions & 0 deletions packages/preaction/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,18 @@ export const setMyColor = make((initialColor = 'blue') => {
<div use:apply={setMyColor('red')}></div>
```

...which is equivalent to...

```html
<script>
import { setMyColor } from './set-my-color.ts'; // see previous step
const { acton, attributes } = setMyColor('red');
</script>

<!-- add data-color on server, and apply action on client -->
<div {...(attributes ?? {})} use:action={'red'}></div>
```

## [Changelog][github.changelog]

<!-- github specifics -->
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,13 +65,13 @@ Which is equivalent to:
</script>

<!-- :::highlight -->
<button {...control.attributes ?? {}} use:control.action={'my-popover'} class="c-btn">
<button {...(control.attributes ?? {})} use:control.action={'my-popover'} class="c-btn">
<!-- ::: -->
Open Popover
</button>

<!-- :::highlight -->
<div {...target.attributes ?? {}} use:target.action={'my-popover'} class="p-10">
<div {...(target.attributes ?? {})} use:target.action={'my-popover'} class="p-10">
<!-- ::: -->
My simple popover
</div>
Expand Down

0 comments on commit c4f7cd3

Please sign in to comment.