docs: 📝 update docs

This commit is contained in:
Leifer Mendez
2022-12-22 10:15:29 +01:00
parent 331e5b0f8e
commit 5ee5973911
65 changed files with 2000 additions and 1 deletions

View File

@@ -0,0 +1,3 @@
export const DarkThemeLauncher = () => (
<script>{`if(localStorage.theme==="dark"){document.documentElement.classList.add("dark");}else if(typeof localStorage.theme==="undefined"){if(window.matchMedia("(prefers-color-scheme: dark)").matches){document.documentElement.classList.add("dark");}}`}</script>
)

View File

@@ -0,0 +1,35 @@
import { component$ } from '@builder.io/qwik'
import { useDocumentHead, useLocation } from '@builder.io/qwik-city'
/**
* The RouterHead component is placed inside of the document `<head>` element.
*/
export const RouterHead = component$(() => {
const head = useDocumentHead()
const loc = useLocation()
return (
<>
<title>{head.title}</title>
<link rel="canonical" href={loc.href} />
<meta
name="viewport"
content="width=device-width, initial-scale=1.0"
/>
<link rel="icon" type="image/svg+xml" href="/favicon.svg" />
{head.meta.map((m) => (
<meta {...m} />
))}
{head.links.map((l) => (
<link {...l} />
))}
{head.styles.map((s) => (
<style {...s.props} dangerouslySetInnerHTML={s.style} />
))}
</>
)
})

View File

@@ -0,0 +1,38 @@
import { component$, useStore } from '@builder.io/qwik'
import { IconMenu } from '~/components/icons/IconMenu'
interface ItemProps {
iconClass?: string
}
export default component$((props: ItemProps) => {
const { iconClass } = props
const store = useStore({
isExpanded: false,
})
return (
<button
type="button"
class={`ml-1.5 text-gray-500 dark:text-gray-400 hover:bg-gray-100 dark:hover:bg-gray-800 focus:outline-none focus:ring-4 focus:ring-gray-200 dark:focus:ring-gray-700 rounded-lg text-sm p-2.5 inline-flex items-center transition ${
store.isExpanded ? 'expanded' : ''
}`}
aria-label="Toggle Menu"
data-aw-toggle-menu={true}
onClick$={() => {
store.isExpanded = store.isExpanded ? false : true
// TODO:
document.body.classList.toggle('overflow-hidden')
document.getElementById('header')?.classList.toggle('h-screen')
document
.querySelector('#header nav')
?.classList.toggle('hidden')
}}
>
<IconMenu class={iconClass} />
</button>
)
})

View File

@@ -0,0 +1,52 @@
import { component$, useStore, useClientEffect$ } from '@builder.io/qwik'
import { IconSun } from '~/components/icons/IconSun'
import { IconMoon } from '../icons/IconMoon'
interface ItemProps {
iconClass?: string
}
export default component$((props: ItemProps) => {
const { iconClass } = props
const store = useStore({
theme:
(typeof window !== 'undefined' && window?.localStorage?.theme) ||
undefined,
})
useClientEffect$(() => {
store.theme =
window.localStorage.theme === 'dark' ||
(!('theme' in window.localStorage) &&
window.matchMedia('(prefers-color-scheme: dark)').matches)
? 'dark'
: 'light'
})
return (
<button
type="button"
class="text-gray-500 dark:text-gray-400 hover:bg-gray-100 dark:hover:bg-gray-700 focus:outline-none focus:ring-4 focus:ring-gray-200 dark:focus:ring-gray-700 rounded-lg text-sm p-2.5 inline-flex items-center"
aria-label="Toggle between Dark and Light mode"
onClick$={() => {
switch (store.theme) {
case 'dark':
document.documentElement.classList.remove('dark')
store.theme = window.localStorage.theme = 'light'
break
default:
document.documentElement.classList.add('dark')
store.theme = window.localStorage.theme = 'dark'
break
}
}}
>
{store.theme == 'dark' ? (
<IconMoon class={iconClass} />
) : (
<IconSun class={iconClass} />
)}
</button>
)
})