Split out specific framework examples (#559)

* rename kitchen sink, pull out react example

* split out the rest of the examples

* align versions

Co-authored-by: Austin Crim <crim.austin@principal.com>
This commit is contained in:
Austin Crim 2021-06-28 07:02:59 -05:00 committed by GitHub
parent 436783d059
commit 3c26035f53
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
26 changed files with 306 additions and 2 deletions

View file

@ -0,0 +1,15 @@
{
"name": "@astrojs/with-multiple-frameworks-example",
"private": true,
"version": "0.0.1",
"scripts": {
"start": "astro dev",
"build": "astro build"
},
"devDependencies": {
"astro": "^0.15.0"
},
"snowpack": {
"workspaceRoot": "../.."
}
}

View file

@ -0,0 +1,2 @@
## force pnpm to hoist
shamefully-hoist = true

View file

@ -1,7 +1,7 @@
{
"name": "@astrojs/kitchen-sink-example",
"name": "@astrojs/with-preact-example",
"private": true,
"version": "1.0.0",
"version": "0.0.1",
"scripts": {
"start": "astro dev",
"build": "astro build"

View file

@ -0,0 +1,19 @@
import { h, Fragment } from 'preact';
import { useState } from 'preact/hooks';
export default function Counter({ children }) {
const [count, setCount] = useState(0);
const add = () => setCount((i) => i + 1);
const subtract = () => setCount((i) => i - 1);
return (
<>
<div className="counter">
<button onClick={subtract}>-</button>
<pre>{count}</pre>
<button onClick={add}>+</button>
</div>
<div className="children">{children}</div>
</>
);
}

View file

@ -0,0 +1,38 @@
---
import Counter from '../components/Counter.jsx'
---
<html>
<head>
<meta charset="utf-8" />
<meta
name="viewport"
content="width=device-width, initial-scale=1, viewport-fit=cover"
/>
<style>
:global(:root) {
font-family: system-ui;
padding: 2em 0;
}
:global(.counter) {
display: grid;
grid-template-columns: repeat(3, minmax(0, 1fr));
place-items: center;
font-size: 2em;
margin-top: 2em;
}
:global(.children) {
display: grid;
place-items: center;
margin-bottom: 2em;
}
</style>
</head>
<body>
<main>
<Counter:visible>
<h1>Hello Preact!</h1>
</Counter:visible>
</main>
</body>
</html>

View file

@ -0,0 +1,2 @@
## force pnpm to hoist
shamefully-hoist = true

View file

@ -0,0 +1,15 @@
{
"name": "@astrojs/with-react-example",
"private": true,
"version": "0.0.1",
"scripts": {
"start": "astro dev",
"build": "astro build"
},
"devDependencies": {
"astro": "^0.15.0"
},
"snowpack": {
"workspaceRoot": "../.."
}
}

View file

@ -0,0 +1,18 @@
import React, { useState } from 'react'
export default function Counter({ children }) {
const [count, setCount] = useState(0)
const add = () => setCount((i) => i + 1)
const subtract = () => setCount((i) => i - 1)
return (
<>
<div className='counter'>
<button onClick={subtract}>-</button>
<pre>{count}</pre>
<button onClick={add}>+</button>
</div>
<div className='children'>{children}</div>
</>
)
}

View file

@ -0,0 +1,38 @@
---
import Counter from '../components/Counter.jsx'
---
<html>
<head>
<meta charset="utf-8" />
<meta
name="viewport"
content="width=device-width, initial-scale=1, viewport-fit=cover"
/>
<style>
:global(:root) {
font-family: system-ui;
padding: 2em 0;
}
:global(.counter) {
display: grid;
grid-template-columns: repeat(3, minmax(0, 1fr));
place-items: center;
font-size: 2em;
margin-top: 2em;
}
:global(.children) {
display: grid;
place-items: center;
margin-bottom: 2em;
}
</style>
</head>
<body>
<main>
<Counter:visible>
<h1>Hello React!</h1>
</Counter:visible>
</main>
</body>
</html>

View file

@ -0,0 +1,2 @@
## force pnpm to hoist
shamefully-hoist = true

View file

@ -0,0 +1,15 @@
{
"name": "@astrojs/with-svelte-example",
"private": true,
"version": "0.0.1",
"scripts": {
"start": "astro dev",
"build": "astro build"
},
"devDependencies": {
"astro": "^0.15.0"
},
"snowpack": {
"workspaceRoot": "../.."
}
}

View file

@ -0,0 +1,20 @@
<script>
let count = 0;
function add() {
count += 1;
}
function subtract() {
count -= 1;
}
</script>
<div class="counter">
<button on:click={subtract}>-</button>
<pre>{ count }</pre>
<button on:click={add}>+</button>
</div>
<div class="children">
<slot />
</div>

View file

@ -0,0 +1,38 @@
---
import Counter from '../components/Counter.svelte'
---
<html>
<head>
<meta charset="utf-8" />
<meta
name="viewport"
content="width=device-width, initial-scale=1, viewport-fit=cover"
/>
<style>
:global(:root) {
font-family: system-ui;
padding: 2em 0;
}
:global(.counter) {
display: grid;
grid-template-columns: repeat(3, minmax(0, 1fr));
place-items: center;
font-size: 2em;
margin-top: 2em;
}
:global(.children) {
display: grid;
place-items: center;
margin-bottom: 2em;
}
</style>
</head>
<body>
<main>
<Counter:visible>
<h1>Hello Svelte!</h1>
</Counter:visible>
</main>
</body>
</html>

2
examples/with-vue/.npmrc Normal file
View file

@ -0,0 +1,2 @@
## force pnpm to hoist
shamefully-hoist = true

View file

@ -0,0 +1,15 @@
{
"name": "@astrojs/with-vue-example",
"private": true,
"version": "0.0.1",
"scripts": {
"start": "astro dev",
"build": "astro build"
},
"devDependencies": {
"astro": "^0.15.0"
},
"snowpack": {
"workspaceRoot": "../.."
}
}

View file

@ -0,0 +1,27 @@
<template>
<div class="counter">
<button @click="subtract()">-</button>
<pre>{{ count }}</pre>
<button @click="add()">+</button>
</div>
<div class="children">
<slot />
</div>
</template>
<script>
import { ref } from 'vue';
export default {
setup() {
const count = ref(0)
const add = () => count.value = count.value + 1;
const subtract = () => count.value = count.value - 1;
return {
count,
add,
subtract
}
}
}
</script>

View file

@ -0,0 +1,38 @@
---
import Counter from '../components/Counter.vue'
---
<html>
<head>
<meta charset="utf-8" />
<meta
name="viewport"
content="width=device-width, initial-scale=1, viewport-fit=cover"
/>
<style>
:global(:root) {
font-family: system-ui;
padding: 2em 0;
}
:global(.counter) {
display: grid;
grid-template-columns: repeat(3, minmax(0, 1fr));
place-items: center;
font-size: 2em;
margin-top: 2em;
}
:global(.children) {
display: grid;
place-items: center;
margin-bottom: 2em;
}
</style>
</head>
<body>
<main>
<Counter:visible>
<h1>Hello Vue!</h1>
</Counter:visible>
</main>
</body>
</html>