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:
parent
436783d059
commit
3c26035f53
26 changed files with 306 additions and 2 deletions
15
examples/with-multiple-frameworks/package.json
Normal file
15
examples/with-multiple-frameworks/package.json
Normal 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": "../.."
|
||||
}
|
||||
}
|
2
examples/with-preact/.npmrc
Normal file
2
examples/with-preact/.npmrc
Normal file
|
@ -0,0 +1,2 @@
|
|||
## force pnpm to hoist
|
||||
shamefully-hoist = true
|
|
@ -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"
|
19
examples/with-preact/src/components/Counter.tsx
Normal file
19
examples/with-preact/src/components/Counter.tsx
Normal 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>
|
||||
</>
|
||||
);
|
||||
}
|
38
examples/with-preact/src/pages/index.astro
Normal file
38
examples/with-preact/src/pages/index.astro
Normal 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>
|
2
examples/with-react/.npmrc
Normal file
2
examples/with-react/.npmrc
Normal file
|
@ -0,0 +1,2 @@
|
|||
## force pnpm to hoist
|
||||
shamefully-hoist = true
|
15
examples/with-react/package.json
Normal file
15
examples/with-react/package.json
Normal 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": "../.."
|
||||
}
|
||||
}
|
18
examples/with-react/src/components/Counter.jsx
Normal file
18
examples/with-react/src/components/Counter.jsx
Normal 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>
|
||||
</>
|
||||
)
|
||||
}
|
38
examples/with-react/src/pages/index.astro
Normal file
38
examples/with-react/src/pages/index.astro
Normal 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>
|
2
examples/with-svelte/.npmrc
Normal file
2
examples/with-svelte/.npmrc
Normal file
|
@ -0,0 +1,2 @@
|
|||
## force pnpm to hoist
|
||||
shamefully-hoist = true
|
15
examples/with-svelte/package.json
Normal file
15
examples/with-svelte/package.json
Normal 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": "../.."
|
||||
}
|
||||
}
|
20
examples/with-svelte/src/components/Counter.svelte
Normal file
20
examples/with-svelte/src/components/Counter.svelte
Normal 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>
|
38
examples/with-svelte/src/pages/index.astro
Normal file
38
examples/with-svelte/src/pages/index.astro
Normal 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
2
examples/with-vue/.npmrc
Normal file
|
@ -0,0 +1,2 @@
|
|||
## force pnpm to hoist
|
||||
shamefully-hoist = true
|
15
examples/with-vue/package.json
Normal file
15
examples/with-vue/package.json
Normal 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": "../.."
|
||||
}
|
||||
}
|
27
examples/with-vue/src/components/Counter.vue
Normal file
27
examples/with-vue/src/components/Counter.vue
Normal 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>
|
38
examples/with-vue/src/pages/index.astro
Normal file
38
examples/with-vue/src/pages/index.astro
Normal 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>
|
Loading…
Reference in a new issue