Skip to content

Commit

Permalink
refactor: standarize starters (QwikDev#230)
Browse files Browse the repository at this point in the history
  • Loading branch information
manucorporat authored Mar 10, 2022
1 parent 8028547 commit 7938ff0
Show file tree
Hide file tree
Showing 11 changed files with 21 additions and 20 deletions.
6 changes: 3 additions & 3 deletions starters/apps/base/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@
<script type="module">
// Vite Dev Mode Only
import '@builder.io/qwik/qwikloader.js';
import { render } from '@builder.io/qwik';
import { App } from '/src/main.tsx';
render(document.body, App);
import { render, jsx } from '@builder.io/qwik';
import { Main } from '/src/main.tsx';
render(document.body, jsx(Main, {}));
</script>
</body>
</html>
5 changes: 3 additions & 2 deletions starters/apps/base/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,10 @@
"build": "npm run typecheck && npm run build.client && npm run build.server",
"build.client": "vite build",
"build.server": "vite build --outDir server/build --ssr src/entry.server.tsx",
"preview": "vite preview",
"dev": "vite",
"dev.ssr": "vite",
"dev.client": "vite --mode clientonly",
"dev.debug": "node --inspect-brk node_modules/vite/bin/vite.js",
"dev": "npm run dev.client",
"start": "npm run dev"
},
"devDependencies": {
Expand Down
4 changes: 2 additions & 2 deletions starters/apps/starter-builder/src/entry.server.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
*/

import { renderToString, RenderToStringOptions, QwikLoader } from '@builder.io/qwik/server';
import { App } from './main';
import { Main } from './main';

/**
* Entry point for server-side pre-rendering.
Expand All @@ -22,7 +22,7 @@ export function render(opts: RenderToStringOptions) {
<title>Qwik Blank App</title>
</head>
<body q:base="/">
<App />
<Main />
<script>({fetchQwikBuilderContent.toString()})();</script>
<QwikLoader debug={opts.debug} />
</body>
Expand Down
2 changes: 1 addition & 1 deletion starters/apps/starter-builder/src/main.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { Header } from './components/header/header';

import './global.css';

export const App = component$(() => {
export const Main = component$(() => {
return $(() => (
<>
<Header />
Expand Down
4 changes: 2 additions & 2 deletions starters/apps/starter-partytown/src/entry.server.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

import { renderToString, RenderToStringOptions, QwikLoader } from '@builder.io/qwik/server';
import { partytownSnippet } from '@builder.io/partytown/integration';
import { App } from './main';
import { Main } from './main';

/**
* Entry point for server-side pre-rendering.
Expand All @@ -24,7 +24,7 @@ export function render(opts: RenderToStringOptions) {
<script children={partytownSnippet({ debug: true })} />
</head>
<body q:base="/">
<App />
<Main />
<script type="text/partytown">
({partyTownExampleWhichBlocksMainThreadForOneSecond.toString()})()
</script>
Expand Down
2 changes: 1 addition & 1 deletion starters/apps/starter-partytown/src/main.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { component$, $, useEvent, useStore } from '@builder.io/qwik';
import './global.css';

export const App = component$(() => {
export const Main = component$(() => {
const state = useStore({ name: 'World', running: true });
return $(() => {
return (
Expand Down
4 changes: 2 additions & 2 deletions starters/apps/starter/src/entry.server.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
*/

import { renderToString, RenderToStringOptions, QwikLoader } from '@builder.io/qwik/server';
import { App } from './main';
import { Main } from './main';

/**
* Entry point for server-side pre-rendering.
Expand All @@ -22,7 +22,7 @@ export function render(opts: RenderToStringOptions) {
<title>Qwik Blank App</title>
</head>
<body q:base="/">
<App />
<Main />
<QwikLoader debug={opts.debug} />
</body>
</html>,
Expand Down
2 changes: 1 addition & 1 deletion starters/apps/starter/src/main.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { Logo } from './components/logo/logo';

import './global.css';

export const App = component$(() => {
export const Main = component$(() => {
const state = useStore({ name: 'World' });
return $(() => (
<Host class="my-app">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import { Item } from '../item/item';
*
* This component only rerenders/hydrates/downloads if the list of todos changes.
*/
export const Main = component$((props: { todos: Todos }) => {
export const Body = component$((props: { todos: Todos }) => {
return $(() => {
return (
<Host class="main">
Expand Down
4 changes: 2 additions & 2 deletions starters/apps/todo/src/entry.server.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
* found in the LICENSE file at https://github.com/BuilderIO/qwik/blob/main/LICENSE
*/
import { renderToString, RenderToStringOptions, QwikLoader } from '@builder.io/qwik/server';
import { App } from './main';
import { Main } from './main';

/**
* Entry point for server-side pre-rendering.
Expand All @@ -21,7 +21,7 @@ export function render(opts: RenderToStringOptions) {
<title>Qwik Demo: ToDo</title>
</head>
<body q:base="/">
<App />
<Main />
<QwikLoader debug={opts.debug} />
</body>
</html>,
Expand Down
6 changes: 3 additions & 3 deletions starters/apps/todo/src/main.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { component$, $, useStore } from '@builder.io/qwik';
import { Footer } from './components/footer/footer';
import { Header } from './components/header/header';
import { Main } from './components/main/main';
import { Body } from './components/body/body';
import type { Todos } from './state/state';

import './base.css';
Expand All @@ -14,7 +14,7 @@ import './index.css';
* Qwik knows that it should never need to be rerendered, and its code will never
* download to the client.
*/
export const App = component$(() => {
export const Main = component$(() => {
const todos = useStore<Todos>({
filter: 'all',
items: [
Expand All @@ -27,7 +27,7 @@ export const App = component$(() => {
return (
<section class="todoapp">
<Header todos={todos} />
<Main todos={todos} />
<Body todos={todos} />
<Footer todos={todos} />
</section>
);
Expand Down

0 comments on commit 7938ff0

Please sign in to comment.