phlex-reactive 0.11.6 → 0.12.0
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.
- checksums.yaml +4 -4
- data/CHANGELOG.md +74 -0
- data/README.md +98 -3
- data/app/assets/stylesheets/phlex/reactive/effects.css +106 -0
- data/app/javascript/phlex/reactive/reactive_controller.js +387 -8
- data/app/javascript/phlex/reactive/reactive_controller.min.js +2 -2
- data/app/javascript/phlex/reactive/reactive_controller.min.js.map +3 -3
- data/lib/phlex/reactive/component/dsl.rb +66 -0
- data/lib/phlex/reactive/component/helpers.rb +75 -9
- data/lib/phlex/reactive/component/registry.rb +2 -0
- data/lib/phlex/reactive/effects.rb +169 -0
- data/lib/phlex/reactive/engine.rb +5 -0
- data/lib/phlex/reactive/reply.rb +20 -15
- data/lib/phlex/reactive/response.rb +28 -19
- data/lib/phlex/reactive/streamable.rb +69 -32
- data/lib/phlex/reactive/version.rb +1 -1
- data/lib/phlex/reactive.rb +30 -2
- metadata +3 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 27841384eb24e3e9d66f404b495705b2db4c30fec683ad21ae0f2b2c258c6a00
|
|
4
|
+
data.tar.gz: 14990c96dd4dfafefd56794531cc116f8a17a9bc6aa76d8caf50679fb95abc1b
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: c36de342a6909b7cbd04f58a9d6da9b77497acfe5f6777c200932a54af5251872ec91b2a5d624f14f1cb5b3faed8fe60e5a169e4363cb6d32bf7d24418fd88ac
|
|
7
|
+
data.tar.gz: 45c811958371300f558d57f41e8ead04e607cc07cd43a9915aa2534fa15b650d1c284ca92b871734b755791b730fdb325f7e28e7f8372616aff383887873f340
|
data/CHANGELOG.md
CHANGED
|
@@ -8,6 +8,80 @@ adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
|
|
8
8
|
|
|
9
9
|
### Added
|
|
10
10
|
|
|
11
|
+
- **Project board — the kanban flagship demo (#216).** A live three-lane board
|
|
12
|
+
on the docs site (`/docs/example-project-board`, `/demos/project-board`)
|
|
13
|
+
composing the toolkit end to end: each card is its own nested reactive root
|
|
14
|
+
(record + signed style state) whose move is ONE reply — the row's remove
|
|
15
|
+
(its exit effect animates before the element leaves), a fresh-token append
|
|
16
|
+
into the new lane (wearing its enter effect), and a `reactive:js` text-op
|
|
17
|
+
stream repainting all three count badges — with the same delta broadcast to
|
|
18
|
+
peers, actor echo excluded. Inline rename morphs in place, archive is
|
|
19
|
+
confirm-gated + optimistic, per-lane composers flash on a blank title, and
|
|
20
|
+
the effect-style picker (including `random`) rides signed state to drive
|
|
21
|
+
per-call `effect:` overrides. Peer count badges stay live everywhere via
|
|
22
|
+
`broadcast_to(js:)` — closing the stale-badge gap the team-inbox flagship
|
|
23
|
+
documents — and empty lanes are pure CSS `:empty`, so the 0↔1 boundary
|
|
24
|
+
needs no bookkeeping on either delivery path. Docs-app only; no gem code
|
|
25
|
+
changes.
|
|
26
|
+
|
|
27
|
+
- **Reactive effects — animate enter/exit/update on every stream render (#215).**
|
|
28
|
+
Opt-in at three levels, most specific wins: `Phlex::Reactive.effects = true`
|
|
29
|
+
(or a `{ enter:/exit:/update: }` hash) is the global switch AND the app-wide
|
|
30
|
+
default set; `reactive_effects enter: :slide, update: false` refines per
|
|
31
|
+
component (`false` opts out entirely; declaring on a component also works
|
|
32
|
+
standalone with no global switch); `effect:` on every stream builder, reply
|
|
33
|
+
verb, and `broadcast_to` overrides one stream (`effect: false` suppresses a
|
|
34
|
+
declared effect for that call). Five built-ins ship as an engine stylesheet —
|
|
35
|
+
`stylesheet_link_tag "phlex/reactive/effects"` — fade/slide/scale/highlight/
|
|
36
|
+
shake, all inside `prefers-reduced-motion: no-preference` and tunable via
|
|
37
|
+
`--reactive-fx-*` custom properties; `:random` picks a built-in per
|
|
38
|
+
application; custom effects take the `{ during:, from:, to: }` class-legs
|
|
39
|
+
vocabulary (issue #186), Tailwind-friendly and stylesheet-free. On the wire
|
|
40
|
+
the resolved hooks ride the component root as `data-reactive-effect-<hook>`
|
|
41
|
+
attributes (omitted entirely when off — byte-identical to previous releases)
|
|
42
|
+
and per-call overrides ride the `<turbo-stream>` element itself; ONE
|
|
43
|
+
document-level `turbo:before-stream-render` interceptor animates replies AND
|
|
44
|
+
broadcasts identically on Action Cable and pgbus. `remove` is special: the
|
|
45
|
+
exit animation runs BEFORE the element leaves the DOM, awaited via
|
|
46
|
+
`animationend`/`transitionend` with a computed-duration fallback hard-capped
|
|
47
|
+
at 1s — and a zero computed duration (no effects CSS loaded) skips the wait
|
|
48
|
+
entirely, so a missing stylesheet can never freeze a removal. Unknown names
|
|
49
|
+
raise at class load server-side and warn-and-skip client-side (two-sided
|
|
50
|
+
default-deny). Zero additional allocations per render with effects on (the
|
|
51
|
+
resolved fragment is a per-class memo keyed on the config + registry
|
|
52
|
+
generations); the render/token hot paths hold flat with effects off.
|
|
53
|
+
|
|
54
|
+
- **Confirm on the draft-row remove — `reactive_nested_remove(confirm:)` (#218).**
|
|
55
|
+
`reactive_nested_remove` now accepts the SAME `confirm:` the other triggers
|
|
56
|
+
(`on`/`on_client`) do — a static message String, or the conditional Hash form
|
|
57
|
+
(`{ when: …, message: }` / `{ predicate: …, message: }`, #179) — routed through
|
|
58
|
+
the shared `apply_confirm!` and gated client-side behind the same overridable
|
|
59
|
+
`confirmResolver` (the styled-modal seam, #52/#55/#178). On accept it does the
|
|
60
|
+
existing remove (a draft row leaves the DOM; a persisted row is `_destroy`-marked
|
|
61
|
+
+ hidden) and the existing JSON/attributes re-sync; on cancel, nothing. Per-row
|
|
62
|
+
messages come for free — the confirm is a per-render string. Works in BOTH wire
|
|
63
|
+
modes (`:attributes` and `as: :json`). No confirm: → the immediate-remove fast
|
|
64
|
+
path, unchanged.
|
|
65
|
+
|
|
66
|
+
- **Fill-then-add for draft nested rows — `reactive_nested_add(:assoc, from:, clear:)` (#208).**
|
|
67
|
+
The draft-rows primitive's add is *inline-edit* — it clones the template and
|
|
68
|
+
focuses the new row's first field, so you type INTO the row. A common
|
|
69
|
+
alternative puts the add controls OUTSIDE the row (a preset `<select>`, a
|
|
70
|
+
typeahead, plain inputs) and "Add" **snapshots** those values into a new row,
|
|
71
|
+
then clears them for the next entry. `from: { row_field => "#source-selector" }`
|
|
72
|
+
seeds each cloned-row field from its source control's current value (matching
|
|
73
|
+
the field by the same trailing-bracket-segment key inference JSON mode uses),
|
|
74
|
+
keeps focus on the sources rather than stealing it into the row, and `clear:
|
|
75
|
+
true` resets the sources (each via the set-value + dispatch contract, so dirty
|
|
76
|
+
tracking and compute observe the reset). `from:` values are raw CSS selectors
|
|
77
|
+
resolved within the reactive root (#15 ownership); an unresolved source or an
|
|
78
|
+
unmatched row-field key is silently skipped (the row still adds). It composes
|
|
79
|
+
with BOTH wire modes: the seeded values ride the renumbered `_attributes` names
|
|
80
|
+
on submit (`:attributes`) and the end-of-add JSON sync serializes them
|
|
81
|
+
(`as: :json`), with no extra wiring. The no-`from:` inline-edit default is
|
|
82
|
+
unchanged. See the "Draft rows for a new parent" README section and the
|
|
83
|
+
`/docs/example-draft-rows` page.
|
|
84
|
+
|
|
11
85
|
- **Multi-field cross-root targets — `reactive_show_targets` speaks the full
|
|
12
86
|
conditions language (#209).** A `"#id"` KEY now takes an `if:`/`if_any:`/
|
|
13
87
|
`unless:` conditions Hash, so an OUTSIDE element can show/hide from a
|
data/README.md
CHANGED
|
@@ -332,11 +332,13 @@ The [inline edit example](https://phlex-reactive.zoolutions.llc/docs/example-inl
|
|
|
332
332
|
| [Client-only ops](https://phlex-reactive.zoolutions.llc/docs/example-client-ops) | `on_client` tabs / outside-close menu / accessible drawer — zero fetches, zero custom JS |
|
|
333
333
|
| [Failure surface](https://phlex-reactive.zoolutions.llc/docs/example-failure) | `error_flash` + `data-reactive-error` + `dismiss_after:` — what you get for free when an action fails |
|
|
334
334
|
| [Team inbox (flagship)](https://phlex-reactive.zoolutions.llc/docs/example-team-inbox) | The whole toolkit in one UI: collection rows, optimistic archive that **reverts on failure**, cross-tab broadcast, an `on_client` kebab, error flashes |
|
|
335
|
+
| [Project board (flagship)](https://phlex-reactive.zoolutions.llc/docs/example-project-board) | The kanban: cards move across lanes with **enter/exit effects** (per-visitor style picker incl. `random`), live count badges in every tab via `broadcast_to(js:)`, nested reactive rows with inline rename, confirm-gated archive |
|
|
335
336
|
|
|
336
337
|
Every page renders its **real** reactive component inline (source read straight
|
|
337
338
|
off the file), so the demo and the code can never drift. The
|
|
338
|
-
[Team inbox](https://phlex-reactive.zoolutions.llc/docs/example-team-inbox)
|
|
339
|
-
|
|
339
|
+
[Team inbox](https://phlex-reactive.zoolutions.llc/docs/example-team-inbox) and the
|
|
340
|
+
[Project board](https://phlex-reactive.zoolutions.llc/docs/example-project-board) are the
|
|
341
|
+
flagships — every feature composed into believable UIs.
|
|
340
342
|
|
|
341
343
|
---
|
|
342
344
|
|
|
@@ -397,7 +399,7 @@ Use in controllers: `render turbo_stream: Counter.replace(counter)`.
|
|
|
397
399
|
| `reactive_dirty` / `reactive_dirty warn_unsaved: true` / `reactive_dirty only: %i[...]` | **Dirty tracking**, declared once at the class level, against the DOM's own `defaultValue`/`defaultChecked`/`defaultSelected` — no client state. Marks changed fields + the root `data-reactive-dirty`; `warn_unsaved:` arms a `beforeunload`/`turbo:before-visit` guard; `only:` scopes tracking to named fields. Style with `[data-reactive-dirty]`. See [Dirty-field tracking](#dirty-field-tracking-reactive_dirty). |
|
|
398
400
|
| `nested_update!(:assoc, attrs)` | Map a nested param onto `<assoc>_attributes` with id preservation; update the record. |
|
|
399
401
|
| `reactive_nested_list(:assoc, as: :attributes \| :json)` / `reactive_nested_template(:assoc)` / `reactive_nested_row` | **Draft nested-attribute rows** (the "new parent + child rows" form): the container rows land in, the `<template>` holding ONE row's markup, and the row wrapper marker — all **client-only** form state, keyed by association (several collections per root). `as: :json` (default `:attributes`) serializes the rows into ONE hidden JSON field instead of posting `accepts_nested_attributes_for` names — for an app whose controller `JSON.parse`s a serialized param. See [Draft rows for a new parent](#draft-rows-for-a-new-parent-reactive_nested_). |
|
|
400
|
-
| `reactive_nested_add(:assoc)` / `reactive_nested_remove` | The row triggers, client-only (zero round trips): add clones the template and renumbers its placeholder index; remove deletes a draft row from the DOM, or `_destroy`-marks + hides a persisted row (a hidden `[_destroy]` input present). |
|
|
402
|
+
| `reactive_nested_add(:assoc, from:, clear:)` / `reactive_nested_remove(confirm:)` | The row triggers, client-only (zero round trips): add clones the template and renumbers its placeholder index; remove deletes a draft row from the DOM, or `_destroy`-marks + hides a persisted row (a hidden `[_destroy]` input present). **Fill-then-add**: `from: { row_field => "#source-selector" }` seeds the new row from add controls that live OUTSIDE it (a preset select, a typeahead), and `clear: true` resets them — composes with `as: :attributes` AND `as: :json`. **Confirm on remove**: `reactive_nested_remove(confirm: "Really delete this row?")` gates the remove behind the same overridable `confirmResolver` as `on`/`on_client` (a per-row string, or the conditional `{ when:, message: }` Hash). See [Draft rows for a new parent](#draft-rows-for-a-new-parent-reactive_nested_). |
|
|
401
403
|
| `nested_field_name(:assoc, :field, index: nil)` | The Rails `accepts_nested_attributes_for` wire name for one row field — `order[line_items_attributes][NEW_ROW][quantity]` (the template placeholder) by default, a real index when given. Scope-aware under `reactive_scope`. |
|
|
402
404
|
| `reactive_collection :name, item:, container:, count:, empty:, size:` | Declare an add/remove-row list once; actions call `reply.append`/`prepend`/`remove`. See [Reactive collections](#reactive-collections-addremove-rows--count--empty-state). |
|
|
403
405
|
| `reply.replace` / `.morph` / `.update` / `.remove` / `.redirect(url)` / `.with(*)` / `.js(ops)` | Return from an action to control the reply (flash, remove, redirect, multi-stream, server-pushed client ops). See [Controlling the action's reply](#reply--controlling-the-actions-reply). |
|
|
@@ -1381,6 +1383,35 @@ marker — an absent row *is* the removal). The per-row `_attributes` names stil
|
|
|
1381
1383
|
render but are ignored by a controller that doesn't permit them; the JSON field
|
|
1382
1384
|
is the single source of truth.
|
|
1383
1385
|
|
|
1386
|
+
**Fill-then-add — snapshot add controls that live OUTSIDE the row.** The default
|
|
1387
|
+
`reactive_nested_add` is *inline-edit*: it clones the template and focuses the
|
|
1388
|
+
new row's first field, so you type INTO the row. A common alternative puts the
|
|
1389
|
+
add controls outside the row — a preset `<select>`, a typeahead, plain inputs —
|
|
1390
|
+
and "Add" **snapshots** those values into a new row, then clears them for the
|
|
1391
|
+
next entry. Pass `from:` (a map of row-field → source-control selector) and
|
|
1392
|
+
optionally `clear:`:
|
|
1393
|
+
|
|
1394
|
+
```ruby
|
|
1395
|
+
input(id: "item-name", type: "text") # the add controls, OUTSIDE the row
|
|
1396
|
+
input(id: "item-qty", type: "number")
|
|
1397
|
+
|
|
1398
|
+
button(**reactive_nested_add(:line_items,
|
|
1399
|
+
from: { name: "#item-name", quantity: "#item-qty" }, # row field => source selector
|
|
1400
|
+
clear: true)) { "Add item" }
|
|
1401
|
+
```
|
|
1402
|
+
|
|
1403
|
+
On click the client clones the template, fills each cloned-row field from its
|
|
1404
|
+
source control's current value (matching the field by the **same** trailing
|
|
1405
|
+
bracket-segment key inference JSON mode uses), keeps focus on the sources (so
|
|
1406
|
+
you keep entering the next item — it does *not* steal focus into the row), and,
|
|
1407
|
+
with `clear: true`, resets the sources (each via the set-value + dispatch
|
|
1408
|
+
contract, so dirty tracking and compute see it). The `from:` values are raw CSS
|
|
1409
|
+
selectors resolved within this root (`#15` ownership); a selector that resolves
|
|
1410
|
+
nothing, or a row-field key with no matching cloned field, is skipped (the row
|
|
1411
|
+
still adds — never a throw). It composes with **both** wire modes: the seeded
|
|
1412
|
+
values ride the renumbered `_attributes` names on submit (`:attributes`) and the
|
|
1413
|
+
end-of-add JSON sync serializes them (`as: :json`), with no extra wiring.
|
|
1414
|
+
|
|
1384
1415
|
Relatedly, a **draft parent can now run real server actions too** (issue #208):
|
|
1385
1416
|
an unsaved record signs a gid-less `{c, state}` token, and the endpoint rebuilds
|
|
1386
1417
|
the component through the record kwarg's **initialize default** —
|
|
@@ -2104,6 +2135,66 @@ end
|
|
|
2104
2135
|
`reactive_collection` is the per-actor add/remove + count + empty-state wrapper,
|
|
2105
2136
|
not a replacement for the broadcast.
|
|
2106
2137
|
|
|
2138
|
+
### Effects — animate enter/exit/update (opt-in)
|
|
2139
|
+
|
|
2140
|
+
Reactive updates land instantly and invisibly: a removed row pops out of
|
|
2141
|
+
existence, an appended row pops in, a cross-tab change gives no cue. Effects
|
|
2142
|
+
make the reactivity *visible* — rows fade/slide in and out, updates flash —
|
|
2143
|
+
with zero app JS. Strictly **opt-in at three levels**, most specific wins:
|
|
2144
|
+
|
|
2145
|
+
```ruby
|
|
2146
|
+
# 1. GLOBAL — setting it is the opt-in AND the app-wide default set:
|
|
2147
|
+
Phlex::Reactive.effects = true # { enter: :fade, exit: :fade, update: :highlight }
|
|
2148
|
+
Phlex::Reactive.effects = { enter: :slide, exit: :fade, update: :highlight }
|
|
2149
|
+
|
|
2150
|
+
# 2. PER COMPONENT — refine or opt out (works standalone too; declaring on a
|
|
2151
|
+
# component opts it in even without the global switch):
|
|
2152
|
+
class Notifications::Row < ApplicationComponent
|
|
2153
|
+
reactive_effects enter: :slide, exit: :fade # built-ins (shipped CSS)
|
|
2154
|
+
# reactive_effects update: false # disable one hook
|
|
2155
|
+
# reactive_effects false # opt this component out entirely
|
|
2156
|
+
# reactive_effects enter: :random # a random built-in per application
|
|
2157
|
+
end
|
|
2158
|
+
|
|
2159
|
+
# 3. PER CALL — the escape hatch for one stream:
|
|
2160
|
+
reply.remove(effect: :shake) # a dramatic one-off exit
|
|
2161
|
+
reply.append(item, to: :items, effect: :scale) # this row only
|
|
2162
|
+
Item.replace(@todo, effect: false) # suppress a declared effect once
|
|
2163
|
+
Row.broadcast_to(@list, :todos, append: todo, target: "rows", effect: :slide)
|
|
2164
|
+
```
|
|
2165
|
+
|
|
2166
|
+
The hooks map to stream actions: **enter** (`append`/`prepend`) animates the
|
|
2167
|
+
arriving element, **exit** (`remove`) runs *before* the element leaves the DOM
|
|
2168
|
+
(the removal waits for the animation, capped at 1s so a missing stylesheet can
|
|
2169
|
+
never wedge it), **update** (`replace`/`update`, plain or morph) flashes the
|
|
2170
|
+
fresh render. Effects fire for the actor's own reply AND for broadcasts alike
|
|
2171
|
+
— if a debounced-save grid flashes too much, declare `reactive_effects
|
|
2172
|
+
update: false` on that component.
|
|
2173
|
+
|
|
2174
|
+
Link the shipped stylesheet once (five built-ins — `:fade`, `:slide`,
|
|
2175
|
+
`:scale`, `:highlight`, `:shake` — wrapped in `prefers-reduced-motion:
|
|
2176
|
+
no-preference`, tunable via `--reactive-fx-*` CSS custom properties):
|
|
2177
|
+
|
|
2178
|
+
```erb
|
|
2179
|
+
<%= stylesheet_link_tag "phlex/reactive/effects" %>
|
|
2180
|
+
```
|
|
2181
|
+
|
|
2182
|
+
Custom effects skip the stylesheet entirely: pass named class legs (the same
|
|
2183
|
+
`{ during:, from:, to: }` vocabulary `js.toggle(transition:)` uses), perfect
|
|
2184
|
+
for Tailwind utilities:
|
|
2185
|
+
|
|
2186
|
+
```ruby
|
|
2187
|
+
reactive_effects enter: { during: %w[transition-all duration-300],
|
|
2188
|
+
from: %w[opacity-0 translate-y-2],
|
|
2189
|
+
to: %w[opacity-100 translate-y-0] }
|
|
2190
|
+
```
|
|
2191
|
+
|
|
2192
|
+
Unknown effect names raise at class load (server) and warn-and-skip on the
|
|
2193
|
+
client (default-deny, two-sided). With effects off (the default) the wire is
|
|
2194
|
+
byte-identical to previous releases; with them on, the resolved hooks ride the
|
|
2195
|
+
component root as `data-reactive-effect-*` attributes — identity, never state,
|
|
2196
|
+
and identical on Action Cable and pgbus.
|
|
2197
|
+
|
|
2107
2198
|
### Configuration (`config/initializers/phlex_reactive.rb`)
|
|
2108
2199
|
|
|
2109
2200
|
```ruby
|
|
@@ -2151,6 +2242,10 @@ Phlex::Reactive.error_flash = ->(kind) do
|
|
|
2151
2242
|
end
|
|
2152
2243
|
end
|
|
2153
2244
|
|
|
2245
|
+
# Effects (issue #215): opt in globally + set the app-wide default hooks; see
|
|
2246
|
+
# "Effects" above. Off (nil) by default — byte-identical wire when off.
|
|
2247
|
+
Phlex::Reactive.effects = { enter: :fade, exit: :fade, update: :highlight }
|
|
2248
|
+
|
|
2154
2249
|
# Turnkey APM integration. Names each action Component#action in AppSignal/Sentry/
|
|
2155
2250
|
# Datadog and reports action-body crashes with component/action tags. SDK is
|
|
2156
2251
|
# runtime-detected (no gem dependency); a custom object responding to
|
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
/* phlex-reactive effects (issue #215) — the shipped built-in animations.
|
|
2
|
+
*
|
|
3
|
+
* Opt in from your layout:
|
|
4
|
+
*
|
|
5
|
+
* <%= stylesheet_link_tag "phlex/reactive/effects" %>
|
|
6
|
+
*
|
|
7
|
+
* The client applies these classes transiently around stream renders:
|
|
8
|
+
* reactive-fx--<name>-<hook>, where <name> is fade/slide/scale/highlight/
|
|
9
|
+
* shake and <hook> is enter (append/prepend), exit (remove), or update
|
|
10
|
+
* (replace/update). Every class is removed again on animationend, so nothing
|
|
11
|
+
* here leaks into steady-state styling.
|
|
12
|
+
*
|
|
13
|
+
* Everything is wrapped in prefers-reduced-motion: no-preference — the client
|
|
14
|
+
* ALSO skips effects entirely under reduced motion (defense in depth; a zero
|
|
15
|
+
* computed duration short-circuits the exit wait, so removals never stall).
|
|
16
|
+
*
|
|
17
|
+
* Tune globally (or per component root) by overriding the custom properties:
|
|
18
|
+
*
|
|
19
|
+
* :root { --reactive-fx-duration: 200ms; --reactive-fx-highlight-color: #bae6fd80; }
|
|
20
|
+
*
|
|
21
|
+
* Keep durations comfortably under 1s — the client hard-caps any effect wait
|
|
22
|
+
* at 1000ms (an exit past the cap is removed mid-animation).
|
|
23
|
+
*/
|
|
24
|
+
@media (prefers-reduced-motion: no-preference) {
|
|
25
|
+
:root {
|
|
26
|
+
--reactive-fx-duration: 300ms;
|
|
27
|
+
--reactive-fx-highlight-duration: 700ms;
|
|
28
|
+
--reactive-fx-highlight-color: rgba(250, 204, 21, 0.5);
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
/* fade — opacity in/out. The update variant re-fades the fresh render in. */
|
|
32
|
+
@keyframes reactive-fx-fade-in {
|
|
33
|
+
from { opacity: 0; }
|
|
34
|
+
to { opacity: 1; }
|
|
35
|
+
}
|
|
36
|
+
@keyframes reactive-fx-fade-out {
|
|
37
|
+
from { opacity: 1; }
|
|
38
|
+
to { opacity: 0; }
|
|
39
|
+
}
|
|
40
|
+
.reactive-fx--fade-enter,
|
|
41
|
+
.reactive-fx--fade-update {
|
|
42
|
+
animation: reactive-fx-fade-in var(--reactive-fx-duration) ease-out both;
|
|
43
|
+
}
|
|
44
|
+
.reactive-fx--fade-exit {
|
|
45
|
+
animation: reactive-fx-fade-out var(--reactive-fx-duration) ease-in both;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
/* slide — a short vertical travel + fade. */
|
|
49
|
+
@keyframes reactive-fx-slide-in {
|
|
50
|
+
from { opacity: 0; transform: translateY(0.5rem); }
|
|
51
|
+
to { opacity: 1; transform: none; }
|
|
52
|
+
}
|
|
53
|
+
@keyframes reactive-fx-slide-out {
|
|
54
|
+
from { opacity: 1; transform: none; }
|
|
55
|
+
to { opacity: 0; transform: translateY(0.5rem); }
|
|
56
|
+
}
|
|
57
|
+
.reactive-fx--slide-enter,
|
|
58
|
+
.reactive-fx--slide-update {
|
|
59
|
+
animation: reactive-fx-slide-in var(--reactive-fx-duration) ease-out both;
|
|
60
|
+
}
|
|
61
|
+
.reactive-fx--slide-exit {
|
|
62
|
+
animation: reactive-fx-slide-out var(--reactive-fx-duration) ease-in both;
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
/* scale — grow in / shrink out around the element's center. */
|
|
66
|
+
@keyframes reactive-fx-scale-in {
|
|
67
|
+
from { opacity: 0; transform: scale(0.92); }
|
|
68
|
+
to { opacity: 1; transform: none; }
|
|
69
|
+
}
|
|
70
|
+
@keyframes reactive-fx-scale-out {
|
|
71
|
+
from { opacity: 1; transform: none; }
|
|
72
|
+
to { opacity: 0; transform: scale(0.92); }
|
|
73
|
+
}
|
|
74
|
+
.reactive-fx--scale-enter,
|
|
75
|
+
.reactive-fx--scale-update {
|
|
76
|
+
animation: reactive-fx-scale-in var(--reactive-fx-duration) ease-out both;
|
|
77
|
+
}
|
|
78
|
+
.reactive-fx--scale-exit {
|
|
79
|
+
animation: reactive-fx-scale-out var(--reactive-fx-duration) ease-in both;
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
/* highlight — the classic background flash that fades to the element's own
|
|
83
|
+
* background. One animation for every hook: flash on arrival, on change,
|
|
84
|
+
* and as a last flare before a removal. */
|
|
85
|
+
@keyframes reactive-fx-highlight {
|
|
86
|
+
from { background-color: var(--reactive-fx-highlight-color); }
|
|
87
|
+
}
|
|
88
|
+
.reactive-fx--highlight-enter,
|
|
89
|
+
.reactive-fx--highlight-update,
|
|
90
|
+
.reactive-fx--highlight-exit {
|
|
91
|
+
animation: reactive-fx-highlight var(--reactive-fx-highlight-duration) ease-out both;
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
/* shake — a quick horizontal oscillation (attention / destructive cue). */
|
|
95
|
+
@keyframes reactive-fx-shake {
|
|
96
|
+
10%, 90% { transform: translateX(-1px); }
|
|
97
|
+
20%, 80% { transform: translateX(2px); }
|
|
98
|
+
30%, 50%, 70% { transform: translateX(-3px); }
|
|
99
|
+
40%, 60% { transform: translateX(3px); }
|
|
100
|
+
}
|
|
101
|
+
.reactive-fx--shake-enter,
|
|
102
|
+
.reactive-fx--shake-update,
|
|
103
|
+
.reactive-fx--shake-exit {
|
|
104
|
+
animation: reactive-fx-shake 400ms cubic-bezier(0.36, 0.07, 0.19, 0.97) both;
|
|
105
|
+
}
|
|
106
|
+
}
|