Commit 9c550f78 authored by Lyza Danger Gardner's avatar Lyza Danger Gardner Committed by Lyza Gardner

Convert `TopBar` to TS

parent c8610002
...@@ -7,10 +7,14 @@ import { ...@@ -7,10 +7,14 @@ import {
} from '@hypothesis/frontend-shared/lib/next'; } from '@hypothesis/frontend-shared/lib/next';
import classnames from 'classnames'; import classnames from 'classnames';
import type { SidebarSettings } from '../../types/config';
import { serviceConfig } from '../config/service-config'; import { serviceConfig } from '../config/service-config';
import { isThirdPartyService } from '../helpers/is-third-party-service'; import { isThirdPartyService } from '../helpers/is-third-party-service';
import { applyTheme } from '../helpers/theme'; import { applyTheme } from '../helpers/theme';
import { withServices } from '../service-context'; import { withServices } from '../service-context';
import type { FrameSyncService } from '../services/frame-sync';
import type { StreamerService } from '../services/streamer';
import { useSidebarStore } from '../store'; import { useSidebarStore } from '../store';
import GroupList from './GroupList'; import GroupList from './GroupList';
...@@ -19,39 +23,38 @@ import SortMenu from './SortMenu'; ...@@ -19,39 +23,38 @@ import SortMenu from './SortMenu';
import StreamSearchInput from './StreamSearchInput'; import StreamSearchInput from './StreamSearchInput';
import UserMenu from './UserMenu'; import UserMenu from './UserMenu';
/** export type TopBarProps = {
* @typedef {import('preact').ComponentChildren} Children /** Flag indicating whether the app is in a sidebar context */
* @typedef {import('../services/frame-sync').FrameSyncService} FrameSyncService isSidebar: boolean;
* @typedef {import('../../types/config').SidebarSettings} SidebarSettings
* @typedef {import('../services/streamer').StreamerService} StreamerService
*/
/** /** Callback invoked when user clicks "Login" button */
* @typedef TopBarProps onLogin: () => void;
* @prop {FrameSyncService} frameSync - injected
* @prop {boolean} isSidebar - Flag indicating whether the app is the sidebar or a top-level page. /** Callback invoked when user clicks "Logout" action in account menu */
* @prop {() => void} onLogin - Callback invoked when user clicks "Login" button. onLogout: () => void;
* @prop {() => void} onLogout - Callback invoked when user clicks "Logout" action in account menu.
* @prop {() => void} onSignUp - Callback invoked when user clicks "Sign up" button. /** Callback invoked when user clicks "Sign up" button */
* @prop {SidebarSettings} settings - injected onSignUp: () => void;
* @prop {StreamerService} streamer - injected
*/ // injected
frameSync: FrameSyncService;
settings: SidebarSettings;
streamer: StreamerService;
};
/** /**
* The toolbar which appears at the top of the sidebar providing actions * The toolbar which appears at the top of the sidebar providing actions
* to switch groups, view account information, sort/filter annotations etc. * to switch groups, view account information, sort/filter annotations etc.
*
* @param {TopBarProps} props
*/ */
function TopBar({ function TopBar({
frameSync,
isSidebar, isSidebar,
onLogin, onLogin,
onLogout, onLogout,
onSignUp, onSignUp,
frameSync,
settings, settings,
streamer, streamer,
}) { }: TopBarProps) {
const showSharePageButton = !isThirdPartyService(settings); const showSharePageButton = !isThirdPartyService(settings);
const loginLinkStyle = applyTheme(['accentColor'], settings); const loginLinkStyle = applyTheme(['accentColor'], settings);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment