Skip to content

Commit

Permalink
fix(app): Disable ReadMore component for FileTree
Browse files Browse the repository at this point in the history
  • Loading branch information
nellh committed Jul 18, 2022
1 parent 6f58fd8 commit 58a0872
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 43 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -11,20 +11,14 @@ import EditDescriptionField from '../fragments/edit-description-field'
*/
export const DatasetDefault = ({ dataset, hasEdit }) => (
<>
<ReadMore
fileTree={true}
id="collapse-tree"
expandLabel="Expand File Tree"
collapseLabel="Collapse File Tree">
<Files
datasetId={dataset.id}
snapshotTag={null}
datasetName={dataset.draft.description.Name}
files={dataset.draft.files}
editMode={hasEdit}
datasetPermissions={dataset.permissions}
/>
</ReadMore>
<Files
datasetId={dataset.id}
snapshotTag={null}
datasetName={dataset.draft.description.Name}
files={dataset.draft.files}
editMode={hasEdit}
datasetPermissions={dataset.permissions}
/>
<MetaDataBlock
heading="README"
className="dataset-readme markdown-body"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,20 +10,14 @@ import Comments from '../comments/comments'
*/
export const SnapshotDefault = ({ dataset, snapshot }) => (
<>
<ReadMore
fileTree={true}
id="collapse-tree"
expandLabel="Read More"
collapseLabel="Collapse">
<Files
datasetId={dataset.id}
snapshotTag={snapshot.tag}
datasetName={snapshot.description.Name}
files={snapshot.files}
editMode={false}
datasetPermissions={dataset.permissions}
/>
</ReadMore>
<Files
datasetId={dataset.id}
snapshotTag={snapshot.tag}
datasetName={snapshot.description.Name}
files={snapshot.files}
editMode={false}
datasetPermissions={dataset.permissions}
/>
<MetaDataBlock
heading="README"
item={
Expand Down
16 changes: 1 addition & 15 deletions packages/openneuro-components/src/read-more/ReadMore.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,13 @@ export interface ReadMoreProps {
id: string
collapseLabel: string
expandLabel: string
fileTree?: boolean
}

export const ReadMore = ({
children,
id,
expandLabel,
collapseLabel,
fileTree,
}: ReadMoreProps) => {
const readmoreRef = useRef<HTMLDivElement>()
const [dimensions, setDimensions] = useState({ height: 0 })
Expand All @@ -27,19 +25,7 @@ export const ReadMore = ({

return (
<div ref={readmoreRef}>
{fileTree && dimensions.height > 990 ? (
<article className="has-read-more readmore-file-tree">
<input type="checkbox" className="show-more" id={id} />

<section>
{children}
<label htmlFor={id} className="expand-collapse">
<span>{expandLabel}</span>
<span>{collapseLabel}</span>
</label>
</section>
</article>
) : !fileTree && dimensions.height > 400 ? (
{dimensions.height > 400 ? (
<article className="has-read-more file-tree">
<input type="checkbox" className="show-more" id={id} />

Expand Down

0 comments on commit 58a0872

Please sign in to comment.