summaryrefslogtreecommitdiff
path: root/docs
diff options
context:
space:
mode:
Diffstat (limited to 'docs')
-rw-r--r--docs/public/index.css83
-rw-r--r--docs/public/theme.css6
-rw-r--r--docs/src/components/DocSidebar.tsx4
-rw-r--r--docs/src/components/SiteSidebar.astro15
-rw-r--r--docs/src/components/ThemeToggle.tsx52
-rw-r--r--docs/src/layouts/Main.astro76
6 files changed, 96 insertions, 140 deletions
diff --git a/docs/public/index.css b/docs/public/index.css
index 34acc7803..06995827c 100644
--- a/docs/public/index.css
+++ b/docs/public/index.css
@@ -47,7 +47,7 @@ nav ul {
:is(h1, h2, h3, h4, h5, h6) {
margin-bottom: 1rem;
font-weight: bold;
- line-height: 1.25;
+ line-height: 1.0;
}
:is(h1, h2) {
@@ -59,11 +59,11 @@ nav ul {
}
h1 {
- font-size: 1.75rem;
+ font-size: 2.25rem;
}
h2 {
- font-size: 1.25rem;
+ font-size: 1.5rem;
}
h3 {
@@ -78,13 +78,14 @@ h5 {
font-size: 0.8rem;
}
-@media (min-width: 60em) {
+@media (min-width: 50em) {
h1 {
- font-size: 2.5rem;
+ font-size: 3.25rem;
+ font-weight: 800;
}
h2 {
- font-size: 1.75rem;
+ font-size: 2rem;
}
h3 {
@@ -268,10 +269,6 @@ img {
align-items: center;
}
-header {
- position: relative;
- margin-bottom: 0.5rem;
-}
header button {
background-color: var(--theme-bg);
@@ -306,12 +303,12 @@ button {
}
#theme-toggle {
- display: flex;
+ display: inline-flex;
align-items: center;
gap: 0.25em;
padding: 0.33em 0.67em;
border-radius: 99em;
- background-color: hsla(215, 28%, 17%, 1);
+ background-color: var(--theme-code-inline-bg);
}
#theme-toggle > label:focus-within {
@@ -320,27 +317,16 @@ button {
}
#theme-toggle > label {
- color: white;
+ color: var( --theme-code-inline-text);
position: relative;
display: flex;
align-items: center;
justify-content: center;
- font-size: 1.5rem;
- width: 1.5rem;
- height: 1.5rem;
opacity: 0.5;
- transition: transform 120ms ease-out, opacity 120ms ease-out;
-}
-
-#theme-toggle > label:hover,
-#theme-toggle > label:focus {
- transform: scale(1.125);
- opacity: 1;
}
#theme-toggle .checked {
color: var(--theme-accent);
- transform: scale(1.125);
opacity: 1;
}
@@ -362,7 +348,7 @@ input[name='theme-toggle'] {
.sidebar-nav-inner {
height: 100%;
padding: 0;
- padding-top: 2rem;
+ padding-top: var(--doc-padding);
overflow: auto;
}
@@ -467,50 +453,3 @@ h2.heading {
:target {
scroll-margin-top: 4rem;
}
-
-.logo {
- display: flex;
- align-items: center;
- gap: 0;
- font-size: 1rem;
- font-weight: 600;
- margin: 0;
- line-height: 1;
- color: hsla(var(--color-base-white), 100%, 1);
- text-decoration: none;
- transform: translateX(-8px) scale(0.8);
-}
-
-@media (min-width: 60em) {
- .logo {
- transform: translateX(-8px) scale(1);
- }
-}
-
-.logo a {
- padding: 0.5em 0.25em;
- margin: -0.5em -0.5em;
-}
-
-.logo svg {
- height: 40px;
- width: auto;
- display: block;
- color: var(--theme-accent);
-}
-
-.logo a:hover,
-.logo a:focus {
- background: hsla(var(--color-orange), 0.6);
-}
-
-.logo a:hover svg,
-.logo a:focus svg {
- color: hsla(var(--color-base-white), 100%, 1);
-}
-
-.logo h1 {
- font: inherit;
- color: inherit;
- margin: 0;
-}
diff --git a/docs/public/theme.css b/docs/public/theme.css
index 217549b40..c43a9e303 100644
--- a/docs/public/theme.css
+++ b/docs/public/theme.css
@@ -75,8 +75,8 @@
--theme-code-inline-text: var(--theme-text);
--theme-code-bg: hsla(217, 19%, 27%, 1);
--theme-code-text: hsla(var(--color-gray-95), 1);
- --theme-navbar-bg: hsla(217, 19%, 27%, 1);
- --theme-navbar-height: 3.5rem;
+ --theme-navbar-bg: hsla(var(--color-base-white), 100%, 1);
+ --theme-navbar-height: 6rem;
--theme-sidebar-offset: var(--theme-navbar-height);
--theme-selection-color: hsla(var(--color-orange), 1);
--theme-selection-bg: hsla(var(--color-orange), var(--theme-accent-opacity));
@@ -108,7 +108,7 @@ body {
--theme-code-inline-text: hsla(var(--color-base-white), 100%, 1);
--theme-code-bg: hsla(var(--color-gray-5), 1);
--theme-code-text: hsla(var(--color-base-white), 100%, 1);
- --theme-navbar-bg: hsla(221, 39%, 11%, 1);
+ --theme-navbar-bg: hsla(215, 28%, 17%, 1);
--theme-selection-color: hsla(var(--color-base-white), 100%, 1);
--theme-selection-bg: hsla(var(--color-purple), var(--theme-accent-opacity));
}
diff --git a/docs/src/components/DocSidebar.tsx b/docs/src/components/DocSidebar.tsx
index 92f34ff61..e1b2a2b17 100644
--- a/docs/src/components/DocSidebar.tsx
+++ b/docs/src/components/DocSidebar.tsx
@@ -2,6 +2,7 @@ import type { FunctionalComponent } from 'preact';
import { h } from 'preact';
import { useState, useEffect, useRef } from 'preact/hooks';
import EditOnGithub from './EditOnGithub';
+import ThemeToggle from './ThemeToggle';
const DocSidebar: FunctionalComponent<{ headers: any[]; editHref: string }> = ({
headers = [],
@@ -104,6 +105,9 @@ const DocSidebar: FunctionalComponent<{ headers: any[]; editHref: string }> = ({
</a>
</li>
</ul>
+ <div style={{margin: '2rem 0', textAlign: 'center'}}>
+ <ThemeToggle />
+ </div>
</div>
</nav>
);
diff --git a/docs/src/components/SiteSidebar.astro b/docs/src/components/SiteSidebar.astro
index 6503c0414..382b122f4 100644
--- a/docs/src/components/SiteSidebar.astro
+++ b/docs/src/components/SiteSidebar.astro
@@ -47,7 +47,7 @@ const {currentPage} = Astro.props;
}
.nav-groups > :first-child {
- padding-top: 2rem;
+ padding-top: var(--doc-padding);
}
.nav-groups > :last-child {
@@ -87,21 +87,10 @@ const {currentPage} = Astro.props;
color: hsla(var(--color-base-white), 100%, 1);
}
- @media (min-width: 60em) {
- .nav-link a {
- border-radius: 999px;
- border-top-left-radius: 0;
- border-bottom-left-radius: 0;
- }
+ @media (min-width: 50em) {
.nav-groups {
padding: 0;
}
}
- @media (min-width: 86.25em) {
- .nav-link a {
- border-radius: 8px;
- }
- }
-
</style>
diff --git a/docs/src/components/ThemeToggle.tsx b/docs/src/components/ThemeToggle.tsx
index 95de4fba1..e990d8ea4 100644
--- a/docs/src/components/ThemeToggle.tsx
+++ b/docs/src/components/ThemeToggle.tsx
@@ -2,7 +2,7 @@ import type { FunctionalComponent } from 'preact';
import { h, Fragment } from 'preact';
import { useState, useEffect } from 'preact/hooks';
-const themes = ['system', 'light', 'dark'];
+const themes = ['light', 'dark'];
const icons = [
<svg
@@ -13,19 +13,6 @@ const icons = [
fill="currentColor"
>
<path
- fill-rule="evenodd"
- d="M3 5a2 2 0 012-2h10a2 2 0 012 2v8a2 2 0 01-2 2h-2.22l.123.489.804.804A1 1 0 0113 18H7a1 1 0 01-.707-1.707l.804-.804L7.22 15H5a2 2 0 01-2-2V5zm5.771 7H5V5h10v7H8.771z"
- clip-rule="evenodd"
- />
- </svg>,
- <svg
- xmlns="http://www.w3.org/2000/svg"
- width="20"
- height="20"
- viewBox="0 0 20 20"
- fill="currentColor"
- >
- <path
fillRule="evenodd"
d="M10 2a1 1 0 011 1v1a1 1 0 11-2 0V3a1 1 0 011-1zm4 8a4 4 0 11-8 0 4 4 0 018 0zm-.464 4.95l.707.707a1 1 0 001.414-1.414l-.707-.707a1 1 0 00-1.414 1.414zm2.12-10.607a1 1 0 010 1.414l-.706.707a1 1 0 11-1.414-1.414l.707-.707a1 1 0 011.414 0zM17 11a1 1 0 100-2h-1a1 1 0 100 2h1zm-7 4a1 1 0 011 1v1a1 1 0 11-2 0v-1a1 1 0 011-1zM5.05 6.464A1 1 0 106.465 5.05l-.708-.707a1 1 0 00-1.414 1.414l.707.707zm1.414 8.486l-.707.707a1 1 0 01-1.414-1.414l.707-.707a1 1 0 011.414 1.414zM4 11a1 1 0 100-2H3a1 1 0 000 2h1z"
clipRule="evenodd"
@@ -44,39 +31,35 @@ const icons = [
const ThemeToggle: FunctionalComponent = () => {
const [theme, setTheme] = useState(() => {
- if (typeof localStorage === 'undefined') {
- return themes[0];
+ if (import.meta.env.SSR) {
+ return undefined;
}
-
- return localStorage.getItem('theme') || themes[0];
+ if (typeof localStorage !== 'undefined' && localStorage.getItem('theme')) {
+ return localStorage.getItem('theme');
+ }
+ if (window.matchMedia('(prefers-color-scheme: dark)').matches) {
+ return 'dark';
+ }
+ return 'light';
});
useEffect(() => {
const root = document.documentElement;
- if (theme === 'system') {
- localStorage.removeItem('theme');
- if (window.matchMedia('(prefers-color-scheme: dark)').matches) {
- root.classList.add('theme-dark');
- } else {
- root.classList.remove('theme-dark');
- }
+ if (theme === 'light') {
+ root.classList.remove('theme-dark');
} else {
- localStorage.setItem('theme', theme);
- if (theme === 'light') {
- root.classList.remove('theme-dark');
- } else {
- root.classList.add('theme-dark');
- }
+ root.classList.add('theme-dark');
}
}, [theme]);
+
return (
<div id="theme-toggle">
{themes.map((t, i) => {
const icon = icons[i];
const checked = t === theme;
return (
- <label className={checked ? 'checked' : ''}>
+ <label className={checked ? ' checked' : ''}>
{icon}
<input
type="radio"
@@ -85,7 +68,10 @@ const ThemeToggle: FunctionalComponent = () => {
value={t}
title={`Use ${t} theme`}
aria-label={`Use ${t} theme`}
- onChange={() => setTheme(t)}
+ onChange={() => {
+ localStorage.setItem('theme', t);
+ setTheme(t);
+ }}
/>
</label>
);
diff --git a/docs/src/layouts/Main.astro b/docs/src/layouts/Main.astro
index 689d52d9c..c7ef2adce 100644
--- a/docs/src/layouts/Main.astro
+++ b/docs/src/layouts/Main.astro
@@ -1,7 +1,6 @@
---
import ArticleFooter from '../components/ArticleFooter.astro';
import SiteSidebar from '../components/SiteSidebar.astro';
-import ThemeToggle from '../components/ThemeToggle.tsx';
import DocSidebar from '../components/DocSidebar.tsx';
import MenuToggle from '../components/MenuToggle.tsx';
import MetaData from "../components/MetaData.astro";
@@ -78,6 +77,46 @@ if (currentPage) {
top: 0;
}
+
+ .logo {
+ display: flex;
+ align-items: center;
+ gap: 0;
+ font-size: 1rem;
+ font-weight: 600;
+ margin: 0;
+ line-height: 1;
+ color: hsla(var(--color-base-white), 100%, 1);
+ text-decoration: none;
+ }
+
+ .logo a {
+ padding: 0.5em 0.25em;
+ margin: -0.5em -0.25em;
+ }
+
+ .logo svg {
+ height: 40px;
+ width: auto;
+ display: block;
+ color: var(--theme-accent);
+ }
+
+ .logo .hover {
+ opacity: 0.0;
+ }
+ .logo a:hover .hover {
+ opacity: 1;
+ }
+
+ .logo h1 {
+ font: inherit;
+ color: inherit;
+ margin: 0;
+ }
+
+
+
.layout {
display: grid;
grid-auto-flow: column;
@@ -92,7 +131,7 @@ if (currentPage) {
display: flex;
align-items: center;
justify-content: center;
- gap: 1em;
+ gap: 0.5em;
z-index: -1;
margin: 0 auto;
}
@@ -180,9 +219,10 @@ if (currentPage) {
display: block;
top: 0;
}
- @media (min-width: 60em) {
+ @media (min-width: 50em) {
header {
position: static;
+ padding: 2rem 0rem 0 2rem;
}
.layout {
overflow: initial;
@@ -194,6 +234,7 @@ if (currentPage) {
}
#sidebar-site {
display: flex;
+ padding-left: 2rem;
}
:global(.mobile-sidebar-toggle) {
overflow: initial;
@@ -225,7 +266,7 @@ if (currentPage) {
}
}
- @media (min-width: 82em) {
+ @media (min-width: 72em) {
.layout {
grid-template-columns:
20rem
@@ -246,9 +287,6 @@ if (currentPage) {
display: flex;
grid-column: 3;
}
- .nav-wrapper {
- padding: 0;
- }
}
</style>
@@ -266,28 +304,28 @@ if (currentPage) {
<a href="https://astro.build/">
<h1 class="sr-only">Astro</h1>
<svg xmlns="http://www.w3.org/2000/svg" width="363" height="102" viewBox="0 0 363 102" fill="none">
- <path fill="url(#paint0_linear)" fill-rule="evenodd" d="M55.07 14.216l16.81 54.865a72.6 72.6 0 00-20.765-6.984L39.808 24.135a1.475 1.475 0 00-2.827.005L25.81 62.078a72.598 72.598 0 00-20.859 6.995L21.847 14.2c.998-3.243 1.497-4.865 2.47-6.066a8 8 0 013.239-2.392c1.434-.576 3.13-.576 6.524-.576h8.751c3.398 0 5.097 0 6.532.577a8 8 0 013.241 2.397c.972 1.203 1.47 2.827 2.465 6.076z" clip-rule="evenodd"/>
+ <style>
+ .text {
+ fill: var(--theme-text);
+ }
+ .hover {
+ fill: var(--theme-accent);
+ }
+ </style>
+ <path class="text" fill-rule="evenodd" d="M55.07 14.216l16.81 54.865a72.6 72.6 0 00-20.765-6.984L39.808 24.135a1.475 1.475 0 00-2.827.005L25.81 62.078a72.598 72.598 0 00-20.859 6.995L21.847 14.2c.998-3.243 1.497-4.865 2.47-6.066a8 8 0 013.239-2.392c1.434-.576 3.13-.576 6.524-.576h8.751c3.398 0 5.097 0 6.532.577a8 8 0 013.241 2.397c.972 1.203 1.47 2.827 2.465 6.076z" clip-rule="evenodd"/>
<path fill="#FF5D01" fill-rule="evenodd" d="M54.618 71.779c-2.863 2.432-8.578 4.091-15.161 4.091-8.08 0-14.852-2.499-16.649-5.86-.642 1.926-.786 4.13-.786 5.539 0 0-.423 6.915 4.418 11.725 0-2.498 2.037-4.522 4.551-4.522 4.309 0 4.304 3.734 4.3 6.764v.27c0 4.6 2.829 8.541 6.852 10.203a9.22 9.22 0 01-.938-4.064c0-4.386 2.592-6.02 5.604-7.917 2.396-1.51 5.06-3.188 6.894-6.554a12.297 12.297 0 001.502-5.905c0-1.314-.206-2.581-.587-3.77z" clip-rule="evenodd"/>
- <path fill="#fff" d="M126.554 69c13.115 0 21.047-3.14 25.68-9.654 0 2.904.157 5.651.55 8.163h7.774c-.706-4.082-.863-6.75-.863-14.128V43.334c0-10.831-8.403-16.56-24.424-16.56-15.47 0-25.522 5.964-26.779 14.598h8.246c1.256-5.808 7.774-8.87 18.533-8.87 10.602 0 16.885 3.69 16.885 9.969v.785l-24.502 1.413c-9.974.549-13.665 1.962-16.492 4.003-2.67 1.962-4.162 5.023-4.162 8.555C107 64.683 114.696 69 126.554 69zm2.513-5.573c-9.109 0-14.135-2.119-14.135-6.357 0-4.553 3.141-6.593 14.214-7.3l23.01-1.412v1.805c0 8.241-9.66 13.264-23.089 13.264zM196.086 69c16.256 0 22.775-5.337 22.775-13.108 0-6.436-4.006-9.732-14.215-10.596l-19.083-1.49c-5.183-.393-8.088-1.884-8.088-5.102 0-4.082 4.476-6.201 14.135-6.201 10.995 0 16.727 2.198 20.497 7.064l6.361-3.061c-3.927-6.122-12.644-9.733-26.151-9.733-13.9 0-22.224 4.631-22.224 12.244 0 6.829 4.947 10.125 14.292 10.91l18.926 1.492c6.204.47 8.089 1.726 8.089 4.944 0 4.631-4.79 6.829-14.293 6.829-11.544 0-18.847-3.14-22.381-8.87l-6.204 3.376C173.312 64.918 181.715 69 196.086 69zM234.929 34.151v18.916c0 7.77 2.67 15.54 17.198 15.54 3.691 0 8.167-.706 10.131-1.57V60.68c-2.749.628-6.047 1.1-9.267 1.1-6.832 0-10.523-2.67-10.523-9.42V34.151h19.633v-5.887h-19.633V15l-7.539 3.061v10.204h-12.33v5.886h12.33zM280.823 28.265h-6.911v39.244h7.461V52.83c0-5.65 1.099-10.439 4.24-13.735 2.749-3.061 6.283-4.788 12.487-4.788 2.12 0 3.455.157 5.262.471v-7.22c-1.65-.393-3.063-.472-5.184-.472-8.402 0-15.078 4.945-17.355 12.558v-11.38zM334.807 69C351.534 69 363 60.523 363 47.887c0-12.637-11.466-21.114-28.193-21.114-16.727 0-28.193 8.477-28.193 21.114C306.614 60.523 318.08 69 334.807 69zm0-6.2c-12.329 0-20.261-5.809-20.261-14.913 0-9.105 7.932-14.913 20.261-14.913 12.251 0 20.261 5.808 20.261 14.913 0 9.104-8.01 14.912-20.261 14.912z"/>
- <defs>
- <linearGradient id="paint0_linear" x1="57.99" x2="38.65" y1="2.161" y2="69.149" gradientUnits="userSpaceOnUse">
- <stop stop-color="#fff"/>
- <stop offset="1" stop-color="#F9FAFB"/>
- </linearGradient>
- </defs>
+ <path class="text" d="M126.554 69c13.115 0 21.047-3.14 25.68-9.654 0 2.904.157 5.651.55 8.163h7.774c-.706-4.082-.863-6.75-.863-14.128V43.334c0-10.831-8.403-16.56-24.424-16.56-15.47 0-25.522 5.964-26.779 14.598h8.246c1.256-5.808 7.774-8.87 18.533-8.87 10.602 0 16.885 3.69 16.885 9.969v.785l-24.502 1.413c-9.974.549-13.665 1.962-16.492 4.003-2.67 1.962-4.162 5.023-4.162 8.555C107 64.683 114.696 69 126.554 69zm2.513-5.573c-9.109 0-14.135-2.119-14.135-6.357 0-4.553 3.141-6.593 14.214-7.3l23.01-1.412v1.805c0 8.241-9.66 13.264-23.089 13.264zM196.086 69c16.256 0 22.775-5.337 22.775-13.108 0-6.436-4.006-9.732-14.215-10.596l-19.083-1.49c-5.183-.393-8.088-1.884-8.088-5.102 0-4.082 4.476-6.201 14.135-6.201 10.995 0 16.727 2.198 20.497 7.064l6.361-3.061c-3.927-6.122-12.644-9.733-26.151-9.733-13.9 0-22.224 4.631-22.224 12.244 0 6.829 4.947 10.125 14.292 10.91l18.926 1.492c6.204.47 8.089 1.726 8.089 4.944 0 4.631-4.79 6.829-14.293 6.829-11.544 0-18.847-3.14-22.381-8.87l-6.204 3.376C173.312 64.918 181.715 69 196.086 69zM234.929 34.151v18.916c0 7.77 2.67 15.54 17.198 15.54 3.691 0 8.167-.706 10.131-1.57V60.68c-2.749.628-6.047 1.1-9.267 1.1-6.832 0-10.523-2.67-10.523-9.42V34.151h19.633v-5.887h-19.633V15l-7.539 3.061v10.204h-12.33v5.886h12.33zM280.823 28.265h-6.911v39.244h7.461V52.83c0-5.65 1.099-10.439 4.24-13.735 2.749-3.061 6.283-4.788 12.487-4.788 2.12 0 3.455.157 5.262.471v-7.22c-1.65-.393-3.063-.472-5.184-.472-8.402 0-15.078 4.945-17.355 12.558v-11.38zM334.807 69C351.534 69 363 60.523 363 47.887c0-12.637-11.466-21.114-28.193-21.114-16.727 0-28.193 8.477-28.193 21.114C306.614 60.523 318.08 69 334.807 69zm0-6.2c-12.329 0-20.261-5.809-20.261-14.913 0-9.105 7.932-14.913 20.261-14.913 12.251 0 20.261 5.808 20.261 14.913 0 9.104-8.01 14.912-20.261 14.912z"/>
+ <rect class="hover" x="106" y="82" width="258" height="6"></rect>
</svg>
</a>
<a href="https://docs.astro.build/">
<h1 class="sr-only">Docs</h1>
<svg xmlns="http://www.w3.org/2000/svg" width="226" height="102" viewBox="0 0 226 102" fill="none">
<path fill="currentColor" d="M25.805 68c14.688 0 24.883-8.41 24.883-21.14 0-12.786-9.62-19.756-24.653-19.756H0V68h25.805zm-14.17-33.005H24.25c8.352 0 14.17 4.09 14.17 12.039 0 8.236-5.3 13.075-14.113 13.075H11.635V34.995zM82.673 69.382c16.704 0 27.418-8.582 27.418-21.83 0-13.248-10.771-21.83-27.418-21.83-16.589 0-27.418 8.582-27.418 21.83 0 13.19 10.83 21.83 27.418 21.83zm0-8.64c-9.1 0-15.149-5.299-15.149-13.19 0-7.891 6.048-13.19 15.15-13.19 9.1 0 15.205 5.299 15.205 13.19 0 7.891-6.105 13.19-15.206 13.19zM141.497 69.382c13.306 0 22.637-5.299 25.978-14.572l-11.866-2.535c-1.67 5.415-6.393 8.295-13.709 8.295-9.216 0-15.033-5.127-15.033-13.018 0-8.006 5.702-13.018 14.918-13.018 7.43 0 12.154 3.053 13.709 8.64l12.038-2.13c-2.707-9.562-12.268-15.322-25.574-15.322-16.128 0-27.302 9.043-27.302 22.003 0 13.133 10.425 21.657 26.841 21.657zM194.94 69.382c14.745 0 23.212-5.01 23.212-14.054 0-7.603-4.665-10.944-15.955-12.096l-11.289-1.094c-5.242-.576-6.97-1.556-6.97-4.09 0-2.765 3.456-4.262 9.792-4.262 7.834 0 13.709 2.476 16.762 6.508l7.315-6.163c-5.069-5.702-13.133-8.41-23.501-8.41-13.997 0-21.888 4.781-21.888 12.903 0 7.546 4.781 11.232 14.803 12.326l12.557 1.383c4.896.518 6.624 1.555 6.624 4.09 0 3.225-3.456 4.723-10.886 4.723-8.352 0-14.688-3.226-18.087-8.007l-8.294 5.818c4.205 6.451 13.709 10.425 25.805 10.425z"/>
+ <rect class="hover" x="0" y="82" width="218" height="6"></rect>
</svg>
</a>
</div>
-
- <div class="theme-toggle-wrapper">
- <ThemeToggle client:idle />
- </div>
</nav>
</header>