Skip to content
Merged
Show file tree
Hide file tree
Changes from 9 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions build/lib/highlighter.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,9 @@ const highlighter = await createHighlighter({
"vue",
"marko",
],
langAlias: {
ripple: "jsx", // until ripple is supported by shiki
},
});

const md = MarkdownIt({
Expand Down
5 changes: 5 additions & 0 deletions content/1-reactivity/1-declare-state/ripple/Name.ripple
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
export component Name() {
let $name = "John";

<h1>{`Hello ${$name}`}</h1>
}
6 changes: 6 additions & 0 deletions content/1-reactivity/2-update-state/ripple/Name.ripple
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
export component Name() {
let $name = "John";
$name = "Jane";

<h1>{`Hello ${$name}`}</h1>
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
export component Name() {
let $count = 10;
const $doubleCount = $count * 2;

<div>{$doubleCount}</div>
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
export component HelloWorld() {
<h1>{"Hello world"}</h1>
}
10 changes: 10 additions & 0 deletions content/2-templating/2-styling/ripple/CssStyle.ripple
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
export component CssStyle() {
<h1 class="title">{"I am red"}</h1>
<button style="font-size: 10rem;">{"I am a button"}</button>

<style>
.title {
color: red;
}
</style>
}
9 changes: 9 additions & 0 deletions content/2-templating/3-loop/ripple/Colors.ripple
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
export component CssStyle() {
const colors = ["red", "green", "blue"];

<ul>
for (const color of colors) {
<li>{color}</li>
}
</ul>
}
10 changes: 10 additions & 0 deletions content/2-templating/4-event-click/ripple/Counter.ripple
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
export component Counter() {
let $count = 0;

function incrementCount() {
$count++;
}

<p>{`Count: ${$count}`}</p>
<button onClick={incrementCount}>{"+1"}</button>
}
7 changes: 7 additions & 0 deletions content/2-templating/5-dom-ref/ripple/InputFocused.ripple
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
export component InputFocused() {
function autofocus(element) {
element.focus();
}

<input {@use autofocus} />
}
24 changes: 24 additions & 0 deletions content/2-templating/6-conditional/ripple/TrafficLight.ripple
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
const TRAFFIC_LIGHTS = ["red", "orange", "green"];

export component TrafficLight() {
let $lightIndex = 0;

const $light = TRAFFIC_LIGHTS[$lightIndex];

function nextLight() {
$lightIndex = ($lightIndex + 1) % TRAFFIC_LIGHTS.length;
}

<button onClick={nextLight}>{"Next light"}</button>
<p>{`Light is ${$light}`}</p>
<p>
{"You must"}
if ($light === "red") {
<span>{"STOP"}</span>
} else if ($light === "orange") {
<span>{"SLOW DOWN"}</span>
} else if ($light === "green") {
<span>{"GO"}</span>
}
Comment on lines +18 to +24
Copy link

@Malix-Labs Malix-Labs Sep 19, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure if pattern matching works for Ripple, but it would be a good use-case, especially since light should be an enum

Suggested change
if (@light === "red") {
<span>{"STOP"}</span>
} else if (@light === "orange") {
<span>{"SLOW DOWN"}</span>
} else if (@light === "green") {
<span>{"GO"}</span>
}
switch (@light) {
case "red":
<span>{"STOP"}</span>
case "orange":
<span>{"SLOW DOWN"}</span>
case "green":
<span>{"GO"}</span>
}

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

switch statements arent implemented as of now, though they are planned :)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Okay, thanks!
I couldn't find the tracker for it in https://github.com/trueadm/ripple/issues

</p>
}
11 changes: 11 additions & 0 deletions content/3-lifecycle/1-on-mount/ripple/PageTitle.ripple
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import { effect } from "ripple";

export component PageTitle() {
let $pageTitle = "";

effect(() => {
$pageTitle = document.title;
});

<h1>{`Page title: ${$pageTitle}`}</h1>
}
15 changes: 15 additions & 0 deletions content/3-lifecycle/2-on-unmount/ripple/Time.ripple
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import { effect } from "ripple";

export component Time() {
let $time = new Date().toLocaleTimeString();

effect(() => {
const timer = setInterval(() => {
$time = new Date().toLocaleTimeString();
}, 1000);

return () => clearInterval(timer);
});

<h1>{`Current time: ${$time}`}</h1>
}
10 changes: 10 additions & 0 deletions content/4-component-composition/1-props/ripple/App.ripple
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import { UserProfile } from "./UserProfile.ripple";

export component App() {
<UserProfile
name="John"
age={20}
favouriteColors={["green", "blue", "red"]}
isAvailable
/>
}
11 changes: 11 additions & 0 deletions content/4-component-composition/1-props/ripple/UserProfile.ripple
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
export component UserProfile({
name = "",
age = null,
favouriteColors = [],
isAvailable = false
}) {
<p>{`My name is ${name}!`}</p>
<p>{`My age is ${age}!`}</p>
<p>{`My favourite colors are ${favouriteColors.join(", ")}!`}</p>
<p>{`I am ${isAvailable ? "available" : "not available"}`}</p>
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
export component AnswerButton({ onYes, onNo }) {
<button onClick={onYes}>{"YES"}</button>

<button onClick={onNo}>{"NO"}</button>
}
17 changes: 17 additions & 0 deletions content/4-component-composition/2-emit-to-parent/ripple/App.ripple
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import { AnswerButton } from "./AnswerButton.ripple";

export component App() {
let $isHappy = true;

function onAnswerNo() {
$isHappy = false;
}

function onAnswerYes() {
$isHappy = true;
}

<p>{`Are you happy?`}</p>
<AnswerButton onYes={onAnswerYes} onNo={onAnswerNo} />
<p style="font-size: 50px;">{$isHappy ? "😀" : "😥"}</p>
}
5 changes: 5 additions & 0 deletions content/4-component-composition/3-slot/ripple/App.ripple
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import { FunnyButton } from "./FunnyButton.ripple";

export component App() {
<FunnyButton>{"Click me!"}</FunnyButton>
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
export component FunnyButton({ $children }) {
<button
style="background: rgba(0, 0, 0, 0.4); color: #fff; padding: 10px 20px; font-size: 30px; border: 2px solid #fff; margin: 8px; transform: scale(0.9); box-shadow: 4px 4px rgba(0, 0, 0, 0.4); transition: transform 0.2s cubic-bezier(0.34, 1.65, 0.88, 0.925) 0s; outline: 0;"
>
<$children />
</button>
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
import { FunnyButton } from "./FunnyButton.ripple";

export component App() {
<FunnyButton />
<FunnyButton>{"I got content!"}</FunnyButton>
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
export component FunnyButton({ $children }) {
<button
style="background: rgba(0, 0, 0, 0.4); color: #fff; padding: 10px 20px; font-size: 30px; border: 2px solid #fff; margin: 8px; transform: scale(0.9); box-shadow: 4px 4px rgba(0, 0, 0, 0.4); transition: transform 0.2s cubic-bezier(0.34, 1.65, 0.88, 0.925) 0s; outline: 0;"
>
if ($children) {
<$children />
} else {
<span>{"No content found"}</span>
}
</button>
}
10 changes: 10 additions & 0 deletions content/6-form-input/1-input-text/ripple/InputHello.ripple
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
export component InputHello() {
let $text = "Hello world";

function handleChange(event) {
$text = event.target.value;
}

<p>{$text}</p>
<input value={$text} onInput={handleChange} />
}
15 changes: 15 additions & 0 deletions content/6-form-input/2-checkbox/ripple/IsAvailable.ripple
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
export component IsAvailable() {
let $isAvailable = false;

function handleChange() {
$isAvailable = !$isAvailable;
}

<input
id="is-available"
type="checkbox"
checked={$isAvailable}
onChange={handleChange}
/>
<label for="is-available">{`Is available`}</label>
}
27 changes: 27 additions & 0 deletions content/6-form-input/3-radio/ripple/PickPill.ripple
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
export component PickPill() {
let $picked = "red";

function handleChange(event) {
$picked = event.target.value;
}

<div>{`Picked: ${$picked}`}</div>

<input
id="blue-pill"
checked={$picked === "blue"}
type="radio"
value="blue"
onChange={handleChange}
/>
<label for="blue-pill">{"Blue pill"}</label>

<input
id="red-pill"
checked={$picked === "red"}
type="radio"
value="red"
onChange={handleChange}
/>
<label for="red-pill">{"Red pill"}</label>
}
22 changes: 22 additions & 0 deletions content/6-form-input/4-select/ripple/ColorSelect.ripple
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
const colors = [
{ id: 1, text: "red" },
{ id: 2, text: "blue" },
{ id: 3, text: "green" },
{ id: 4, text: "gray", isDisabled: true },
];

export component ColorSelect() {
let $selectedColorId = 2;

function handleChange(event) {
$selectedColorId = event.target.value;
}

<select value={$selectedColorId} onChange={handleChange}>
for (const color of colors) {
<option value={color.id} disabled={color.isDisabled}>
{color.text}
</option>
}
</select>
}
3 changes: 3 additions & 0 deletions content/7-webapp-features/1-render-app/ripple/App.ripple
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
export component App() {
<h1>{"Hello world"}</h1>
}
7 changes: 7 additions & 0 deletions content/7-webapp-features/1-render-app/ripple/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
<!doctype html>
<html>
<body>
<div id="app"></div>
<script type="module" src="./main.js"></script>
</body>
</html>
6 changes: 6 additions & 0 deletions content/7-webapp-features/1-render-app/ripple/main.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
import { mount } from "ripple";
import { App } from "./App.ripple";

mount(App, {
target: document.getElementById("app"),
});
17 changes: 17 additions & 0 deletions frameworks.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -475,6 +475,23 @@ const frameworks = [
repositoryLink: "https://github.com/aurelia/framework",
mainPackageName: "aurelia-framework",
},
{
id: "ripple",
title: "Ripple",
frameworkName: "Ripple",
isCurrentVersion: true,
img: "framework/ripple.svg",
eslint: {
files: ["!**"],
},
playgroundURL: "https://www.ripplejs.com/playground",
documentationURL: "https://www.ripplejs.com/",
filesSorter(files) {
return sortAllFilenames(files, ["index.html", "main.js", "App.ripple"]);
},
repositoryLink: "https://github.com/trueadm/ripple",
mainPackageName: "ripple",
},
];

export function matchFrameworkId(id) {
Expand Down
5 changes: 5 additions & 0 deletions public/framework/ripple.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.