🎛 Switched the layout on dashboard to masonry

This commit is contained in:
2021-09-22 14:54:14 -07:00
parent 384f1ce81e
commit 49d0533a5d
3 changed files with 132 additions and 65 deletions

View File

@@ -27,13 +27,27 @@ $border-color: red;
} }
// Dashboard // Dashboard
.stack-card-container { .recent-comics-container {
display: grid; display: -webkit-box; /* Not needed if autoprefixing */
grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); display: -ms-flexbox; /* Not needed if autoprefixing */
column-gap: 0.5em; display: flex;
row-gap: 1.2em; margin-left: -30px; /* gutter size offset */
width: auto;
.recent-comics-column {
padding-left: 25px; /* gutter size */
background-clip: padding-box;
& > div {
/* change div to reference your elements you put in <Masonry> */
margin-bottom: 20px;
}
}
}
.volumes-container {
margin-top: 3rem;
.stack { .stack {
width: 200px; max-width: 200px;
border-radius: 0.3rem; border-radius: 0.3rem;
box-shadow: box-shadow:
/* The top layer shadow */ 0 -1px 1px rgba(0, 0, 0, 0.15), /* The top layer shadow */ 0 -1px 1px rgba(0, 0, 0, 0.15),
@@ -48,6 +62,9 @@ $border-color: red;
border-bottom-left-radius: 0; border-bottom-left-radius: 0;
border-bottom-right-radius: 0; border-bottom-right-radius: 0;
} }
.stack-title {
margin-bottom: 0.4rem;
}
.content { .content {
margin: -5px 0 0 0; margin: -5px 0 0 0;
padding: 0.5rem 1rem; padding: 0.5rem 1rem;
@@ -56,8 +73,25 @@ $border-color: red;
border-bottom-right-radius: 0.25rem; border-bottom-right-radius: 0.25rem;
} }
} }
.volumes-grid {
display: -webkit-box; /* Not needed if autoprefixing */
display: -ms-flexbox; /* Not needed if autoprefixing */
display: flex;
margin-left: -30px; /* gutter size offset */
width: auto;
}
.volumes-grid-column {
padding-left: 25px; /* gutter size */
background-clip: padding-box;
& > div {
/* change div to reference your elements you put in <Masonry> */
margin-bottom: 20px;
}
}
} }
.min { .min {
overflow: visible; overflow: visible;
margin: auto; margin: auto;
@@ -209,6 +243,7 @@ $border-color: red;
} }
} }
} }
// Search // Search
.search { .search {
.main-search-bar { .main-search-bar {

View File

@@ -8,6 +8,7 @@ import {
} from "../shared/utils/formatting.utils"; } from "../shared/utils/formatting.utils";
import { isEmpty, isNil, map } from "lodash"; import { isEmpty, isNil, map } from "lodash";
import { detectTradePaperbacks } from "../shared/utils/tradepaperback.utils"; import { detectTradePaperbacks } from "../shared/utils/tradepaperback.utils";
import Masonry from "react-masonry-css";
type RecentlyImportedProps = { type RecentlyImportedProps = {
comicBookCovers: any; comicBookCovers: any;
@@ -15,57 +16,75 @@ type RecentlyImportedProps = {
export const RecentlyImported = ({ export const RecentlyImported = ({
comicBookCovers, comicBookCovers,
}: RecentlyImportedProps): ReactElement => ( }: RecentlyImportedProps): ReactElement => {
<> const breakpointColumnsObj = {
<h2 className="subtitle">Recently Imported</h2> default: 5,
<section className="card-container"> 1100: 4,
{map(comicBookCovers.docs, ({ _id, rawFileDetails, sourcedMetadata }) => { 700: 2,
let imagePath = ""; 500: 1,
let comicName = ""; };
if (!isNil(rawFileDetails)) { return (
const encodedFilePath = encodeURI( <>
"http://localhost:3000" + removeLeadingPeriod(rawFileDetails.path), <h2 className="subtitle">Recently Imported</h2>
); <Masonry
imagePath = escapePoundSymbol(encodedFilePath); breakpointCols={breakpointColumnsObj}
comicName = rawFileDetails.name; className="recent-comics-container"
} else if (!isNil(sourcedMetadata)) { columnClassName="recent-comics-column"
imagePath = sourcedMetadata.comicvine.image.small_url; >
comicName = sourcedMetadata.comicvine.name; {map(
} comicBookCovers.docs,
const titleElement = ( ({ _id, rawFileDetails, sourcedMetadata }) => {
<Link to={"/comic/details/" + _id}>{ellipsize(comicName, 18)}</Link> let imagePath = "";
); let comicName = "";
return ( if (!isNil(rawFileDetails)) {
<Card const encodedFilePath = encodeURI(
key={_id} "http://localhost:3000" +
orientation={"vertical"} removeLeadingPeriod(rawFileDetails.path),
imageUrl={imagePath} );
hasDetails imagePath = escapePoundSymbol(encodedFilePath);
title={comicName ? titleElement : null} comicName = rawFileDetails.name;
> } else if (!isNil(sourcedMetadata)) {
<div className="content is-flex is-flex-direction-row"> imagePath = sourcedMetadata.comicvine.image.small_url;
{!isNil(sourcedMetadata.comicvine) && ( comicName = sourcedMetadata.comicvine.name;
<span className="icon cv-icon is-small"> }
<img src="/dist/img/cvlogo.svg" /> const titleElement = (
</span> <Link to={"/comic/details/" + _id}>
)} {ellipsize(comicName, 18)}
{isNil(rawFileDetails) && ( </Link>
<span className="icon has-text-info"> );
<i className="fas fa-adjust" /> return (
</span> <Card
)} key={_id}
{!isNil(sourcedMetadata.comicvine) && orientation={"vertical"}
!isEmpty( imageUrl={imagePath}
detectTradePaperbacks( hasDetails
sourcedMetadata.comicvine.volumeInformation.description, title={comicName ? titleElement : null}
), >
) ? ( <div className="content is-flex is-flex-direction-row">
<span className="tag is-warning">TPB</span> {!isNil(sourcedMetadata.comicvine) && (
) : null} <span className="icon cv-icon is-small">
</div> <img src="/dist/img/cvlogo.svg" />
</Card> </span>
); )}
})} {isNil(rawFileDetails) && (
</section> <span className="icon has-text-info">
</> <i className="fas fa-adjust" />
); </span>
)}
{!isNil(sourcedMetadata.comicvine) &&
!isEmpty(
detectTradePaperbacks(
sourcedMetadata.comicvine.volumeInformation.description,
),
) ? (
<span className="tag is-warning">TPB</span>
) : null}
</div>
</Card>
);
},
)}
</Masonry>
</>
);
};

View File

@@ -3,8 +3,15 @@ import React, { ReactElement, useEffect } from "react";
import { useSelector, useDispatch } from "react-redux"; import { useSelector, useDispatch } from "react-redux";
import ellipsize from "ellipsize"; import ellipsize from "ellipsize";
import { fetchVolumeGroups } from "../actions/fileops.actions"; import { fetchVolumeGroups } from "../actions/fileops.actions";
import Masonry from "react-masonry-css";
export const VolumeGroups = (): ReactElement => { export const VolumeGroups = (): ReactElement => {
const breakpointColumnsObj = {
default: 5,
1100: 4,
700: 2,
500: 1,
};
const dispatch = useDispatch(); const dispatch = useDispatch();
useEffect(() => { useEffect(() => {
dispatch(fetchVolumeGroups()); dispatch(fetchVolumeGroups());
@@ -13,9 +20,13 @@ export const VolumeGroups = (): ReactElement => {
(state: RootState) => state.fileOps.comicVolumeGroups, (state: RootState) => state.fileOps.comicVolumeGroups,
); );
return ( return (
<> <section className="volumes-container">
<h2 className="subtitle">Volumes</h2> <h2 className="subtitle">Volumes</h2>
<div className="stack-card-container"> <Masonry
breakpointCols={breakpointColumnsObj}
className="volumes-grid"
columnClassName="volumes-grid-column"
>
{!isNil(volumeGroups) && {!isNil(volumeGroups) &&
volumeGroups && volumeGroups &&
map(volumeGroups.data, (group) => { map(volumeGroups.data, (group) => {
@@ -24,7 +35,9 @@ export const VolumeGroups = (): ReactElement => {
<div className="stack"> <div className="stack">
<img src={group.results.image.small_url} /> <img src={group.results.image.small_url} />
<div className="content"> <div className="content">
{ellipsize(group.results.name, 18)} <div className="stack-title">
{ellipsize(group.results.name, 18)}
</div>
<div className="control"> <div className="control">
<span className="tags has-addons"> <span className="tags has-addons">
<span className="tag is-primary is-light">Issues</span> <span className="tag is-primary is-light">Issues</span>
@@ -38,8 +51,8 @@ export const VolumeGroups = (): ReactElement => {
); );
} }
})} })}
</div> </Masonry>
</> </section>
); );
}; };