feat(dashboard-v2): Archie motion mark on login, mark favicon
This commit is contained in:
1 parent
0d8c48cbf4
commit
1add0fca32
3 files changed
+212
-10
No files matched your search
@@ -5,7 +5,7 @@
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||
<link
|
||||
rel="icon"
|
||||
href="data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3E%3Crect width='16' height='16' rx='3' fill='%23111'/%3E%3C/svg%3E"
|
||||
href="data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='2 3 20 18'%3E%3Cpath d='M2.00 21.00 L6.00 21.00 L14.00 3.00 L10.00 3.00Z' fill='%23111'/%3E%3Cpath d='M14.90 5.03 L22.00 21.00 L18.00 21.00 L12.90 9.53Z' fill='%23111'/%3E%3Cpath d='M10.47 15.00 L13.53 15.00 L14.64 17.50 L9.36 17.50Z' fill='%2351a580'/%3E%3C/svg%3E"
|
||||
/>
|
||||
<title>Status | Archie</title>
|
||||
</head>
|
||||
|
||||
@@ -0,0 +1,209 @@
|
||||
import {
|
||||
useCallback,
|
||||
useEffect,
|
||||
useLayoutEffect,
|
||||
useRef,
|
||||
useState,
|
||||
type CSSProperties,
|
||||
} from "react";
|
||||
|
||||
/** Brand sage, mirroring v1's shared `--sage` accent. */
|
||||
export const ARCHIE_SAGE = "#51a580";
|
||||
|
||||
const LEGS_LEFT = "M2.00 21.00 L6.00 21.00 L14.00 3.00 L10.00 3.00Z";
|
||||
const LEGS_RIGHT = "M14.90 5.03 L22.00 21.00 L18.00 21.00 L12.90 9.53Z";
|
||||
const BAR = "M10.47 15.00 L13.53 15.00 L14.64 17.50 L9.36 17.50Z";
|
||||
|
||||
/** Suffixes the open mark cycles through, with their accessible names. */
|
||||
const NAMES = ["rchie", "rchitect", "rchimedes", "rchipelago"];
|
||||
const LABELS = ["Archie", "Architect", "Archimedes", "archipelago"];
|
||||
|
||||
const EASE = "cubic-bezier(0.2, 0.7, 0.2, 1)";
|
||||
const BOOT_OPEN_MS = 700;
|
||||
const HOLD_MS = 2400;
|
||||
const CYCLE_MS = 1800;
|
||||
const SWAP_MS = 200;
|
||||
|
||||
function MarkArt({booted}: {booted: boolean}): React.JSX.Element {
|
||||
return (
|
||||
<svg
|
||||
viewBox="2 3 20 18"
|
||||
aria-hidden="true"
|
||||
style={{
|
||||
height: "0.698em",
|
||||
width: "calc(0.698em * 20 / 18)",
|
||||
display: "block",
|
||||
flex: "none",
|
||||
alignSelf: "baseline",
|
||||
overflow: "visible",
|
||||
}}
|
||||
>
|
||||
<path d={LEGS_LEFT} fill="currentColor" />
|
||||
<path d={LEGS_RIGHT} fill="currentColor" />
|
||||
<path
|
||||
d={BAR}
|
||||
fill={ARCHIE_SAGE}
|
||||
style={{
|
||||
transition: "transform 520ms cubic-bezier(0.2, 0.7, 0.2, 1)",
|
||||
transform: booted ? undefined : "translateY(6px)",
|
||||
opacity: booted ? undefined : 0,
|
||||
}}
|
||||
/>
|
||||
</svg>
|
||||
);
|
||||
}
|
||||
|
||||
/** The static A mark, for shells and topbars. */
|
||||
export function ArchieMark({size = 16}: {size?: number}): React.JSX.Element {
|
||||
return (
|
||||
<span
|
||||
role="img"
|
||||
aria-label="Archie"
|
||||
style={{fontSize: size, lineHeight: 1, display: "inline-flex"}}
|
||||
>
|
||||
<MarkArt booted />
|
||||
</span>
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* The full logo: the A opens out to the name on mount, holds, folds back,
|
||||
* and reopens on hover or focus, cycling the name while open. Reduced motion
|
||||
* gets no transitions and the name on hover only.
|
||||
*/
|
||||
export default function ArchieLogo({
|
||||
size = 32,
|
||||
}: {
|
||||
size?: number;
|
||||
}): React.JSX.Element {
|
||||
const [booted, setBooted] = useState(false);
|
||||
const [open, setOpen] = useState(false);
|
||||
const [nameIndex, setNameIndex] = useState(0);
|
||||
const [swapping, setSwapping] = useState(false);
|
||||
const [hovering, setHovering] = useState(false);
|
||||
const [reduced] = useState(
|
||||
() =>
|
||||
typeof window !== "undefined" &&
|
||||
window.matchMedia("(prefers-reduced-motion: reduce)").matches,
|
||||
);
|
||||
const suffixRef = useRef<HTMLSpanElement>(null);
|
||||
const textRef = useRef<HTMLSpanElement>(null);
|
||||
const foldTimer = useRef<number>(0);
|
||||
|
||||
const fit = useCallback(() => {
|
||||
const suffix = suffixRef.current;
|
||||
const text = textRef.current;
|
||||
if (suffix && text) {
|
||||
suffix.style.maxWidth = `${Math.ceil(text.getBoundingClientRect().width)}px`;
|
||||
}
|
||||
}, []);
|
||||
|
||||
const close = useCallback(() => {
|
||||
setOpen(false);
|
||||
window.setTimeout(() => setNameIndex(0), reduced ? 0 : 460);
|
||||
}, [reduced]);
|
||||
|
||||
// Boot once on mount: bar rises, name opens, holds, folds back.
|
||||
useEffect(() => {
|
||||
if (reduced) {
|
||||
setBooted(true);
|
||||
return;
|
||||
}
|
||||
const rise = window.setTimeout(() => setBooted(true), 150);
|
||||
const show = window.setTimeout(() => setOpen(true), BOOT_OPEN_MS);
|
||||
foldTimer.current = window.setTimeout(() => {
|
||||
setHovering(current => {
|
||||
if (!current) {
|
||||
setOpen(false);
|
||||
}
|
||||
return current;
|
||||
});
|
||||
}, BOOT_OPEN_MS + 460 + HOLD_MS);
|
||||
return () => {
|
||||
window.clearTimeout(rise);
|
||||
window.clearTimeout(show);
|
||||
window.clearTimeout(foldTimer.current);
|
||||
};
|
||||
}, [reduced]);
|
||||
|
||||
// Fit the suffix to the name whenever it opens or the name changes.
|
||||
useLayoutEffect(() => {
|
||||
if (open) {
|
||||
fit();
|
||||
} else if (suffixRef.current) {
|
||||
suffixRef.current.style.maxWidth = "0px";
|
||||
}
|
||||
}, [open, nameIndex, fit]);
|
||||
|
||||
// Cycle the name while open.
|
||||
useEffect(() => {
|
||||
if (!open || reduced) {
|
||||
return;
|
||||
}
|
||||
const timer = window.setInterval(() => {
|
||||
setSwapping(true);
|
||||
window.setTimeout(() => {
|
||||
setNameIndex(i => (i + 1) % NAMES.length);
|
||||
setSwapping(false);
|
||||
}, SWAP_MS);
|
||||
}, CYCLE_MS);
|
||||
return () => window.clearInterval(timer);
|
||||
}, [open, reduced]);
|
||||
|
||||
const show = () => {
|
||||
window.clearTimeout(foldTimer.current);
|
||||
setHovering(true);
|
||||
setOpen(true);
|
||||
};
|
||||
const hide = () => {
|
||||
setHovering(false);
|
||||
close();
|
||||
};
|
||||
|
||||
const logoStyle: CSSProperties = {
|
||||
display: "inline-flex",
|
||||
alignItems: "baseline",
|
||||
fontWeight: 600,
|
||||
letterSpacing: "-0.01em",
|
||||
lineHeight: 1,
|
||||
whiteSpace: "nowrap",
|
||||
fontSize: size,
|
||||
borderRadius: 8,
|
||||
outline: "none",
|
||||
};
|
||||
const suffixStyle: CSSProperties = {
|
||||
display: "inline-block",
|
||||
overflow: "hidden",
|
||||
paddingBottom: "0.25em",
|
||||
marginBottom: "-0.25em",
|
||||
maxWidth: 0,
|
||||
transition: reduced ? "none" : `max-width 460ms ${EASE}`,
|
||||
};
|
||||
const textStyle: CSSProperties = {
|
||||
display: "inline-block",
|
||||
width: "max-content",
|
||||
paddingLeft: "0.02em",
|
||||
transition: reduced ? "none" : "opacity 200ms ease, transform 200ms ease",
|
||||
opacity: swapping ? 0 : undefined,
|
||||
transform: swapping ? "translateY(0.18em)" : undefined,
|
||||
};
|
||||
|
||||
return (
|
||||
<span
|
||||
tabIndex={0}
|
||||
aria-label={LABELS[nameIndex]}
|
||||
style={logoStyle}
|
||||
onMouseEnter={show}
|
||||
onFocus={show}
|
||||
onMouseLeave={hide}
|
||||
onBlur={hide}
|
||||
>
|
||||
<MarkArt booted={booted} />
|
||||
<span ref={suffixRef} style={suffixStyle} aria-hidden="true">
|
||||
<span ref={textRef} style={textStyle}>
|
||||
{NAMES[nameIndex]}
|
||||
</span>
|
||||
</span>
|
||||
</span>
|
||||
);
|
||||
}
|
||||
@@ -4,12 +4,11 @@ import { Banner } from "@astryxdesign/core/Banner";
|
||||
import { Button } from "@astryxdesign/core/Button";
|
||||
import { Card } from "@astryxdesign/core/Card";
|
||||
import { Center } from "@astryxdesign/core/Center";
|
||||
import { Icon } from "@astryxdesign/core/Icon";
|
||||
import { VStack } from "@astryxdesign/core/Layout";
|
||||
import { Heading, Text } from "@astryxdesign/core/Text";
|
||||
import { TextInput } from "@astryxdesign/core/TextInput";
|
||||
import { CubeIcon } from "@heroicons/react/24/outline";
|
||||
|
||||
import ArchieLogo from "../components/ArchieLogo.tsx";
|
||||
import { useSession } from "../session.tsx";
|
||||
|
||||
// Standalone auth page paints its own body background (no host shell).
|
||||
@@ -50,13 +49,7 @@ export default function LoginPage() {
|
||||
return (
|
||||
<Center axis="both" padding={6} style={pageStyle}>
|
||||
<VStack gap={4} hAlign="center" style={contentStyle}>
|
||||
{/* Logo */}
|
||||
<VStack gap={2} hAlign="center">
|
||||
<Icon icon={CubeIcon} size="lg" />
|
||||
<Text type="body" weight="bold" size="lg">
|
||||
Archie
|
||||
</Text>
|
||||
</VStack>
|
||||
<ArchieLogo size={40} />
|
||||
|
||||
{/* Card */}
|
||||
<Card padding={8} width="100%">
|
||||
|
||||
Reference in new issue
Block a user