-
Notifications
You must be signed in to change notification settings - Fork 267
add RippleJS #300
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
add RippleJS #300
Changes from 9 commits
Commits
Show all changes
14 commits
Select commit
Hold shift + click to select a range
8d8bcf3
feat: add ripple framework
tijnjh 8045c86
refactor: change some data
tijnjh 4ca94a4
refactor: simplify InputFocused
tijnjh 1f1b15b
refactor: make example more clear
tijnjh f68856b
feat: add section three
tijnjh 47c23ce
feat: add almost all others
tijnjh 0a605bd
feat: add app rendering example
tijnjh 60b89b3
refactor: add comment
tijnjh 6425700
feat: use new ripple logo
tijnjh 71b5317
fix: correct component name from CssStyle to Colors
tijnjh 2d9ce03
fix: rename component from Name to DoubleCount
tijnjh 5be2366
fix: replace @use with ref
tijnjh 0a88bc1
refactor: use new reactivity system
tijnjh 6442f63
refactor: destructure children prop
tijnjh File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| export component Name() { | ||
| let $name = "John"; | ||
|
|
||
| <h1>{`Hello ${$name}`}</h1> | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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> | ||
| } |
6 changes: 6 additions & 0 deletions
6
content/1-reactivity/3-computed-state/ripple/DoubleCount.ripple
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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> | ||
| } |
3 changes: 3 additions & 0 deletions
3
content/2-templating/1-minimal-template/ripple/HelloWorld.ripple
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,3 @@ | ||
| export component HelloWorld() { | ||
| <h1>{"Hello world"}</h1> | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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> | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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> | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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> | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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
24
content/2-templating/6-conditional/ripple/TrafficLight.ripple
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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> | ||
| } | ||
| </p> | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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> | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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> | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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
11
content/4-component-composition/1-props/ripple/UserProfile.ripple
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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> | ||
| } |
5 changes: 5 additions & 0 deletions
5
content/4-component-composition/2-emit-to-parent/ripple/AnswerButton.ripple
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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
17
content/4-component-composition/2-emit-to-parent/ripple/App.ripple
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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> | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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> | ||
| } |
7 changes: 7 additions & 0 deletions
7
content/4-component-composition/3-slot/ripple/FunnyButton.ripple
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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> | ||
| } |
6 changes: 6 additions & 0 deletions
6
content/4-component-composition/4-slot-fallback/ripple/App.ripple
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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> | ||
| } |
11 changes: 11 additions & 0 deletions
11
content/4-component-composition/4-slot-fallback/ripple/FunnyButton.ripple
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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
10
content/6-form-input/1-input-text/ripple/InputHello.ripple
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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} /> | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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> | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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> | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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> | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,3 @@ | ||
| export component App() { | ||
| <h1>{"Hello world"}</h1> | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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"), | ||
| }); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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 :)
There was a problem hiding this comment.
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