refactor: file list grid layout
This commit is contained in:
@@ -62,8 +62,16 @@ function ResourceManagement({ fileMessages }) {
|
|||||||
};
|
};
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (view == Views.grid && listContainerRef) {
|
if (view == Views.grid && listContainerRef) {
|
||||||
|
const container = listContainerRef.current;
|
||||||
|
const cWidth = container.getBoundingClientRect().width - 16 * 2;
|
||||||
|
const count = Math.floor(cWidth / 368);
|
||||||
|
const leftWidth = cWidth % 368;
|
||||||
|
const gutter = Math.max(Math.floor(leftWidth / (count - 1)), 8);
|
||||||
|
console.log("gutter", gutter, cWidth, count, leftWidth);
|
||||||
msnry = new Masonry(listContainerRef.current, {
|
msnry = new Masonry(listContainerRef.current, {
|
||||||
// options
|
// options
|
||||||
|
fitWidth: true,
|
||||||
|
gutter,
|
||||||
itemSelector: ".file_box",
|
itemSelector: ".file_box",
|
||||||
// columnWidth: 200
|
// columnWidth: 200
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -19,19 +19,17 @@ const Styled = styled.div`
|
|||||||
height: 100%;
|
height: 100%;
|
||||||
overflow-y: scroll;
|
overflow-y: scroll;
|
||||||
width: 100%;
|
width: 100%;
|
||||||
|
|
||||||
display: flex;
|
display: flex;
|
||||||
&.item {
|
&.item {
|
||||||
gap: 8px;
|
gap: 8px;
|
||||||
flex-direction: column;
|
flex-direction: column;
|
||||||
/* align-items: flex-start; */
|
|
||||||
}
|
}
|
||||||
&.grid {
|
&.grid {
|
||||||
flex-direction: row;
|
flex-direction: row;
|
||||||
flex-wrap: wrap;
|
flex-wrap: wrap;
|
||||||
> .file_box {
|
> .file_box {
|
||||||
flex-direction: column;
|
flex-direction: column;
|
||||||
margin-right: 8px;
|
/* margin-right: 8px; */
|
||||||
margin-bottom: 8px;
|
margin-bottom: 8px;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user