Skip to content
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

Feature: Add Aurelia v1 samples (complete) #133

Merged
merged 28 commits into from Jan 6, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
fdc10b2
Add 1-reactivity files for Aurelia 1
mroeling Dec 29, 2022
9e46b6c
Add 3x templating, update readme (20%)
mroeling Dec 31, 2022
434c47f
Update readme to reflect proper icon for aurelia
mroeling Dec 31, 2022
0718645
Finish 2-templating
mroeling Dec 31, 2022
18e7268
Fix incorrect 2-3-loop and 2-4-event-click
mroeling Dec 31, 2022
8fc6a38
Add on-mount
mroeling Dec 31, 2022
6703c62
Add un-mount
mroeling Dec 31, 2022
526d99a
Add 4-1-component-composition
mroeling Dec 31, 2022
d84a01a
Add 4-2-emit-to-parent
mroeling Dec 31, 2022
3b9806c
Merge branch 'main' of github.com:matschik/component-party
mroeling Jan 3, 2023
301acb7
Merge branch 'main' of github.com:matschik/component-party
mroeling Jan 3, 2023
28b5bec
Add 4-3 slot
mroeling Jan 3, 2023
9b141d1
Merge branch 'main' of github.com:mroeling/component-party
mroeling Jan 3, 2023
22d95d5
Fix typo in 4-3-slot button
mroeling Jan 3, 2023
de2081b
Add 4-4-slot-fallback
mroeling Jan 3, 2023
f26e2b2
Add 6-1-input
mroeling Jan 3, 2023
6e25170
Add 6-2-checkbox
mroeling Jan 3, 2023
7312eba
Add 6-3-radio
mroeling Jan 3, 2023
c2a4c5f
6-3-radio add ts file for default value
mroeling Jan 3, 2023
d7be68f
Add 6-4-select with object model
mroeling Jan 3, 2023
d6ded22
Add 7-1-fetch-data
mroeling Jan 3, 2023
ae8c570
Add 7-2-router-link
mroeling Jan 3, 2023
33aabaa
Add 7-3-router-configuration
mroeling Jan 3, 2023
d1d33f5
Update 7-1-fetch-data
mroeling Jan 3, 2023
b403655
Merge branch 'main' of github.com:matschik/component-party
mroeling Jan 5, 2023
a855361
Update files after PR feedback
mroeling Jan 5, 2023
376e680
Update Aurelia files
mroeling Jan 6, 2023
49be62c
Merge branch 'main' of github.com:matschik/component-party
mroeling Jan 6, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
35 changes: 35 additions & 0 deletions README.md
Expand Up @@ -361,6 +361,41 @@ How do we solve this? Developers love having framework overview by examples. It'
- [x] Router link
- [x] Routing

</details><details>
<summary>
<img width="18" height="18" src="public/framework/aurelia.svg" />
<b>Aurelia 1</b>
<img src="https://us-central1-progress-markdown.cloudfunctions.net/progress/100" /></summary>

- [x] Reactivity
- [x] Declare state
- [x] Update state
- [x] Computed state
- [x] Templating
- [x] Minimal template
- [x] Styling
- [x] Loop
- [x] Event click
- [x] Dom ref
- [x] Conditional
- [x] Lifecycle
- [x] On mount
- [x] On unmount
- [x] Component composition
- [x] Props
- [x] Emit to parent
- [x] Slot
- [x] Slot fallback
- [x] Form input
- [x] Input text
- [x] Checkbox
- [x] Radio
- [x] Select
- [x] Webapp features
- [x] Fetch data
- [x] Router link
- [x] Routing

</details>

## 🤝 Contributing
Expand Down
3 changes: 3 additions & 0 deletions content/1-reactivity/1-declare-state/aurelia1/name.html
@@ -0,0 +1,3 @@
<template>
<h1>Hello ${name}</h1>
</template>
3 changes: 3 additions & 0 deletions content/1-reactivity/1-declare-state/aurelia1/name.ts
@@ -0,0 +1,3 @@
export class Name {
matschik marked this conversation as resolved.
Show resolved Hide resolved
name = "John";
}
3 changes: 3 additions & 0 deletions content/1-reactivity/2-update-state/aurelia1/name.html
@@ -0,0 +1,3 @@
<template>
<h1>Hello ${name}</h1>
</template>
7 changes: 7 additions & 0 deletions content/1-reactivity/2-update-state/aurelia1/name.ts
@@ -0,0 +1,7 @@
export class Name {
name = "John";

constructor() {
this.name = "Jane";
}
}
@@ -0,0 +1,3 @@
<template>
<div>${doubleCount}</div>
</template>
@@ -0,0 +1,4 @@
export class DoubleCount {
count: number = 10;
doubleCount = this.count * 2;
}
@@ -0,0 +1,3 @@
<template>
<h1>Hello world</h1>
</template>
3 changes: 3 additions & 0 deletions content/2-templating/2-styling/aurelia1/css-style.css
@@ -0,0 +1,3 @@
.title {
color: red;
}
6 changes: 6 additions & 0 deletions content/2-templating/2-styling/aurelia1/css-style.html
@@ -0,0 +1,6 @@
<template>
<require from="./styling.css"></require>

<h1 class="title">I am red</h1>
<button style="font-size: 10rem">I am a button</button>
</template>
5 changes: 5 additions & 0 deletions content/2-templating/3-loop/aurelia1/colors.html
@@ -0,0 +1,5 @@
<template>
<ul>
<li repeat.for="color of colors">${color}</li>
</ul>
</template>
3 changes: 3 additions & 0 deletions content/2-templating/3-loop/aurelia1/colors.ts
@@ -0,0 +1,3 @@
export class Colors {
colors = ["red", "green", "blue"];
}
4 changes: 4 additions & 0 deletions content/2-templating/4-event-click/aurelia1/counter.html
@@ -0,0 +1,4 @@
<template>
<p>Counter: ${count}</p>
<button click.trigger="incrementCount()">+1</button>
</template>
7 changes: 7 additions & 0 deletions content/2-templating/4-event-click/aurelia1/counter.ts
@@ -0,0 +1,7 @@
export class Counter {
count: number = 0;

incrementCount() {
this.count++;
}
}
3 changes: 3 additions & 0 deletions content/2-templating/5-dom-ref/aurelia1/input-focused.html
@@ -0,0 +1,3 @@
<template>
<input ref="inputElement" />
</template>
7 changes: 7 additions & 0 deletions content/2-templating/5-dom-ref/aurelia1/input-focused.ts
@@ -0,0 +1,7 @@
export class InputFocused {
inputElement: HTMLInputElement;

attached() {
this.inputElement.focus();
}
}
10 changes: 10 additions & 0 deletions content/2-templating/6-conditional/aurelia1/traffic-light.html
@@ -0,0 +1,10 @@
<template>
<button click.trigger="nextLight()">Next light</button>
<p>Light is: ${light}</p>
<p>
You must
<span if.bind="light === 'red'">STOP</span>
<span if.bind="light === 'orange'">SLOW DOWN</span>
<span if.bind="light === 'green'">GO</span>
</p>
</template>
15 changes: 15 additions & 0 deletions content/2-templating/6-conditional/aurelia1/traffic-light.ts
@@ -0,0 +1,15 @@
export class App {
TRAFFIC_LIGHTS = ["red", "orange", "green"];
lightIndex = 0;
light: string = this.TRAFFIC_LIGHTS[this.lightIndex];

nextLight() {
if (this.lightIndex + 1 > this.TRAFFIC_LIGHTS.length - 1) {
this.lightIndex = 0;
} else {
this.lightIndex++;
}

this.light = this.TRAFFIC_LIGHTS[this.lightIndex];
}
}
3 changes: 3 additions & 0 deletions content/3-lifecycle/1-on-mount/aurelia1/page-title.html
@@ -0,0 +1,3 @@
<template>
<p>Page title is: ${pageTitle}</p>
</template>
7 changes: 7 additions & 0 deletions content/3-lifecycle/1-on-mount/aurelia1/page-title.ts
@@ -0,0 +1,7 @@
export class PageTitle {
pageTitle = "";

attached(): void {
this.pageTitle = document.title;
}
}
3 changes: 3 additions & 0 deletions content/3-lifecycle/2-on-unmount/aurelia1/time.html
@@ -0,0 +1,3 @@
<template>
<p>Current time: ${time}</p>
</template>
14 changes: 14 additions & 0 deletions content/3-lifecycle/2-on-unmount/aurelia1/time.ts
@@ -0,0 +1,14 @@
export class Time {
time: string = new Date().toLocaleTimeString();
timer: any;

constructor() {
this.timer = setInterval(() => {
this.time = new Date().toLocaleTimeString();
}, 1000);
}

detached() {
clearInterval(this.timer);
}
}
9 changes: 9 additions & 0 deletions content/4-component-composition/1-props/aurelia1/app.html
@@ -0,0 +1,9 @@
<template>
<require from="./user-profile"></require>
<user-profile
name.bind="name"
age.bind="age"
favourite-colors.bind="colors"
is-available.bind="available"
></user-profile>
</template>
6 changes: 6 additions & 0 deletions content/4-component-composition/1-props/aurelia1/app.ts
@@ -0,0 +1,6 @@
export class App {
age = 20;
name = "John";
colors = ["green", "blue", "red"];
available = false;
}
@@ -0,0 +1,6 @@
<template>
<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>
</template>
@@ -0,0 +1,9 @@
import { customElement, bindable } from "aurelia-templating";

@customElement("user-profile")
export class UserProfile {
@bindable name = "";
@bindable age = null;
@bindable favouriteColors = [];
@bindable isAvailable = true;
}
@@ -0,0 +1,4 @@
<template>
<button click.trigger="clickYes()">YES</button>
<button click.trigger="clickNo()">NO</button>
</template>
@@ -0,0 +1,14 @@
import { customElement, bindable } from "aurelia-templating";

@customElement("answer-button")
export class AnswerButton {
@bindable actionHandler;

clickYes() {
this.actionHandler({ reply: "yes" });
}

clickNo() {
this.actionHandler({ reply: "no" });
}
}
@@ -0,0 +1,6 @@
<template>
<require from="./answer-button"></require>
<p>Can I come ?</p>
<answer-button action-handler.call="handleAnswer(reply)"></answer-button>
<p style="font-size: 50px">${canCome ? "😀" : "😥"}</p>
</template>
@@ -0,0 +1,7 @@
export class App {
canCome = false;

handleAnswer(...reply) {
this.canCome = reply[0] === "yes" ? true : false;
}
}
5 changes: 5 additions & 0 deletions content/4-component-composition/3-slot/aurelia1/app.html
@@ -0,0 +1,5 @@
<template>
<require from="./funny-button"></require>

<funny-button>Click me !</funny-button>
</template>
18 changes: 18 additions & 0 deletions content/4-component-composition/3-slot/aurelia1/funny-button.html
@@ -0,0 +1,18 @@
<template>
<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;
"
>
<slot></slot>
</button>
</template>
@@ -0,0 +1,6 @@
<template>
<require from="./funny-button"></require>

<funny-button></funny-button>
<funny-button>Click me !</funny-button>
</template>
@@ -0,0 +1,18 @@
<template>
<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;
"
>
<slot><span> No content </span></slot>
</button>
</template>
4 changes: 4 additions & 0 deletions content/6-form-input/1-input-text/aurelia1/input-hello.html
@@ -0,0 +1,4 @@
<template>
<p>${text}</p>
<input value.bind="text" />
</template>
3 changes: 3 additions & 0 deletions content/6-form-input/1-input-text/aurelia1/input-hello.ts
@@ -0,0 +1,3 @@
export class InputHello {
texts: string = "Hello World";
}
4 changes: 4 additions & 0 deletions content/6-form-input/2-checkbox/aurelia1/is-available.html
@@ -0,0 +1,4 @@
<template>
<input id="is-available" type="checkbox" checked.bind="isAvailable" />
<label for="is-available">Is available</label>: ${isAvailable}
</template>
3 changes: 3 additions & 0 deletions content/6-form-input/2-checkbox/aurelia1/is-available.ts
@@ -0,0 +1,3 @@
export class IsAvailable {
isAvailable = false;
}
9 changes: 9 additions & 0 deletions content/6-form-input/3-radio/aurelia1/pick-pill.html
@@ -0,0 +1,9 @@
<template>
<div>Picked: ${picked}</div>

<input id="blue-pill" checked.bind="picked" type="radio" value="blue" />
<label for="blue-pill">Blue pill</label>

<input id="red-pill" checked.bind="picked" type="radio" value="red" />
<label for="red-pill">Red pill</label>
</template>
3 changes: 3 additions & 0 deletions content/6-form-input/3-radio/aurelia1/pick-pill.ts
@@ -0,0 +1,3 @@
export class PickPill {
picked = "red";
}
12 changes: 12 additions & 0 deletions content/6-form-input/4-select/aurelia1/color-select.html
@@ -0,0 +1,12 @@
<template>
<select value.bind="selectedColorId">
<option value="">Select A Color</option>
<option
repeat.for="color of colors"
value.bind="color.id"
disabled.bind="color.isDisabled"
>
${color.text}
</option>
</select>
</template>
10 changes: 10 additions & 0 deletions content/6-form-input/4-select/aurelia1/color-select.ts
@@ -0,0 +1,10 @@
export class Select {
selectedColorId = 2;

colors = [
{ id: 1, text: "red" },
{ id: 2, text: "blue" },
{ id: 3, text: "green" },
{ id: 4, text: "gray", isDisabled: true },
];
}
10 changes: 10 additions & 0 deletions content/7-webapp-features/1-fetch-data/aurelia1/app.html
@@ -0,0 +1,10 @@
<template>
<p if.bind="isLoading">Fetching users...</p>
<p if.bind="error">An error ocurred while fetching users</p>
<ul if.bind="users">
<li repeat.for="user of users">
<img src.bind="user.picture.thumbnail" alt="user" />
<p>${ user.name.first } ${ user.name.last }</p>
</li>
</ul>
</template>
26 changes: 26 additions & 0 deletions content/7-webapp-features/1-fetch-data/aurelia1/app.ts
@@ -0,0 +1,26 @@
import { autoinject, computedFrom } from "aurelia-framework";
import { UseFetchUsers } from "./use-fetch-users";

@autoinject()
export class App {
constructor(private useFetchUsers: UseFetchUsers) {}

attached() {
this.useFetchUsers.fetchData();
}

@computedFrom("useFetchUsers.data")
get data() {
return this.useFetchUsers.data;
}

@computedFrom("useFetchUsers.error")
get error() {
return this.useFetchUsers.error;
}

@computedFrom("useFetchUsers.isLoading")
get isLoading() {
return this.useFetchUsers.isLoading;
}
}