Skip to content

Commit 34048cf

Browse files
authored
add RippleJS (#300)
1 parent 886fdcd commit 34048cf

File tree

29 files changed

+311
-0
lines changed

29 files changed

+311
-0
lines changed

build/lib/highlighter.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,9 @@ const highlighter = await createHighlighter({
1616
"vue",
1717
"marko",
1818
],
19+
langAlias: {
20+
ripple: "jsx", // until ripple is supported by shiki
21+
},
1922
});
2023

2124
const md = MarkdownIt({
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
import { track } from "ripple";
2+
3+
export component Name() {
4+
let name = track("John");
5+
6+
<h1>{`Hello ${@name}`}</h1>
7+
}
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
import { track } from "ripple";
2+
3+
export component Name() {
4+
let name = track("John");
5+
@name = "Jane";
6+
7+
<h1>{`Hello ${@name}`}</h1>
8+
}
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
import { track } from "ripple";
2+
3+
export component DoubleCount() {
4+
let count = track(10);
5+
const doubleCount = track(() => @count * 2);
6+
7+
<div>{@doubleCount}</div>
8+
}
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
export component HelloWorld() {
2+
<h1>{"Hello world"}</h1>
3+
}
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
export component CssStyle() {
2+
<h1 class="title">{"I am red"}</h1>
3+
<button style="font-size: 10rem;">{"I am a button"}</button>
4+
5+
<style>
6+
.title {
7+
color: red;
8+
}
9+
</style>
10+
}
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
export component Colors() {
2+
const colors = ["red", "green", "blue"];
3+
4+
<ul>
5+
for (const color of colors) {
6+
<li>{color}</li>
7+
}
8+
</ul>
9+
}
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
export component Counter() {
2+
let $count = 0;
3+
4+
function incrementCount() {
5+
$count++;
6+
}
7+
8+
<p>{`Count: ${$count}`}</p>
9+
<button onClick={incrementCount}>{"+1"}</button>
10+
}
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
export component InputFocused() {
2+
function autofocus(element) {
3+
element.focus();
4+
}
5+
6+
<input {ref autofocus} />
7+
}
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
import { track } from "ripple";
2+
3+
const TRAFFIC_LIGHTS = ["red", "orange", "green"];
4+
5+
export component TrafficLight() {
6+
let lightIndex = track(0);
7+
8+
const light = track(() => TRAFFIC_LIGHTS[@lightIndex]);
9+
10+
function nextLight() {
11+
@lightIndex = (@lightIndex + 1) % TRAFFIC_LIGHTS.length;
12+
}
13+
14+
<button onClick={nextLight}>{"Next light"}</button>
15+
<p>{`Light is ${@light}`}</p>
16+
<p>
17+
{"You must "}
18+
if (@light === "red") {
19+
<span>{"STOP"}</span>
20+
} else if (@light === "orange") {
21+
<span>{"SLOW DOWN"}</span>
22+
} else if (@light === "green") {
23+
<span>{"GO"}</span>
24+
}
25+
</p>
26+
}

0 commit comments

Comments
 (0)