2021-07-07 14:52:44 -05:00
|
|
|
export const COUNTER_COMPONENTS = {
|
|
|
|
'@astrojs/renderer-preact': {
|
|
|
|
filename: `src/components/PreactCounter.jsx`,
|
2021-07-21 18:10:03 -05:00
|
|
|
content: `import { useState } from 'preact/hooks';
|
2021-07-07 14:52:44 -05:00
|
|
|
|
2021-07-21 18:10:03 -05:00
|
|
|
export default function PreactCounter() {
|
2021-07-07 14:52:44 -05:00
|
|
|
const [count, setCount] = useState(0);
|
|
|
|
const add = () => setCount((i) => i + 1);
|
|
|
|
const subtract = () => setCount((i) => i - 1);
|
|
|
|
|
|
|
|
return (
|
|
|
|
<div id="preact" class="counter">
|
|
|
|
<button onClick={subtract}>-</button>
|
|
|
|
<pre>{count}</pre>
|
|
|
|
<button onClick={add}>+</button>
|
|
|
|
</div>
|
|
|
|
);
|
|
|
|
}
|
2021-07-07 15:10:09 -05:00
|
|
|
`,
|
2021-07-07 14:52:44 -05:00
|
|
|
},
|
|
|
|
'@astrojs/renderer-react': {
|
|
|
|
filename: `src/components/ReactCounter.jsx`,
|
2021-07-21 18:10:03 -05:00
|
|
|
content: `import { useState } from 'react';
|
2021-07-07 14:52:44 -05:00
|
|
|
|
2021-07-21 18:10:03 -05:00
|
|
|
export default function ReactCounter() {
|
2021-07-07 14:52:44 -05:00
|
|
|
const [count, setCount] = useState(0);
|
|
|
|
const add = () => setCount((i) => i + 1);
|
|
|
|
const subtract = () => setCount((i) => i - 1);
|
|
|
|
|
|
|
|
return (
|
|
|
|
<div id="react" className="counter">
|
|
|
|
<button onClick={subtract}>-</button>
|
|
|
|
<pre>{count}</pre>
|
|
|
|
<button onClick={add}>+</button>
|
|
|
|
</div>
|
|
|
|
);
|
|
|
|
}
|
2021-07-21 18:10:03 -05:00
|
|
|
`,
|
|
|
|
},
|
|
|
|
'@astrojs/renderer-solid': {
|
|
|
|
filename: `src/components/SolidCounter.jsx`,
|
|
|
|
content: `import { createSignal } from "solid-js";
|
|
|
|
|
|
|
|
export default function SolidCounter() {
|
|
|
|
const [count, setCount] = createSignal(0);
|
|
|
|
const add = () => setCount(count() + 1);
|
|
|
|
const subtract = () => setCount(count() - 1);
|
|
|
|
|
|
|
|
return (
|
|
|
|
<div id="solid" class="counter">
|
|
|
|
<button onClick={subtract}>-</button>
|
|
|
|
<pre>{count()}</pre>
|
|
|
|
<button onClick={add}>+</button>
|
|
|
|
</div>
|
|
|
|
);
|
|
|
|
}
|
2021-07-07 15:10:09 -05:00
|
|
|
`,
|
2021-07-07 14:52:44 -05:00
|
|
|
},
|
|
|
|
'@astrojs/renderer-svelte': {
|
|
|
|
filename: `src/components/SvelteCounter.svelte`,
|
|
|
|
content: `<script>
|
|
|
|
let count = 0;
|
|
|
|
|
|
|
|
function add() {
|
|
|
|
count += 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
function subtract() {
|
|
|
|
count -= 1;
|
|
|
|
}
|
|
|
|
</script>
|
|
|
|
|
|
|
|
<div id="svelte" class="counter">
|
|
|
|
<button on:click={subtract}>-</button>
|
|
|
|
<pre>{ count }</pre>
|
|
|
|
<button on:click={add}>+</button>
|
|
|
|
</div>
|
2021-07-07 15:10:09 -05:00
|
|
|
`,
|
2021-07-07 14:52:44 -05:00
|
|
|
},
|
|
|
|
'@astrojs/renderer-vue': {
|
|
|
|
filename: `src/components/VueCounter.vue`,
|
|
|
|
content: `<template>
|
|
|
|
<div id="vue" class="counter">
|
|
|
|
<button @click="subtract()">-</button>
|
|
|
|
<pre>{{ count }}</pre>
|
|
|
|
<button @click="add()">+</button>
|
|
|
|
</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>
|
2021-07-07 15:10:09 -05:00
|
|
|
`,
|
|
|
|
},
|
2021-07-07 14:52:44 -05:00
|
|
|
};
|
|
|
|
|
|
|
|
export const FRAMEWORKS = [
|
|
|
|
{
|
|
|
|
title: 'Preact',
|
|
|
|
value: '@astrojs/renderer-preact',
|
|
|
|
},
|
|
|
|
{
|
|
|
|
title: 'React',
|
|
|
|
value: '@astrojs/renderer-react',
|
|
|
|
},
|
2021-07-21 18:10:03 -05:00
|
|
|
{
|
|
|
|
title: 'Solid',
|
|
|
|
value: '@astrojs/renderer-solid',
|
|
|
|
},
|
2021-07-07 14:52:44 -05:00
|
|
|
{
|
|
|
|
title: 'Svelte',
|
|
|
|
value: '@astrojs/renderer-svelte',
|
|
|
|
},
|
|
|
|
{
|
|
|
|
title: 'Vue',
|
|
|
|
value: '@astrojs/renderer-vue',
|
2021-07-07 15:10:09 -05:00
|
|
|
},
|
2021-07-07 14:52:44 -05:00
|
|
|
];
|