@alpinejs/docs 3.14.0-revision.1 → 3.14.1-revision.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@alpinejs/docs",
3
- "version": "3.14.0-revision.1",
3
+ "version": "3.14.1-revision.2",
4
4
  "description": "The documentation for Alpine",
5
5
  "author": "Caleb Porzio",
6
6
  "license": "MIT"
@@ -118,3 +118,26 @@ Alpine.data('counter', () => ({
118
118
  },
119
119
  }))
120
120
  ```
121
+
122
+ The CSP build supports accessing nested properties (property accessors) using the dot notation.
123
+
124
+ ```alpine
125
+ <!-- This works too -->
126
+ <div x-data="counter">
127
+ <button @click="foo.increment">Increment</button>
128
+
129
+ <span x-text="foo.count"></span>
130
+ </div>
131
+ ```
132
+
133
+ ```js
134
+ Alpine.data('counter', () => ({
135
+ foo: {
136
+ count: 1,
137
+
138
+ increment() {
139
+ this.count++
140
+ },
141
+ },
142
+ }))
143
+ ```
@@ -51,7 +51,7 @@ You may also pass objects to `x-for`.
51
51
 
52
52
  There are two rules worth noting about `x-for`:
53
53
 
54
- >`x-for` MUST be declared on a `<template>` element
54
+ >`x-for` MUST be declared on a `<template>` element.
55
55
  > That `<template>` element MUST contain only one root element
56
56
 
57
57
  <a name="keys"></a>
@@ -33,7 +33,7 @@ This is by far the simplest way to get started with Alpine. Include the followin
33
33
  Notice the `@3.x.x` in the provided CDN link. This will pull the latest version of Alpine version 3. For stability in production, it's recommended that you hardcode the latest version in the CDN link.
34
34
 
35
35
  ```alpine
36
- <script defer src="https://cdn.jsdelivr.net/npm/alpinejs@3.14.0/dist/cdn.min.js"></script>
36
+ <script defer src="https://cdn.jsdelivr.net/npm/alpinejs@3.14.1/dist/cdn.min.js"></script>
37
37
  ```
38
38
 
39
39
  That's it! Alpine is now available for use inside your page.
@@ -1,5 +1,5 @@
1
1
  ---
2
- order: 5
2
+ order: 7
3
3
  title: Anchor
4
4
  description: Anchor an element's positioning to another element on the page
5
5
  graph_image: https://alpinejs.dev/social_anchor.jpg
@@ -1,5 +1,5 @@
1
1
  ---
2
- order: 4
2
+ order: 6
3
3
  title: Collapse
4
4
  description: Collapse and expand elements with robust animations
5
5
  graph_image: https://alpinejs.dev/social_collapse.jpg
@@ -1,5 +1,5 @@
1
1
  ---
2
- order: 3
2
+ order: 5
3
3
  title: Focus
4
4
  description: Easily manage focus within the page
5
5
  graph_image: https://alpinejs.dev/social_focus.jpg
@@ -1,5 +1,5 @@
1
1
  ---
2
- order: 6
2
+ order: 8
3
3
  title: Morph
4
4
  description: Morph an element into the provided HTML
5
5
  graph_image: https://alpinejs.dev/social_morph.jpg
@@ -1,5 +1,5 @@
1
1
  ---
2
- order: 2
2
+ order: 4
3
3
  title: Persist
4
4
  description: Easily persist data across page loads using localStorage
5
5
  graph_image: https://alpinejs.dev/social_persist.jpg
@@ -0,0 +1,99 @@
1
+ ---
2
+ order: 3
3
+ title: Resize
4
+ description: An Alpine convenience wrapper for the Resize Observer API that allows you to easily react when an element is resized.
5
+ graph_image: https://alpinejs.dev/social_resize.jpg
6
+ ---
7
+
8
+ # Resize Plugin
9
+
10
+ Alpine's Resize plugin is a convenience wrapper for the [Resize Observer](https://developer.mozilla.org/en-US/docs/Web/API/Resize_Observer_API) that allows you to easily react when an element changes size.
11
+
12
+ This is useful for: custom size-based animations, intelligent sticky positioning, conditionally adding attributes based on the element's size, etc.
13
+
14
+ <a name="installation"></a>
15
+ ## Installation
16
+
17
+ You can use this plugin by either including it from a `<script>` tag or installing it via NPM:
18
+
19
+ ### Via CDN
20
+
21
+ You can include the CDN build of this plugin as a `<script>` tag, just make sure to include it BEFORE Alpine's core JS file.
22
+
23
+ ```alpine
24
+ <!-- Alpine Plugins -->
25
+ <script defer src="https://cdn.jsdelivr.net/npm/@alpinejs/resize@3.x.x/dist/cdn.min.js"></script>
26
+
27
+ <!-- Alpine Core -->
28
+ <script defer src="https://cdn.jsdelivr.net/npm/alpinejs@3.x.x/dist/cdn.min.js"></script>
29
+ ```
30
+
31
+ ### Via NPM
32
+
33
+ You can install Resize from NPM for use inside your bundle like so:
34
+
35
+ ```shell
36
+ npm install @alpinejs/resize
37
+ ```
38
+
39
+ Then initialize it from your bundle:
40
+
41
+ ```js
42
+ import Alpine from 'alpinejs'
43
+ import resize from '@alpinejs/resize'
44
+
45
+ Alpine.plugin(resize)
46
+
47
+ ...
48
+ ```
49
+
50
+ <a name="x-resize"></a>
51
+ ## x-resize
52
+
53
+ The primary API for using this plugin is `x-resize`. You can add `x-resize` to any element within an Alpine component, and when that element is resized for any reason, the provided expression will execute with two magic properties: `$width` and `$height`.
54
+
55
+ For example, here's a simple example of using `x-resize` do display the width and height of an element as it changes size.
56
+
57
+ ```alpine
58
+ <div
59
+ x-data="{ width: 0, height: 0 }"
60
+ x-resize="width = $width; height = $height"
61
+ >
62
+ <p x-text="'Width: ' + width + 'px'"></p>
63
+ <p x-text="'Height: ' + height + 'px'"></p>
64
+ </div>
65
+ ```
66
+
67
+ <!-- START_VERBATIM -->
68
+ <div class="demo">
69
+ <div x-data="{ width: 0, height: 0 }" x-resize="width = $width; height = $height">
70
+ <i>Resize your browser window to see the width and height values change.</i>
71
+ <br><br>
72
+ <p x-text="'Width: ' + width + 'px'"></p>
73
+ <p x-text="'Height: ' + height + 'px'"></p>
74
+ </div>
75
+ </div>
76
+ <!-- END_VERBATIM -->
77
+
78
+ <a name="modifiers"></a>
79
+ ## Modifiers
80
+
81
+ <a name="document"></a>
82
+ ### .document
83
+
84
+ It's often useful to observer the entire document's size, rather than a specific element. To do this, you can add the `.document` modifier to `x-resize`:
85
+
86
+ ```alpine
87
+ <div x-resize.document="...">
88
+ ```
89
+
90
+ <!-- START_VERBATIM -->
91
+ <div class="demo">
92
+ <div x-data="{ width: 0, height: 0 }" x-resize.document="width = $width; height = $height">
93
+ <i>Resize your browser window to see the document width and height values change.</i>
94
+ <br><br>
95
+ <p x-text="'Width: ' + width + 'px'"></p>
96
+ <p x-text="'Height: ' + height + 'px'"></p>
97
+ </div>
98
+ </div>
99
+ <!-- END_VERBATIM -->
@@ -1,5 +1,5 @@
1
1
  ---
2
- order: 6
2
+ order: 9
3
3
  title: Sort
4
4
  description: Easily re-order elements by dragging them with your mouse
5
5
  graph_image: https://alpinejs.dev/social_sort.jpg