mirror of
https://github.com/blitzkit/blitzkit.git
synced 2026-11-29 04:44:23 +01:00
fancy navbar
This commit is contained in:
17 files changed
+422
-198
No files matched your search
@@ -50,10 +50,12 @@ Pages that are not migrated yet are named `_index.astro` so Astro skips them. Mi
|
|||||||
- Select elements by their own class, never by structure or tag (`> *`, `> div`, `:first-child`, bare `svg`, `[data-x] > *`). If an element needs styling, give it a class and nest that class under its parent. The exception is content a component renders internally that has no `className` to pass, like the icon inside an `IconButton` (`.swatch svg`).
|
- Select elements by their own class, never by structure or tag (`> *`, `> div`, `:first-child`, bare `svg`, `[data-x] > *`). If an element needs styling, give it a class and nest that class under its parent. The exception is content a component renders internally that has no `className` to pass, like the icon inside an `IconButton` (`.swatch svg`).
|
||||||
- Nest CSS to mirror the markup: a child's rules go inside its parent's block (`.marker { .bar { } }`), so the stylesheet reads like the HTML tree.
|
- Nest CSS to mirror the markup: a child's rules go inside its parent's block (`.marker { .bar { } }`), so the stylesheet reads like the HTML tree.
|
||||||
- Fully rounded corners use `var(--radius-max)`, never `var(--max-size)`.
|
- Fully rounded corners use `var(--radius-max)`, never `var(--max-size)`.
|
||||||
- `z-index` stays at `1` unless a real overlap needs more.
|
- Avoid `z-index: 2` or above unless nothing else works. Resolve overlaps first by DOM order (a later sibling at the same `z-index` paints on top, so put overlays and curtains before what must sit above them) or by leveling the field (give competing siblings the same `position: relative`/`z-index: 1`, or `isolation: isolate` a container so its children's layers stay inside it).
|
||||||
|
|
||||||
## Components
|
## Components
|
||||||
|
|
||||||
|
- Don't copy the same markup or styles across files. As soon as a block repeats, extract it into a component and use that everywhere it appeared.
|
||||||
|
|
||||||
- Dialog-like surfaces (`Dialog`, `AlertDialog`, `Popover`) share their extra parts, which live as their own top-level components: `DialogHeader`, `DialogBody`, `DialogActions` and `DialogField` (a labeled control, taking a `label` prop). Each surface attaches them as `X.Header`, `X.Body`, `X.Actions` and `X.Field`; none defines its own copy. Fix their spacing in the part's own CSS module.
|
- Dialog-like surfaces (`Dialog`, `AlertDialog`, `Popover`) share their extra parts, which live as their own top-level components: `DialogHeader`, `DialogBody`, `DialogActions` and `DialogField` (a labeled control, taking a `label` prop). Each surface attaches them as `X.Header`, `X.Body`, `X.Actions` and `X.Field`; none defines its own copy. Fix their spacing in the part's own CSS module.
|
||||||
- Other extra non-Radix parts of a composed component are local functions in that component's `index.tsx`, `function Name({ className, ...props }: ComponentProps<"div">)` using `classNames(styles["kebab-class"], className)`, spread in with `{ ...composeRadixComponents(_, styles), Name }`. Once a part is shared by several components, it moves out into its own top-level component instead, like the `Dialog*` parts. A part shared across menus (`Discriminator` in DropdownMenu) is styled through a data attribute, since CSS modules re-hash classes per importing file.
|
- Other extra non-Radix parts of a composed component are local functions in that component's `index.tsx`, `function Name({ className, ...props }: ComponentProps<"div">)` using `classNames(styles["kebab-class"], className)`, spread in with `{ ...composeRadixComponents(_, styles), Name }`. Once a part is shared by several components, it moves out into its own top-level component instead, like the `Dialog*` parts. A part shared across menus (`Discriminator` in DropdownMenu) is styled through a data attribute, since CSS modules re-hash classes per importing file.
|
||||||
|
|
||||||
|
|||||||
@@ -73,6 +73,10 @@ styles += "}";
|
|||||||
--duration-brief: 200ms;
|
--duration-brief: 200ms;
|
||||||
--duration-subtle: 2s;
|
--duration-subtle: 2s;
|
||||||
--duration-spinner: 1s;
|
--duration-spinner: 1s;
|
||||||
|
/* Gap between consecutive items in a staggered entrance */
|
||||||
|
--duration-stagger: 20ms;
|
||||||
|
|
||||||
|
--easing-standard: cubic-bezier(0.4, 0, 0.6, 1);
|
||||||
|
|
||||||
--tank-card-min-width: 8rem;
|
--tank-card-min-width: 8rem;
|
||||||
--drop-down-min-width: 16rem;
|
--drop-down-min-width: 16rem;
|
||||||
@@ -81,6 +85,11 @@ styles += "}";
|
|||||||
</style>
|
</style>
|
||||||
|
|
||||||
<style is:global>
|
<style is:global>
|
||||||
|
/* Zero specificity, so any component's own timing function still wins */
|
||||||
|
* {
|
||||||
|
transition-timing-function: var(--easing-standard);
|
||||||
|
}
|
||||||
|
|
||||||
.composable-radius {
|
.composable-radius {
|
||||||
&[data-radius="1"] {
|
&[data-radius="1"] {
|
||||||
border-radius: var(--space-3);
|
border-radius: var(--space-3);
|
||||||
|
|||||||
@@ -13,11 +13,28 @@ const { locale } = Astro.props;
|
|||||||
|
|
||||||
const strings = await api.strings(locale);
|
const strings = await api.strings(locale);
|
||||||
|
|
||||||
// Meteorological seasons, starting at december
|
// Seasons start a month early, so winter covers november to january
|
||||||
const SEASONS = ["winter", "spring", "summer", "fall"];
|
const SEASONS = [
|
||||||
|
{
|
||||||
|
name: "winter",
|
||||||
|
position: "bottom",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "spring",
|
||||||
|
position: "bottom",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "summer",
|
||||||
|
position: "bottom",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "fall",
|
||||||
|
position: "bottom",
|
||||||
|
},
|
||||||
|
];
|
||||||
|
|
||||||
const month = new Date().getMonth();
|
const month = new Date().getMonth();
|
||||||
const season = SEASONS[Math.floor(((month + 1) % 12) / 3)];
|
const season = SEASONS[Math.floor(((month + 2) % 12) / 3)];
|
||||||
---
|
---
|
||||||
|
|
||||||
<style>
|
<style>
|
||||||
@@ -62,7 +79,8 @@ const season = SEASONS[Math.floor(((month + 1) % 12) / 3)];
|
|||||||
<section
|
<section
|
||||||
class="wrapper"
|
class="wrapper"
|
||||||
style={{
|
style={{
|
||||||
backgroundImage: `url(${alias("api", `/hero/${season}.webp`)})`,
|
backgroundPosition: season.position,
|
||||||
|
backgroundImage: `url(${alias("api", `/hero/${season.name}.webp`)})`,
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
<div class="blur"></div>
|
<div class="blur"></div>
|
||||||
|
|||||||
@@ -2,16 +2,18 @@
|
|||||||
import { alias } from "@blitzkit/core";
|
import { alias } from "@blitzkit/core";
|
||||||
import { CaretUpIcon, GearIcon } from "@radix-ui/react-icons";
|
import { CaretUpIcon, GearIcon } from "@radix-ui/react-icons";
|
||||||
import { api } from "../api/dynamic";
|
import { api } from "../api/dynamic";
|
||||||
|
import { tools, type Tool } from "../config/tools";
|
||||||
import { getLocaleOptions } from "../core/i18n/getLocaleOptions";
|
import { getLocaleOptions } from "../core/i18n/getLocaleOptions";
|
||||||
|
import type { LocaleAcceptorProps } from "../hooks/useLocale";
|
||||||
import { Logo } from "../icons/Logo";
|
import { Logo } from "../icons/Logo";
|
||||||
import { LinkI18nWrapper } from "./LinkI18nWrapper";
|
import { LinkI18nWrapper } from "./LinkI18nWrapper";
|
||||||
import { filtered, type Props as NavbarFineProps } from "./NavbarFine.astro";
|
|
||||||
import NavbarMobileAutoHide from "./NavbarMobileAutoHide.astro";
|
import NavbarMobileAutoHide from "./NavbarMobileAutoHide.astro";
|
||||||
import { Scroller, ScrollerOrientation } from "./Scroller";
|
import { Scroller, ScrollerOrientation } from "./Scroller";
|
||||||
import { SettingsDialog } from "./SettingsDialog";
|
import { SettingsDialog } from "./SettingsDialog";
|
||||||
import { Text } from "./Text";
|
import { Text } from "./Text";
|
||||||
|
|
||||||
export type Props = NavbarFineProps & {
|
export type Props = LocaleAcceptorProps & {
|
||||||
|
tool: Tool;
|
||||||
solid?: boolean;
|
solid?: boolean;
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -19,6 +21,10 @@ const { locale, tool, solid = false } = Astro.props;
|
|||||||
|
|
||||||
const strings = await api.strings(locale);
|
const strings = await api.strings(locale);
|
||||||
const localeOptions = await getLocaleOptions();
|
const localeOptions = await getLocaleOptions();
|
||||||
|
|
||||||
|
const filtered = Object.values(tools).filter(
|
||||||
|
(tool) => !tool.href && !tool.hide_in_navbar && !tool.disabled,
|
||||||
|
);
|
||||||
---
|
---
|
||||||
|
|
||||||
<style>
|
<style>
|
||||||
@@ -46,7 +52,7 @@ const localeOptions = await getLocaleOptions();
|
|||||||
left: 0;
|
left: 0;
|
||||||
bottom: 0;
|
bottom: 0;
|
||||||
|
|
||||||
z-index: 2;
|
z-index: 1;
|
||||||
|
|
||||||
background-color: var(--black-a9);
|
background-color: var(--black-a9);
|
||||||
backdrop-filter: var(--blur-tint);
|
backdrop-filter: var(--blur-tint);
|
||||||
@@ -183,7 +189,7 @@ const localeOptions = await getLocaleOptions();
|
|||||||
|
|
||||||
transition-duration: var(--duration-brief);
|
transition-duration: var(--duration-brief);
|
||||||
|
|
||||||
#navbar-mobile[data-expanded="true"] ~ & {
|
&[data-expanded="true"] {
|
||||||
pointer-events: auto;
|
pointer-events: auto;
|
||||||
background-color: var(--black-a8);
|
background-color: var(--black-a8);
|
||||||
}
|
}
|
||||||
@@ -200,14 +206,20 @@ const localeOptions = await getLocaleOptions();
|
|||||||
const overlay = document.getElementById("navbar-mobile-overlay")!;
|
const overlay = document.getElementById("navbar-mobile-overlay")!;
|
||||||
|
|
||||||
tool.addEventListener("click", () => {
|
tool.addEventListener("click", () => {
|
||||||
navbar.dataset.expanded = `${navbar.dataset.expanded !== "true"}`;
|
const expanded = `${navbar.dataset.expanded !== "true"}`;
|
||||||
|
|
||||||
|
navbar.dataset.expanded = expanded;
|
||||||
|
overlay.dataset.expanded = expanded;
|
||||||
});
|
});
|
||||||
|
|
||||||
overlay.addEventListener("pointerdown", () => {
|
overlay.addEventListener("pointerdown", () => {
|
||||||
navbar.dataset.expanded = "false";
|
navbar.dataset.expanded = "false";
|
||||||
|
overlay.dataset.expanded = "false";
|
||||||
});
|
});
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
<div id="navbar-mobile-overlay" data-expanded="false" />
|
||||||
|
|
||||||
<nav
|
<nav
|
||||||
id="navbar-mobile"
|
id="navbar-mobile"
|
||||||
data-visible="true"
|
data-visible="true"
|
||||||
@@ -269,8 +281,6 @@ const localeOptions = await getLocaleOptions();
|
|||||||
</div>
|
</div>
|
||||||
</nav>
|
</nav>
|
||||||
|
|
||||||
<div id="navbar-mobile-overlay" />
|
|
||||||
|
|
||||||
{solid && <div id="navbar-mobile-spacer" />}
|
{solid && <div id="navbar-mobile-spacer" />}
|
||||||
|
|
||||||
{!solid && <NavbarMobileAutoHide />}
|
{!solid && <NavbarMobileAutoHide />}
|
||||||
@@ -2,35 +2,45 @@
|
|||||||
import { alias } from "@blitzkit/core";
|
import { alias } from "@blitzkit/core";
|
||||||
import { GearIcon } from "@radix-ui/react-icons";
|
import { GearIcon } from "@radix-ui/react-icons";
|
||||||
import { api } from "../api/dynamic";
|
import { api } from "../api/dynamic";
|
||||||
|
import { toolGroups, tools } from "../config/tools";
|
||||||
import { getLocaleOptions } from "../core/i18n/getLocaleOptions";
|
import { getLocaleOptions } from "../core/i18n/getLocaleOptions";
|
||||||
import { tools, type Tool } from "../config/tools";
|
|
||||||
import type { LocaleAcceptorProps } from "../hooks/useLocale";
|
import type { LocaleAcceptorProps } from "../hooks/useLocale";
|
||||||
import { Logo } from "../icons/Logo";
|
import { Logo } from "../icons/Logo";
|
||||||
import { LinkI18nWrapper } from "./LinkI18nWrapper";
|
import { LinkI18nWrapper } from "./LinkI18nWrapper";
|
||||||
import { SettingsDialog } from "./SettingsDialog";
|
import { SettingsDialog } from "./SettingsDialog";
|
||||||
import { Text } from "./Text";
|
import { Text } from "./Text";
|
||||||
|
|
||||||
// TODO: combine all navbar after adding NavbarCourseLandscape
|
export type Props = LocaleAcceptorProps;
|
||||||
|
|
||||||
export type Props = LocaleAcceptorProps & {
|
|
||||||
tool: Tool;
|
|
||||||
};
|
|
||||||
|
|
||||||
const { locale } = Astro.props;
|
const { locale } = Astro.props;
|
||||||
|
|
||||||
const strings = await api.strings(locale);
|
const strings = await api.strings(locale);
|
||||||
const localeOptions = await getLocaleOptions();
|
const localeOptions = await getLocaleOptions();
|
||||||
|
|
||||||
export const filtered = Object.values(tools).filter(
|
// TODO: restore filtering out disabled tools and empty groups after testing
|
||||||
(tool) => !tool.href && !tool.hide_in_navbar && !tool.disabled,
|
const groups = toolGroups.map((group) => {
|
||||||
);
|
const name = strings.home[group.id as keyof typeof strings.home];
|
||||||
|
const fallback = tools[group.default];
|
||||||
|
const href = `/${fallback.slug ?? fallback.id}`;
|
||||||
|
|
||||||
|
return {
|
||||||
|
...group,
|
||||||
|
|
||||||
|
name,
|
||||||
|
href,
|
||||||
|
tools: group.tools.map((id) => tools[id]),
|
||||||
|
};
|
||||||
|
});
|
||||||
---
|
---
|
||||||
|
|
||||||
<style>
|
<style>
|
||||||
#navbar-desktop {
|
#navbar-fine {
|
||||||
--icon-size: 1.5rem;
|
--icon-size: 1.5rem;
|
||||||
--padding: var(--page-padding);
|
--padding: var(--space-4);
|
||||||
--min-content-width: calc(var(--icon-size) + 2 * var(--padding));
|
--content-inset: max(
|
||||||
|
var(--page-padding),
|
||||||
|
(100% - var(--page-width)) / 2
|
||||||
|
);
|
||||||
|
|
||||||
display: none;
|
display: none;
|
||||||
|
|
||||||
@@ -38,170 +48,307 @@ export const filtered = Object.values(tools).filter(
|
|||||||
display: block;
|
display: block;
|
||||||
}
|
}
|
||||||
|
|
||||||
width: var(--min-content-width);
|
|
||||||
height: 100dvh;
|
|
||||||
|
|
||||||
position: sticky;
|
position: sticky;
|
||||||
top: 0;
|
top: 0;
|
||||||
|
|
||||||
z-index: 1;
|
z-index: 1;
|
||||||
|
|
||||||
.expander {
|
.bar {
|
||||||
background-color: var(--gray-1);
|
|
||||||
|
|
||||||
z-index: 1;
|
|
||||||
|
|
||||||
position: relative;
|
|
||||||
left: 0;
|
|
||||||
|
|
||||||
display: flex;
|
display: flex;
|
||||||
flex-direction: column;
|
align-items: center;
|
||||||
justify-content: space-between;
|
justify-content: space-between;
|
||||||
|
gap: var(--space-4);
|
||||||
|
|
||||||
box-sizing: border-box;
|
padding: var(--padding) var(--content-inset);
|
||||||
|
|
||||||
|
background-color: var(--black-a9);
|
||||||
|
backdrop-filter: var(--blur-tint);
|
||||||
|
border-bottom: var(--space-0) solid var(--white-a1);
|
||||||
|
|
||||||
transition-duration: var(--duration-brief);
|
transition-duration: var(--duration-brief);
|
||||||
|
|
||||||
height: 100%;
|
#navbar-fine[data-open="true"] & {
|
||||||
width: var(--min-content-width);
|
border-bottom-color: transparent;
|
||||||
overflow: hidden;
|
|
||||||
|
|
||||||
padding: calc(var(--padding) + 2 * var(--space-2)) var(--padding);
|
|
||||||
|
|
||||||
border-right: 0 solid var(--gray-4);
|
|
||||||
|
|
||||||
&:hover {
|
|
||||||
width: fit-content;
|
|
||||||
border-right: var(--space-0) solid var(--gray-4);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
.logo {
|
.icon {
|
||||||
|
display: block;
|
||||||
|
|
||||||
width: var(--icon-size);
|
width: var(--icon-size);
|
||||||
height: var(--icon-size);
|
height: var(--icon-size);
|
||||||
|
|
||||||
|
color: var(--gray-11);
|
||||||
|
|
||||||
|
transition-duration: var(--duration-brief);
|
||||||
|
|
||||||
|
&:hover {
|
||||||
|
color: var(--gray-12);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
.named-link {
|
.trigger {
|
||||||
display: flex;
|
.name {
|
||||||
align-items: center;
|
|
||||||
gap: var(--space-3);
|
|
||||||
|
|
||||||
.icon {
|
|
||||||
flex-shrink: 0;
|
|
||||||
|
|
||||||
width: var(--icon-size);
|
|
||||||
height: var(--icon-size);
|
|
||||||
|
|
||||||
color: var(--gray-11);
|
color: var(--gray-11);
|
||||||
|
|
||||||
transition-duration: var(--duration-brief);
|
transition-duration: var(--duration-brief);
|
||||||
|
}
|
||||||
|
|
||||||
.expander:hover & {
|
&:hover .name,
|
||||||
color: var(--gray-12);
|
&[data-open="true"] .name {
|
||||||
|
color: var(--gray-12);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
.flyout {
|
||||||
|
position: absolute;
|
||||||
|
top: 100%;
|
||||||
|
left: 0;
|
||||||
|
right: 0;
|
||||||
|
|
||||||
|
overflow: hidden;
|
||||||
|
|
||||||
|
height: 0;
|
||||||
|
|
||||||
|
background-color: var(--black-a9);
|
||||||
|
backdrop-filter: var(--blur-tint);
|
||||||
|
border-bottom: 0 solid var(--white-a1);
|
||||||
|
|
||||||
|
transition-property: height, border-bottom-width;
|
||||||
|
|
||||||
|
#navbar-fine[data-open="true"] & {
|
||||||
|
border-bottom-width: var(--space-0);
|
||||||
|
}
|
||||||
|
|
||||||
|
.panel {
|
||||||
|
display: none;
|
||||||
|
flex-direction: column;
|
||||||
|
gap: var(--space-4);
|
||||||
|
|
||||||
|
padding: var(--space-5) var(--content-inset) var(--space-6);
|
||||||
|
|
||||||
|
&[data-active="true"] {
|
||||||
|
display: flex;
|
||||||
|
}
|
||||||
|
|
||||||
|
.header,
|
||||||
|
.tool {
|
||||||
|
transition-duration: var(--duration-brief);
|
||||||
|
transition-delay: calc(var(--index, 0) * var(--duration-stagger));
|
||||||
|
|
||||||
|
@starting-style {
|
||||||
|
opacity: 0;
|
||||||
|
translate: 0 calc(-1 * var(--space-2));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
.name {
|
.tools {
|
||||||
transition-duration: var(--duration-brief);
|
|
||||||
white-space: nowrap;
|
|
||||||
|
|
||||||
.expander:not(:hover) & {
|
|
||||||
opacity: 0;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
.tools {
|
|
||||||
display: flex;
|
|
||||||
flex-direction: column;
|
|
||||||
gap: var(--space-3);
|
|
||||||
|
|
||||||
.tool {
|
|
||||||
display: flex;
|
display: flex;
|
||||||
align-items: center;
|
flex-direction: column;
|
||||||
gap: var(--space-3);
|
gap: var(--space-3);
|
||||||
|
|
||||||
.logo {
|
.tool {
|
||||||
flex-shrink: 0;
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
gap: var(--space-3);
|
||||||
|
|
||||||
transition-duration: var(--duration-brief);
|
.thumbnail {
|
||||||
|
flex-shrink: 0;
|
||||||
|
|
||||||
width: var(--icon-size);
|
|
||||||
height: var(--icon-size);
|
|
||||||
|
|
||||||
filter: opacity(0.75);
|
|
||||||
background-size: cover;
|
|
||||||
background-position: center;
|
|
||||||
|
|
||||||
border-radius: var(--radius-max);
|
|
||||||
|
|
||||||
.expander:hover & {
|
|
||||||
width: calc(2 * var(--icon-size));
|
width: calc(2 * var(--icon-size));
|
||||||
|
height: var(--icon-size);
|
||||||
|
|
||||||
filter: opacity(1);
|
background-size: cover;
|
||||||
|
background-position: center;
|
||||||
|
|
||||||
|
border-radius: var(--radius-max);
|
||||||
|
}
|
||||||
|
|
||||||
|
.name {
|
||||||
|
color: var(--gray-12);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
.overlay {
|
#navbar-fine-curtain {
|
||||||
position: fixed;
|
position: fixed;
|
||||||
inset: 0;
|
inset: 0;
|
||||||
|
|
||||||
z-index: 1;
|
z-index: 1;
|
||||||
pointer-events: none;
|
pointer-events: none;
|
||||||
|
|
||||||
background-color: transparent;
|
background-color: transparent;
|
||||||
|
backdrop-filter: blur(0);
|
||||||
|
|
||||||
transition-duration: var(--duration-brief);
|
transition-duration: var(--duration-brief);
|
||||||
|
|
||||||
#navbar-desktop:hover & {
|
&[data-open="true"] {
|
||||||
background-color: var(--black-a8);
|
pointer-events: auto;
|
||||||
}
|
|
||||||
|
background-color: var(--black-a8);
|
||||||
|
backdrop-filter: blur(var(--space-3));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
</style>
|
</style>
|
||||||
|
|
||||||
<nav id="navbar-desktop">
|
<script>
|
||||||
<div class="overlay" />
|
// Mirrors apple.com's global nav: hover intent before opening, and a
|
||||||
|
// collapse duration that scales with the flyout's height
|
||||||
|
const HOVER_DELAY = 120;
|
||||||
|
const MIN_DURATION = 240;
|
||||||
|
const MAX_DURATION = 480;
|
||||||
|
|
||||||
<div class="expander">
|
const navbar = document.getElementById("navbar-fine")!;
|
||||||
|
const curtain = document.getElementById("navbar-fine-curtain")!;
|
||||||
|
const flyout = navbar.querySelector<HTMLElement>(".flyout")!;
|
||||||
|
const triggers = navbar.querySelectorAll<HTMLElement>(".trigger");
|
||||||
|
const panels = navbar.querySelectorAll<HTMLElement>(".panel");
|
||||||
|
const icons = navbar.querySelectorAll<HTMLElement>(".bar .icon");
|
||||||
|
|
||||||
|
let hoverTimeout: number | undefined;
|
||||||
|
|
||||||
|
function resize(height: number) {
|
||||||
|
const duration = Math.min(MAX_DURATION, Math.max(MIN_DURATION, height / 2));
|
||||||
|
|
||||||
|
flyout.style.transitionDuration = `${duration}ms`;
|
||||||
|
flyout.style.height = `${height}px`;
|
||||||
|
}
|
||||||
|
|
||||||
|
function open(group: string) {
|
||||||
|
let height = 0;
|
||||||
|
|
||||||
|
navbar.dataset.open = "true";
|
||||||
|
curtain.dataset.open = "true";
|
||||||
|
|
||||||
|
for (const trigger of triggers) {
|
||||||
|
trigger.dataset.open = `${trigger.dataset.group === group}`;
|
||||||
|
}
|
||||||
|
|
||||||
|
for (const panel of panels) {
|
||||||
|
const active = panel.dataset.group === group;
|
||||||
|
|
||||||
|
panel.dataset.active = `${active}`;
|
||||||
|
if (active) height = panel.offsetHeight;
|
||||||
|
}
|
||||||
|
|
||||||
|
resize(height);
|
||||||
|
}
|
||||||
|
|
||||||
|
function close() {
|
||||||
|
clearTimeout(hoverTimeout);
|
||||||
|
|
||||||
|
if (navbar.dataset.open !== "true") return;
|
||||||
|
|
||||||
|
navbar.dataset.open = "false";
|
||||||
|
curtain.dataset.open = "false";
|
||||||
|
|
||||||
|
for (const trigger of triggers) trigger.dataset.open = "false";
|
||||||
|
|
||||||
|
resize(0);
|
||||||
|
}
|
||||||
|
|
||||||
|
for (const trigger of triggers) {
|
||||||
|
const group = trigger.dataset.group!;
|
||||||
|
|
||||||
|
trigger.addEventListener("mouseenter", () => {
|
||||||
|
clearTimeout(hoverTimeout);
|
||||||
|
hoverTimeout = window.setTimeout(() => open(group), HOVER_DELAY);
|
||||||
|
});
|
||||||
|
|
||||||
|
trigger.addEventListener("mouseleave", () => {
|
||||||
|
clearTimeout(hoverTimeout);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
for (const icon of icons) {
|
||||||
|
icon.addEventListener("mouseenter", () => {
|
||||||
|
clearTimeout(hoverTimeout);
|
||||||
|
hoverTimeout = window.setTimeout(close, HOVER_DELAY);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
// Panels stay mounted while collapsing; unmount them after so the next
|
||||||
|
// open replays the staggered fade in
|
||||||
|
flyout.addEventListener("transitionend", (event) => {
|
||||||
|
if (event.target !== flyout || navbar.dataset.open === "true") return;
|
||||||
|
|
||||||
|
for (const panel of panels) panel.dataset.active = "false";
|
||||||
|
});
|
||||||
|
|
||||||
|
navbar.addEventListener("mouseleave", close);
|
||||||
|
curtain.addEventListener("pointerdown", close);
|
||||||
|
window.addEventListener("scroll", close, { passive: true });
|
||||||
|
|
||||||
|
navbar.addEventListener("focusout", (event) => {
|
||||||
|
if (navbar.contains(event.relatedTarget as Node | null)) return;
|
||||||
|
|
||||||
|
close();
|
||||||
|
});
|
||||||
|
|
||||||
|
document.addEventListener("keydown", (event) => {
|
||||||
|
if (event.key !== "Escape" || navbar.dataset.open !== "true") return;
|
||||||
|
|
||||||
|
const trigger = navbar.querySelector<HTMLElement>(
|
||||||
|
'.trigger[data-open="true"]',
|
||||||
|
);
|
||||||
|
|
||||||
|
close();
|
||||||
|
trigger!.closest("a")!.focus();
|
||||||
|
});
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<div id="navbar-fine-curtain" data-open="false"></div>
|
||||||
|
|
||||||
|
<nav id="navbar-fine" data-open="false">
|
||||||
|
<div class="bar">
|
||||||
<LinkI18nWrapper {locale} href="/">
|
<LinkI18nWrapper {locale} href="/">
|
||||||
<div class="named-link">
|
<Logo className="icon" />
|
||||||
<Logo className="icon" />
|
|
||||||
<Text className="name">{strings.navbar.home}</Text>
|
|
||||||
</div>
|
|
||||||
</LinkI18nWrapper>
|
</LinkI18nWrapper>
|
||||||
|
|
||||||
<div class="tools">
|
{groups.map((group) => (
|
||||||
{filtered
|
<LinkI18nWrapper {locale} href={group.href}>
|
||||||
.filter((tool) => !tool.hide_in_navbar_desktop)
|
<span class="trigger" data-group={group.id} data-open="false">
|
||||||
.map((tool) => (
|
<Text size="minor" className="name">
|
||||||
<>
|
{group.name}
|
||||||
|
</Text>
|
||||||
|
</span>
|
||||||
|
</LinkI18nWrapper>
|
||||||
|
))}
|
||||||
|
|
||||||
|
<SettingsDialog {locale} {localeOptions} client:load>
|
||||||
|
<GearIcon className="icon" />
|
||||||
|
</SettingsDialog>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="flyout">
|
||||||
|
{groups.map((group) => (
|
||||||
|
<div class="panel" data-group={group.id} data-active="false">
|
||||||
|
<Text size="minor" lowContrast className="header">
|
||||||
|
{group.name}
|
||||||
|
</Text>
|
||||||
|
|
||||||
|
<div class="tools">
|
||||||
|
{group.tools.map((tool, index) => (
|
||||||
<LinkI18nWrapper {locale} href={`/${tool.slug ?? tool.id}`}>
|
<LinkI18nWrapper {locale} href={`/${tool.slug ?? tool.id}`}>
|
||||||
<div class="tool">
|
<div class="tool" style={`--index: ${index + 1}`}>
|
||||||
<div
|
<div
|
||||||
|
class="thumbnail"
|
||||||
style={`background-image: url(${alias(
|
style={`background-image: url(${alias(
|
||||||
"api",
|
"api",
|
||||||
`/tools/${tool.id}/banners/thumbnail.webp`,
|
`/tools/${tool.id}/banners/thumbnail.webp`,
|
||||||
)})`}
|
)})`}
|
||||||
class="logo"
|
|
||||||
/>
|
/>
|
||||||
|
|
||||||
<Text className="name">
|
<Text size="major" weight="medium" className="name">
|
||||||
{strings.tools[tool.id as keyof typeof strings.tools]}
|
{strings.tools[tool.id as keyof typeof strings.tools]}
|
||||||
</Text>
|
</Text>
|
||||||
</div>
|
</div>
|
||||||
</LinkI18nWrapper>
|
</LinkI18nWrapper>
|
||||||
</>
|
))}
|
||||||
))}
|
</div>
|
||||||
</div>
|
|
||||||
|
|
||||||
<SettingsDialog {locale} {localeOptions} client:load>
|
|
||||||
<div class="named-link">
|
|
||||||
<GearIcon className="icon" />
|
|
||||||
<Text className="name">{strings.navbar.settings}</Text>
|
|
||||||
</div>
|
</div>
|
||||||
</SettingsDialog>
|
))}
|
||||||
</div>
|
</div>
|
||||||
</nav>
|
</nav>
|
||||||
@@ -2,22 +2,6 @@
|
|||||||
display: flex;
|
display: flex;
|
||||||
flex-direction: column;
|
flex-direction: column;
|
||||||
|
|
||||||
padding-right: var(--page-padding);
|
|
||||||
|
|
||||||
/* astro island's children sometimes end up being first deeper into the div's */
|
|
||||||
&:first-child:not(astro-island > &) {
|
|
||||||
padding-top: var(--page-padding);
|
|
||||||
}
|
|
||||||
|
|
||||||
&:last-child {
|
|
||||||
flex: 1;
|
|
||||||
padding-bottom: var(--page-padding);
|
|
||||||
}
|
|
||||||
|
|
||||||
@media (pointer: coarse) {
|
|
||||||
padding-left: var(--page-padding);
|
|
||||||
}
|
|
||||||
|
|
||||||
&[data-overflow="true"] {
|
&[data-overflow="true"] {
|
||||||
overflow-x: auto;
|
overflow-x: auto;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,15 @@
|
|||||||
|
<style>
|
||||||
|
.sections {
|
||||||
|
flex: 1;
|
||||||
|
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
gap: var(--page-padding);
|
||||||
|
|
||||||
|
padding: 0 var(--page-padding) var(--page-padding);
|
||||||
|
}
|
||||||
|
</style>
|
||||||
|
|
||||||
|
<div class="sections">
|
||||||
|
<slot />
|
||||||
|
</div>
|
||||||
@@ -18,17 +18,11 @@ const name = strings.tools[tool.id as keyof typeof strings.tools];
|
|||||||
<style>
|
<style>
|
||||||
.tool-banner {
|
.tool-banner {
|
||||||
--tool-banner-overlap: 8rem;
|
--tool-banner-overlap: 8rem;
|
||||||
--margin: var(--space-4);
|
|
||||||
|
|
||||||
overflow: hidden;
|
overflow: hidden;
|
||||||
|
|
||||||
background-size: cover;
|
background-size: cover;
|
||||||
|
|
||||||
@media (pointer: fine) {
|
|
||||||
border-radius: var(--space-4);
|
|
||||||
margin: var(--page-padding) var(--page-padding) 0 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
.content {
|
.content {
|
||||||
width: 100%;
|
width: 100%;
|
||||||
height: 100%;
|
height: 100%;
|
||||||
|
|||||||
@@ -10,7 +10,6 @@ export interface Tool {
|
|||||||
|
|
||||||
banner_background_position: "top" | "center" | "bottom";
|
banner_background_position: "top" | "center" | "bottom";
|
||||||
hide_in_navbar?: boolean;
|
hide_in_navbar?: boolean;
|
||||||
hide_in_navbar_desktop?: boolean;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export const tools: Record<string, Tool> = {
|
export const tools: Record<string, Tool> = {
|
||||||
@@ -18,7 +17,6 @@ export const tools: Record<string, Tool> = {
|
|||||||
id: "home",
|
id: "home",
|
||||||
slug: "",
|
slug: "",
|
||||||
banner_background_position: "center",
|
banner_background_position: "center",
|
||||||
hide_in_navbar_desktop: true,
|
|
||||||
},
|
},
|
||||||
tanks: {
|
tanks: {
|
||||||
id: "tanks",
|
id: "tanks",
|
||||||
@@ -97,6 +95,42 @@ export const tools: Record<string, Tool> = {
|
|||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
|
export interface ToolGroup {
|
||||||
|
// Key into strings.home, which titles the group on the home page
|
||||||
|
id: string;
|
||||||
|
// Where clicking the group's title in the navbar goes
|
||||||
|
default: string;
|
||||||
|
tools: string[];
|
||||||
|
}
|
||||||
|
|
||||||
|
export const toolGroups: ToolGroup[] = [
|
||||||
|
{
|
||||||
|
id: "tanks",
|
||||||
|
default: "tanks",
|
||||||
|
tools: ["tanks", "compare", "performance", "tier_list"],
|
||||||
|
},
|
||||||
|
{
|
||||||
|
id: "players",
|
||||||
|
default: "players",
|
||||||
|
tools: ["players", "session", "embed", "playlist"],
|
||||||
|
},
|
||||||
|
{
|
||||||
|
id: "games",
|
||||||
|
default: "mixer",
|
||||||
|
tools: ["mixer", "guesser"],
|
||||||
|
},
|
||||||
|
{
|
||||||
|
id: "cosmetics",
|
||||||
|
default: "avatars",
|
||||||
|
tools: ["avatars", "backgrounds"],
|
||||||
|
},
|
||||||
|
{
|
||||||
|
id: "technical",
|
||||||
|
default: "api",
|
||||||
|
tools: ["api", "changelogs"],
|
||||||
|
},
|
||||||
|
];
|
||||||
|
|
||||||
export enum ToolBannerSize {
|
export enum ToolBannerSize {
|
||||||
Thumbnail = "thumbnail",
|
Thumbnail = "thumbnail",
|
||||||
Poster = "poster",
|
Poster = "poster",
|
||||||
|
|||||||
@@ -58,10 +58,6 @@ const { locale, accent, solidNavbar = false, tool } = Astro.props;
|
|||||||
display: flex;
|
display: flex;
|
||||||
flex-direction: column;
|
flex-direction: column;
|
||||||
|
|
||||||
@media (pointer: fine) {
|
|
||||||
flex-direction: row-reverse;
|
|
||||||
}
|
|
||||||
|
|
||||||
background-color: var(--gray-1);
|
background-color: var(--gray-1);
|
||||||
color: var(--gray-12);
|
color: var(--gray-12);
|
||||||
font-family: var(--font-family-regular);
|
font-family: var(--font-family-regular);
|
||||||
@@ -70,6 +66,9 @@ const { locale, accent, solidNavbar = false, tool } = Astro.props;
|
|||||||
flex: 1;
|
flex: 1;
|
||||||
min-width: 0;
|
min-width: 0;
|
||||||
|
|
||||||
|
/* Contains the page's own z-index: 1 layers so they can't rise over the navbars */
|
||||||
|
isolation: isolate;
|
||||||
|
|
||||||
display: flex;
|
display: flex;
|
||||||
flex-direction: column;
|
flex-direction: column;
|
||||||
|
|
||||||
@@ -80,13 +79,14 @@ const { locale, accent, solidNavbar = false, tool } = Astro.props;
|
|||||||
</head>
|
</head>
|
||||||
|
|
||||||
<body data-solid-navbar={solidNavbar}>
|
<body data-solid-navbar={solidNavbar}>
|
||||||
|
<NavbarFine {locale} />
|
||||||
|
|
||||||
<main class="main">
|
<main class="main">
|
||||||
<slot />
|
<slot />
|
||||||
</main>
|
</main>
|
||||||
|
|
||||||
<AutoFocus />
|
<AutoFocus />
|
||||||
|
|
||||||
<NavbarFine {locale} {tool} />
|
|
||||||
<NavbarCourse {locale} {tool} solid={solidNavbar} />
|
<NavbarCourse {locale} {tool} solid={solidNavbar} />
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
Binary file not shown.
|
After Width: | Height: | Size: 325 KiB |
Binary file not shown.
|
After Width: | Height: | Size: 322 KiB |
Binary file not shown.
|
After Width: | Height: | Size: 308 KiB |
@@ -4,6 +4,7 @@ import { CompareControls } from "../../../../components/CompareControls";
|
|||||||
import { CompareTable } from "../../../../components/CompareTable";
|
import { CompareTable } from "../../../../components/CompareTable";
|
||||||
import CompareURLManager from "../../../../components/CompareURLManager.astro";
|
import CompareURLManager from "../../../../components/CompareURLManager.astro";
|
||||||
import { Section } from "../../../../components/Section";
|
import { Section } from "../../../../components/Section";
|
||||||
|
import Sections from "../../../../components/Sections.astro";
|
||||||
import ToolBanner from "../../../../components/ToolBanner.astro";
|
import ToolBanner from "../../../../components/ToolBanner.astro";
|
||||||
import { tools } from "../../../../config/tools";
|
import { tools } from "../../../../config/tools";
|
||||||
import BaseLayout from "../../../../layouts/BaseLayout.astro";
|
import BaseLayout from "../../../../layouts/BaseLayout.astro";
|
||||||
@@ -30,13 +31,15 @@ const { locale } = Astro.props;
|
|||||||
<ToolBanner tool={tools.compare} {locale} />
|
<ToolBanner tool={tools.compare} {locale} />
|
||||||
<CompareURLManager />
|
<CompareURLManager />
|
||||||
|
|
||||||
<Section>
|
<Sections>
|
||||||
<div class="controls">
|
<Section>
|
||||||
<CompareControls {locale} client:load />
|
<div class="controls">
|
||||||
</div>
|
<CompareControls {locale} client:load />
|
||||||
</Section>
|
</div>
|
||||||
|
</Section>
|
||||||
|
|
||||||
<Section overflow>
|
<Section overflow>
|
||||||
<CompareTable {locale} client:load />
|
<CompareTable {locale} client:load />
|
||||||
</Section>
|
</Section>
|
||||||
|
</Sections>
|
||||||
</BaseLayout>
|
</BaseLayout>
|
||||||
@@ -3,7 +3,7 @@ import { assertSecret } from "@blitzkit/core";
|
|||||||
import locales from "@blitzkit/i18n/locales.json";
|
import locales from "@blitzkit/i18n/locales.json";
|
||||||
import { mixStaticPaths } from "../../../astro/mixStaticPaths";
|
import { mixStaticPaths } from "../../../astro/mixStaticPaths";
|
||||||
import HomeHero from "../../../components/HomeHero.astro";
|
import HomeHero from "../../../components/HomeHero.astro";
|
||||||
import HomeTanks from "../../../components/HomeTanks.astro";
|
import Sections from "../../../components/Sections.astro";
|
||||||
import { tools, type Tool } from "../../../config/tools";
|
import { tools, type Tool } from "../../../config/tools";
|
||||||
import BaseLayout from "../../../layouts/BaseLayout.astro";
|
import BaseLayout from "../../../layouts/BaseLayout.astro";
|
||||||
import { getStaticPaths as _getStaticPaths } from "../_index";
|
import { getStaticPaths as _getStaticPaths } from "../_index";
|
||||||
@@ -47,11 +47,13 @@ export const getStaticPaths = mixStaticPaths(_getStaticPaths, () => {
|
|||||||
|
|
||||||
<!-- {environment === "preview" && <AesonPlug />} -->
|
<!-- {environment === "preview" && <AesonPlug />} -->
|
||||||
|
|
||||||
<HomeTanks {locale} />
|
<Sections>
|
||||||
<!-- <HomePlayers {locale} /> -->
|
<!-- <HomeTanks {locale} /> -->
|
||||||
<!-- <HomeGames {locale} /> -->
|
<!-- <HomePlayers {locale} /> -->
|
||||||
<!-- <HomeCosmetics {locale} /> -->
|
<!-- <HomeGames {locale} /> -->
|
||||||
<!-- <HomeTechnical {locale} /> -->
|
<!-- <HomeCosmetics {locale} /> -->
|
||||||
|
<!-- <HomeTechnical {locale} /> -->
|
||||||
|
</Sections>
|
||||||
</BaseLayout>
|
</BaseLayout>
|
||||||
|
|
||||||
<!-- TODO: read temp/notes.md for user testing fixes -->
|
<!-- TODO: read temp/notes.md for user testing fixes -->
|
||||||
@@ -6,6 +6,7 @@ import { Section } from "../../../../components/Section";
|
|||||||
import { TankSearchBar } from "../../../../components/TankSearchBar";
|
import { TankSearchBar } from "../../../../components/TankSearchBar";
|
||||||
import { TankSearchFilters } from "../../../../components/TankSearchFilters";
|
import { TankSearchFilters } from "../../../../components/TankSearchFilters";
|
||||||
import { TankSearchResults } from "../../../../components/TankSearchResults";
|
import { TankSearchResults } from "../../../../components/TankSearchResults";
|
||||||
|
import Sections from "../../../../components/Sections.astro";
|
||||||
import ToolBanner from "../../../../components/ToolBanner.astro";
|
import ToolBanner from "../../../../components/ToolBanner.astro";
|
||||||
import { tools } from "../../../../config/tools";
|
import { tools } from "../../../../config/tools";
|
||||||
import BaseLayout from "../../../../layouts/BaseLayout.astro";
|
import BaseLayout from "../../../../layouts/BaseLayout.astro";
|
||||||
@@ -22,21 +23,23 @@ const { locale } = Astro.props;
|
|||||||
<BaseLayout tool={tools.tanks} {locale} accent="purple">
|
<BaseLayout tool={tools.tanks} {locale} accent="purple">
|
||||||
<ToolBanner {locale} tool={tools.tanks} />
|
<ToolBanner {locale} tool={tools.tanks} />
|
||||||
|
|
||||||
<Section overflow>
|
<Sections>
|
||||||
<ScrollerCurtains client:load />
|
<Section overflow>
|
||||||
<RecentlyViewedTanks {locale} client:load />
|
<ScrollerCurtains client:load />
|
||||||
</Section>
|
<RecentlyViewedTanks {locale} client:load />
|
||||||
|
</Section>
|
||||||
|
|
||||||
<Section>
|
<Section>
|
||||||
<TankSearchBar {locale} client:load />
|
<TankSearchBar {locale} client:load />
|
||||||
</Section>
|
</Section>
|
||||||
|
|
||||||
<Section overflow>
|
<Section overflow>
|
||||||
<ScrollerCurtains client:load />
|
<ScrollerCurtains client:load />
|
||||||
<TankSearchFilters {locale} client:load />
|
<TankSearchFilters {locale} client:load />
|
||||||
</Section>
|
</Section>
|
||||||
|
|
||||||
<Section>
|
<Section>
|
||||||
<TankSearchResults {locale} client:load />
|
<TankSearchResults {locale} client:load />
|
||||||
</Section>
|
</Section>
|
||||||
|
</Sections>
|
||||||
</BaseLayout>
|
</BaseLayout>
|
||||||
@@ -6,6 +6,7 @@ import { TankSearchFilters } from "../../../../components/TankSearchFilters";
|
|||||||
import { TierListControls } from "../../../../components/TierListControls";
|
import { TierListControls } from "../../../../components/TierListControls";
|
||||||
import { TierListTable } from "../../../../components/TierListTable";
|
import { TierListTable } from "../../../../components/TierListTable";
|
||||||
import { TierListTiles } from "../../../../components/TierListTiles";
|
import { TierListTiles } from "../../../../components/TierListTiles";
|
||||||
|
import Sections from "../../../../components/Sections.astro";
|
||||||
import TierListURLManager from "../../../../components/TierListURLManager.astro";
|
import TierListURLManager from "../../../../components/TierListURLManager.astro";
|
||||||
import ToolBanner from "../../../../components/ToolBanner.astro";
|
import ToolBanner from "../../../../components/ToolBanner.astro";
|
||||||
import { tierListColors } from "../../../../config/tierList";
|
import { tierListColors } from "../../../../config/tierList";
|
||||||
@@ -26,20 +27,22 @@ const { locale } = Astro.props;
|
|||||||
<ToolBanner tool={tools.tier_list} {locale} />
|
<ToolBanner tool={tools.tier_list} {locale} />
|
||||||
<TierListURLManager />
|
<TierListURLManager />
|
||||||
|
|
||||||
<Section>
|
<Sections>
|
||||||
<TierListControls {locale} client:load />
|
<Section>
|
||||||
</Section>
|
<TierListControls {locale} client:load />
|
||||||
|
</Section>
|
||||||
|
|
||||||
<Section>
|
<Section>
|
||||||
<TierListTable {locale} client:load />
|
<TierListTable {locale} client:load />
|
||||||
</Section>
|
</Section>
|
||||||
|
|
||||||
<Section overflow>
|
<Section overflow>
|
||||||
<ScrollerCurtains client:load />
|
<ScrollerCurtains client:load />
|
||||||
<TankSearchFilters {locale} client:load />
|
<TankSearchFilters {locale} client:load />
|
||||||
</Section>
|
</Section>
|
||||||
|
|
||||||
<Section>
|
<Section>
|
||||||
<TierListTiles {locale} client:load />
|
<TierListTiles {locale} client:load />
|
||||||
</Section>
|
</Section>
|
||||||
|
</Sections>
|
||||||
</BaseLayout>
|
</BaseLayout>
|
||||||
Reference in new issue
Block a user