Skip to content

Commit

Permalink
Merge pull request #1 from enflow/updatedDocs
Browse files Browse the repository at this point in the history
Added basic component example
  • Loading branch information
mbardelmeijer authored Oct 13, 2020
2 parents 6e46e51 + 8a96e49 commit 952afb3
Showing 1 changed file with 47 additions and 1 deletion.
48 changes: 47 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,16 +23,62 @@ This package only provides a wrapper for the `@livewireScripts`, `@livewireStyle
You can register your Livewire components like normal.

## Example
In the head
```twig
{{ livewireStyles() }}
{{ livewireScripts() }}
```

In the body
```twig
{# The Twig version of '@livewire' #}
{% livewire counter %}
{# If you wish to pass along variables to your component #}
{% livewire counter with {'count': 3} %}
```

{{ livewireScripts() }}
In resources/views/livewire/counter.twig
```twig
<div>
<div wire:click="add">+</div>
<div>{{ count }}</div>
<div wire:click="subtract">-</div>
</div>
```
In app/Http/Livewire/Counter.php
```php
<?php

namespace App\Http\Livewire;

use Livewire\Component;

class Counter extends Component
{
public $count;

public function mount($count = 1)
{
$this->count = $count;
}

public function add()
{
$this->count++;
}

public function subtract()
{
$this->count--;
}

public function render()
{
return view('livewire.counter');
}
}
```

## Todo
Expand Down

0 comments on commit 952afb3

Please sign in to comment.