Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

#704 responsive breadcrumbs #713

Closed
wants to merge 5 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading