mirror of
https://github.com/blitzkit/blitzkit.git
synced 2026-12-04 23:32:54 +01:00
sticky search
This commit is contained in:
6 files changed
+86
-41
No files matched your search
@@ -0,0 +1,32 @@
|
||||
.controls {
|
||||
position: sticky;
|
||||
z-index: 1;
|
||||
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: var(--space-4);
|
||||
|
||||
margin-block: calc(-1 * var(--space-4));
|
||||
padding-block: var(--space-4);
|
||||
|
||||
/* Bleeds across the page gutters so results don't peek out beside it */
|
||||
&[data-surface="page"] {
|
||||
top: var(--navbar-big-height, 0);
|
||||
|
||||
margin-inline: calc(-1 * var(--page-padding));
|
||||
padding-inline: var(--page-padding);
|
||||
|
||||
background-color: var(--gray-1);
|
||||
}
|
||||
|
||||
/* Cancels the overlay's padding, which sticky offsets are measured inside of */
|
||||
&[data-surface="dialog"] {
|
||||
top: calc(-1 * var(--space-4));
|
||||
|
||||
background-color: var(--gray-2);
|
||||
}
|
||||
|
||||
.filters {
|
||||
overflow-x: auto;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,35 @@
|
||||
import type { TankDefinition } from "@blitzkit/protos";
|
||||
import type { LocaleAcceptorProps } from "../../hooks/useLocale";
|
||||
import { ScrollerCurtains } from "../ScrollerCurtains";
|
||||
import { TankSearchBar } from "../TankSearchBar";
|
||||
import { TankSearchFilters } from "../TankSearchFilters";
|
||||
import styles from "./index.module.css";
|
||||
|
||||
export enum TankSearchControlsSurface {
|
||||
Page = "page",
|
||||
Dialog = "dialog",
|
||||
}
|
||||
|
||||
interface TankSearchControlsProps extends LocaleAcceptorProps {
|
||||
// Which surface it sticks within, deciding its offset and background
|
||||
surface: TankSearchControlsSurface;
|
||||
onSelect?: (tank: TankDefinition) => void;
|
||||
}
|
||||
|
||||
// The search bar and filters, stuck flush to the top while the results scroll
|
||||
export function TankSearchControls({
|
||||
locale,
|
||||
surface,
|
||||
onSelect,
|
||||
}: TankSearchControlsProps) {
|
||||
return (
|
||||
<div className={styles.controls} data-surface={surface}>
|
||||
<TankSearchBar locale={locale} onSelect={onSelect} />
|
||||
|
||||
<div className={styles.filters}>
|
||||
<ScrollerCurtains />
|
||||
<TankSearchFilters locale={locale} />
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
@@ -1,18 +0,0 @@
|
||||
.controls {
|
||||
position: sticky;
|
||||
top: calc(-1 * var(--space-4));
|
||||
z-index: 1;
|
||||
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: var(--space-4);
|
||||
|
||||
margin-block: calc(-1 * var(--space-4));
|
||||
padding-block: var(--space-4);
|
||||
|
||||
background-color: var(--gray-2);
|
||||
|
||||
.filters {
|
||||
overflow-x: auto;
|
||||
}
|
||||
}
|
||||
@@ -3,11 +3,11 @@ import { useCallback, useState, type ReactNode } from "react";
|
||||
import { useLocale } from "../../hooks/useLocale";
|
||||
import { useStrings } from "../../hooks/useStrings";
|
||||
import { Dialog } from "../Dialog";
|
||||
import { ScrollerCurtains } from "../ScrollerCurtains";
|
||||
import { TankSearchBar } from "../TankSearchBar";
|
||||
import { TankSearchFilters } from "../TankSearchFilters";
|
||||
import {
|
||||
TankSearchControls,
|
||||
TankSearchControlsSurface,
|
||||
} from "../TankSearchControls";
|
||||
import { TankSearchResults } from "../TankSearchResults";
|
||||
import styles from "./index.module.css";
|
||||
|
||||
interface TankSearchDialogProps {
|
||||
// the trigger, passed to Dialog.Trigger with asChild
|
||||
@@ -64,14 +64,11 @@ export function TankSearchDialog({
|
||||
</Dialog.Header>
|
||||
|
||||
<Dialog.Body>
|
||||
<div className={styles.controls}>
|
||||
<TankSearchBar locale={locale} onSelect={handleSelect} />
|
||||
|
||||
<div className={styles.filters}>
|
||||
<ScrollerCurtains />
|
||||
<TankSearchFilters locale={locale} />
|
||||
</div>
|
||||
</div>
|
||||
<TankSearchControls
|
||||
locale={locale}
|
||||
surface={TankSearchControlsSurface.Dialog}
|
||||
onSelect={handleSelect}
|
||||
/>
|
||||
|
||||
<TankSearchResults
|
||||
locale={locale}
|
||||
|
||||
Reference in new issue
Block a user