diff --git a/packages/docs/pages/examples/examples-menu.json b/packages/docs/pages/examples/examples-menu.json index 85e6cc32475..a5b3cd5d032 100644 --- a/packages/docs/pages/examples/examples-menu.json +++ b/packages/docs/pages/examples/examples-menu.json @@ -1,12 +1,35 @@ [ { - "id": "hello-world", - "title": "Hello World", - "description": "The simplest qwik app" + "id": "introduction", + "title": "Introduction", + "apps": [ + { + "id": "hello-world", + "title": "Hello World", + "description": "The simplest Qwik app." + } + ] }, { - "id": "counter", - "title": "Counter", - "description": "A simple standard counter example" + "id": "reactivity", + "title": "Reactivity", + "apps": [ + { + "id": "counter", + "title": "Counter", + "description": "A simple standard counter example." + } + ] + }, + { + "id": "visibility", + "title": "Visibility", + "apps": [ + { + "id": "clock", + "title": "Below the fold Clock", + "description": "Component which requires lazy initialization when it comes into view." + } + ] } ] diff --git a/packages/docs/pages/playground/hello-world/app.tsx b/packages/docs/pages/examples/introduction/hello-world/app.tsx similarity index 73% rename from packages/docs/pages/playground/hello-world/app.tsx rename to packages/docs/pages/examples/introduction/hello-world/app.tsx index 46e5b732433..62b4c088796 100644 --- a/packages/docs/pages/playground/hello-world/app.tsx +++ b/packages/docs/pages/examples/introduction/hello-world/app.tsx @@ -1,5 +1,5 @@ import { component$ } from '@builder.io/qwik'; export const App = component$(() => { - return
Hello Qwik
; + return

Hello Qwik

; }); diff --git a/packages/docs/pages/examples/counter/entry.server.tsx b/packages/docs/pages/examples/introduction/hello-world/entry.server.tsx similarity index 100% rename from packages/docs/pages/examples/counter/entry.server.tsx rename to packages/docs/pages/examples/introduction/hello-world/entry.server.tsx diff --git a/packages/docs/pages/examples/hello-world/root.tsx b/packages/docs/pages/examples/introduction/hello-world/root.tsx similarity index 100% rename from packages/docs/pages/examples/hello-world/root.tsx rename to packages/docs/pages/examples/introduction/hello-world/root.tsx diff --git a/packages/docs/pages/examples/counter/app.tsx b/packages/docs/pages/examples/reactivity/counter/app.tsx similarity index 100% rename from packages/docs/pages/examples/counter/app.tsx rename to packages/docs/pages/examples/reactivity/counter/app.tsx diff --git a/packages/docs/pages/examples/hello-world/entry.server.tsx b/packages/docs/pages/examples/reactivity/counter/entry.server.tsx similarity index 100% rename from packages/docs/pages/examples/hello-world/entry.server.tsx rename to packages/docs/pages/examples/reactivity/counter/entry.server.tsx diff --git a/packages/docs/pages/examples/counter/root.tsx b/packages/docs/pages/examples/reactivity/counter/root.tsx similarity index 100% rename from packages/docs/pages/examples/counter/root.tsx rename to packages/docs/pages/examples/reactivity/counter/root.tsx diff --git a/packages/docs/pages/examples/visibility/clock/app.tsx b/packages/docs/pages/examples/visibility/clock/app.tsx new file mode 100644 index 00000000000..57adbadc35b --- /dev/null +++ b/packages/docs/pages/examples/visibility/clock/app.tsx @@ -0,0 +1,56 @@ +import { component$, useStore, useStyles$, useClientEffect$ } from '@builder.io/qwik'; +import styles from './clock.css'; + +export const App = component$(() => { + const items = new Array(40).fill(null).map((_, index) => 'item ' + index); + + return ( +
+

This is an example of Lazy executing code on component when component becomes visible.

+ +

+ ⬇️ Scroll down until the clock is in view. +

+ + + + +
+ ); +}); + +export const Clock = component$(() => { + useStyles$(styles); + + const store = useStore({ + hour: 10, + minute: 20, + second: 30, + }); + + useClientEffect$(() => { + const tmrId = setInterval(() => { + const now = new Date(); + store.second = (now.getSeconds() * 60) / 360; + store.minute = (now.getMinutes() * 60) / 360; + store.hour = (now.getHours() * 60) / 360; + }, 1000); + return () => clearInterval(tmrId); + }); + + return ( +
+
+
+
+
+
+
+
+
+ ); +}); diff --git a/packages/docs/pages/examples/visibility/clock/clock.css b/packages/docs/pages/examples/visibility/clock/clock.css new file mode 100644 index 00000000000..a8529f15d64 --- /dev/null +++ b/packages/docs/pages/examples/visibility/clock/clock.css @@ -0,0 +1,92 @@ +/* Clock inspired by: https://paulund.co.uk/create-a-clock-in-css */ + +.clock { + background: #fff; + border: 10px solid #7a7a7a; + border-radius: 50%; + box-sizing: border-box; + height: 300px; + margin: 0 auto; + position: relative; + width: 300px; +} + +.twelve, +.three, +.six, +.nine { + background: #333; + position: absolute; +} + +.twelve, +.six { + height: 10px; + width: 4px; +} + +.three, +.nine { + height: 4px; + width: 10px; +} + +.twelve { + left: 50%; + top: -1px; +} + +.three { + right: -1px; + top: 50%; +} + +.six { + left: 50%; + bottom: -1px; +} + +.nine { + left: -1px; + top: 50%; +} + +.hour { + height: 120px; + width: 4px; + background: #333; + position: absolute; + left: 50%; + top: 20px; + animation: tick 43200s infinite linear; + -webkit-animation: tick 43200s infinite linear; +} + +.minute { + height: 100px; + width: 4px; + background: #777; + position: absolute; + left: 50%; + top: 40px; + animation: tick 3600s infinite linear; + -webkit-animation: tick 3600s infinite linear; +} + +.second { + height: 60px; + width: 4px; + background: #fc0505; + position: absolute; + left: 50%; + top: 80px; + animation: tick 60s infinite linear; + -webkit-animation: tick 60s infinite linear; +} + +.hour, +.minute, +.second { + transform-origin: 2px 100%; + -webkit-transform-origin: 2px 100%; +} diff --git a/packages/docs/pages/playground/counter/entry.server.tsx b/packages/docs/pages/examples/visibility/clock/entry.server.tsx similarity index 100% rename from packages/docs/pages/playground/counter/entry.server.tsx rename to packages/docs/pages/examples/visibility/clock/entry.server.tsx diff --git a/packages/docs/pages/playground/counter/root.tsx b/packages/docs/pages/examples/visibility/clock/root.tsx similarity index 84% rename from packages/docs/pages/playground/counter/root.tsx rename to packages/docs/pages/examples/visibility/clock/root.tsx index 72d9c413835..b94f106c4eb 100644 --- a/packages/docs/pages/playground/counter/root.tsx +++ b/packages/docs/pages/examples/visibility/clock/root.tsx @@ -4,7 +4,7 @@ export const Root = () => { return ( - Counter + Clockk diff --git a/packages/docs/pages/examples/hello-world/app.tsx b/packages/docs/pages/playground/app/app.tsx similarity index 100% rename from packages/docs/pages/examples/hello-world/app.tsx rename to packages/docs/pages/playground/app/app.tsx diff --git a/packages/docs/pages/playground/hello-world/entry.server.tsx b/packages/docs/pages/playground/app/entry.server.tsx similarity index 100% rename from packages/docs/pages/playground/hello-world/entry.server.tsx rename to packages/docs/pages/playground/app/entry.server.tsx diff --git a/packages/docs/pages/playground/hello-world/root.tsx b/packages/docs/pages/playground/app/root.tsx similarity index 100% rename from packages/docs/pages/playground/hello-world/root.tsx rename to packages/docs/pages/playground/app/root.tsx diff --git a/packages/docs/pages/playground/counter/app.tsx b/packages/docs/pages/playground/counter/app.tsx deleted file mode 100644 index 59fb94682b3..00000000000 --- a/packages/docs/pages/playground/counter/app.tsx +++ /dev/null @@ -1,14 +0,0 @@ -import { component$, useStore } from '@builder.io/qwik'; - -export const App = component$(() => { - const store = useStore({ count: 0 }); - - return ( -
-

Count: {store.count}

-

- -

-
- ); -}); diff --git a/packages/docs/pages/playground/playground-menu.json b/packages/docs/pages/playground/playground-menu.json deleted file mode 100644 index 5c84414ca00..00000000000 --- a/packages/docs/pages/playground/playground-menu.json +++ /dev/null @@ -1,6 +0,0 @@ -[ - { - "id": "hello-world", - "title": "Hello World" - } -] diff --git a/packages/docs/pages/tutorial/tutorial-menu.json b/packages/docs/pages/tutorial/tutorial-menu.json index 38a2091897d..43e2f5d9107 100644 --- a/packages/docs/pages/tutorial/tutorial-menu.json +++ b/packages/docs/pages/tutorial/tutorial-menu.json @@ -2,7 +2,7 @@ { "id": "introduction", "title": "Introduction", - "tutorials": [ + "apps": [ { "id": "basics", "title": "Basics", @@ -22,7 +22,7 @@ { "id": "reactivity", "title": "Reactivity", - "tutorials": [ + "apps": [ { "id": "assignments", "title": "Assignments" diff --git a/packages/docs/public/_headers b/packages/docs/public/_headers index 3229ebb88f6..62d62e107f2 100644 --- a/packages/docs/public/_headers +++ b/packages/docs/public/_headers @@ -1,6 +1,6 @@ /build/* Cache-Control: public, max-age=31536000, s-maxage=31536000, immutable -/repl/ +/repl/repl-server Cross-Origin-Embedder-Policy: require-corp Cross-Origin-Resource-Policy: cross-origin diff --git a/packages/docs/public/logos/qwik.svg b/packages/docs/public/logos/qwik.svg index a97c1bea5ec..91088ea3d30 100644 --- a/packages/docs/public/logos/qwik.svg +++ b/packages/docs/public/logos/qwik.svg @@ -1 +1 @@ - \ No newline at end of file + \ No newline at end of file diff --git a/packages/docs/public/repl/index.html b/packages/docs/public/repl/index.html deleted file mode 100644 index 5dea08a9677..00000000000 --- a/packages/docs/public/repl/index.html +++ /dev/null @@ -1,110 +0,0 @@ - - - - - - - - diff --git a/packages/docs/public/repl/repl-server.html b/packages/docs/public/repl/repl-server.html new file mode 100644 index 00000000000..5da575e2c99 --- /dev/null +++ b/packages/docs/public/repl/repl-server.html @@ -0,0 +1,129 @@ + + + + + Qwik REPL Server + + + + + + diff --git a/packages/docs/src/components/app/global.css b/packages/docs/src/components/app/global.css index 08a0a1237a9..c9193a243e0 100644 --- a/packages/docs/src/components/app/global.css +++ b/packages/docs/src/components/app/global.css @@ -22,7 +22,7 @@ pre[class*='language-'] { html { --header-height: 56px; --repl-tab-height: 56px; - --repl-tab-bg-color: rgb(195 231 255); + --repl-tab-bg-color: #daf0ff; } a, diff --git a/packages/docs/src/components/header/header.css b/packages/docs/src/components/header/header.css index d196491213f..97d7b5bb180 100644 --- a/packages/docs/src/components/header/header.css +++ b/packages/docs/src/components/header/header.css @@ -1,5 +1,5 @@ header { - @apply text-slate-200; + color: white; background: #0099ff; box-shadow: 0px 2px 7px #0000003d; } @@ -9,34 +9,39 @@ header li { @apply py-4 md:py-0; } -header li:hover { +header a:hover { text-decoration: underline; } +header li a:hover svg { + opacity: 0.8; +} + header ul { @apply hidden md:block; @apply pt-14 pb-6 md:pt-0; } header .more-icon { - @apply block; + display: block; } header .close-icon { - @apply hidden; + display: none; } @media (max-width: 767px) { .header-open header ul { - @apply block; + display: block; + background: #0099ff; } .header-open header .more-icon { - @apply hidden; + display: none; } .header-open header .close-icon { - @apply block; + display: block; } } @@ -49,7 +54,7 @@ header .header-inner { } header .header-logo { - @apply fixed top-[13px] left-[max(0px,calc(50%-45rem))] pl-4; + @apply fixed top-[5px] left-[max(0px,calc(50%-45rem))] pl-4; } .full-width header .header-logo { diff --git a/packages/docs/src/components/header/header.tsx b/packages/docs/src/components/header/header.tsx index 5267a62d736..9e9c592be90 100644 --- a/packages/docs/src/components/header/header.tsx +++ b/packages/docs/src/components/header/header.tsx @@ -25,9 +25,9 @@ export const Header = component$(
- + Qwik Homepage - +
); diff --git a/packages/docs/src/components/repl/repl-input-panel.tsx b/packages/docs/src/components/repl/repl-input-panel.tsx index d0874aeb9d1..3c0573450f7 100644 --- a/packages/docs/src/components/repl/repl-input-panel.tsx +++ b/packages/docs/src/components/repl/repl-input-panel.tsx @@ -2,17 +2,18 @@ import type { QRL } from '@builder.io/qwik'; import { Editor } from './editor'; import { ReplTabButton } from './repl-tab-button'; import { ReplTabButtons } from './repl-tab-buttons'; -import type { ReplStore } from './types'; +import type { ReplStore, ReplModuleInput } from './types'; export const ReplInputPanel = ({ store, + inputs, onInputChangeQrl, onInputDeleteQrl, }: ReplInputPanelProps) => { return (
- {store.inputs.map((input) => + {inputs.map((input) => input.hidden ? null : (
@@ -54,6 +55,7 @@ const formatFilePath = (path: string) => { interface ReplInputPanelProps { store: ReplStore; + inputs: ReplModuleInput[]; onInputChangeQrl: QRL<(path: string, code: string) => void>; onInputDeleteQrl: QRL<(path: string) => void>; } diff --git a/packages/docs/src/components/repl/repl-options.tsx b/packages/docs/src/components/repl/repl-options.tsx index e4a8bab1d74..bee3cc99b11 100644 --- a/packages/docs/src/components/repl/repl-options.tsx +++ b/packages/docs/src/components/repl/repl-options.tsx @@ -1,10 +1,8 @@ import type { ReplStore } from './types'; export const ReplOptions = ({ store }: ReplOptionsProps) => { - const versions = filterVersions(store.versions, store.version); - return ( -
+
{
); }; -const filterVersions = (versions: string[], version: string | undefined) => { - if (!versions) { - if (version) { - return [version]; - } else { - return []; - } - } - - return versions.filter((v) => { - if (v === version) { - return true; - } - if (v.includes('-')) { - return false; - } - const parts = v.split('.'); - if (parts.length !== 3) { - return false; - } - if (isNaN(parts[2] as any)) { - return false; - } - if (parts[0] === '0' && parts[1] === '0') { - if (parseInt(parts[2], 10) < 20) { - return false; - } - } - return true; - }); -}; - const StoreOption = (props: StoreOptionProps) => { return (