Open History to see the last commit
1import { useState } from 'react'
2import cn from 'classnames'
3import { Search } from './Search'
4export const Sidebar = ({ active, children, fixed }) => {
5 const [searching, setSearching] = useState(false)
6 return (
7 <aside
8 className={cn('sidebar bg-white top-24 flex-shrink-0 pr-2', {
9 active,
10 ['pb-0 flex flex-col z-1 sticky']: fixed,
11 fixed,
12 searching,
13 })}
14 >
15 <div className="sidebar-search my-2 lg:hidden">
16 <Search />
17 </div>
18 <div className="sidebar-content overflow-y-auto pb-4">{children}</div>
19 <style jsx>{`
20 .sidebar {
21 -webkit-overflow-scrolling: touch;
22 }
23 .sidebar.fixed {
24 width: 300px;
25 padding-right: 2.5rem;
26 /* Full page - content margin - header size - banner */
27 height: calc(100vh - 1.5rem - 64px - 42px);
28 }
29 .sidebar.fixed.searching > .sidebar-content {
30 display: none;
31 }
32 .sidebar-search {
33 position: relative;
34 z-index: 1;
35 }
36 @media screen and (max-width: 1024px) {
37 .sidebar,
38 .sidebar.fixed {
39 display: none;
40 }
41 .sidebar.active {
42 display: block;
43 }
44 }
45 `}</style>
46 </aside>
47 )
48}