Skip to content

Commit 9d799ce

Browse files
authored
Merge pull request #153 from oasisprotocol/mz/sidebar
Fix SidebarFooter content when collapsed
2 parents 26a2e51 + e7d3667 commit 9d799ce

File tree

2 files changed

+71
-24
lines changed

2 files changed

+71
-24
lines changed

src/components/Layout/MainLayout.tsx

Lines changed: 2 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ import {
2525
BreadcrumbSeparator,
2626
} from '@oasisprotocol/ui-library/src/components/ui/breadcrumb'
2727
import { ErrorBoundary } from '../ErrorBoundary'
28+
import { SidebarFooterContent } from './SidebarFooter'
2829

2930
const navItems = {
3031
dashboard: { label: 'Dashboard', path: '/dashboard' },
@@ -159,30 +160,7 @@ export const MainLayout: FC = () => {
159160
</SidebarGroup>
160161
</SidebarContent>
161162
<SidebarFooter className="mb-2">
162-
<div className="bg-sidebar-accent p-4 rounded-md text-sm text-foreground">
163-
<span className="font-bold">Running in Beta</span>
164-
<br />
165-
<a
166-
href="https://forms.gle/yewQDdMzNg81wKtw9"
167-
target="_blank"
168-
rel="noopener noreferrer"
169-
className="underline text-foreground"
170-
>
171-
Provide feedback here
172-
</a>
173-
</div>
174-
<div className="bg-sidebar-accent p-4 rounded-md text-sm text-foreground">
175-
<span className="font-bold">Need Support?</span>
176-
<br />
177-
<a
178-
href="https://oasis.io/discord"
179-
target="_blank"
180-
rel="noopener noreferrer"
181-
className="underline text-foreground"
182-
>
183-
Speak to our devs
184-
</a>
185-
</div>
163+
<SidebarFooterContent />
186164
</SidebarFooter>
187165
</Sidebar>
188166
}
Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
import { type FC, type ReactNode } from 'react'
2+
import { SidebarMenuButton, useSidebar } from '@oasisprotocol/ui-library/src/components/ui/sidebar'
3+
import { MessageSquare, HelpCircle } from 'lucide-react'
4+
import { Button } from '@oasisprotocol/ui-library/src/components/ui/button'
5+
6+
const MessageAnchor = ({ children, className }: { children: ReactNode; className?: string }) => (
7+
<a
8+
href="https://forms.gle/yewQDdMzNg81wKtw9"
9+
target="_blank"
10+
rel="noopener noreferrer"
11+
title="Provide feedback"
12+
className={className}
13+
>
14+
{children}
15+
</a>
16+
)
17+
18+
const DiscordAnchor = ({ children, className }: { children: ReactNode; className?: string }) => (
19+
<a
20+
href="https://oasis.io/discord"
21+
target="_blank"
22+
rel="noopener noreferrer"
23+
title="Get support"
24+
className={className}
25+
>
26+
{children}
27+
</a>
28+
)
29+
30+
export const SidebarFooterContent: FC = () => {
31+
const { state } = useSidebar()
32+
const isCollapsed = state === 'collapsed'
33+
34+
if (isCollapsed) {
35+
return (
36+
<>
37+
<MessageAnchor>
38+
<SidebarMenuButton asChild>
39+
<Button variant="ghost" className="w-full justify-start p-2 h-8 rounded-md cursor-pointer">
40+
<MessageSquare className="h-4 w-4 text-sidebar-foreground" />
41+
</Button>
42+
</SidebarMenuButton>
43+
</MessageAnchor>
44+
<DiscordAnchor>
45+
<SidebarMenuButton asChild>
46+
<Button variant="ghost" className="w-full justify-start p-2 h-8 rounded-md cursor-pointer">
47+
<HelpCircle className="h-4 w-4 text-sidebar-foreground" />
48+
</Button>
49+
</SidebarMenuButton>
50+
</DiscordAnchor>
51+
</>
52+
)
53+
}
54+
55+
return (
56+
<>
57+
<div className="bg-sidebar-accent p-4 rounded-md text-sm text-foreground">
58+
<span className="font-bold">Running in Beta</span>
59+
<br />
60+
<MessageAnchor className="underline">Provide feedback here</MessageAnchor>
61+
</div>
62+
<div className="bg-sidebar-accent p-4 rounded-md text-sm text-foreground">
63+
<span className="font-bold">Need Support?</span>
64+
<br />
65+
<DiscordAnchor className="underline">Speak to our devs</DiscordAnchor>
66+
</div>
67+
</>
68+
)
69+
}

0 commit comments

Comments
 (0)