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

Implement navigation changes #267

Merged
merged 37 commits into from
Sep 10, 2024
Merged
Show file tree
Hide file tree
Changes from 28 commits
Commits
Show all changes
37 commits
Select commit Hold shift + click to select a range
b9efed3
feat: add dropdown menu component
1egoman Sep 5, 2024
b50a518
refactor: rework app layout to support different navbars in different…
1egoman Sep 5, 2024
84c5849
feat: add srcbook fetching to populate list of recent srcbooks
1egoman Sep 5, 2024
98daa75
feat: add logic to reinitialize the session view when navigating to a…
1egoman Sep 5, 2024
afb3cc3
fix: remove current srcbook from quick picker list
1egoman Sep 5, 2024
2046fc7
feat: add ability to add srcbook from top navbar
1egoman Sep 5, 2024
5083352
feat: add regular navbar implementation for rest of srcbook views
1egoman Sep 5, 2024
09fe0cc
fix: run npm run format
1egoman Sep 5, 2024
e626ab8
feat: add open srcbook modal to SessionNavbar
1egoman Sep 5, 2024
53d92e2
fix: adjust dropdown focus state colors to match select component
1egoman Sep 5, 2024
de0c54b
fix: remove downwards nudge on active state for navbar buttons
1egoman Sep 6, 2024
e6cb95f
fix: adjust z-index of navbar to make sure it's always above everythi…
1egoman Sep 6, 2024
db3e365
fix: remove relative from navbar
1egoman Sep 6, 2024
715d18a
feat: add initial sidebar and open / close mechanics
1egoman Sep 6, 2024
37a43a7
feat: define components for each page of the sidebar panel
1egoman Sep 6, 2024
68268e0
fix: run npm run format
1egoman Sep 6, 2024
a797054
feat: add ability to render sheet outside of a portal
1egoman Sep 9, 2024
cff4a4a
feat: add ability to open side panel in a sheet if the screen is too …
1egoman Sep 9, 2024
521be16
feat: decrease padding on sides of session wrapping div
1egoman Sep 9, 2024
7465006
feat: disable secrets panel for now
1egoman Sep 9, 2024
555942b
fix: allow vertical scrolling in session side panel
1egoman Sep 9, 2024
d3f5221
feat: adjust side panel text styling
1egoman Sep 9, 2024
0899cf6
chore: remove unused import
1egoman Sep 9, 2024
dafda3c
fix: address issue where "installing dependencies" toast would show t…
1egoman Sep 9, 2024
217796a
feat: render session sidebar on the left side of the SessionMenuPanel…
1egoman Sep 9, 2024
815f784
fix: remove dead code
1egoman Sep 9, 2024
34146b6
fix: update incorrect prop name
1egoman Sep 10, 2024
ea99a37
fix: address linter issues
1egoman Sep 10, 2024
835e7f4
fix: work around dialog closing leaving pointer-events: none on the body
1egoman Sep 10, 2024
2b67b6d
fix: remove secrets panel to reintroduce in a future change
1egoman Sep 10, 2024
dc44169
refactor: remove comments
1egoman Sep 10, 2024
d8944f0
feat: remove X icon from navbar
1egoman Sep 10, 2024
02b7fe1
feat: adjust text size of table of contents body text
1egoman Sep 10, 2024
f14c282
fix: remove commented out icon
1egoman Sep 10, 2024
f9a8480
feat: add keyboard shortcuts and feedback buttons to sidebar
1egoman Sep 10, 2024
c719659
fix: ensure that modals are closed when opening a new srcbook
1egoman Sep 10, 2024
76c5b80
feat: add changeset file entry
1egoman Sep 10, 2024
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
1 change: 1 addition & 0 deletions packages/web/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
"@lezer/javascript": "^1.4.17",
"@radix-ui/react-collapsible": "^1.0.3",
"@radix-ui/react-dialog": "^1.0.5",
"@radix-ui/react-dropdown-menu": "^2.1.1",
"@radix-ui/react-icons": "^1.3.0",
"@radix-ui/react-navigation-menu": "^1.2.0",
"@radix-ui/react-popover": "^1.0.7",
Expand Down
62 changes: 3 additions & 59 deletions packages/web/src/Layout.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
import { NavLink, useLoaderData } from 'react-router-dom';
import { useLoaderData } from 'react-router-dom';
import { Toaster } from '@/components/ui/sonner';
import { SrcbookLogo } from './components/logos';
import useTheme from './components/use-theme';
import { SettingsProvider } from '@/components/use-settings';
import { type SettingsType } from '@/types';
import { getConfig } from '@/lib/server';
Expand All @@ -14,65 +12,11 @@ export async function loader() {

export default function Layout(props: { children: React.ReactNode }) {
const { config } = useLoaderData() as { config: SettingsType };
const { theme, toggleTheme } = useTheme();

return (
<>
<div className="flex flex-col">
<header className="h-8 min-h-8 max-h-8 w-full flex items-center justify-between fixed bg-background z-10 border-b border-border text-sm">
<nav className="px-6 flex-1">
<ul className="flex items-center space-x-6">
<li>
<NavLink to="/">
<h1 className="font-mono font-bold flex items-center space-x-[10px]">
<SrcbookLogo size={20} />
<span>Srcbook</span>
</h1>
</NavLink>
</li>
<li>
<NavLink
to="/"
className="font-semibold text-tertiary-foreground visited:text-tertiary-foreground hover:text-foreground transition-colors"
>
Home
</NavLink>
</li>
<li>
<NavLink
to="/secrets"
className="font-semibold text-tertiary-foreground visited:text-tertiary-foreground hover:text-foreground transition-colors"
>
Secrets
</NavLink>
</li>
<li>
<NavLink
to="/settings"
className="font-semibold text-tertiary-foreground visited:text-tertiary-foreground hover:text-foreground transition-colors"
>
Settings
</NavLink>
</li>
</ul>
</nav>
{process.env.NODE_ENV !== 'production' && (
<div className="pr-3">
<button
onClick={toggleTheme}
className="border-none outline-none text-muted-foreground hover:text-foreground font-semibold transition-colors"
>
{theme === 'light' ? '(DEV) Dark mode' : '(DEV) Light mode'}
</button>
</div>
)}
</header>
<SettingsProvider config={config}>
<div className="w-full max-w-[936px] mx-auto px-4 lg:px-0 py-12 mt-8">
{props.children}
</div>
</SettingsProvider>
</div>
<SettingsProvider config={config}>{props.children}</SettingsProvider>

<Toaster position="top-right" offset="20px" closeButton />
</>
);
Expand Down
31 changes: 31 additions & 0 deletions packages/web/src/LayoutNavbar.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
import { useLoaderData } from 'react-router-dom';
import { Toaster } from '@/components/ui/sonner';
import { SettingsProvider } from '@/components/use-settings';
import { type SettingsType } from '@/types';
import { getConfig } from '@/lib/server';
import { Navbar } from './components/navbar';

export async function loader() {
const { result: config } = await getConfig();

return { config };
}

export default function LayoutNavbar(props: { children: React.ReactNode }) {
const { config } = useLoaderData() as { config: SettingsType };

return (
<>
<div className="flex flex-col">
<Navbar />

<SettingsProvider config={config}>
<div className="w-full max-w-[936px] mx-auto px-4 lg:px-0 py-12 mt-8">
{props.children}
</div>
</SettingsProvider>
</div>
<Toaster position="top-right" offset="20px" closeButton />
</>
);
}
31 changes: 31 additions & 0 deletions packages/web/src/components/collapsible-container.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
import { ChevronRight } from 'lucide-react';
import { cn } from '@/lib/utils';
import { Collapsible, CollapsibleContent, CollapsibleTrigger } from '@/components/ui/collapsible';

export default function CollapsibleContainer(props: {
open: boolean;
onChangeOpen: (value: boolean) => void;
title: string;
className?: string | null;
children: React.ReactNode;
}) {
const { open, onChangeOpen, title, children } = props;

return (
<Collapsible open={open} onOpenChange={onChangeOpen}>
<div className={cn('w-full border rounded-sm', props.className)}>
<CollapsibleTrigger className="block w-full">
<div className="p-3 flex items-center justify-between">
<h5 className="font-bold leading-none">{title}</h5>
<ChevronRight
className={cn('w-4 h-4 transition-transform text-tertiary-foreground', {
'transform rotate-90': open,
})}
/>
</div>
</CollapsibleTrigger>
<CollapsibleContent>{children}</CollapsibleContent>
</div>
</Collapsible>
);
}
Loading