Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

💄 Sticky TopBar #439

Merged
merged 1 commit into from
Jun 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 24 additions & 1 deletion frontend/src/common/top_bar.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
import clsx from 'clsx';
import { useLocation } from 'wouter';

import { storeAuthToken } from '../api';
import { logout } from '../api/user';
import { primitiveWithClassname } from '../styled';
Expand All @@ -8,7 +10,28 @@ import { Popup } from '../components/popup';
import { showModal } from '../components/modal';
import { ChangePasswordModal } from '../components/change_password';
import { useAuthData } from '../utils/auth';
export const TopBar = primitiveWithClassname('div', 'mb-8 flex items-center gap-4 justify-between');

const TopBarBg = primitiveWithClassname(
'div',
'fixed left-0 right-0 top-0 bg-black h-[52px] -z-10 bg-white dark:bg-neutral-900',
);

export function TopBar({ children, className }: { children: React.ReactNode; className?: string }) {
return (
<div
className={clsx(
'sticky top-0 z-10',
'-mx-6 px-6 -mt-6 mb-6 py-2',
'flex items-center gap-4 justify-between',
'bg-white dark:bg-neutral-900',
className,
)}
>
<TopBarBg />
{children}
</div>
);
}
export const TopBarTitle = primitiveWithClassname('h2', 'text-xl font-bold');
export const TopBarPart = primitiveWithClassname('div', 'gap-4 flex items-center');

Expand Down
2 changes: 1 addition & 1 deletion frontend/src/pages/document.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ export function DocumentPage({
<Helmet>
<title>{data?.name}</title>
</Helmet>
<TopBar className="!items-start z-40 relative">
<TopBar className="!items-start z-40">
<TopBarPart className={isLoggedIn ? 'sticky left-4 -ml-12 !items-start' : ''}>
{isLoggedIn && (
<IconButton
Expand Down
Loading