-
Notifications
You must be signed in to change notification settings - Fork 370
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Showing
21 changed files
with
199 additions
and
103 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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
.detail-body { | ||
flex: 1; | ||
display: flex; | ||
flex-direction: column; | ||
overflow-y: auto; | ||
overflow-x: hidden; | ||
padding: 16px; | ||
} |
20 changes: 20 additions & 0 deletions
20
frontend/src/components/dirent-detail/detail/body/index.js
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,20 @@ | ||
import React from 'react'; | ||
import PropTypes from 'prop-types'; | ||
import classnames from 'classnames'; | ||
|
||
import './index.css'; | ||
|
||
const Body = ({ className, children }) => { | ||
return ( | ||
<div className={classnames('detail-body dirent-info', className)}> | ||
{children} | ||
</div> | ||
); | ||
}; | ||
|
||
Body.propTypes = { | ||
className: PropTypes.string, | ||
children: PropTypes.any, | ||
}; | ||
|
||
export default Body; |
21 changes: 21 additions & 0 deletions
21
frontend/src/components/dirent-detail/detail/detail/index.css
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,21 @@ | ||
@keyframes move { | ||
from { | ||
right: -500px; | ||
opacity: 0.5; | ||
} | ||
to { | ||
right: 0px; | ||
opacity: 1; | ||
} | ||
} | ||
|
||
.cur-view-detail { | ||
display: flex; | ||
flex-direction: column; | ||
background-color: #fff; | ||
width: 400px; | ||
height: 100%; | ||
border-left: 1px solid #eee; | ||
animation: move .5s ease-in-out 1; | ||
position: relative; | ||
} |
79 changes: 79 additions & 0 deletions
79
frontend/src/components/dirent-detail/detail/detail/index.js
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 React, { useCallback, useEffect, useRef, useState } from 'react'; | ||
import PropTypes from 'prop-types'; | ||
import classnames from 'classnames'; | ||
import ResizeBar from '../../../resize-bar'; | ||
import { DRAG_HANDLER_HEIGHT } from '../../../resize-bar/constants'; | ||
|
||
import './index.css'; | ||
|
||
const Detail = ({ children, className }) => { | ||
const [width, setWidth] = useState(300); | ||
const [inResizing, setResizing] = useState(false); | ||
const resizeBarRef = useRef(null); | ||
const dragHandlerRef = useRef(null); | ||
|
||
const onResizeMouseMove = useCallback((e) => { | ||
const newWidth = Math.max(Math.min(window.innerWidth - e.clientX, 600), 300); | ||
if (width === newWidth) return; | ||
setWidth(newWidth); | ||
}, [width]); | ||
|
||
const onResizeMouseUp = useCallback(() => { | ||
window.removeEventListener('mousemove', onResizeMouseMove); | ||
window.removeEventListener('mouseup', onResizeMouseUp); | ||
inResizing && setResizing(false); | ||
localStorage.setItem('sf_cur_view_detail_width', width); | ||
}, [width, inResizing, onResizeMouseMove]); | ||
|
||
const onResizeMouseDown = useCallback(() => { | ||
window.addEventListener('mouseup', onResizeMouseUp); | ||
window.addEventListener('mousemove', onResizeMouseMove); | ||
setResizing(true); | ||
}, [onResizeMouseUp, onResizeMouseMove]); | ||
|
||
const setDragHandlerTop = useCallback((top) => { | ||
dragHandlerRef.current.style.top = top + 'px'; | ||
}, []); | ||
|
||
const onResizeMouseOver = useCallback((event) => { | ||
if (!dragHandlerRef.current) return; | ||
const { top } = resizeBarRef.current.getBoundingClientRect(); | ||
const dragHandlerRefTop = event.pageY - top - DRAG_HANDLER_HEIGHT / 2; | ||
setDragHandlerTop(dragHandlerRefTop); | ||
}, [setDragHandlerTop]); | ||
|
||
useEffect(() => { | ||
const width = localStorage.getItem('sf_cur_view_detail_width', 300); | ||
setWidth(width); | ||
}, []); | ||
|
||
return ( | ||
<div | ||
className={classnames('cur-view-detail', className, { | ||
'cur-view-detail-small': width < 400, | ||
'cur-view-detail-large': width > 400 | ||
})} | ||
style={{ width }} | ||
// onMouseMove={inResizing ? onResizeMouseMove : null} | ||
// onMouseUp={onResizeMouseUp} | ||
> | ||
{children} | ||
<ResizeBar | ||
resizeBarRef={resizeBarRef} | ||
dragHandlerRef={dragHandlerRef} | ||
resizeBarStyle={{ left: -1 }} | ||
dragHandlerStyle={{ height: DRAG_HANDLER_HEIGHT }} | ||
onResizeMouseDown={onResizeMouseDown} | ||
onResizeMouseOver={onResizeMouseOver} | ||
/> | ||
</div> | ||
); | ||
|
||
}; | ||
|
||
Detail.propTypes = { | ||
className: PropTypes.string, | ||
children: PropTypes.any, | ||
}; | ||
|
||
export default Detail; |
File renamed without changes.
2 changes: 1 addition & 1 deletion
2
.../components/dirent-detail/header/index.js → ...ents/dirent-detail/detail/header/index.js
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
import Detail from './detail'; | ||
import Header from './header'; | ||
import Body from './body'; | ||
|
||
export { | ||
Detail, | ||
Header, | ||
Body, | ||
}; |
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
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 was deleted.
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
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
Oops, something went wrong.