-
-
Notifications
You must be signed in to change notification settings - Fork 218
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
2967e8c
commit b6dc1f4
Showing
8 changed files
with
275 additions
and
102 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,79 @@ | ||
import { DraggablePanel } from '@/components' | ||
import { ZoomInOutlined } from '@ant-design/icons' | ||
import { Slider } from 'antd' | ||
import { useResponsive } from 'antd-style' | ||
import React, { CSSProperties, useEffect, useState } from 'react' | ||
import styled from 'styled-components' | ||
|
||
const View = styled.div` | ||
display: flex; | ||
flex-direction: column; | ||
height: -webkit-fill-available; | ||
overflow: hidden; | ||
` | ||
|
||
const SidebarView = styled.div<{ size: number }>` | ||
padding: 16px; | ||
overflow-x: hidden; | ||
overflow-y: auto; | ||
flex: 1; | ||
.extra-network-thumbs { | ||
display: grid; | ||
grid-template-columns: repeat(auto-fill, minmax(${({ size }) => size}px, 1fr)); | ||
> .card { | ||
height: ${({ size }) => size * 1.5}px !important; | ||
width: -webkit-fill-available !important; | ||
} | ||
} | ||
` | ||
|
||
const Footer = styled.div` | ||
flex: 0; | ||
padding: 12px 16px; | ||
border-top: 1px soild ${({ theme }) => theme.colorSplit}; | ||
display: flex; | ||
align-items: center; | ||
justify-content: flex-start; | ||
` | ||
|
||
const ZoomSlider = styled(Slider)` | ||
margin-left: 16px; | ||
flex: 1; | ||
` | ||
|
||
interface SidebarProps { | ||
children: React.ReactNode | ||
loading?: boolean | ||
style?: CSSProperties | ||
} | ||
|
||
const Sidebar: React.FC<SidebarProps> = ({ children, style }) => { | ||
const { mobile } = useResponsive() | ||
const [expand, setExpand] = useState<boolean>(!mobile) | ||
const [size, setSize] = useState<number>(96) | ||
|
||
useEffect(() => { | ||
setExpand(!mobile) | ||
}, [mobile]) | ||
|
||
return ( | ||
<DraggablePanel | ||
style={style} | ||
placement="right" | ||
defaultSize={{ width: 340 }} | ||
isExpand={expand} | ||
onExpandChange={setExpand} | ||
> | ||
<View> | ||
<SidebarView size={size}>{children}</SidebarView> | ||
<Footer> | ||
<ZoomInOutlined /> | ||
<ZoomSlider defaultValue={86} step={8} max={256} min={64} onChange={setSize} /> | ||
</Footer> | ||
</View> | ||
</DraggablePanel> | ||
) | ||
} | ||
|
||
export default React.memo(Sidebar) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,5 @@ | ||
export { default as Content } from './Content' | ||
export * from './DraggablePanel' | ||
export { default as ExtraNetworkSidebar } from './ExtraNetworkSidebar' | ||
export { default as Header } from './Header' | ||
export { default as Sidebar } from './Sidebar' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters