Skip to content

Commit 80b2507

Browse files
committed
Add TOC to each page and fix heading links
1 parent 7685c1d commit 80b2507

36 files changed

+278
-122
lines changed

actions.blade.php

+6-8
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,11 @@
1-
* [Introduction](#introduction) { .text-blue-800 }
2-
* [Passing Action Parameters](#action-parameters) { .text-blue-800 }
3-
* [Event Modifiers](#event-modifiers) { .text-blue-800 }
4-
* [Keydown Modifiers](#keydown-modifiers) { .font-normal.text-sm.text-blue-800 }
5-
* [Magic Actions](#magic-actions) { .text-blue-800 }
6-
7-
<div>&nbsp;</div>
8-
91
@include('includes.screencast-cta')
102

3+
* [Introduction](#introduction)
4+
* [Passing Action Parameters](#action-parameters)
5+
* [Event Modifiers](#event-modifiers)
6+
* [Keydown Modifiers](#keydown-modifiers)
7+
* [Magic Actions](#magic-actions)
8+
119
## Introduction {#introduction}
1210

1311
The goal of actions in Livewire is to be able to easily listen to page interactions, and call a method on your Livewire component (re-rendering the component).

alpine-js.blade.php

+17-6
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,14 @@
1+
* [Installation](#installation)
2+
* [Using Alpine Inside Of Livewire](#alpine-in-livewire)
3+
* [Extracting Reusable Blade Components](#extracting-blade-components)
4+
* [Interacting With Livewire From Alpine: `$wire`](#interacting-with-livewire-from-alpine)
5+
* [Sharing State Between Livewire And Alpine: @verbatim`@entangle`@endverbatim](#sharing-state)
6+
* [Using the `@verbatim@js@endverbatim` directive](#js-directive)
7+
* [Accessing Livewire Directives From Blade Components](#livewire-directives-from-blade-components)
8+
* [Creating A DatePicker Component](#creating-a-datepicker)
9+
* [Forwarding `wire:model` `input` Events](#forwarding-wire-model-input-events)
10+
* [Ignoring DOM-changes (using `wire:ignore`)](#ignoring-dom-changes)
11+
112
There are lots of instances where a page interaction doesn't warrant a full server-roundtrip, like toggling a modal.
213

314
For these cases, AlpineJS is the perfect companion to Livewire.
@@ -91,7 +102,7 @@
91102

92103
Now, the Livewire and Alpine syntaxes are completely separate, AND you have a reusable Blade component to use from other components.
93104

94-
## Interacting With Livewire From Alpine: `$wire`
105+
## Interacting With Livewire From Alpine: `$wire` {#interacting-with-livewire-from-alpine}
95106

96107
From any Alpine component inside a Livewire component, you can access a magic `$wire` object to access and manipulate the Livewire component.
97108

@@ -193,7 +204,7 @@ public function increment()
193204
$wire.__instance
194205
@endcomponent
195206

196-
## Sharing State Between Livewire And Alpine: @verbatim`@entangle`@endverbatim
207+
## Sharing State Between Livewire And Alpine: @verbatim`@entangle`@endverbatim {#sharing-state}
197208
Livewire has an incredibly powerful feature called "entangle" that allows you to "entangle" a Livewire and Alpine property together. With entanglement, when one value changes, the other will also be changed.
198209

199210
To demonstrate, consider the dropdown example from before, but now with its `showDropdown` property entangled between Livewire and Alpine. By using entanglement, we are now able to control the state of the dropdown from both Alpine AND Livewire.
@@ -248,7 +259,7 @@ public function delete()
248259

249260
If you are having trouble following this difference. Open your browser's devtools and observe the difference in XHR requests with and without `.defer` added.
250261

251-
## Using the `@verbatim@js@endverbatim` directive
262+
## Using the `@verbatim@js@endverbatim` directive {#js-directive}
252263

253264
If ever you need to output PHP data for use in Alpine, you can now use the `@verbatim@js@endverbatim` directive.
254265

@@ -260,7 +271,7 @@ public function delete()
260271
@endverbatim
261272
@endcomponent
262273

263-
## Accessing Livewire Directives From Blade Components
274+
## Accessing Livewire Directives From Blade Components {#livewire-directives-from-blade-components}
264275
Extracting re-usable Blade components within your Livewire application is an essential pattern.
265276

266277
One difficulty you might encounter while implementing Blade components within a Livewire context is accessing the value of attributes like `wire:model` from inside the component.
@@ -408,7 +419,7 @@ public function delete()
408419

409420
> Note: The @verbatim {{ $attributes }} @endverbatim expression is a mechanism in Laravel 7 and above to forward extra HTML attributes declared on the component tag.
410421

411-
## Forwarding `wire:model` `input` Events
422+
## Forwarding `wire:model` `input` Events {#forwarding-wire-model-input-events}
412423

413424
Under the hood, `wire:model` adds an event listener to update a property every time the `input` event is dispatched on or under the element. Another way to communicate between Livewire and Alpine is by using Alpine to dispatch an `input` event with some data within or on an element with `wire:model` on it.
414425

@@ -492,7 +503,7 @@ public function delete()
492503
@endverbatim
493504
@endcomponent
494505

495-
## Ignoring DOM-changes (using `wire:ignore`)
506+
## Ignoring DOM-changes (using `wire:ignore`) {#ignoring-dom-changes}
496507

497508
Fortunately a library like Pikaday adds its extra DOM at the end of the page. Many other libraries manipulate the DOM as soon as they are initialized and continue to mutate the DOM as you interact with them.
498509

artisan-commands.blade.php

+7-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,10 @@
1-
## The `make` command
1+
* [The `make` command](#make-command)
2+
* [Modifying Stubs](#modifying-stubs)
3+
* [The `move` Command](#move-command)
4+
* [The `copy` Command](#copy-command)
5+
* [The `delete` Command](#delete-command)
6+
7+
## The `make` command {#make-command}
28

39
@component('components.code', ['lang' => 'shell'])
410
php artisan make:livewire foo

authorization.blade.php

+3
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
* [Introduction](#introduction)
2+
3+
## Introduction {#introduction}
14

25
To authorize actions in Livewire, you can use the `AuthorizesRequests` trait in any component, then call `$this->authorize()` like you normally would inside a controller. For example:
36

contribution-guide.blade.php

+14-15
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,21 @@
1+
* [Setup Livewire locally](#setup-livewire-locally)
2+
* [Fork Livewire](#fork-livewire)
3+
* [Git clone your fork locally](#clone-fork)
4+
* [Install dependencies](#install-dependencies)
5+
* [Configure dusk](#configure-dusk)
6+
* [Run tests](#setup-run-tests)
7+
* [Bug fix/ feature development](#bug-fix-feature-development)
8+
* [Create a branch](#create-a-branch)
9+
* [Add failing tests](#add-failing-tests)
10+
* [Add working code](#add-working-code)
11+
* [Run tests](#development-run-tests)
12+
* [Submit PR](#submit-pr)
13+
* [Thanks for contributing! 🙌](#thanks)
14+
115
At Livewire we appreciate and welcome all contributions!
216

317
If that's something you would be interested in doing, we recommend going through this contribution guide first before starting.
418

5-
* [Setup Livewire locally](#setup-livewire-locally) { .text-blue-800 }
6-
* [Fork Livewire](#fork-livewire) { .font-normal.text-sm.text-blue-800 }
7-
* [Git clone your fork locally](#clone-fork) { .font-normal.text-sm.text-blue-800 }
8-
* [Install dependencies](#install-dependencies) { .font-normal.text-sm.text-blue-800 }
9-
* [Configure dusk](#configure-dusk) { .font-normal.text-sm.text-blue-800 }
10-
* [Run tests](#setup-run-tests) { .font-normal.text-sm.text-blue-800 }
11-
* [Bug fix/ feature development](#bug-fix-feature-development) { .text-blue-800 }
12-
* [Create a branch](#create-a-branch) { .font-normal.text-sm.text-blue-800 }
13-
* [Add failing tests](#add-failing-tests) { .font-normal.text-sm.text-blue-800 }
14-
* [Add working code](#add-working-code) { .font-normal.text-sm.text-blue-800 }
15-
* [Run tests](#development-run-tests) { .font-normal.text-sm.text-blue-800 }
16-
* [Submit PR](#submit-pr) { .font-normal.text-sm.text-blue-800 }
17-
* [Thanks for contributing! 🙌](#thanks) { .font-normal.text-sm.text-blue-800 }
18-
19-
2019
## Setup Livewire locally {#setup-livewire-locally}
2120

2221
The first step is to create a fork of Livewire and set it up locally. You should only need to do this the first time.

defer-loading.blade.php

+3
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
* [Introduction](#introduction)
2+
3+
## Introduction {#introduction}
14

25
Livewire offers a `wire:init` directive to run an action as soon as the component is rendered. This can be helpful in cases where you don't want to hold up the entire page load, but want to load some data immediately after the page load.
36

deployment.blade.php

+4-4
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
* [Livewire Changes](#livewire-changes) { .text-blue-800 }
2-
* [Page Expired Dialog and Hook](#page-expired-dialog-and-hook) { .text-blue-800 }
3-
* [Page Expired Dialog](#page-expired-dialog) { .text-blue-800 }
4-
* [Page Expired Hook](#page-expired-hook) { .text-blue-800 }
1+
* [Livewire Changes](#livewire-changes)
2+
* [Page Expired Dialog and Hook](#page-expired-dialog-and-hook)
3+
* [Page Expired Dialog](#page-expired-dialog)
4+
* [Page Expired Hook](#page-expired-hook)
55

66
## Livewire Changes {#livewire-changes}
77

dirty-states.blade.php

+3
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
* [Toggling classes on "dirty" elements](#toggling-classes)
2+
* [Toggling elements](#toggling-elements)
3+
* [Toggling classes on other elements](#toggling-classes)
14

25
There are cases where it may be useful to provide feedback that content has changed and is not yet in-sync with the back-end Livewire component.
36

events.blade.php

+13-15
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,18 @@
1-
* [Firing Events](#firing-events) { .text-blue-800 }
2-
* [From The Template](#from-template) { .font-normal.text-sm.text-blue-800 }
3-
* [From The Component](#from-component) { .font-normal.text-sm.text-blue-800 }
4-
* [From Global JavaScript](#from-js) { .font-normal.text-sm.text-blue-800 }
5-
* [Event Listeners](#event-listeners) { .text-blue-800 }
6-
* [Passing Parameters](#passing-parameters) { .text-blue-800 }
7-
* [Scoping Events](#scoping-events) { .text-blue-800 }
8-
* [Scoping To Parent Listeners](#scope-to-parents) { .font-normal.text-sm.text-blue-800 }
9-
* [Scoping To Components By Name](#scope-by-name) { .font-normal.text-sm.text-blue-800 }
10-
* [Scoping To Self](#scope-to-self) { .font-normal.text-sm.text-blue-800 }
11-
* [Listening For Events In JavaScript](#in-js) { .text-blue-800 }
12-
* [Dispatching Browser Events](#browser) { .text-blue-800 }
13-
14-
<div>&nbsp;</div>
15-
161
@include('includes.screencast-cta')
172

3+
* [Firing Events](#firing-events)
4+
* [From The Template](#from-template)
5+
* [From The Component](#from-component)
6+
* [From Global JavaScript](#from-js)
7+
* [Event Listeners](#event-listeners)
8+
* [Passing Parameters](#passing-parameters)
9+
* [Scoping Events](#scoping-events)
10+
* [Scoping To Parent Listeners](#scope-to-parents)
11+
* [Scoping To Components By Name](#scope-by-name)
12+
* [Scoping To Self](#scope-to-self)
13+
* [Listening For Events In JavaScript](#in-js)
14+
* [Dispatching Browser Events](#browser)
15+
1816
Livewire components can communicate with each other through a global event system. As long as two Livewire components are living on the same page, they can communicate using events and listeners.
1917

2018
## Firing Events {#firing-events}

file-downloads.blade.php

+6-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
* [Introduction](#introduction)
2+
* [Testing File Downloads](#testing-file-downloads)
3+
4+
## Introduction {#introduction}
5+
16
Livewire supports triggering file downloads for users with a simple, intuitive API.
27

38
To trigger a file download, you can return a Laravel file download from any component action.
@@ -39,7 +44,7 @@ public function export()
3944
@endverbatim
4045
@endcomponent
4146

42-
## Testing File Downloads
47+
## Testing File Downloads {#testing-file-downloads}
4348
Testing file downloads is simple with livewire.
4449

4550
Here is an example of testing the component above and making sure the export was downloaded.

file-uploads.blade.php

+17-19
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,22 @@
1-
* [Basic Upload](#basic-upload) { .text-blue-800 }
2-
* [Storing Uploaded Files](#storing-files) { .font-normal.text-sm.text-blue-800 }
3-
* [Handling Multiple Files](#multiple-files) { .text-blue-800 }
4-
* [File Validation](#file-validation) { .text-blue-800 }
5-
* [Real-time Validation](#real-time-validation) { .font-normal.text-sm.text-blue-800 }
6-
* [Temporary Preview Urls](#preview-urls) { .text-blue-800 }
7-
* [Testing File Uploads](#testing-uploads) { .text-blue-800 }
8-
* [Uploading Directly To Amazon S3](#upload-to-s3) { .text-blue-800 }
9-
* [Configuring Automatic File Cleanup](#auto-cleanup) { .font-normal.text-sm.text-blue-800 }
10-
* [Loading Indicators](#loading-indicators) { .text-blue-800 }
11-
* [Progress Indicators (And All JavaScript Events)](#js-hooks) { .text-blue-800 }
12-
* [JavaScript Upload API](#js-api) { .text-blue-800 }
13-
* [Configuration](#configuration) { .text-blue-800 }
14-
* [Global Validation](#global-validation) { .font-normal.text-sm.text-blue-800 }
15-
* [Global Middleware](#global-middleware) { .font-normal.text-sm.text-blue-800 }
16-
* [Temporary Upload Directory](#temporary-upload-directory) { .font-normal.text-sm.text-blue-800 }
17-
18-
<div>&nbsp;</div>
19-
201
@include('includes.screencast-cta')
212

3+
* [Basic Upload](#basic-upload)
4+
* [Storing Uploaded Files](#storing-files)
5+
* [Handling Multiple Files](#multiple-files)
6+
* [File Validation](#file-validation)
7+
* [Real-time Validation](#real-time-validation)
8+
* [Temporary Preview Urls](#preview-urls)
9+
* [Testing File Uploads](#testing-uploads)
10+
* [Uploading Directly To Amazon S3](#upload-to-s3)
11+
* [Configuring Automatic File Cleanup](#auto-cleanup)
12+
* [Loading Indicators](#loading-indicators)
13+
* [Progress Indicators (And All JavaScript Events)](#js-hooks)
14+
* [JavaScript Upload API](#js-api)
15+
* [Configuration](#configuration)
16+
* [Global Validation](#global-validation)
17+
* [Global Middleware](#global-middleware)
18+
* [Temporary Upload Directory](#temporary-upload-directory)
19+
2220
## Basic File Upload {#basic-upload}
2321

2422
> Note: Your Livewire version must be >= 1.2.0 to use this feature.

flash-messages.blade.php

+3
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
* [Introduction](#introduction)
2+
3+
## Introduction {#introduction}
14

25
In cases where it's useful to "flash" a success or failure message to the user, Livewire supports Laravel's system for flashing data to the session.
36

inline-scripts.blade.php

+8-2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,9 @@
1+
* [Introduction](#introduction)
2+
* [Using the `@verbatim@js@endverbatim` directive](#using-js-directive)
3+
* [Accessing the JavaScript component instance](#accessing-javascript-component-instance)
4+
5+
## Introduction {#introduction}
6+
17
Livewire recommends that you use AlpineJS for most of your JavaScript needs, but it does support using `<script>` tags directly inside your component's view.
28
39
@component('components.code', ['lang' => 'blade'])
@@ -32,7 +38,7 @@
3238
@endverbatim
3339
@endcomponent
3440
35-
### Using the `@verbatim@js@endverbatim` directive
41+
## Using the `@verbatim@js@endverbatim` directive {#using-js-directive}
3642
3743
If ever you need to output PHP data for use in Javascript, you can now use the `@verbatim@js@endverbatim` directive.
3844
@@ -46,7 +52,7 @@
4652
@endverbatim
4753
@endcomponent
4854
49-
### Accessing the JavaScript component instance
55+
## Accessing the JavaScript component instance {#accessing-javascript-component-instance}
5056
5157
Because Livewire has both a PHP AND a JavaScript portion, each component also has a JavaScript object. You can access this object using the special `@@this` blade directive in your component's view.
5258

input-validation.blade.php

+13-3
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,13 @@
1+
* [Introduction](#introduction)
2+
* [Real-time Validation](#real-time-validation)
3+
* [Validating with rules outside of the `$rules` property](#validating-with-other-rules)
4+
* [Customize Error Message & Attributes](#customize-error-message-and-attributes)
5+
* [Direct Error Message Manipulation](#error-bag-manipulation)
6+
* [Access Validator instance](#access-validator-instance)
7+
* [Testing Validation](#testing-validation)
8+
* [Custom validators](#custom-validators)
9+
10+
## Introduction {#introduction}
111

212
Validation in Livewire should feel similar to standard form validation in Laravel. In short, Livewire provides a `$rules` property for setting validation rules on a per-component basis, and a `$this->validate()` method for validating a component's properties using those rules.
313

@@ -131,7 +141,7 @@ public function saveContact()
131141

132142
If you are wondering, "why do I need `validateOnly`? Can't I just use `validate`?". The reason is because otherwise, every single update to any field would validate ALL of the fields. This can be a jarring user experience. Imagine if you typed one character into the first field of a form, and all of a sudden every single field had a validation message. `validateOnly` prevents that, and only validates the current field being updated.
133143

134-
## Validating with rules outside of the `$rules` property
144+
## Validating with rules outside of the `$rules` property {#validating-with-other-rules}
135145
If for whatever reason you want to validate using rules other than the ones defined in the `$rules` property, you can always do this by passing the rules directly into the `validate()` and `validateOnly()` methods.
136146

137147
@component('components.code-component')
@@ -164,7 +174,7 @@ public function saveContact()
164174
@endslot
165175
@endcomponent
166176

167-
## Customize Error Message & Attributes
177+
## Customize Error Message & Attributes {#customize-error-message-and-attributes}
168178

169179
If you wish to customize the validation messages used by a Livewire component, you can do so with the `$messages` property.
170180

@@ -262,7 +272,7 @@ public function saveContact()
262272
@endverbatim
263273
@endcomponent
264274

265-
## Access Validator instance
275+
## Access Validator instance {#access-validator-instance}
266276

267277
Sometimes you may want to access the Validator instance that Livewire uses in the `validate()` and `validateOnly()` methods. This is possible using the `withValidator` method. The closure you provide receives the fully constructed validator as an argument, allowing you to call any of its methods before the validation rules are actually evaluated.
268278

installation.blade.php

+8-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,12 @@
11
@include('includes.screencast-cta')
22

3+
* [Requirements](#requirements)
4+
* [Install The Package](#install-package)
5+
* [Include The Assets](#include-js)
6+
* [Publishing The Config File](#publishing-config)
7+
* [Publishing Frontend Assets](#publish-assets)
8+
* [Configuring The Asset Base URL](#configuring-the-asset-base-url)
9+
310
## Requirements {#requirements}
411

512
1. PHP 7.2.5 or higher
@@ -81,7 +88,7 @@
8188
@endverbatim
8289
@endcomponent
8390
84-
## Configuring The Asset Base URL
91+
## Configuring The Asset Base URL {#configuring-the-asset-base-url}
8592
8693
By default, Livewire serves its JavaScript portion (`livewire.js`) from the following route in your app: `/livewire/livewire.js`.
8794

laravel-echo.blade.php

+4
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
* [Introduction](#introduction)
2+
3+
## Introduction {#introduction}
4+
15
Livewire pairs nicely with Laravel Echo to provide real-time functionality on your web-pages using WebSockets.
26

37
@component('components.warning')

lifecycle-hooks.blade.php

+4-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
@include('includes.screencast-cta')
22

3-
## Class Hooks
3+
* [Class Hooks](#class-hooks)
4+
* [Javascript Hooks](#js-hooks)
5+
6+
## Class Hooks {#class-hooks}
47

58
Each Livewire component undergoes a lifecycle. Lifecycle hooks allow you to run code at any part of the component's lifecyle, or before specific properties are updated.
69

loading-states.blade.php

+9
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,12 @@
1+
* [Introduction](#introduction)
2+
* [Toggling elements during "loading" states](#toggling-elements)
3+
* [Delaying loading indicator](#delaying-loading)
4+
* [Targeting specific actions](#targeting-actions)
5+
* [Targeting models](#targeting-models)
6+
* [Toggling classes](#toggling-classes)
7+
* [Toggling attributes](#toggling-attributes)
8+
9+
## Introduction {#introduction}
110

211
Because Livewire makes a roundtrip to the server every time an action is triggered on the page, there are cases when the page may not react immediately to a user event (like a click). Livewire allows you to easily display loading states, which can make your app feel more responsive.
312

0 commit comments

Comments
 (0)