Skip to content

Commit

Permalink
#704 Improve breadcrumbs and folder list view on mobile
Browse files Browse the repository at this point in the history
  • Loading branch information
Polleps authored and joepio committed Nov 27, 2023
1 parent 46f8a44 commit bb47ad1
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 51 deletions.
58 changes: 10 additions & 48 deletions browser/data-browser/src/components/Parent.tsx
Original file line number Diff line number Diff line change
@@ -1,14 +1,7 @@
import { styled, css } from 'styled-components';
import {
useResource,
useString,
useTitle,
properties,
Resource,
useCanWrite,
} from '@tomic/react';
import { useResource, useString, useTitle, Resource, core } from '@tomic/react';
import { constructOpenURL } from '../helpers/navigation';
import { FaEdit, FaSearch } from 'react-icons/fa';
import { FaSearch } from 'react-icons/fa';
import { Row } from './Row';
import { useQueryScopeHandler } from '../hooks/useQueryScope';
import { IconButton } from './IconButton/IconButton';
Expand All @@ -24,9 +17,7 @@ export const PARENT_PADDING_BLOCK = '0.2rem';

/** Breadcrumb list. Recursively renders parents. */
function Parent({ resource }: ParentProps): JSX.Element {
const [parent] = useString(resource, properties.parent);
const [title, setTitle] = useTitle(resource);
const [canEdit] = useCanWrite(resource);
const [parent] = useString(resource, core.properties.parent);
const { enableScope } = useQueryScopeHandler(resource.getSubject());

return (
Expand All @@ -37,21 +28,11 @@ function Parent({ resource }: ParentProps): JSX.Element {
) : (
<DriveMismatch subject={resource.getSubject()} />
)}
{canEdit ? (
<BreadCrumbInputWrapper>
<BreadCrumbInput
value={title}
onChange={e => setTitle(e.target.value)}
/>
<FaEdit />
</BreadCrumbInputWrapper>
) : (
<BreadCrumbCurrent>{title}</BreadCrumbCurrent>
)}
<BreadCrumbCurrent>{resource.title}</BreadCrumbCurrent>
<Spacer />
<ScopedSearchButton
onClick={enableScope}
title={`Search in ${title}`}
title={`Search in ${resource.title}`}
color='textLight'
>
<FaSearch />
Expand Down Expand Up @@ -113,7 +94,7 @@ function DriveMismatch({ subject }: { subject: string }) {
/** The actually recursive part */
function NestedParent({ subject, depth }: NestedParentProps): JSX.Element {
const resource = useResource(subject, { allowIncomplete: true });
const [parent] = useString(resource, properties.parent);
const [parent] = useString(resource, core.properties.parent);
const navigate = useNavigateWithTransition();
const [title] = useTitle(resource);

Expand Down Expand Up @@ -151,36 +132,17 @@ const BreadCrumbBase = css`
font-family: ${props => props.theme.fontFamily};
padding: 0.1rem 0.5rem;
color: ${p => p.theme.colors.textLight};
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;
`;

const BreadCrumbCurrent = styled.div`
${BreadCrumbBase}
`;

const BreadCrumbInput = styled.input`
const BreadCrumbCurrent = styled.span`
${BreadCrumbBase}
background: none;
outline: none;
border: none;
`;

const BreadCrumbInputWrapper = styled.div`
display: flex;
&:hover svg {
display: flex;
}
svg {
display: none;
}
`;

const Breadcrumb = styled.a`
${BreadCrumbBase}
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;
align-self: center;
cursor: 'pointer';
text-decoration: none;
Expand Down
12 changes: 9 additions & 3 deletions browser/data-browser/src/views/FolderPage/ListView.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ export function ListView({
<th>
<TitleHeaderWrapper>Title</TitleHeaderWrapper>
</th>
<th>Class</th>
<ClassCell as='th'>Class</ClassCell>
<AlignRight as='th'>Last Modified</AlignRight>
</tr>
</thead>
Expand All @@ -38,9 +38,9 @@ export function ListView({
<td>
<Title resource={resource} />
</td>
<td>
<ClassCell>
<ClassType resource={resource} />
</td>
</ClassCell>
<AlignRight>
<LastCommit resource={resource} />
</AlignRight>
Expand Down Expand Up @@ -176,6 +176,12 @@ const TableRow = styled.tr`
}
`;

const ClassCell = styled.td`
@container (max-width: 500px) {
display: none;
}
`;

const NewButton = styled(Button)`
margin-top: 1rem;
margin-inline-start: calc(
Expand Down

0 comments on commit bb47ad1

Please sign in to comment.