Skip to content

Commit 5d8dfeb

Browse files
authored
Merge pull request #45 from solidjs/claude/project-thread-k44bg2
Highlight ```rx blocks in Markdown, tag the docs' .rx blocks, add the logo
2 parents 8d20916 + a002130 commit 5d8dfeb

128 files changed

Lines changed: 480 additions & 344 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

‎README.md‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
<img src="assets/logo.svg" width="96" height="96" alt="">
2+
13
# ReactiveScript
24

35
A small language for reactive UIs that carries

‎assets/README.md‎

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
# Logo
2+
3+
`logo.svg` is `r = x`: the name read as an equation, `=` being how .rx writes
4+
one (an equation stays true). The two bars are two colours, two values held
5+
equal.
6+
7+
- Tile `#12233D`, corner radius 22 of 100. On a dark ground the tile can be
8+
`#1F3B63`.
9+
- Letters `#FFFFFF`, JetBrains Mono ExtraBold at 38/100, outlined to paths, so
10+
the SVG needs no font.
11+
- Top bar `#5B9BE6`, bottom bar `#F0B44C`, 7/100 thick with round caps.
12+
13+
`tooling/vscode-rx/icon.png` is this SVG rendered at 256 px.

‎assets/logo.svg‎

Lines changed: 8 additions & 0 deletions
Loading

‎guide/async.md‎

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ submitted, close a menu, clear an error), give it its own instant: `onFlush(() =
2323
compiler can't tell a reset from a write that should wait with the rest, such as a tab highlight that moves with its
2424
page, so it's your call. Decide it for each write that sits next to work that loads.
2525

26-
```
26+
```rx
2727
// submit a todo: the input clears now, the row shows as a guess until the server answers
2828
let t = text
2929
onFlush(() => { text := "" })
@@ -32,7 +32,7 @@ addTodo(t)
3232

3333
## 1. Reading from the server: an equation
3434

35-
```
35+
```rx
3636
forecast = city == "" ? null : city.length < 3 ? throw TooShort(city) : await fetchForecast(city)
3737
```
3838

@@ -59,7 +59,7 @@ forecast = city == "" ? null : city.length < 3 ? throw TooShort(city) : await fe
5959

6060
## 3. Writing to the server: an action
6161

62-
```
62+
```rx
6363
export source profile: Profile = await loadProfile() // a source with a question: it can take a guess
6464
export source saveError: string = ""
6565
@@ -95,7 +95,7 @@ by what the screen should do:
9595

9696
When several actions can each change a different row of one list, guess the row, not the list:
9797

98-
```
98+
```rx
9999
export source todos: Todo[] key id = await loadTodos()
100100
101101
export action markDone(id: number) {
@@ -136,7 +136,7 @@ A guess on a value whose question reads a selection holds the selection with it:
136136
something else waits for the server, and the screen stays on the old choice until the action ends (F-1). Keep the
137137
pending items in a source of their own, with a constant question, and show them beside the loaded ones:
138138

139-
```
139+
```rx
140140
source photo: number := 1
141141
tags = await loadTags(photo)
142142
source adding: { photo: number; tag: string }[] = []
@@ -169,7 +169,7 @@ and the screen reads only the top:
169169

170170
`examples/todos.rx` is the whole app:
171171

172-
```
172+
```rx
173173
server = await loadTodos() // 1. what the server has: re-asked after every write
174174
source failures: Failure[] := [] // outlives a reset: kept until a retry is accepted
175175
source todos: Row[] key id = withFailures(server, failures) // 2. the client's layer; 3. row guesses go on it

‎guide/language.md‎

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ code. When the compiler reports an error, `diagnostics.md` has its code: why, an
77

88
## Modules
99

10-
```
10+
```rx
1111
import pure { fetchUser } from "./api" // a loader: callable anywhere, re-asked when its inputs change
1212
import { saveUser } from "./api" // io: callable only in imperative code (handlers, actions, effects)
1313
import { Avatar } from "./Avatar.rx" // another .rx module
@@ -21,7 +21,7 @@ does (`export action select(id) { selected := id }`, or an action passed as a pr
2121

2222
## Declarations
2323

24-
```
24+
```rx
2525
source count: number := 0 // state; written only with `:=` in imperative code
2626
source user = await fetchUser(id) // state with a question: re-asked when `id` changes, can take a guess
2727
double = count * 2 // an equation: always equal to its right side, never written
@@ -57,7 +57,7 @@ values. Arrays and strings have their usual methods: `xs.filter(f)`, `xs.map(f)`
5757

5858
A component body is declarations, then markup. JSX is verbatim; control flow is braced:
5959

60-
```
60+
```rx
6161
component IssueList(props: { issues: Issue[] }) {
6262
source open := true
6363
<section>
@@ -87,7 +87,7 @@ component IssueList(props: { issues: Issue[] }) {
8787

8888
Handlers, `action` bodies and `effect` apply blocks:
8989

90-
```
90+
```rx
9191
<button onClick={() => { count := count + 1 }}>+</button>
9292
9393
effect (count) { log($0) } // runs after `count` changes; `$0` is its value (async.md §6)
@@ -106,7 +106,7 @@ effect (count) { log($0) } // runs after `count` changes; `$0` is its value (a
106106

107107
## Components
108108

109-
```
109+
```rx
110110
component Card(props: { title: string; children: View }) {
111111
source open := false
112112
<div onClick={() => { open := !open }}>

‎scenarios/S-action-1.md‎

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ Rules: AC-7, AC-1, AC-3, W-6, R-f-6.
44

55
## Program
66

7-
```
7+
```rx
88
export default component App() {
99
source cart = [1, 2]
1010
source status := ""
@@ -45,7 +45,7 @@ a failed action: the action handled it.
4545

4646
## Variant: a panic ends the body — the held writes still commit
4747

48-
```
48+
```rx
4949
export default component App() {
5050
source cart = [1, 2]
5151
source status := ""
@@ -76,7 +76,7 @@ rejection or a `throw` the body does not catch is a compile error (below).
7676

7777
## Variant: throw caught in a plain handler
7878

79-
```
79+
```rx
8080
export default component App() {
8181
source status := ""
8282
@@ -90,7 +90,7 @@ export default component App() {
9090

9191
## Rejected variants
9292

93-
```
93+
```rx
9494
-- reject: UNCAUGHT_ACTION_FAILURE
9595
export default component App() {
9696
source cart = [1, 2]
@@ -111,7 +111,7 @@ R-f-6: the rejection of `fetch("checkout")` (a JS promise: `fails(Error)`)
111111
leaves the body uncaught, and nothing can catch it after — the handler
112112
that launched the action does not await it.
113113

114-
```
114+
```rx
115115
-- reject: UNCAUGHT_ACTION_FAILURE
116116
error Declined(reason)
117117
export default component App() {

‎scenarios/S-action-2.md‎

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ authoritative view), `tests/until.test.ts`.
55

66
## Program
77

8-
```
8+
```rx
99
export default component App() {
1010
source name := "Ann" // the truth, as a live channel pushes it
1111
source shown = name
@@ -55,7 +55,7 @@ The truth is already `Ann`: `until` resolves at once.
5555

5656
## Rejected variants
5757

58-
```
58+
```rx
5959
-- reject: IO_IN_REACTIVE
6060
export default component App() {
6161
source ok := false
@@ -67,7 +67,7 @@ export default component App() {
6767
`until` waits for the world; it is called from imperative scope (Solid:
6868
"Cannot call until inside a reactive scope").
6969

70-
```
70+
```rx
7171
-- reject: UNTIL_PREDICATE
7272
export default component App() {
7373
source ok := false
@@ -79,7 +79,7 @@ export default component App() {
7979
The argument is a predicate, `() => e`: a value is read once, and would never
8080
change.
8181

82-
```
82+
```rx
8383
-- reject: REACTIVE_WRITE_IN_OWNED_SCOPE
8484
export default component App() {
8585
source ok := false
@@ -90,7 +90,7 @@ export default component App() {
9090

9191
The predicate is reactive scope: it reads; it does not write.
9292

93-
```
93+
```rx
9494
-- reject: UNCAUGHT_ACTION_FAILURE
9595
export default component App() {
9696
source id := 1

‎scenarios/S-action-3.md‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ compiled .rx show `1` at instant 1; the interpreter showed `3`.
55

66
## Program
77

8-
```
8+
```rx
99
export default component App() {
1010
source n := 0
1111
source guess = n

‎scenarios/S-action-4.md‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ Solid and compiled .rx show `0` at instant 3; the interpreter showed `5`.
55

66
## Program
77

8-
```
8+
```rx
99
export default component App() {
1010
source n := 0
1111
source guess = n

‎scenarios/S-ai-feed.md‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ change and lands with the body's end (AC-7).
6161

6262
## Rejected variants
6363

64-
```
64+
```rx
6565
-- reject: OPTIMISTIC_NO_QUESTION
6666
-- handler: pick()
6767
export default component App() {
@@ -74,7 +74,7 @@ export default component App() {
7474

7575
`selected` is declared with `:=` — it has no question for a guess to confirm against (ST-5c).
7676

77-
```
77+
```rx
7878
-- reject: RG-7b
7979
context room: number
8080
component Room(props: { id: number }) {

0 commit comments

Comments
 (0)