| 1 | import styled from "styled-components"; |
| 2 | import { |
| 3 | defaultBorderRadius, |
| 4 | vscCommandCenterInactiveBorder, |
| 5 | vscInputBackground, |
| 6 | } from "../.."; |
| 7 | import { useLump } from "./LumpContext"; |
| 8 | import { LumpToolbar } from "./LumpToolbar/LumpToolbar"; |
| 9 | import { SelectedSection } from "./sections/SelectedSection"; |
| 10 | |
| 11 | const LumpDiv = styled.div` |
| 12 | background-color: ${vscInputBackground}; |
| 13 | margin-left: 4px; |
| 14 | margin-right: 4px; |
| 15 | border-radius: ${defaultBorderRadius} ${defaultBorderRadius} 0 0; |
| 16 | border-top: 1px solid ${vscCommandCenterInactiveBorder}; |
| 17 | border-left: 1px solid ${vscCommandCenterInactiveBorder}; |
| 18 | border-right: 1px solid ${vscCommandCenterInactiveBorder}; |
| 19 | `; |
| 20 | |
| 21 | const ContentDiv = styled.div<{ hasSection: boolean; isVisible: boolean }>` |
| 22 | transition: |
| 23 | max-height 0.3s ease-in-out, |
| 24 | margin 0.3s ease-in-out, |
| 25 | opacity 0.2s ease-in-out; |
| 26 | max-height: ${(props) => (props.hasSection ? "200px" : "0px")}; |
| 27 | margin: ${(props) => (props.hasSection ? "4px 0" : "0")}; |
| 28 | opacity: ${(props) => (props.isVisible ? "1" : "0")}; |
| 29 | overflow-y: auto; |
| 30 | `; |
| 31 | |
| 32 | /** |
| 33 | * Internal component that consumes the LumpContext |
| 34 | */ |
| 35 | export function Lump() { |
| 36 | const { isLumpVisible, selectedSection } = useLump(); |
| 37 | |
| 38 | return ( |
| 39 | <LumpDiv> |
| 40 | <div className="xs:px-2 px-1 py-0.5"> |
| 41 | <LumpToolbar /> |
| 42 | |
| 43 | <ContentDiv |
| 44 | className="no-scrollbar pr-0.5" |
| 45 | hasSection={!!selectedSection} |
| 46 | isVisible={isLumpVisible} |
| 47 | > |
| 48 | <SelectedSection /> |
| 49 | </ContentDiv> |
| 50 | </div> |
| 51 | </LumpDiv> |
| 52 | ); |
| 53 | } |