summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGravatar Austin Crim <aust.crim@gmail.com> 2021-06-28 07:02:59 -0500
committerGravatar GitHub <noreply@github.com> 2021-06-28 07:02:59 -0500
commit3c26035f535d4e54a60fde871a75fb4371ccdbe8 (patch)
tree75b37a3caf9ac3be607a6c9df0cbb71fb07392d2
parent436783d059ad70e1f7d8438d9eefcb9c5257e2d3 (diff)
downloadastro-3c26035f535d4e54a60fde871a75fb4371ccdbe8.tar.gz
astro-3c26035f535d4e54a60fde871a75fb4371ccdbe8.tar.zst
astro-3c26035f535d4e54a60fde871a75fb4371ccdbe8.zip
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>
-rw-r--r--examples/with-multiple-frameworks/.npmrc (renamed from examples/kitchen-sink/.npmrc)0
-rw-r--r--examples/with-multiple-frameworks/package.json15
-rw-r--r--examples/with-multiple-frameworks/src/components/A.astro (renamed from examples/kitchen-sink/src/components/A.astro)0
-rw-r--r--examples/with-multiple-frameworks/src/components/B.astro (renamed from examples/kitchen-sink/src/components/B.astro)0
-rw-r--r--examples/with-multiple-frameworks/src/components/PreactCounter.tsx (renamed from examples/kitchen-sink/src/components/PreactCounter.tsx)0
-rw-r--r--examples/with-multiple-frameworks/src/components/ReactCounter.jsx (renamed from examples/kitchen-sink/src/components/ReactCounter.jsx)0
-rw-r--r--examples/with-multiple-frameworks/src/components/SvelteCounter.svelte (renamed from examples/kitchen-sink/src/components/SvelteCounter.svelte)0
-rw-r--r--examples/with-multiple-frameworks/src/components/VueCounter.vue (renamed from examples/kitchen-sink/src/components/VueCounter.vue)0
-rw-r--r--examples/with-multiple-frameworks/src/components/index.ts (renamed from examples/kitchen-sink/src/components/index.ts)0
-rw-r--r--examples/with-multiple-frameworks/src/pages/index.astro (renamed from examples/kitchen-sink/src/pages/index.astro)0
-rw-r--r--examples/with-preact/.npmrc2
-rw-r--r--examples/with-preact/package.json (renamed from examples/kitchen-sink/package.json)4
-rw-r--r--examples/with-preact/src/components/Counter.tsx19
-rw-r--r--examples/with-preact/src/pages/index.astro38
-rw-r--r--examples/with-react/.npmrc2
-rw-r--r--examples/with-react/package.json15
-rw-r--r--examples/with-react/src/components/Counter.jsx18
-rw-r--r--examples/with-react/src/pages/index.astro38
-rw-r--r--examples/with-svelte/.npmrc2
-rw-r--r--examples/with-svelte/package.json15
-rw-r--r--examples/with-svelte/src/components/Counter.svelte20
-rw-r--r--examples/with-svelte/src/pages/index.astro38
-rw-r--r--examples/with-vue/.npmrc2
-rw-r--r--examples/with-vue/package.json15
-rw-r--r--examples/with-vue/src/components/Counter.vue27
-rw-r--r--examples/with-vue/src/pages/index.astro38
26 files changed, 306 insertions, 2 deletions
diff --git a/examples/kitchen-sink/.npmrc b/examples/with-multiple-frameworks/.npmrc
index 0cc653b2c..0cc653b2c 100644
--- a/examples/kitchen-sink/.npmrc
+++ b/examples/with-multiple-frameworks/.npmrc
diff --git a/examples/with-multiple-frameworks/package.json b/examples/with-multiple-frameworks/package.json
new file mode 100644
index 000000000..8213a731f
--- /dev/null
+++ b/examples/with-multiple-frameworks/package.json
@@ -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": "../.."
+ }
+}
diff --git a/examples/kitchen-sink/src/components/A.astro b/examples/with-multiple-frameworks/src/components/A.astro
index 702a4be35..702a4be35 100644
--- a/examples/kitchen-sink/src/components/A.astro
+++ b/examples/with-multiple-frameworks/src/components/A.astro
diff --git a/examples/kitchen-sink/src/components/B.astro b/examples/with-multiple-frameworks/src/components/B.astro
index 9022cb372..9022cb372 100644
--- a/examples/kitchen-sink/src/components/B.astro
+++ b/examples/with-multiple-frameworks/src/components/B.astro
diff --git a/examples/kitchen-sink/src/components/PreactCounter.tsx b/examples/with-multiple-frameworks/src/components/PreactCounter.tsx
index be4ddb6ce..be4ddb6ce 100644
--- a/examples/kitchen-sink/src/components/PreactCounter.tsx
+++ b/examples/with-multiple-frameworks/src/components/PreactCounter.tsx
diff --git a/examples/kitchen-sink/src/components/ReactCounter.jsx b/examples/with-multiple-frameworks/src/components/ReactCounter.jsx
index 06d8f2513..06d8f2513 100644
--- a/examples/kitchen-sink/src/components/ReactCounter.jsx
+++ b/examples/with-multiple-frameworks/src/components/ReactCounter.jsx
diff --git a/examples/kitchen-sink/src/components/SvelteCounter.svelte b/examples/with-multiple-frameworks/src/components/SvelteCounter.svelte
index 8d6b3f5e1..8d6b3f5e1 100644
--- a/examples/kitchen-sink/src/components/SvelteCounter.svelte
+++ b/examples/with-multiple-frameworks/src/components/SvelteCounter.svelte
diff --git a/examples/kitchen-sink/src/components/VueCounter.vue b/examples/with-multiple-frameworks/src/components/VueCounter.vue
index 8179fb1d9..8179fb1d9 100644
--- a/examples/kitchen-sink/src/components/VueCounter.vue
+++ b/examples/with-multiple-frameworks/src/components/VueCounter.vue
diff --git a/examples/kitchen-sink/src/components/index.ts b/examples/with-multiple-frameworks/src/components/index.ts
index 4077dcacd..4077dcacd 100644
--- a/examples/kitchen-sink/src/components/index.ts
+++ b/examples/with-multiple-frameworks/src/components/index.ts
diff --git a/examples/kitchen-sink/src/pages/index.astro b/examples/with-multiple-frameworks/src/pages/index.astro
index 3fbef72e0..3fbef72e0 100644
--- a/examples/kitchen-sink/src/pages/index.astro
+++ b/examples/with-multiple-frameworks/src/pages/index.astro
diff --git a/examples/with-preact/.npmrc b/examples/with-preact/.npmrc
new file mode 100644
index 000000000..0cc653b2c
--- /dev/null
+++ b/examples/with-preact/.npmrc
@@ -0,0 +1,2 @@
+## force pnpm to hoist
+shamefully-hoist = true \ No newline at end of file
diff --git a/examples/kitchen-sink/package.json b/examples/with-preact/package.json
index b1254eb7c..0daf05f53 100644
--- a/examples/kitchen-sink/package.json
+++ b/examples/with-preact/package.json
@@ -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"
diff --git a/examples/with-preact/src/components/Counter.tsx b/examples/with-preact/src/components/Counter.tsx
new file mode 100644
index 000000000..7c520b167
--- /dev/null
+++ b/examples/with-preact/src/components/Counter.tsx
@@ -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>
+ </>
+ );
+}
diff --git a/examples/with-preact/src/pages/index.astro b/examples/with-preact/src/pages/index.astro
new file mode 100644
index 000000000..66fa9e84b
--- /dev/null
+++ b/examples/with-preact/src/pages/index.astro
@@ -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>
diff --git a/examples/with-react/.npmrc b/examples/with-react/.npmrc
new file mode 100644
index 000000000..0cc653b2c
--- /dev/null
+++ b/examples/with-react/.npmrc
@@ -0,0 +1,2 @@
+## force pnpm to hoist
+shamefully-hoist = true \ No newline at end of file
diff --git a/examples/with-react/package.json b/examples/with-react/package.json
new file mode 100644
index 000000000..9c09d6154
--- /dev/null
+++ b/examples/with-react/package.json
@@ -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": "../.."
+ }
+}
diff --git a/examples/with-react/src/components/Counter.jsx b/examples/with-react/src/components/Counter.jsx
new file mode 100644
index 000000000..488854fd3
--- /dev/null
+++ b/examples/with-react/src/components/Counter.jsx
@@ -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>
+ </>
+ )
+}
diff --git a/examples/with-react/src/pages/index.astro b/examples/with-react/src/pages/index.astro
new file mode 100644
index 000000000..3bd650e02
--- /dev/null
+++ b/examples/with-react/src/pages/index.astro
@@ -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>
diff --git a/examples/with-svelte/.npmrc b/examples/with-svelte/.npmrc
new file mode 100644
index 000000000..0cc653b2c
--- /dev/null
+++ b/examples/with-svelte/.npmrc
@@ -0,0 +1,2 @@
+## force pnpm to hoist
+shamefully-hoist = true \ No newline at end of file
diff --git a/examples/with-svelte/package.json b/examples/with-svelte/package.json
new file mode 100644
index 000000000..22220cb7c
--- /dev/null
+++ b/examples/with-svelte/package.json
@@ -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": "../.."
+ }
+}
diff --git a/examples/with-svelte/src/components/Counter.svelte b/examples/with-svelte/src/components/Counter.svelte
new file mode 100644
index 000000000..9aaf421c1
--- /dev/null
+++ b/examples/with-svelte/src/components/Counter.svelte
@@ -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>
diff --git a/examples/with-svelte/src/pages/index.astro b/examples/with-svelte/src/pages/index.astro
new file mode 100644
index 000000000..5a0c1039d
--- /dev/null
+++ b/examples/with-svelte/src/pages/index.astro
@@ -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>
diff --git a/examples/with-vue/.npmrc b/examples/with-vue/.npmrc
new file mode 100644
index 000000000..0cc653b2c
--- /dev/null
+++ b/examples/with-vue/.npmrc
@@ -0,0 +1,2 @@
+## force pnpm to hoist
+shamefully-hoist = true \ No newline at end of file
diff --git a/examples/with-vue/package.json b/examples/with-vue/package.json
new file mode 100644
index 000000000..a3d07b573
--- /dev/null
+++ b/examples/with-vue/package.json
@@ -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": "../.."
+ }
+}
diff --git a/examples/with-vue/src/components/Counter.vue b/examples/with-vue/src/components/Counter.vue
new file mode 100644
index 000000000..8179fb1d9
--- /dev/null
+++ b/examples/with-vue/src/components/Counter.vue
@@ -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>
diff --git a/examples/with-vue/src/pages/index.astro b/examples/with-vue/src/pages/index.astro
new file mode 100644
index 000000000..949012d0f
--- /dev/null
+++ b/examples/with-vue/src/pages/index.astro
@@ -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>