create-qwik 0.0.36 → 0.0.39-dev20220722190315

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (46) hide show
  1. package/create-qwik +14 -14
  2. package/index.js +12 -8
  3. package/package.json +1 -1
  4. package/starters/apps/base/{.eslintrc.js → .eslintrc.cjs} +0 -0
  5. package/starters/apps/base/package.json +9 -8
  6. package/starters/apps/blank/package.json +5 -1
  7. package/starters/apps/library/package.json +9 -5
  8. package/starters/apps/library/vite.config.ts +2 -1
  9. package/starters/apps/qwik-city/package.json +6 -1
  10. package/starters/apps/qwik-city/src/components/breadcrumbs/breadcrumbs.css +25 -0
  11. package/starters/apps/qwik-city/src/components/breadcrumbs/breadcrumbs.tsx +77 -0
  12. package/starters/apps/qwik-city/src/components/footer/footer.css +1 -1
  13. package/starters/apps/qwik-city/src/components/footer/footer.tsx +3 -1
  14. package/starters/apps/qwik-city/src/components/header/header.css +10 -1
  15. package/starters/apps/qwik-city/src/components/header/header.tsx +24 -32
  16. package/starters/apps/qwik-city/src/components/menu/menu.css +10 -0
  17. package/starters/apps/qwik-city/src/components/menu/menu.tsx +4 -4
  18. package/starters/apps/qwik-city/src/global.css +21 -12
  19. package/starters/apps/qwik-city/src/routes/about-us.tsx +2 -4
  20. package/starters/apps/qwik-city/src/routes/api/[org]/[user].json/index.ts +12 -23
  21. package/starters/apps/qwik-city/src/routes/api/_layout-foo/index.tsx +16 -22
  22. package/starters/apps/qwik-city/src/routes/api/data.json.ts +6 -9
  23. package/starters/apps/qwik-city/src/routes/api/index@foo.tsx +7 -4
  24. package/starters/apps/qwik-city/src/routes/blog/[...slug].tsx +28 -5
  25. package/starters/apps/qwik-city/src/routes/blog/_layout/index.tsx +2 -2
  26. package/starters/apps/qwik-city/src/routes/dashboard/index.tsx +8 -0
  27. package/starters/apps/qwik-city/src/routes/docs/[category]/[id]/index.tsx +14 -6
  28. package/starters/apps/qwik-city/src/routes/docs/{_layout/docs.css → _layout!/index.css} +2 -1
  29. package/starters/apps/qwik-city/src/routes/docs/_layout!/index.tsx +31 -0
  30. package/starters/apps/qwik-city/src/routes/docs/_menu.md +4 -2
  31. package/starters/apps/qwik-city/src/routes/docs/getting-started.md +44 -0
  32. package/starters/apps/qwik-city/src/routes/docs/index.tsx +2 -4
  33. package/starters/apps/qwik-city/src/routes/docs/{introduction → overview}/index.md +2 -2
  34. package/starters/apps/qwik-city/src/routes/index.tsx +6 -1
  35. package/starters/apps/qwik-city/src/routes/products/[id].tsx +132 -0
  36. package/starters/features/react/package.json +2 -2
  37. package/starters/features/react/src/react/app.tsx +1 -1
  38. package/starters/servers/cloudflare-pages/functions/[[path]].ts +1 -1
  39. package/starters/servers/express/package.json +1 -1
  40. package/starters/servers/express/src/entry.express.tsx +2 -1
  41. package/starters/apps/qwik-city/src/routes/__auth/_layout.tsx +0 -17
  42. package/starters/apps/qwik-city/src/routes/__auth/sign-in.tsx +0 -25
  43. package/starters/apps/qwik-city/src/routes/__auth/sign-up.tsx +0 -29
  44. package/starters/apps/qwik-city/src/routes/api/on-sign-in.ts +0 -67
  45. package/starters/apps/qwik-city/src/routes/docs/_layout/index.tsx +0 -23
  46. package/starters/apps/qwik-city/src/routes/docs/getting-started.mdx +0 -32
@@ -21,7 +21,9 @@ export default component$(
21
21
  <a href="/sign-in">Sign In</a>
22
22
  </li>
23
23
  <li>
24
- <a href="/">Home</a>
24
+ <a class="footer-home" href="/">
25
+ Home
26
+ </a>
25
27
  </li>
26
28
  </ul>
27
29
  </Host>
@@ -1,8 +1,17 @@
1
1
  header {
2
+ background-color: #0093ee;
3
+ }
4
+
5
+ header .header-inner {
2
6
  display: grid;
3
7
  grid-template-columns: 1fr auto auto;
4
8
  padding: 10px;
5
- background-color: #0093ee;
9
+ max-width: 800px;
10
+ margin: 0 auto;
11
+ }
12
+
13
+ .full-screen header .header-inner {
14
+ max-width: 100%;
6
15
  }
7
16
 
8
17
  header a {
@@ -3,43 +3,35 @@ import { useLocation } from '@builder.io/qwik-city';
3
3
  import styles from './header.css?inline';
4
4
 
5
5
  export default component$(
6
- (props: { fullWidth?: boolean }) => {
6
+ () => {
7
7
  useStyles$(styles);
8
8
 
9
9
  const pathname = useLocation().pathname;
10
10
 
11
11
  return (
12
- <Host class={{ 'full-width': !!props.fullWidth }}>
13
- <section>
14
- <a href="/">Qwik City 🏙</a>
15
- </section>
16
- <nav>
17
- <a href="/blog" class={{ active: pathname === '/blog' }}>
18
- Blog
19
- </a>
20
- <a href="/docs" class={{ active: pathname === '/docs' }}>
21
- Docs
22
- </a>
23
- <a href="/api" class={{ active: pathname === '/api' }}>
24
- API
25
- </a>
26
- <a href="/about-us" class={{ active: pathname === '/about-us' }}>
27
- About Us
28
- </a>
29
- <a href="/sign-in" class={{ active: pathname === '/sign-in' }}>
30
- Sign In
31
- </a>
32
- </nav>
33
- {/* <button
34
- class="theme-toggle"
35
- onClick$={() => {
36
- if (themeCtx.theme === 'light') {
37
- themeCtx.theme = 'dark';
38
- } else {
39
- themeCtx.theme = 'light';
40
- }
41
- }}
42
- /> */}
12
+ <Host>
13
+ <div class="header-inner">
14
+ <section class="logo">
15
+ <a href="/">Qwik City 🏙</a>
16
+ </section>
17
+ <nav>
18
+ <a href="/blog" class={{ active: pathname.startsWith('/blog') }}>
19
+ Blog
20
+ </a>
21
+ <a href="/docs" class={{ active: pathname.startsWith('/docs') }}>
22
+ Docs
23
+ </a>
24
+ <a href="/api" class={{ active: pathname.startsWith('/api') }}>
25
+ API
26
+ </a>
27
+ <a href="/products/hat" class={{ active: pathname.startsWith('/products') }}>
28
+ Products
29
+ </a>
30
+ <a href="/about-us" class={{ active: pathname.startsWith('/about-us') }}>
31
+ About Us
32
+ </a>
33
+ </nav>
34
+ </div>
43
35
  </Host>
44
36
  );
45
37
  },
@@ -1,3 +1,13 @@
1
1
  .menu {
2
2
  background: #eee;
3
+ padding: 20px 10px;
4
+ }
5
+
6
+ .menu h5 {
7
+ margin: 0;
8
+ }
9
+
10
+ .menu ul {
11
+ padding-left: 20px;
12
+ margin: 5px 0 25px 0;
3
13
  }
@@ -1,12 +1,12 @@
1
1
  import { component$, Host, useScopedStyles$ } from '@builder.io/qwik';
2
- import { useContentMenu, useLocation } from '@builder.io/qwik-city';
2
+ import { useContent, Link, useLocation } from '@builder.io/qwik-city';
3
3
  import styles from './menu.css?inline';
4
4
 
5
5
  export const Menu = component$(
6
6
  () => {
7
7
  useScopedStyles$(styles);
8
8
 
9
- const menu = useContentMenu();
9
+ const { menu } = useContent();
10
10
  const loc = useLocation();
11
11
 
12
12
  return (
@@ -18,14 +18,14 @@ export const Menu = component$(
18
18
  <ul>
19
19
  {item.items?.map((item) => (
20
20
  <li>
21
- <a
21
+ <Link
22
22
  href={item.href}
23
23
  class={{
24
24
  'is-active': loc.pathname === item.href,
25
25
  }}
26
26
  >
27
27
  {item.text}
28
- </a>
28
+ </Link>
29
29
  </li>
30
30
  ))}
31
31
  </ul>
@@ -1,15 +1,24 @@
1
- html {
2
- line-height: 1.5;
3
- -webkit-text-size-adjust: 100%;
4
- -moz-tab-size: 4;
5
- -o-tab-size: 4;
6
- tab-size: 4;
7
- font-family: ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto,
8
- 'Helvetica Neue', Arial, 'Noto Sans', sans-serif, 'Apple Color Emoji', 'Segoe UI Emoji',
9
- 'Segoe UI Symbol', 'Noto Color Emoji';
10
- }
11
-
12
1
  body {
2
+ margin: 0;
13
3
  padding: 0;
14
- line-height: inherit;
4
+ font-family: system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue',
5
+ sans-serif;
6
+ }
7
+
8
+ main {
9
+ padding: 10px 20px;
10
+ max-width: 800px;
11
+ margin: 0 auto;
12
+ }
13
+
14
+ .full-screen main {
15
+ max-width: 100%;
16
+ }
17
+
18
+ a {
19
+ color: #006eb3;
20
+ }
21
+
22
+ a:hover {
23
+ text-decoration: none;
15
24
  }
@@ -12,8 +12,6 @@ export default component$(() => {
12
12
  );
13
13
  });
14
14
 
15
- export const head: DocumentHead = () => {
16
- return {
17
- title: 'About US',
18
- };
15
+ export const head: DocumentHead = {
16
+ title: 'About Us',
19
17
  };
@@ -3,30 +3,19 @@ import os from 'os';
3
3
 
4
4
  export const onGet: EndpointHandler = ({ request, params }) => {
5
5
  return {
6
- status: 200,
7
- body: {
8
- timestamp: Date.now(),
9
- method: request.method,
10
- url: request.url,
11
- params,
12
- os: os.platform(),
13
- arch: os.arch(),
14
- node: process.versions.node,
15
- },
6
+ timestamp: Date.now(),
7
+ method: request.method,
8
+ url: request.url,
9
+ params,
10
+ os: os.platform(),
11
+ arch: os.arch(),
12
+ node: process.versions.node,
16
13
  };
17
14
  };
18
15
 
19
- export const onPost: EndpointHandler = async ({ request, params }) => {
20
- return {
21
- status: 200,
22
- body: {
23
- timestamp: Date.now(),
24
- method: request.method,
25
- url: request.url,
26
- params,
27
- os: os.platform(),
28
- arch: os.arch(),
29
- node: process.versions.node,
30
- },
31
- };
16
+ export const onPost: EndpointHandler = async ({ request, response }) => {
17
+ response.headers.set('Content-Type', 'text/plain');
18
+ return `Platform: ${os.platform()}, Node: ${process.versions.node}, HTTP Method: ${
19
+ request.method
20
+ }`;
32
21
  };
@@ -1,38 +1,32 @@
1
1
  import { component$, Host, Slot, useScopedStyles$ } from '@builder.io/qwik';
2
2
  import type { DocumentHead } from '@builder.io/qwik-city';
3
- import Footer from '../../../components/footer/footer';
4
- import Header from '../../../components/header/header';
5
3
  import styles from './api.css?inline';
6
4
 
7
5
  export default component$(() => {
8
6
  useScopedStyles$(styles);
9
7
 
10
8
  return (
11
- <Host>
12
- <Header fullWidth={true} />
13
- <main class="api">
14
- <aside class="api-menu">
15
- <h2>API</h2>
16
- <ul>
17
- <li>
18
- <a href="/api/builder.io/oss.json">Org/User</a>
19
- </li>
20
- <li>
21
- <a href="/api/data.json">Data</a>
22
- </li>
23
- </ul>
24
- </aside>
25
- <section class="api-content">
26
- <Slot />
27
- </section>
28
- </main>
29
- <Footer />
9
+ <Host class="api">
10
+ <aside class="api-menu">
11
+ <h2>API</h2>
12
+ <ul>
13
+ <li>
14
+ <a href="/api/builder.io/oss.json">Org/User</a>
15
+ </li>
16
+ <li>
17
+ <a href="/api/data.json">Data</a>
18
+ </li>
19
+ </ul>
20
+ </aside>
21
+ <section class="api-content">
22
+ <Slot />
23
+ </section>
30
24
  </Host>
31
25
  );
32
26
  });
33
27
 
34
28
  export const head: DocumentHead = ({ pathname }) => {
35
29
  return {
36
- title: pathname,
30
+ title: `API: ${pathname}`,
37
31
  };
38
32
  };
@@ -3,14 +3,11 @@ import os from 'os';
3
3
 
4
4
  export const onGet: EndpointHandler = ({ request }) => {
5
5
  return {
6
- status: 200,
7
- body: {
8
- timestamp: Date.now(),
9
- method: request.method,
10
- url: request.url,
11
- os: os.platform(),
12
- arch: os.arch(),
13
- node: process.versions.node,
14
- },
6
+ timestamp: Date.now(),
7
+ method: request.method,
8
+ url: request.url,
9
+ os: os.platform(),
10
+ arch: os.arch(),
11
+ node: process.versions.node,
15
12
  };
16
13
  };
@@ -1,7 +1,7 @@
1
1
  import { component$, Host, useClientEffect$, useStore } from '@builder.io/qwik';
2
2
 
3
3
  export default component$(() => {
4
- const store = useStore({ timestamp: 0, os: '', arch: '', node: '' });
4
+ const store = useStore({ timestamp: '', os: '', arch: '', node: '' });
5
5
 
6
6
  useClientEffect$(async () => {
7
7
  const url = `/api/builder.io/oss.json`;
@@ -28,9 +28,12 @@ export default component$(() => {
28
28
  </ul>
29
29
 
30
30
  <p>Timestamp: {store.timestamp}</p>
31
- <p>OS: {store.os}</p>
32
- <p>Arch: {store.arch}</p>
33
- <p>Node: {store.node}</p>
31
+ <p>
32
+ Node: <span>{store.node}</span>
33
+ </p>
34
+ <p>
35
+ OS: <span>{store.os}</span>
36
+ </p>
34
37
  </Host>
35
38
  );
36
39
  });
@@ -1,13 +1,36 @@
1
- import { component$, Host } from '@builder.io/qwik';
2
- import { useLocation } from '@builder.io/qwik-city';
1
+ import { component$, Host, Resource } from '@builder.io/qwik';
2
+ import { useEndpoint, DocumentHead, EndpointHandler } from '@builder.io/qwik-city';
3
3
 
4
4
  export default component$(() => {
5
- const { pathname, params } = useLocation();
5
+ const resource = useEndpoint<EndpointData>();
6
6
 
7
7
  return (
8
8
  <Host>
9
- <h1>Blog {pathname}</h1>
10
- <p>Slug: {params.slug}</p>
9
+ <Resource
10
+ resource={resource}
11
+ onResolved={(blog) => (
12
+ <>
13
+ <h1>{blog.blogTitle}</h1>
14
+ <p>{blog.blogContent}</p>
15
+ </>
16
+ )}
17
+ />
11
18
  </Host>
12
19
  );
13
20
  });
21
+
22
+ export const onGet: EndpointHandler<EndpointData> = async ({ params, request }) => {
23
+ return {
24
+ blogTitle: `Blog: ${params.slug}`,
25
+ blogContent: `${params.slug}, ${request.url}`,
26
+ };
27
+ };
28
+
29
+ export const head: DocumentHead<EndpointData> = ({ data }) => {
30
+ return { title: data?.blogTitle };
31
+ };
32
+
33
+ export interface EndpointData {
34
+ blogTitle: string;
35
+ blogContent: string;
36
+ }
@@ -9,10 +9,10 @@ export default component$(() => {
9
9
  <aside class="blog-menu">
10
10
  <ul>
11
11
  <li>
12
- <a href="/blog/how-to-use-a-toaster">How to use a toaster</a>
12
+ <a href="/blog/what-is-resumability">What Is Resumability?</a>
13
13
  </li>
14
14
  <li>
15
- <a href="/blog/how-to-crack-an-egg">How to crack an egg</a>
15
+ <a href="/blog/serializing-props">Serializing Props</a>
16
16
  </li>
17
17
  </ul>
18
18
  </aside>
@@ -1,9 +1,17 @@
1
1
  import { component$, Host } from '@builder.io/qwik';
2
+ import type { DocumentHead } from '@builder.io/qwik-city';
2
3
 
3
4
  export default component$(() => {
4
5
  return (
5
6
  <Host>
6
7
  <h1>Dashboard</h1>
8
+ <p>
9
+ <a href="/sign-out">Sign Out</a>
10
+ </p>
7
11
  </Host>
8
12
  );
9
13
  });
14
+
15
+ export const head: DocumentHead = {
16
+ title: 'Dashboard',
17
+ };
@@ -1,15 +1,23 @@
1
1
  import { component$, Host } from '@builder.io/qwik';
2
- import { useLocation } from '@builder.io/qwik-city';
2
+ import { useLocation, DocumentHead } from '@builder.io/qwik-city';
3
3
 
4
4
  export default component$(() => {
5
- const loc = useLocation();
5
+ const { pathname, params } = useLocation();
6
6
 
7
7
  return (
8
8
  <Host>
9
- <h1>Docs</h1>
10
- <p>pathname: {loc.pathname}</p>
11
- <p>category: {loc.params.category}</p>
12
- <p>id: {loc.params.id}</p>
9
+ <h1>
10
+ Docs: {params.category} {params.id}
11
+ </h1>
12
+ <p>pathname: {pathname}</p>
13
+ <p>category: {params.category}</p>
14
+ <p>id: {params.id}</p>
13
15
  </Host>
14
16
  );
15
17
  });
18
+
19
+ export const head: DocumentHead = ({ params }) => {
20
+ return {
21
+ title: `${params.category} ${params.id}`,
22
+ };
23
+ };
@@ -1,7 +1,8 @@
1
- .docs {
1
+ .docs main {
2
2
  display: grid;
3
3
  grid-template-columns: 200px 1fr;
4
4
  padding: 0;
5
+ margin: 0;
5
6
  }
6
7
 
7
8
  .docs-content {
@@ -0,0 +1,31 @@
1
+ import { component$, Host, Slot, useStyles$ } from '@builder.io/qwik';
2
+ import type { DocumentHead } from '@builder.io/qwik-city';
3
+ import { Breadcrumbs } from '../../../components/breadcrumbs/breadcrumbs';
4
+ import Footer from '../../../components/footer/footer';
5
+ import Header from '../../../components/header/header';
6
+ import { Menu } from '../../../components/menu/menu';
7
+ import styles from './index.css?inline';
8
+
9
+ export default component$(() => {
10
+ useStyles$(styles);
11
+
12
+ return (
13
+ <Host class="docs full-screen">
14
+ <Header />
15
+ <main>
16
+ <Menu />
17
+ <section class="docs-content">
18
+ <Breadcrumbs />
19
+ <Slot />
20
+ <Footer />
21
+ </section>
22
+ </main>
23
+ </Host>
24
+ );
25
+ });
26
+
27
+ export const head: DocumentHead = ({ head }) => {
28
+ return {
29
+ title: `Docs: ${head.title}`,
30
+ };
31
+ };
@@ -1,9 +1,11 @@
1
1
  # Docs
2
2
 
3
- ## Getting Started
3
+ ## Introduction
4
4
 
5
- - [Introduction](introduction/index.md)
5
+ - [Overview](overview/index.md)
6
+ - [Getting Started](getting-started.md)
6
7
 
7
8
  ## Components
8
9
 
9
10
  - [Basics](/docs/components/basics)
11
+ - [Listeners](/docs/components/listeners)
@@ -0,0 +1,44 @@
1
+ ---
2
+ title: Getting Started
3
+ ---
4
+
5
+ # Getting Started
6
+
7
+ ## Creating an app using the CLI
8
+
9
+ The first step is to create an application. Qwik comes with a CLI that allows you to create a basic working skeleton of an application. We will use the CLI to create a Todo sample app, and we will use that application to do a walk-through of Qwik so that you can familiarize yourself with it.
10
+
11
+ ## Running in development
12
+
13
+ Once the application is download.
14
+
15
+ 1. Change into the directory created by the `npm create qwik@latest`.
16
+
17
+ ```shell
18
+ cd qwik-todo
19
+ ```
20
+
21
+ 2. Install NPM modules:
22
+
23
+ ```shell
24
+ npm install
25
+ ```
26
+
27
+ 3. Invoke the dev server
28
+
29
+ ```shell
30
+ npm start
31
+ ```
32
+
33
+ 4. You should see a server running with your To-do application
34
+
35
+ ```shell
36
+ vite v2.8.6 dev server running at:
37
+
38
+ > Local: http://localhost:3000/
39
+ > Network: use `--host` to expose
40
+
41
+ ready in 157ms.
42
+ ```
43
+
44
+ 5. Visit http://localhost:3000/ to explore the To-do app.
@@ -9,8 +9,6 @@ export default component$(() => {
9
9
  );
10
10
  });
11
11
 
12
- export const head: DocumentHead = () => {
13
- return {
14
- title: 'Welcome!',
15
- };
12
+ export const head: DocumentHead = {
13
+ title: 'Welcome!',
16
14
  };
@@ -1,7 +1,7 @@
1
1
  ---
2
- title: Introduction
2
+ title: Overview
3
3
  ---
4
4
 
5
- # Introduction
5
+ # Overview
6
6
 
7
7
  Qwik is a new kind of web framework that can deliver instant loading web applications at any size or complexity. Your sites and apps can boot with less than 1kb of JS (_including_ your code, regardless of complexity), and achieve unheard of performance at scale.
@@ -1,11 +1,16 @@
1
1
  import { component$, Host } from '@builder.io/qwik';
2
+ import type { DocumentHead } from '@builder.io/qwik-city';
2
3
 
3
4
  export default component$(() => {
4
5
  return (
5
6
  <Host>
6
- <h1>Welcome to QwikCity</h1>
7
+ <h1 onClick$={() => console.warn('hola')}>Welcome to Qwik City</h1>
7
8
 
8
9
  <p>The meta-framework for Qwik.</p>
9
10
  </Host>
10
11
  );
11
12
  });
13
+
14
+ export const head: DocumentHead = {
15
+ title: 'Welcome to Qwik City',
16
+ };