From 636b0323075225c584b62719ed51e75521bb7ffb Mon Sep 17 00:00:00 2001 From: aura Date: Tue, 17 Feb 2026 22:39:42 +0100 Subject: push source --- moneyjsx/src/header.tsx | 98 +++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 98 insertions(+) create mode 100644 moneyjsx/src/header.tsx (limited to 'moneyjsx/src/header.tsx') diff --git a/moneyjsx/src/header.tsx b/moneyjsx/src/header.tsx new file mode 100644 index 0000000..e79e256 --- /dev/null +++ b/moneyjsx/src/header.tsx @@ -0,0 +1,98 @@ +import $ from 'jquery'; +import * as JSX from './jsx'; +import * as user from './user'; +import * as settings from './settings'; +import { Dropdown, DropdownItem, Spinner, addPopup } from './components'; + + +async function logout() { + await user.logout(); +} + +/** + * NavItem component + * takes in title and route, optionally "disabled" +**/ +function NavItem( props: any ) { + const url = new URL( window.location.href ); + var style = `height: 45px;`; + var onclick = () => JSX.navigate( props.route ); + if( props.disabled || url.pathname == props.route ) { + style += "color: #888;pointer-events: none;"; + onclick = null; + } + + return + [ { props.title } ] + +} + +function SettingsButton( props: any ) { + let openSettings = settings.openPopup; + let style = `height: 45px;`; + + if( props.disabled ) { + openSettings = null; + style += "color: #888; pointer-events: none;"; + } + + return + [ Settings ] + +} + +function EmailInput() { + const sendLink = async () => { + const email = $( "#login-email" ).val().toString(); + $( "#login-btn-wrapper" ).append( ); + + const res = await user.sendLoginLink( email ); + if( res === true ) { + $( "#header-login-dropdown" ).replaceWith( +
Success! Check your inbox for a login link.
+ ); + } else { + $( "#header-login-dropdown" ).replaceWith( +
Error sending email: { res }
+ ); + } + }; + + return
+
+ Log in + +
+ +
+
+
+} + +function showLoginPopup() { + addPopup( $( ) ); +} + +export function Header() { + return +} -- cgit v1.2.3