@fast-compose/compose-script 0.1.1 → 0.1.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.
|
Binary file
|
package/README.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
<div align="center">
|
|
2
2
|
|
|
3
|
-
<img src="docs/images/logo.png" width="160" alt="Compose Script logo">
|
|
3
|
+
<img src="https://raw.githubusercontent.com/fast-compose/compose-script/v0.1.2/docs/images/logo.png" width="160" alt="Compose Script logo">
|
|
4
4
|
|
|
5
5
|
# Compose Script
|
|
6
6
|
|
|
@@ -20,19 +20,25 @@ Add one script, write Compose in your HTML, and it renders in the page, powered
|
|
|
20
20
|
|
|
21
21
|
## Quick start
|
|
22
22
|
|
|
23
|
+
Add the library to your page:
|
|
24
|
+
|
|
23
25
|
```html
|
|
24
|
-
<script src="https://cdn.jsdelivr.net/npm/@fast-compose/compose-script/compose-script.js"></script>
|
|
26
|
+
<script src="https://cdn.jsdelivr.net/npm/@fast-compose/compose-script@0.1.2/compose-script.js"></script>
|
|
27
|
+
```
|
|
28
|
+
|
|
29
|
+
- Load `compose-script.js` with a plain `<script src>`, not `type="module"`: it loads its `.wasm` files from its own URL.
|
|
30
|
+
- The URL points to the latest release. Without the `@X.Y.Z` part, the CDN serves the newest release instead. Each
|
|
31
|
+
release is built with the newest Fast Compose release of its time, named in its npm description.
|
|
25
32
|
|
|
33
|
+
Then write Compose anywhere in the page:
|
|
34
|
+
|
|
35
|
+
```html
|
|
26
36
|
<script type="text/compose-content">
|
|
27
37
|
var count by remember { mutableStateOf<Int>(0) }
|
|
28
38
|
Button(onClick = { count++ }) { Text("Clicked $count times") }
|
|
29
39
|
</script>
|
|
30
40
|
```
|
|
31
41
|
|
|
32
|
-
- Load `compose-script.js` with a plain `<script src>`, not `type="module"`: it loads its `.wasm` files from its own URL.
|
|
33
|
-
- The URL serves the latest version. To pin one, add it after the package name, e.g. `compose-script@X.Y.Z`. Each
|
|
34
|
-
version is built with the newest Fast Compose release of its time, named in its npm description.
|
|
35
|
-
|
|
36
42
|
## Script types
|
|
37
43
|
|
|
38
44
|
| Type | Shows | Size |
|
|
@@ -93,6 +99,17 @@ must be a top-level `@Composable` function without parameters; the file may decl
|
|
|
93
99
|
The composable sets the element's width and height, up to the width of its parent and the height of the window.
|
|
94
100
|
Content that fills or scrolls needs a size in the code, e.g. `Modifier.height(300.dp)`.
|
|
95
101
|
|
|
102
|
+
A `width` or `height` in the script's `style` attribute is kept, in any CSS unit, and the composable is measured
|
|
103
|
+
within it; content larger than a fixed size is cut off. The composable still sets the side that is not given.
|
|
104
|
+
|
|
105
|
+
```html
|
|
106
|
+
<script type="text/compose-content" style="width: 200px">
|
|
107
|
+
Text("Wraps within 200 px, and the composable sets the height")
|
|
108
|
+
</script>
|
|
109
|
+
```
|
|
110
|
+
|
|
111
|
+
Sizes from stylesheets or classes are not read; to size by class, put the script in an element with that class.
|
|
112
|
+
|
|
96
113
|
## compose-preview
|
|
97
114
|
|
|
98
115
|
The code is a whole Kotlin file. Every `@Composable` function with `@Preview` is shown with its name, size, background,
|