frontend: styling
This commit is contained in:
@@ -4,13 +4,22 @@ import { getTagColorStyle } from '../utils/colors';
|
|||||||
import { DownloadIcon, EditIcon, ViewListIcon, ViewGridIcon, FolderIcon } from '../ui/icons';
|
import { DownloadIcon, EditIcon, ViewListIcon, ViewGridIcon, FolderIcon } from '../ui/icons';
|
||||||
|
|
||||||
const TAG_MIME_TYPES = ['application/x-papercrate-tag', 'text/papercrate-tag'];
|
const TAG_MIME_TYPES = ['application/x-papercrate-tag', 'text/papercrate-tag'];
|
||||||
|
const DEFAULT_GRID_ICON_SIZE = 96;
|
||||||
|
const DEFAULT_GRID_TITLE_SIZE = '11px';
|
||||||
|
const LIST_ICON_SIZE = 48;
|
||||||
|
|
||||||
const getPageCount = (doc) =>
|
const getPageCount = (doc) =>
|
||||||
Number.isFinite(doc?.current_version?.metadata?.page_count)
|
Number.isFinite(doc?.current_version?.metadata?.page_count)
|
||||||
? doc.current_version.metadata.page_count
|
? doc.current_version.metadata.page_count
|
||||||
: null;
|
: null;
|
||||||
|
|
||||||
const DocumentThumbnailImage = ({ document, ensureAssetUrl, getDocumentAsset, alt, maxSize = 48 }) => {
|
const DocumentThumbnailImage = ({
|
||||||
|
document,
|
||||||
|
ensureAssetUrl,
|
||||||
|
getDocumentAsset,
|
||||||
|
alt,
|
||||||
|
maxSize = LIST_ICON_SIZE,
|
||||||
|
}) => {
|
||||||
const resolvedMaxSize = Math.max(1, Math.round(maxSize || 1));
|
const resolvedMaxSize = Math.max(1, Math.round(maxSize || 1));
|
||||||
const thumbnailAsset = useMemo(() => getAssetFromVersion(document?.current_version, 'thumbnail'), [document?.current_version]);
|
const thumbnailAsset = useMemo(() => getAssetFromVersion(document?.current_version, 'thumbnail'), [document?.current_version]);
|
||||||
const assetWidth = Number(thumbnailAsset?.metadata?.width);
|
const assetWidth = Number(thumbnailAsset?.metadata?.width);
|
||||||
@@ -129,6 +138,7 @@ const DocumentsTable = ({
|
|||||||
);
|
);
|
||||||
const scrollRef = useRef(null);
|
const scrollRef = useRef(null);
|
||||||
const isGridView = viewMode === 'grid';
|
const isGridView = viewMode === 'grid';
|
||||||
|
const gridIconSize = DEFAULT_GRID_ICON_SIZE;
|
||||||
const handleSetViewMode = useCallback(
|
const handleSetViewMode = useCallback(
|
||||||
(nextMode) => {
|
(nextMode) => {
|
||||||
if (!onViewModeChange) {
|
if (!onViewModeChange) {
|
||||||
@@ -369,6 +379,7 @@ const DocumentsTable = ({
|
|||||||
className="documents-grid"
|
className="documents-grid"
|
||||||
role="list"
|
role="list"
|
||||||
onClick={handleGridBackgroundClick}
|
onClick={handleGridBackgroundClick}
|
||||||
|
style={{ '--documents-grid-icon-size': `${gridIconSize}px` }}
|
||||||
>
|
>
|
||||||
{!showingSearchResults &&
|
{!showingSearchResults &&
|
||||||
subfolders.map((folder) => {
|
subfolders.map((folder) => {
|
||||||
@@ -417,7 +428,7 @@ const DocumentsTable = ({
|
|||||||
<div className="folder-card__icon">
|
<div className="folder-card__icon">
|
||||||
<FolderIcon
|
<FolderIcon
|
||||||
className="folder-card__icon-svg"
|
className="folder-card__icon-svg"
|
||||||
size={128}
|
size={gridIconSize}
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
<div className="folder-card__meta">
|
<div className="folder-card__meta">
|
||||||
@@ -461,7 +472,7 @@ const DocumentsTable = ({
|
|||||||
ensureAssetUrl={ensureAssetUrl}
|
ensureAssetUrl={ensureAssetUrl}
|
||||||
getDocumentAsset={getDocumentAsset}
|
getDocumentAsset={getDocumentAsset}
|
||||||
alt={`Thumbnail for ${doc.title || doc.original_name}`}
|
alt={`Thumbnail for ${doc.title || doc.original_name}`}
|
||||||
maxSize={128}
|
maxSize={gridIconSize}
|
||||||
/>
|
/>
|
||||||
<div className="document-card__meta">
|
<div className="document-card__meta">
|
||||||
<div
|
<div
|
||||||
|
|||||||
+12
-7
@@ -36,6 +36,8 @@
|
|||||||
--sidebar-hover-bg: rgba(63, 106, 216, 0.08);
|
--sidebar-hover-bg: rgba(63, 106, 216, 0.08);
|
||||||
--sidebar-active-bg: rgba(63, 106, 216, 0.16);
|
--sidebar-active-bg: rgba(63, 106, 216, 0.16);
|
||||||
--selection-ring: #9bb6ff;
|
--selection-ring: #9bb6ff;
|
||||||
|
--documents-grid-title-size: 12px;
|
||||||
|
--documents-grid-icon-size: 128px;
|
||||||
|
|
||||||
/* Semantic colors */
|
/* Semantic colors */
|
||||||
--success: #2e7d6b;
|
--success: #2e7d6b;
|
||||||
@@ -1179,13 +1181,15 @@ button.icon-button.ghost:hover:not([disabled]) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
.documents-panel--view-grid .document-thumbnail-wrapper {
|
.documents-panel--view-grid .document-thumbnail-wrapper {
|
||||||
width: 128px;
|
width: var(--documents-grid-icon-size);
|
||||||
height: 128px;
|
height: var(--documents-grid-icon-size);
|
||||||
padding: 8px;
|
padding: 8px;
|
||||||
border-radius: 10px;
|
border-radius: 10px;
|
||||||
|
display: flex;
|
||||||
|
justify-content: center;
|
||||||
|
align-items: center;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
.document-thumbnail-inner {
|
.document-thumbnail-inner {
|
||||||
position: relative;
|
position: relative;
|
||||||
display: inline-flex;
|
display: inline-flex;
|
||||||
@@ -1316,7 +1320,7 @@ button.icon-button.ghost:hover:not([disabled]) {
|
|||||||
|
|
||||||
.documents-grid {
|
.documents-grid {
|
||||||
display: grid;
|
display: grid;
|
||||||
grid-template-columns: repeat(auto-fill, minmax(128px, 1fr));
|
grid-template-columns: repeat(auto-fill, minmax(var(--documents-grid-icon-size), 1fr));
|
||||||
gap: 0.3rem 1.3rem;
|
gap: 0.3rem 1.3rem;
|
||||||
padding: 0;
|
padding: 0;
|
||||||
}
|
}
|
||||||
@@ -1358,6 +1362,7 @@ button.icon-button.ghost:hover:not([disabled]) {
|
|||||||
border-radius: 1rem;
|
border-radius: 1rem;
|
||||||
max-width: 100%;
|
max-width: 100%;
|
||||||
word-break: break-word;
|
word-break: break-word;
|
||||||
|
font-size: var(--documents-grid-title-size);
|
||||||
}
|
}
|
||||||
|
|
||||||
.document-card.selected .document-card__title {
|
.document-card.selected .document-card__title {
|
||||||
@@ -1386,8 +1391,8 @@ button.icon-button.ghost:hover:not([disabled]) {
|
|||||||
display: flex;
|
display: flex;
|
||||||
align-items: center;
|
align-items: center;
|
||||||
justify-content: center;
|
justify-content: center;
|
||||||
width: 128px;
|
width: var(--documents-grid-icon-size);
|
||||||
height: 128px;
|
height: var(--documents-grid-icon-size);
|
||||||
}
|
}
|
||||||
|
|
||||||
.folder-card__icon-svg {
|
.folder-card__icon-svg {
|
||||||
@@ -1408,11 +1413,11 @@ button.icon-button.ghost:hover:not([disabled]) {
|
|||||||
overflow: hidden;
|
overflow: hidden;
|
||||||
text-overflow: ellipsis;
|
text-overflow: ellipsis;
|
||||||
white-space: break-word;
|
white-space: break-word;
|
||||||
|
font-size: var(--documents-grid-title-size);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
.doc-name__title {
|
.doc-name__title {
|
||||||
font-weight: 600;
|
|
||||||
max-width: 100%;
|
max-width: 100%;
|
||||||
word-break: break-word;
|
word-break: break-word;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user