mirror of
https://github.com/blitzkit/blitzkit.git
synced 2026-11-19 11:53:25 +01:00
both!
This commit is contained in:
3 files changed
+179
-49
No files matched your search
@@ -1,19 +1,21 @@
|
||||
---
|
||||
import { GearIcon } from "@radix-ui/react-icons";
|
||||
import { api } from "../api/dynamic";
|
||||
import { tools } from "../constants/tools";
|
||||
import { tools, type Tool } from "../constants/tools";
|
||||
import type { LocaleAcceptorProps } from "../hooks/useLocale";
|
||||
import { Logo } from "../icons/Logo";
|
||||
import { LinkI18nWrapper } from "./LinkI18nWrapper";
|
||||
import { Text } from "./Text";
|
||||
|
||||
type Props = LocaleAcceptorProps;
|
||||
export type Props = LocaleAcceptorProps & {
|
||||
tool: Tool;
|
||||
};
|
||||
|
||||
const { locale } = Astro.props;
|
||||
|
||||
const strings = await api.strings(locale);
|
||||
|
||||
const filtered = Object.values(tools).filter(
|
||||
export const filtered = Object.values(tools).filter(
|
||||
(tool) => !tool.href && (tool.navbar ?? true),
|
||||
);
|
||||
---
|
||||
|
||||
@@ -1,14 +1,12 @@
|
||||
---
|
||||
import { CaretUpIcon, GearIcon } from "@radix-ui/react-icons";
|
||||
import { api } from "../api/dynamic";
|
||||
import type { Tool } from "../constants/tools";
|
||||
import type { LocaleAcceptorProps } from "../hooks/useLocale";
|
||||
import { Logo } from "../icons/Logo";
|
||||
import { LinkI18nWrapper } from "./LinkI18nWrapper";
|
||||
import { filtered } from "./NavbarDesktop.astro";
|
||||
import { Scroller, ScrollerOrientation } from "./Scroller";
|
||||
import { Text } from "./Text";
|
||||
|
||||
type Props = LocaleAcceptorProps & {
|
||||
tool: Tool;
|
||||
};
|
||||
export { type Props } from "./NavbarDesktop.astro";
|
||||
|
||||
const { locale, tool } = Astro.props;
|
||||
|
||||
@@ -18,73 +16,164 @@ const strings = await api.strings(locale);
|
||||
<style>
|
||||
#navbar-mobile {
|
||||
--icon-size: 1.5rem;
|
||||
--padding: var(--space-4);
|
||||
|
||||
position: fixed;
|
||||
overflow: hidden;
|
||||
|
||||
left: 0;
|
||||
bottom: 0;
|
||||
|
||||
width: 100%;
|
||||
padding: var(--space-4);
|
||||
box-sizing: border-box;
|
||||
|
||||
justify-content: space-between;
|
||||
|
||||
z-index: 1;
|
||||
z-index: 2;
|
||||
|
||||
background-color: var(--black-a9);
|
||||
backdrop-filter: var(--blur-tint);
|
||||
|
||||
border-top: var(--space-0) solid var(--white-a4);
|
||||
|
||||
height: auto;
|
||||
|
||||
transition-duration: var(--duration-brief);
|
||||
|
||||
display: none;
|
||||
flex-direction: column;
|
||||
justify-content: flex-end;
|
||||
|
||||
@media screen and (max-width: 80rem) {
|
||||
display: flex;
|
||||
}
|
||||
|
||||
width: 100%;
|
||||
height: calc(var(--icon-size) + 2 * var(--padding));
|
||||
box-sizing: border-box;
|
||||
|
||||
&[data-expanded="true"] {
|
||||
height: fit-content;
|
||||
max-height: 100dvh;
|
||||
|
||||
background-color: var(--gray-1);
|
||||
}
|
||||
|
||||
&[data-visible="false"] {
|
||||
transform: translateY(100%);
|
||||
border-top: 0 solid var(--white-a3);
|
||||
}
|
||||
|
||||
.icon {
|
||||
color: var(--gray-11);
|
||||
|
||||
width: var(--icon-size);
|
||||
height: var(--icon-size);
|
||||
}
|
||||
|
||||
.tool {
|
||||
.control {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: var(--space-4);
|
||||
padding: var(--padding);
|
||||
|
||||
.logo {
|
||||
flex-shrink: 0;
|
||||
box-sizing: border-box;
|
||||
|
||||
width: 100%;
|
||||
|
||||
.icon {
|
||||
color: var(--gray-11);
|
||||
|
||||
width: var(--icon-size);
|
||||
height: var(--icon-size);
|
||||
|
||||
background-size: cover;
|
||||
background-position: center;
|
||||
transition-duration: var(--duration-brief);
|
||||
|
||||
border-radius: var(--radius-max);
|
||||
|
||||
margin-right: var(--space-4);
|
||||
#navbar-mobile[data-expanded="true"] & {
|
||||
color: var(--gray-12);
|
||||
}
|
||||
}
|
||||
|
||||
.icon {
|
||||
margin-left: var(--space-2);
|
||||
color: var(--gray-12);
|
||||
.tool {
|
||||
flex: 1;
|
||||
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
|
||||
cursor: pointer;
|
||||
|
||||
.logo {
|
||||
flex-shrink: 0;
|
||||
|
||||
width: var(--icon-size);
|
||||
height: var(--icon-size);
|
||||
|
||||
background-size: cover;
|
||||
background-position: center;
|
||||
|
||||
border-radius: var(--radius-max);
|
||||
|
||||
margin-right: var(--space-4);
|
||||
}
|
||||
|
||||
.icon {
|
||||
margin-left: var(--space-2);
|
||||
|
||||
color: var(--gray-12);
|
||||
|
||||
transition-duration: var(--duration-brief);
|
||||
|
||||
#navbar-mobile[data-expanded="true"] & {
|
||||
transform: rotate(180deg);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
.scroller {
|
||||
--scroller-curtain-color: black;
|
||||
|
||||
background-color: black;
|
||||
|
||||
.tools {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: var(--space-3);
|
||||
padding: var(--padding);
|
||||
|
||||
.tool {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: var(--space-3);
|
||||
|
||||
.logo {
|
||||
width: calc(2 * var(--icon-size));
|
||||
height: var(--icon-size);
|
||||
|
||||
padding: var(--space-3);
|
||||
|
||||
background-size: cover;
|
||||
background-position: center;
|
||||
|
||||
border-radius: var(--radius-max);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#navbar-mobile-overlay {
|
||||
position: fixed;
|
||||
inset: 0;
|
||||
|
||||
pointer-events: none;
|
||||
z-index: 1;
|
||||
|
||||
background-color: transparent;
|
||||
|
||||
#navbar-mobile[data-expanded="true"] ~ & {
|
||||
pointer-events: auto;
|
||||
background-color: var(--black-a8);
|
||||
}
|
||||
}
|
||||
|
||||
:global(html:has(#navbar-mobile[data-expanded="true"])) {
|
||||
overflow: hidden;
|
||||
}
|
||||
</style>
|
||||
|
||||
<script>
|
||||
const navbar = document.getElementById("navbar-mobile")!;
|
||||
const tool = document.getElementById("current-tool")!;
|
||||
const overlay = document.getElementById("navbar-mobile-overlay")!;
|
||||
let lastScrollY = window.scrollY;
|
||||
|
||||
window.addEventListener(
|
||||
@@ -99,23 +188,62 @@ const strings = await api.strings(locale);
|
||||
},
|
||||
{ passive: true },
|
||||
);
|
||||
|
||||
tool.addEventListener("click", () => {
|
||||
navbar.dataset.expanded = `${navbar.dataset.expanded !== "true"}`;
|
||||
});
|
||||
|
||||
overlay.addEventListener("pointerdown", () => {
|
||||
navbar.dataset.expanded = "false";
|
||||
});
|
||||
</script>
|
||||
|
||||
<nav id="navbar-mobile" data-visible="true">
|
||||
<Logo className="icon" />
|
||||
<nav id="navbar-mobile" data-visible="true" data-expanded="false">
|
||||
<Scroller
|
||||
client:load
|
||||
orientation={ScrollerOrientation.Vertical}
|
||||
className="scroller"
|
||||
>
|
||||
<div class="tools">
|
||||
{filtered.map((tool) => (
|
||||
<LinkI18nWrapper {locale} href={`/${tool.slug ?? tool.id}`}>
|
||||
<div class="tool">
|
||||
<div
|
||||
style={`background-image: url(/media/tools/banners/${tool.slug ?? tool.id}.webp)`}
|
||||
class="logo"
|
||||
/>
|
||||
|
||||
<div class="tool">
|
||||
<div
|
||||
style={`background-image: url(/media/tools/banners/${tool.slug ?? tool.id}.webp)`}
|
||||
class="logo"
|
||||
/>
|
||||
<Text className="name">
|
||||
{strings.tools[tool.id as keyof typeof strings.tools].name}
|
||||
</Text>
|
||||
</div>
|
||||
</LinkI18nWrapper>
|
||||
))}
|
||||
</div>
|
||||
</Scroller>
|
||||
|
||||
<Text className="name">
|
||||
{strings.tools[tool.id as keyof typeof strings.tools].name}
|
||||
</Text>
|
||||
<div class="control">
|
||||
<LinkI18nWrapper {locale} href="/">
|
||||
<Logo className="icon" />
|
||||
</LinkI18nWrapper>
|
||||
|
||||
<CaretUpIcon className="icon" />
|
||||
<div class="tool" id="current-tool">
|
||||
<div
|
||||
style={`background-image: url(/media/tools/banners/${tool.slug ?? tool.id}.webp)`}
|
||||
class="logo"
|
||||
/>
|
||||
|
||||
<Text className="name">
|
||||
{strings.tools[tool.id as keyof typeof strings.tools].name}
|
||||
</Text>
|
||||
|
||||
<CaretUpIcon className="icon" />
|
||||
</div>
|
||||
|
||||
<LinkI18nWrapper {locale} href="/settings">
|
||||
<GearIcon className="icon" />
|
||||
</LinkI18nWrapper>
|
||||
</div>
|
||||
|
||||
<GearIcon className="icon" />
|
||||
</nav>
|
||||
|
||||
<div id="navbar-mobile-overlay" />
|
||||
Reference in new issue
Block a user