style
This commit is contained in:
@@ -10,6 +10,7 @@ import { resolveDocumentAssetUrl, createAssetView } from './asset_manager';
|
|||||||
import { useAssetNavigator } from './hooks/useAssetNavigator';
|
import { useAssetNavigator } from './hooks/useAssetNavigator';
|
||||||
import { ArrowLeftIcon, ArrowRightIcon } from './ui/icons';
|
import { ArrowLeftIcon, ArrowRightIcon } from './ui/icons';
|
||||||
import { createDocumentsTableHeaderActions } from './documents/DocumentsTable';
|
import { createDocumentsTableHeaderActions } from './documents/DocumentsTable';
|
||||||
|
import createWorkspaceSurfaceConfig from './documents/workspaceHeader';
|
||||||
import { clamp, formatTransform } from './desktop/math';
|
import { clamp, formatTransform } from './desktop/math';
|
||||||
import { preventAll } from './desktop/events';
|
import { preventAll } from './desktop/events';
|
||||||
import useDocumentDrag from './desktop/useDocumentDrag';
|
import useDocumentDrag from './desktop/useDocumentDrag';
|
||||||
@@ -2017,7 +2018,12 @@ const DesktopWorkspaceView = () => {
|
|||||||
|
|
||||||
export default DesktopWorkspace;
|
export default DesktopWorkspace;
|
||||||
|
|
||||||
export const createDesktopSurface = ({ workspaceProps, renderSidebarToggle }) => {
|
export const createDesktopSurface = ({
|
||||||
|
workspaceProps,
|
||||||
|
renderSidebarToggle,
|
||||||
|
parentBreadcrumb,
|
||||||
|
onNavigateParent,
|
||||||
|
}) => {
|
||||||
if (!workspaceProps) {
|
if (!workspaceProps) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
@@ -2034,26 +2040,28 @@ export const createDesktopSurface = ({ workspaceProps, renderSidebarToggle }) =>
|
|||||||
? `${searchResults.length} matching document${searchResults.length === 1 ? '' : 's'}`
|
? `${searchResults.length} matching document${searchResults.length === 1 ? '' : 's'}`
|
||||||
: null;
|
: null;
|
||||||
|
|
||||||
const sidebarToggle = renderSidebarToggle ? renderSidebarToggle() : null;
|
|
||||||
const leading = sidebarToggle ? <>{sidebarToggle}</> : null;
|
|
||||||
|
|
||||||
const actions = createDocumentsTableHeaderActions({
|
const actions = createDocumentsTableHeaderActions({
|
||||||
viewMode: viewMode || 'desk',
|
viewMode: viewMode || 'desk',
|
||||||
onViewModeChange,
|
onViewModeChange,
|
||||||
onRefresh,
|
onRefresh,
|
||||||
});
|
});
|
||||||
|
|
||||||
return {
|
const sidebarToggle = renderSidebarToggle ? renderSidebarToggle() : null;
|
||||||
|
const surfaceConfig = createWorkspaceSurfaceConfig({
|
||||||
key: 'workspace',
|
key: 'workspace',
|
||||||
variant: 'workspace',
|
variant: 'workspace',
|
||||||
header: {
|
|
||||||
title,
|
title,
|
||||||
subtitle,
|
subtitle,
|
||||||
leading,
|
sidebarToggle,
|
||||||
|
parentBreadcrumb,
|
||||||
|
onNavigateParent,
|
||||||
actions,
|
actions,
|
||||||
breadcrumbs: workspaceProps?.breadcrumbs || null,
|
breadcrumbs: workspaceProps?.breadcrumbs || null,
|
||||||
},
|
|
||||||
content: <DesktopWorkspace {...workspaceProps} />,
|
content: <DesktopWorkspace {...workspaceProps} />,
|
||||||
|
});
|
||||||
|
|
||||||
|
return {
|
||||||
|
...surfaceConfig,
|
||||||
supportsDetail: false,
|
supportsDetail: false,
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -101,8 +101,10 @@ export const useWorkspaceSurface = ({
|
|||||||
return createDesktopSurface({
|
return createDesktopSurface({
|
||||||
workspaceProps: deskWorkspaceProps,
|
workspaceProps: deskWorkspaceProps,
|
||||||
renderSidebarToggle,
|
renderSidebarToggle,
|
||||||
|
parentBreadcrumb,
|
||||||
|
onNavigateParent: parentBreadcrumb ? onNavigateParent : null,
|
||||||
});
|
});
|
||||||
}, [viewMode, deskWorkspaceProps, renderSidebarToggle]);
|
}, [viewMode, deskWorkspaceProps, renderSidebarToggle, parentBreadcrumb, onNavigateParent]);
|
||||||
|
|
||||||
const surface = useMemo(() => {
|
const surface = useMemo(() => {
|
||||||
if (showPreviewWorkspace) {
|
if (showPreviewWorkspace) {
|
||||||
|
|||||||
@@ -1,7 +1,6 @@
|
|||||||
import React, { useCallback, useEffect, useMemo, useRef, useState } from 'react';
|
import React, { useCallback, useEffect, useMemo, useRef, useState } from 'react';
|
||||||
import { getAssetFromVersion, resolveDocumentAssetUrl, createAssetView } from '../asset_manager';
|
import { getAssetFromVersion, resolveDocumentAssetUrl, createAssetView } from '../asset_manager';
|
||||||
import { getTagColorStyle } from '../utils/colors';
|
import { getTagColorStyle } from '../utils/colors';
|
||||||
import DetailPanel from '../detail/DetailPanel';
|
|
||||||
import {
|
import {
|
||||||
DownloadIcon,
|
DownloadIcon,
|
||||||
EditIcon,
|
EditIcon,
|
||||||
@@ -12,9 +11,10 @@ import {
|
|||||||
TrashIcon,
|
TrashIcon,
|
||||||
RefreshIcon,
|
RefreshIcon,
|
||||||
MinusVerticalIcon,
|
MinusVerticalIcon,
|
||||||
ArrowUpIcon,
|
|
||||||
} from '../ui/icons';
|
} from '../ui/icons';
|
||||||
import BreadcrumbTrail from '../ui/BreadcrumbTrail';
|
import BreadcrumbTrail from '../ui/BreadcrumbTrail';
|
||||||
|
import createWorkspaceSurfaceConfig from './workspaceHeader';
|
||||||
|
import DetailPanel from '../detail/DetailPanel';
|
||||||
|
|
||||||
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 = 144;
|
const DEFAULT_GRID_ICON_SIZE = 144;
|
||||||
@@ -1161,35 +1161,21 @@ export const createDocumentsSurface = ({
|
|||||||
});
|
});
|
||||||
|
|
||||||
const sidebarToggle = renderSidebarToggle ? renderSidebarToggle() : null;
|
const sidebarToggle = renderSidebarToggle ? renderSidebarToggle() : null;
|
||||||
const parentControl = parentBreadcrumb
|
|
||||||
? (
|
|
||||||
<button
|
|
||||||
type="button"
|
|
||||||
className="icon-button"
|
|
||||||
onClick={onNavigateParent}
|
|
||||||
aria-label="Go to parent folder"
|
|
||||||
title="Go to parent folder"
|
|
||||||
>
|
|
||||||
<ArrowUpIcon />
|
|
||||||
</button>
|
|
||||||
)
|
|
||||||
: null;
|
|
||||||
const leading = sidebarToggle || parentControl
|
|
||||||
? (
|
|
||||||
<>
|
|
||||||
{sidebarToggle}
|
|
||||||
{parentControl}
|
|
||||||
</>
|
|
||||||
)
|
|
||||||
: null;
|
|
||||||
|
|
||||||
const detail = detailOpen && detailProps ? <DetailPanel {...detailProps} /> : null;
|
const detail = detailOpen && detailProps ? <DetailPanel {...detailProps} /> : null;
|
||||||
|
|
||||||
return {
|
const surfaceConfig = createWorkspaceSurfaceConfig({
|
||||||
key: 'documents',
|
key: 'documents',
|
||||||
variant: 'documents',
|
variant: 'documents',
|
||||||
header: { title, subtitle, leading, actions, breadcrumbs },
|
title,
|
||||||
|
subtitle,
|
||||||
|
sidebarToggle,
|
||||||
|
parentBreadcrumb,
|
||||||
|
onNavigateParent,
|
||||||
|
actions,
|
||||||
|
breadcrumbs,
|
||||||
content: <DocumentsTable {...tableProps} showHeader={false} />,
|
content: <DocumentsTable {...tableProps} showHeader={false} />,
|
||||||
detail,
|
detail,
|
||||||
};
|
});
|
||||||
|
|
||||||
|
return surfaceConfig;
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -0,0 +1,55 @@
|
|||||||
|
import React from 'react';
|
||||||
|
import { ArrowUpIcon } from '../ui/icons';
|
||||||
|
|
||||||
|
export const createWorkspaceSurfaceConfig = ({
|
||||||
|
title,
|
||||||
|
subtitle = null,
|
||||||
|
sidebarToggle = null,
|
||||||
|
parentBreadcrumb = null,
|
||||||
|
onNavigateParent = null,
|
||||||
|
actions = null,
|
||||||
|
breadcrumbs = null,
|
||||||
|
content = null,
|
||||||
|
detail = null,
|
||||||
|
variant = 'documents',
|
||||||
|
key = 'documents',
|
||||||
|
}) => {
|
||||||
|
const showParent = parentBreadcrumb && typeof onNavigateParent === 'function';
|
||||||
|
|
||||||
|
const parentControl = showParent ? (
|
||||||
|
<button
|
||||||
|
type="button"
|
||||||
|
className="icon-button"
|
||||||
|
onClick={onNavigateParent}
|
||||||
|
aria-label="Go to parent folder"
|
||||||
|
title="Go to parent folder"
|
||||||
|
>
|
||||||
|
<ArrowUpIcon />
|
||||||
|
</button>
|
||||||
|
) : null;
|
||||||
|
|
||||||
|
const leading = sidebarToggle || parentControl
|
||||||
|
? (
|
||||||
|
<>
|
||||||
|
{sidebarToggle}
|
||||||
|
{parentControl}
|
||||||
|
</>
|
||||||
|
)
|
||||||
|
: null;
|
||||||
|
|
||||||
|
return {
|
||||||
|
key,
|
||||||
|
variant,
|
||||||
|
header: {
|
||||||
|
title,
|
||||||
|
subtitle,
|
||||||
|
leading,
|
||||||
|
actions,
|
||||||
|
breadcrumbs,
|
||||||
|
},
|
||||||
|
content,
|
||||||
|
detail,
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
export default createWorkspaceSurfaceConfig;
|
||||||
@@ -2395,7 +2395,7 @@ button.danger:hover:not([disabled]) {
|
|||||||
.panel-header {
|
.panel-header {
|
||||||
display: flex;
|
display: flex;
|
||||||
align-items: center;
|
align-items: center;
|
||||||
gap: 0.75rem;
|
gap: 0.5rem;
|
||||||
padding: 0.5rem;
|
padding: 0.5rem;
|
||||||
min-width: 0;
|
min-width: 0;
|
||||||
}
|
}
|
||||||
@@ -2404,7 +2404,7 @@ button.danger:hover:not([disabled]) {
|
|||||||
.panel-header__actions {
|
.panel-header__actions {
|
||||||
display: flex;
|
display: flex;
|
||||||
align-items: center;
|
align-items: center;
|
||||||
gap: 0.5rem;
|
gap: 0.25rem;
|
||||||
}
|
}
|
||||||
|
|
||||||
.panel-header__title {
|
.panel-header__title {
|
||||||
|
|||||||
Reference in New Issue
Block a user