+
I am declaratively styled by an action! yey
```
-
## Motivation
+# Think about how custom variables as props would affect this.
+
+# Action arguments {} -> {{}} desugaring.
+
+Currently, writing an action takes away all Svelte's ergonomics. You can't use directives, you can't use {# ... } blocks and you can't apply styles using css sheets (or `` blocks) without somehow including it globally (my particular use case).
+
+As an example of a slightly more complicated action than the one I provided in the [Summary](#Summary), I will use the tutorial's [pannable](https://svelte.dev/tutorial/actions).
+
+Something like:
+
+```javascript
+// pannable.js
+export function pannable(node) {
+ let x;
+ let y;
+
+ function handleMousedown(event) {
+ x = event.clientX;
+ y = event.clientY;
+
+ node.dispatchEvent(
+ new CustomEvent("panstart", {
+ detail: { x, y },
+ })
+ );
+
+ window.addEventListener("mousemove", handleMousemove);
+ window.addEventListener("mouseup", handleMouseup);
+ }
+
+ function handleMousemove(event) {
+ const dx = event.clientX - x;
+ const dy = event.clientY - y;
+ x = event.clientX;
+ y = event.clientY;
+
+ node.dispatchEvent(
+ new CustomEvent("panmove", {
+ detail: { x, y, dx, dy },
+ })
+ );
+ }
+
+ function handleMouseup(event) {
+ x = event.clientX;
+ y = event.clientY;
+
+ node.dispatchEvent(
+ new CustomEvent("panend", {
+ detail: { x, y },
+ })
+ );
+
+ window.removeEventListener("mousemove", handleMousemove);
+ window.removeEventListener("mouseup", handleMouseup);
+ }
+
+ node.addEventListener("mousedown", handleMousedown);
+
+ return {
+ destroy() {
+ node.removeEventListener("mousedown", handleMousedown);
+ },
+ };
+}
+```
+
+Would become:
+
+```html
+
+
+
+
+
+```
+
> Why are we doing this? What use cases does it support?
> Please provide specific examples. If you say "this would be more flexible" then
@@ -102,7 +227,7 @@ Consumer component:
### Implementation
> Explain the design in enough detail for somebody familiar with the framework to
-understand, and for somebody familiar with the implementation to implement. Any
+> understand, and for somebody familiar with the implementation to implement. Any
> new terminology should be defined here.
> Explain not just the final design, but also how you arrived at it. What
@@ -119,21 +244,21 @@ understand, and for somebody familiar with the implementation to implement. Any
## How we teach this
> What names and terminology work best for these concepts and why? How is this
-idea best presented? As a continuation of existing Svelte patterns, or as a
-wholly new one?
+> idea best presented? As a continuation of existing Svelte patterns, or as a
+> wholly new one?
> Would the acceptance of this proposal mean the Svelte guides must be
-re-organized or altered? Does it change how Svelte is taught to new users
-at any level?
+> re-organized or altered? Does it change how Svelte is taught to new users
+> at any level?
> How should this feature be introduced and taught to existing Svelte
-users?
+> users?
## Drawbacks
-> Why should we *not* do this? Please consider the impact on teaching Svelte,
-on the integration of this feature with other existing and planned features,
-on the impact of the API churn on existing apps, etc.
+> Why should we _not_ do this? Please consider the impact on teaching Svelte,
+> on the integration of this feature with other existing and planned features,
+> on the impact of the API churn on existing apps, etc.
> There are tradeoffs to choosing any path, please attempt to identify them here.
From bbd14c85b82171085184e505986f26f2ff9ef9ef Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Bernardo=20Ant=C3=B3nio=20Borda=20d=27=C3=81gua?=
Date: Thu, 19 Nov 2020 05:23:39 +0000
Subject: [PATCH 10/22] comentarios e panning
---
0000-declarative-actions.md | 21 ++++++++++++---------
1 file changed, 12 insertions(+), 9 deletions(-)
diff --git a/0000-declarative-actions.md b/0000-declarative-actions.md
index a8a69d2..422392b 100644
--- a/0000-declarative-actions.md
+++ b/0000-declarative-actions.md
@@ -31,7 +31,7 @@ Action:
-
+
```
+The second version
+
> Why are we doing this? What use cases does it support?
> Please provide specific examples. If you say "this would be more flexible" then
From 185245a4b7d2a81d26576cb4b3f89045ceb36982 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Bernardo=20Ant=C3=B3nio=20Borda=20d=27=C3=81gua?=
Date: Sun, 22 Nov 2020 04:36:27 +0000
Subject: [PATCH 11/22] Motivation e detailed design done
---
.vscode/settings.json | 13 ++
0000-declarative-actions.md | 262 ++++++++++++++++++++++++++++++------
2 files changed, 234 insertions(+), 41 deletions(-)
create mode 100644 .vscode/settings.json
diff --git a/.vscode/settings.json b/.vscode/settings.json
new file mode 100644
index 0000000..effd5f8
--- /dev/null
+++ b/.vscode/settings.json
@@ -0,0 +1,13 @@
+{
+ "cSpell.words": [
+ "mousedown",
+ "mousemove",
+ "mouseup",
+ "panend",
+ "panmove",
+ "pannable",
+ "panstart",
+ "pointerdown",
+ "pointerup"
+ ]
+}
\ No newline at end of file
diff --git a/0000-declarative-actions.md b/0000-declarative-actions.md
index 422392b..65c8ae6 100644
--- a/0000-declarative-actions.md
+++ b/0000-declarative-actions.md
@@ -14,9 +14,13 @@ Action:
@@ -62,15 +67,21 @@ Consumer component:
```
+##### [\*parameters will slightly vary from current action consumption](#Parameters)
+
+##### [\*\*more on the Target Element](<#The\ Target\ Element>)
+
## Motivation
# Think about how custom variables as props would affect this.
# Action arguments {} -> {{}} desugaring.
-Currently, writing an action takes away all Svelte's ergonomics. You can't use directives, you can't use {# ... } blocks and you can't apply styles using css sheets (or `` blocks) without somehow including it globally (my particular use case).
+## Motivation
+
+Currently, writing an action takes away all of Svelte's ergonomics. You can't use directives, you can't use {# ... } or {@ ... } blocks and you can't apply styles using css sheets (or `` blocks) without somehow including them globally (my particular use case).
-As an example of a slightly more complicated action than the one I provided in the [Summary](#Summary), I will use the tutorial's [pannable](https://svelte.dev/tutorial/actions).
+As an example of a slightly more complicated action than the one I provided in the [summary](#Summary), I will use the tutorial's [pannable](https://svelte.dev/tutorial/actions).
Something like:
@@ -131,7 +142,7 @@ export function pannable(node) {
}
```
-Would become:
+Could become:
```html
@@ -169,18 +180,15 @@ Would become:
}
function handleMousedown(event) {
- panning = true;
x = event.clientX;
y = event.clientY;
+ panning = true;
target.dispatchEvent(
new CustomEvent("panstart", {
detail: { x, y },
})
);
-
- windowMousemove = handleMousemove;
- windowMouseup = handleMouseup;
}
@@ -191,27 +199,145 @@ Would become: