From ab331b6b4432c95c2ecbe31b3cc892bb63a855c3 Mon Sep 17 00:00:00 2001 From: Ross Lovas Date: Tue, 11 Aug 2026 11:38:01 +0930 Subject: [PATCH 1/3] Add logged-in state to WIP new top nav --- dictionary-octopus.txt | 5 + src/components/Avatar.astro | 143 ++++++++++++++++++++++++++ src/components/TopNav.astro | 24 ++++- src/lib/avatar.ts | 59 +++++++++++ src/lib/signedInUser.ts | 68 +++++++++++++ src/pages/components.mdx | 23 +++++ src/scripts/avatar.ts | 71 +++++++++++++ src/scripts/signed-in-user.ts | 74 ++++++++++++++ src/styles/button.css | 4 + tests/avatar-fallback-text.spec.ts | 50 +++++++++ tests/topnav-signedin.spec.ts | 157 +++++++++++++++++++++++++++++ 11 files changed, 676 insertions(+), 2 deletions(-) create mode 100644 src/components/Avatar.astro create mode 100644 src/lib/avatar.ts create mode 100644 src/lib/signedInUser.ts create mode 100644 src/scripts/avatar.ts create mode 100644 src/scripts/signed-in-user.ts create mode 100644 tests/avatar-fallback-text.spec.ts create mode 100644 tests/topnav-signedin.spec.ts diff --git a/dictionary-octopus.txt b/dictionary-octopus.txt index 3d54554a5e..45b0d8d11c 100644 --- a/dictionary-octopus.txt +++ b/dictionary-octopus.txt @@ -6,6 +6,7 @@ advfirewall agentic allatclaims ALLUSERSPROFILE +andré anglin anotherdir Antiforgery @@ -59,6 +60,7 @@ buildevent buildinfo buildmetadata CAIQ +çelik Ceph certkeyName Certstore @@ -182,6 +184,7 @@ fontawesome frontmatter functionapp g3662re9njtelsyfhm7t +García gcloud gcore getenv @@ -246,6 +249,7 @@ ITSM javac jdbc jjones +José journalctl jsondecode JSSE @@ -309,6 +313,7 @@ msiexec mssqldb MSSQLSERVER MTTR +Müller multifactor Multipath multistep diff --git a/src/components/Avatar.astro b/src/components/Avatar.astro new file mode 100644 index 0000000000..81a0ce2f55 --- /dev/null +++ b/src/components/Avatar.astro @@ -0,0 +1,143 @@ +--- +import type { HTMLAttributes } from 'astro/types'; +import type { AvatarShape, AvatarSize } from '../lib/avatar'; + +type SharedProps = { + size: AvatarSize; + shape: AvatarShape; + src?: string; + srcSet?: string; + alt?: string; + isMuted?: boolean; + title?: string; +}; + +type Props = + | (HTMLAttributes<'div'> & SharedProps & { href?: never }) + | (HTMLAttributes<'a'> & SharedProps & { href: string | URL }); + +const { + size, + shape, + src, + srcSet, + alt = '', + isMuted = false, + title, + href, + class: className, + ...rest +} = Astro.props satisfies Props; + +const classes = `avatar avatar--${size} avatar--${shape}${isMuted ? ' avatar--muted' : ''}${className ? ` ${className}` : ''}`; + +const Tag = href ? 'a' : 'div'; +--- + + + + + + + + + diff --git a/src/components/TopNav.astro b/src/components/TopNav.astro index 7ef723885e..0b32e3f792 100644 --- a/src/components/TopNav.astro +++ b/src/components/TopNav.astro @@ -1,5 +1,6 @@ --- import Logo from '../assets/octopus-logo-v2.svg'; +import Avatar from './Avatar.astro'; import Button from './Button.astro'; type Props = { @@ -50,7 +51,26 @@ const {