Skip to content

Commit

Permalink
Merge branch 'main' into add-marko
Browse files Browse the repository at this point in the history
  • Loading branch information
tigt authored Apr 3, 2023
2 parents 61927b2 + 11975c8 commit 8e893d5
Show file tree
Hide file tree
Showing 19 changed files with 210 additions and 1,795 deletions.
16 changes: 8 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ How do we solve this ? Developers love having framework overview by examples. It
- [x] Emit to parent
- [x] Slot
- [x] Slot fallback
- [ ] Context
- [x] Context
- [x] Form input
- [x] Input text
- [x] Checkbox
Expand Down Expand Up @@ -153,8 +153,8 @@ How do we solve this ? Developers love having framework overview by examples. It
- [x] Checkbox
- [x] Radio
- [x] Select
- [ ] Webapp features
- [ ] Render app
- [x] Webapp features
- [x] Render app
- [x] Fetch data
- [x] Router link
- [x] Routing
Expand All @@ -179,12 +179,12 @@ How do we solve this ? Developers love having framework overview by examples. It
- [x] Lifecycle
- [x] On mount
- [x] On unmount
- [ ] Component composition
- [x] Component composition
- [x] Props
- [x] Emit to parent
- [x] Slot
- [x] Slot fallback
- [ ] Context
- [x] Context
- [x] Form input
- [x] Input text
- [x] Checkbox
Expand Down Expand Up @@ -274,7 +274,7 @@ How do we solve this ? Developers love having framework overview by examples. It
<summary>
<img width="18" height="18" src="public/framework/vue.svg" />
<b>Vue 2</b>
<img alt="96% progress" src="https://us-central1-progress-markdown.cloudfunctions.net/progress/96" /></summary>
<img alt="100% progress" src="https://us-central1-progress-markdown.cloudfunctions.net/progress/100" /></summary>

- [x] Reactivity
- [x] Declare state
Expand All @@ -290,12 +290,12 @@ How do we solve this ? Developers love having framework overview by examples. It
- [x] Lifecycle
- [x] On mount
- [x] On unmount
- [ ] Component composition
- [x] Component composition
- [x] Props
- [x] Emit to parent
- [x] Slot
- [x] Slot fallback
- [ ] Context
- [x] Context
- [x] Form input
- [x] Input text
- [x] Checkbox
Expand Down
1 change: 1 addition & 0 deletions content/4-component-composition/5-context/ember/app.hbs
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
<UserProfile />
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<div>
<h2>My Profile</h2>
<p>Username: {{this.user.username}}</p>
<p>Email: {{this.user.email}}</p>
<button {{on "click" (fn this.userService.updateUserName "Jane")}}>
Update username to Jane
</button>
</div>
10 changes: 10 additions & 0 deletions content/4-component-composition/5-context/ember/user-profile.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import Component from '@glimmer/component';
import { service } from '@ember/service';

export default class UserProfileComponent extends Component {
@service userService;

get user() {
return this.userService.user;
}
}
22 changes: 22 additions & 0 deletions content/4-component-composition/5-context/ember/user-service.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
import Service from '@ember/service';
import { tracked } from '@glimmer/tracking';
import { action } from '@ember/object';

export default class UserServiceService extends Service {
@tracked id = 1;
@tracked username = 'unicorn42';
@tracked email = '[email protected]';

get user() {
return {
id: this.id,
username: this.username,
email: this.email,
};
}

@action
updateUserName(newUsername) {
this.username = newUsername;
}
}
33 changes: 33 additions & 0 deletions content/4-component-composition/5-context/qwik/App.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
import {
component$,
useStore,
useContextProvider,
createContext,
$,
} from "@builder.io/qwik";
import UserProfile from "./UserProfile";

export const UserContext = createContext("user-context");

const App = component$(() => {
const user = useStore({
id: 1,
username: "unicorn42",
email: "[email protected]",
});

const updateUsername = $((newUsername) => {
user.username = newUsername;
});

useContextProvider(UserContext, { user, updateUsername });

return (
<>
<h1>Welcome back, {user.username}</h1>
<UserProfile />
</>
);
});

export default App;
19 changes: 19 additions & 0 deletions content/4-component-composition/5-context/qwik/UserProfile.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import { component$, useContext } from "@builder.io/qwik";
import { UserContext } from "./App";

const UserProfile = component$(() => {
const { user, updateUsername } = useContext(UserContext);

return (
<div>
<h2>My Profile</h2>
<p>Username: {user.username}</p>
<p>Email: {user.email}</p>
<button onClick$={() => updateUsername("Jane")}>
Update username to Jane
</button>
</div>
);
});

export default UserProfile;
2 changes: 1 addition & 1 deletion content/4-component-composition/5-context/react/App.jsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { useState, createContext } from "react";
import UserProfile from "./UserProfile";

const UserContext = createContext();
export const UserContext = createContext();

export default function App() {
// In a real app, you would fetch the user data from an API
Expand Down
35 changes: 35 additions & 0 deletions content/4-component-composition/5-context/vue2/App.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
<script>
import UserProfile from "./UserProfile.vue";
export default {
components: { UserProfile },
provide() {
return {
user: Object.assign(this.user, {
updateUsername: this.updateUsername,
}),
};
},
data() {
return {
user: {
id: 1,
username: "unicorn42",
email: "[email protected]",
},
};
},
methods: {
updateUsername(newUsername) {
this.user.username = newUsername;
},
},
};
</script>

<template>
<div>
<h1>Welcome back, {{ user.username }}</h1>
<UserProfile />
</div>
</template>
16 changes: 16 additions & 0 deletions content/4-component-composition/5-context/vue2/UserProfile.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<script>
export default {
inject: ["user"],
};
</script>

<template>
<div>
<h2>My Profile</h2>
<p>Username: {{ user.username }}</p>
<p>Email: {{ user.email }}</p>
<button @click="() => user.updateUsername('Jane')">
Update username to Jane
</button>
</div>
</template>
21 changes: 21 additions & 0 deletions content/4-component-composition/5-context/vue3/App.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
<script setup>
import { ref, provide } from "vue";
import UserProfile from "./UserProfile.vue";
const user = ref({
id: 1,
username: "unicorn42",
email: "[email protected]",
});
function updateUsername(username) {
user.value.username = username;
}
provide("user", { user, updateUsername });
</script>

<template>
<h1>Welcome back, {{ user.username }}</h1>
<UserProfile />
</template>
15 changes: 15 additions & 0 deletions content/4-component-composition/5-context/vue3/UserProfile.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<script setup>
import { inject } from "vue";
const { user, updateUsername } = inject("user");
</script>

<template>
<div>
<h2>My Profile</h2>
<p>Username: {{ user.username }}</p>
<p>Email: {{ user.email }}</p>
<button @click="() => updateUsername('Jane')">
Update username to Jane
</button>
</div>
</template>
3 changes: 3 additions & 0 deletions content/7-webapp-features/1-render-app/solid/App.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
export default function App() {
return <h1>Hello world</h1>;
}
7 changes: 7 additions & 0 deletions content/7-webapp-features/1-render-app/solid/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.jsx"></script>
</body>
</html>
4 changes: 4 additions & 0 deletions content/7-webapp-features/1-render-app/solid/main.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
import { render } from "solid-js/web";
import App from "./App";

render(() => <App />, document.getElementById("app"));
2 changes: 1 addition & 1 deletion frameworks.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ export default [
playgroundURL: "https://playground.solidjs.com/",
documentationURL: "https://www.solidjs.com/",
filesSorter(files) {
return sortAllFilenames(files, ["App.jsx"]);
return sortAllFilenames(files, ["index.html", "App.jsx"]);
},
},
{
Expand Down
2 changes: 1 addition & 1 deletion index.html
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@
font-family: "Mona Sans";
src: url("/font/Mona-Sans.woff2") format("woff2 supports variations"),
url("/font/Mona-Sans.woff2") format("woff2-variations");
font-weight: 200 500;
font-weight: 200 500 600;
font-stretch: 75% 125%;
font-display: swap;
}
Expand Down
Loading

0 comments on commit 8e893d5

Please sign in to comment.