Added support for settings without JS

This commit is contained in:
DrMint 2024-02-02 01:13:39 +01:00
parent f4cead3f9c
commit df7d8397aa
9 changed files with 191 additions and 17 deletions

View File

@ -1,4 +1,4 @@
{ {
"recommendations": ["astro-build.astro-vscode"], "recommendations": ["astro-build.astro-vscode", "antfu.iconify"],
"unwantedRecommendations": [] "unwantedRecommendations": []
} }

View File

@ -372,6 +372,10 @@ const { currentTheme } = Astro.locals;
display: none; display: none;
} }
} }
.when-no-js {
display: none;
}
</style> </style>
<script> <script>

View File

@ -25,6 +25,7 @@ const { t } = await getI18n(currentLocale);
<a <a
class:list={{ current: locale === currentLocale }} class:list={{ current: locale === currentLocale }}
href={`?action-lang=${locale}`} href={`?action-lang=${locale}`}
data-astro-prefetch="tap"
> >
{locale.toString().toUpperCase()} {locale.toString().toUpperCase()}
</a> </a>

View File

@ -43,19 +43,31 @@ const { t } = await getI18n(Astro.locals.currentLocale);
</div> </div>
) )
} }
<div id="toolbar" class="when-js"> <div id="toolbar">
<Button <Button
icon="material-symbols:search" icon="material-symbols:search"
ariaLabel={t("header.topbar.search.tooltip")} ariaLabel={t("header.topbar.search.tooltip")}
/> />
<div class="separator"></div> <div class="separator"></div>
<ThemeSelector />
<LanguageSelector class="m-not" withTitle /> <div class="when-no-js">
<LanguageSelector class="m-only" /> <a href="/settings">
<Button
icon="material-symbols:settings-outline"
ariaLabel={t("header.topbar.search.tooltip")}
/>
</a>
</div>
<CurrencySelector class="m-not" withTitle /> <div class="when-js">
<CurrencySelector class="m-only" /> <ThemeSelector />
<LanguageSelector class="m-not" withTitle />
<LanguageSelector class="m-only" />
<CurrencySelector class="m-not" withTitle />
<CurrencySelector class="m-only" />
</div>
</div> </div>
</nav> </nav>
@ -130,17 +142,22 @@ const { t } = await getI18n(Astro.locals.currentLocale);
} }
} }
& > :global(.m-only) { & > div.when-js {
display: none; display: flex;
} gap: 12px;
@media (max-width: 40rem) {
& > :global(.m-only) { & > :global(.m-only) {
display: flex; display: none;
} }
& > :global(.m-not) { @media (max-width: 40rem) {
display: none; & > :global(.m-only) {
display: flex;
}
& > :global(.m-not) {
display: none;
}
} }
} }
} }

View File

@ -0,0 +1,62 @@
---
---
<details>
<summary><slot name="header" /></summary>
<div class="content">
<div class="content2">
<slot />
</div>
</div>
</details>
<style>
details {
--foreground-color: var(--color-base-650);
color: var(--foreground-color);
border: 0.1em solid var(--foreground-color);
background-color: var(--color-elevation-0);
border-radius: 1.25em;
transition: all 1s;
&[open] {
& > summary {
border-bottom: 1px solid #aaa;
}
& > .content {
animation: animate 0.5s forwards;
}
}
& > summary {
list-style: none;
height: 2.5em;
padding-left: 1em;
padding-right: 1em;
display: flex;
place-items: center;
gap: 1em;
}
& > .content {
padding: 1em;
display: grid;
& > .content2 {
overflow: hidden;
}
}
}
@keyframes animate {
from {
grid-template-rows: 0fr;
}
to {
grid-template-rows: 1fr;
}
}
</style>

View File

@ -39,7 +39,7 @@ const { icon, title, href } = Astro.props;
gap: 2px; gap: 2px;
& > h3 { & > h3 {
font-size: 24px; font-size: 1.25em;
} }
} }
} }

View File

@ -16,7 +16,7 @@ const { t, getLocalizedUrl } = await getI18n(Astro.locals.currentLocale);
<AppLayout <AppLayout
title="Accords Library" title="Accords Library"
illustration="/img/bg-home.webp" illustration="/img/bg-home.webp"
illustrationSize="100vh" illustrationSize="60vw"
illustrationPosition="20%" illustrationPosition="20%"
> >
<div id="title" slot="header-title"> <div id="title" slot="header-title">

View File

@ -0,0 +1,90 @@
---
import AppLayout from "components/AppLayout/AppLayout.astro";
import { getI18n, locales } from "translations/translations";
const { currentLocale, currentTheme, currentCurrency } = Astro.locals;
const { t } = await getI18n(currentLocale);
---
<AppLayout
title="Settings"
breadcrumb={[{ name: "Settings", slug: "settings" }]}
>
<div id="main" slot="main">
<div class="section">
<h2>Language</h2>
<p>{t("header.topbar.language.tooltip")}</p><br />
{
locales.map((locale) => (
<a
class:list={{ current: locale === currentLocale }}
href={`?action-lang=${locale}`}
data-astro-prefetch="tap"
>
{locale.toString().toUpperCase()}
</a>
))
}
</div>
<div class="section">
<h2>Theme</h2>
<p>{t("header.topbar.theme.tooltip")}</p><br />
<a
class:list={{ current: currentTheme === "dark" }}
href="?action-theme=dark"
data-astro-prefetch="tap"
>
{t("header.topbar.theme.dark")}
</a>
<a
class:list={{ current: currentTheme === "auto" }}
href="?action-theme=auto"
data-astro-prefetch="tap"
>
{t("header.topbar.theme.auto")}
</a>
<a
class:list={{ current: currentTheme === "light" }}
href="?action-theme=light"
data-astro-prefetch="tap"
>
{t("header.topbar.theme.light")}
</a>
</div>
<div class="section">
<h2>Currency</h2>
<p>{t("header.topbar.currency.tooltip")}</p><br />
<a
class:list={{ current: currentCurrency === "usd" }}
href="?action-currency=usd"
data-astro-prefetch="tap">USD</a
>
<a
class:list={{ current: currentCurrency === "eur" }}
href="?action-currency=eur"
data-astro-prefetch="tap">EUR</a
>
</div>
</div>
</AppLayout>
<style>
.section {
display: flex;
flex-direction: column;
gap: 0.5em;
& > .current {
color: var(--color-base-750);
text-decoration: underline 0.08em var(--color-base-650);
}
}
#main {
display: grid;
grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
gap: 5em;
}
</style>

View File

@ -42,7 +42,7 @@ const { icon, subtitle, title, href } = Astro.props;
gap: 0.15em; gap: 0.15em;
& > h3 { & > h3 {
font-size: 1.5em; font-size: 1.25em;
} }
& > p { & > p {