Reactivity
Declare state
Update state
Templating
Styling
Loop
Event click
Dom ref
Conditional
static const TRAFFIC_LIGHTS = ["red", "orange", "green"];
<let/lightIndex=0>
<const/light=TRAFFIC_LIGHTS[lightIndex]>
<button onClick() { lightIndex = (lightIndex + 1) % TRAFFIC_LIGHTS.length }>
Next light
</button>
<p>Light is: ${light}</p>
<p>
You must
<if=light === "red">STOP</if>
<else if=light === "orange">SLOW DOWN</else>
<else>GO</else>
</p>
Aurelia 1
<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>
Lifecycle
On mount
Component composition
Props
Emit to parent
<let/isHappy=true>
<p>Are you happy?</p>
<AnswerButton
onYes() { isHappy = true }
onNo() { isHappy = false }
/>
<p style={ "font-size": 50 }>${isHappy ? "😀" : "😥"}</p>
Aurelia 1
<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">${isHappy ? "😀" : "😥"}</p>
</template>
Slot
Slot fallback
Context
<let/user={
id: 1,
username: "unicorn42",
email: "[email protected]",
}>
<const/updateUsername(newUsername) {
user = { ...user, username: newUsername };
}>
<h1>Welcome back, ${user.username}</h1>
<context={ ...user, updateUsername }>
<UserProfile />
</context>
Aurelia 1
Missing snippet Help us to improve Component Party 
Form input
Input text
Checkbox
Radio
<let/picked="red">
<div>Picked: ${picked}</div>
<input#blue-pill
type="radio"
value="blue"
checkedValue:=picked
>
<label for="blue-pill">Blue pill</label>
<input#red-pill
type="radio"
value="red"
checkedValue:=picked
>
<label for="red-pill">Red pill</label>
Aurelia 1
<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>
Select
static const colors = [
{ id: 1, text: "red" },
{ id: 2, text: "blue" },
{ id: 3, text: "green" },
{ id: 4, text: "gray", isDisabled: true },
];
<let/selectedColorId=2>
<select value:=selectedColorId>
<for|{ id, isDisabled, text }| of=colors>
<option value=id disabled=isDisabled>
${text}
</option>
</for>
</select>
Aurelia 1
<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>
Webapp features
Render app
<!doctype html>
<html>
<body>
<div id="app"></div>
<script type="module" src="./app.js"></script>
</body>
</html>
Aurelia 1
Missing snippet Help us to improve Component Party 
Fetch data
<try>
<await|{ results: users }|=fetch("https://randomuser.me/api/?results=3").then(res => res.json())>
<ul>
<for|{ picture, name }| of=users>
<li>
<img src=picture.thumbnail alt="user">
<p>${name.first} ${name.last}</p>
</li>
</for>
</ul>
</await>
<@placeholder>
<p>Fetching users...</p>
</@placeholder>
<@catch|error|>
<p>An error occurred while fetching users</p>
</@catch>
</try>
Aurelia 1
<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>