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