Skip to content

Commit

Permalink
Record page style updates (#1316)
Browse files Browse the repository at this point in the history
* Remove ordering by targetType

* Expand nav panel category when shortcut of child is clicked

* Expand active nav panel section on page load

* Make some whitespace adjustments

* Fix issue with PopoverButton causing page jumps
  • Loading branch information
dmfalke authored Jan 23, 2025
1 parent ef9275a commit 9cfd746
Show file tree
Hide file tree
Showing 6 changed files with 57 additions and 7 deletions.
28 changes: 26 additions & 2 deletions packages/libs/wdk-client/src/Utils/CategoryUtils.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import {
} from '../Utils/OntologyUtils';
import { areTermsInString } from '../Utils/SearchUtils';
import { Seq } from '../Utils/IterableUtils';
import { preorderSeq, getBranches } from '../Utils/TreeUtils';
import { preorderSeq, getBranches, foldStructure } from '../Utils/TreeUtils';
import { Question, RecordClass } from '../Utils/WdkModel';
// import {Tooltip} from '@veupathdb/components/lib/components/widgets/Tooltip';

Expand Down Expand Up @@ -136,6 +136,30 @@ export function getChildren(node: CategoryTreeNode) {
return node.children;
}

export function getAncestors(
tree: CategoryTreeNode,
descendantId: string
): CategoryTreeNode[] {
return foldStructure<CategoryTreeNode, CategoryTreeNode[]>(
(acc, node) => {
const directDescendantId = acc[0] && getId(acc[0]);
if (
node.children.some((childNode) => {
const childNodeId = getId(childNode);
return (
childNodeId === directDescendantId || childNodeId === descendantId
);
})
) {
return [node, ...acc];
}
return acc;
},
[],
tree
).slice(0, -1);
}

// TODO Make this more genericL createCategoryNode and createWdkEntityNode (or, createLeafNode??)
/**
* Returns a JSON object representing a simplified category tree node that will be properly interpreted
Expand Down Expand Up @@ -408,7 +432,7 @@ function makeComparator(
questions: Dict<Question>
) {
return composeComparators(
compareByTargetType,
// compareByTargetType,
compareByChildren,
compareBySortNumber,
makeCompareBySortName(recordClasses, questions)
Expand Down
2 changes: 1 addition & 1 deletion packages/libs/wdk-client/src/Views/Records/Record.css
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
.wdk-RecordActions {
padding: 0;
margin: 0;
padding-top: 1em;
}

.wdk-RecordHeading {
Expand Down Expand Up @@ -50,6 +49,7 @@
/* make prevent contents panel from being clipped. */
min-height: 65vh;
margin-left: 2em;
width: 100%;
}

.wdk-RecordSidebar {
Expand Down
8 changes: 7 additions & 1 deletion packages/libs/wdk-client/src/Views/Records/RecordUI.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import classnames from 'classnames';
import { debounce, get, isEqual, memoize } from 'lodash';
import React, { Component } from 'react';
import { findDOMNode } from 'react-dom';
import { getId } from '../../Utils/CategoryUtils';
import { getAncestors, getId } from '../../Utils/CategoryUtils';
import { wrappable } from '../../Utils/ComponentUtils';
import { findAncestorNode } from '../../Utils/DomUtils';
import { postorderSeq, preorderSeq } from '../../Utils/TreeUtils';
Expand Down Expand Up @@ -121,6 +121,12 @@ class RecordUI extends Component {
if (isFirstLoadForRecordId) {
// open the target section
this.props.updateSectionVisibility(sectionNode.id, true);
const ancestorCategoryNodes = getAncestors(
this.props.categoryTree,
sectionNode.id
).slice(1);
const ancestorNodeId = ancestorCategoryNodes.map(getId);
this.props.updateNavigationCategoryExpansion(ancestorNodeId);
}

const rect = targetNode.getBoundingClientRect();
Expand Down
5 changes: 4 additions & 1 deletion packages/libs/web-common/src/styles/AllSites.scss
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,10 @@ html {
--page-offset-top: 100px;
}
html {
overflow: auto;
// The following rule causes the page to jump around when using the mui
// Popover component. I'm leaving this commented-out rule in place for
// future reference.
// overflow: auto;
scroll-padding-top: var(--page-offset-top);
}

Expand Down
3 changes: 2 additions & 1 deletion packages/libs/web-common/src/styles/client.scss
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,7 @@ td.wdk-DataTableCell__thumbnail {
}

.eupathdb-RecordOverview {
padding-top: 1rem;
padding-bottom: 2rem;
border-bottom: 1px solid #aaa;
}
Expand Down Expand Up @@ -183,8 +184,8 @@ td.wdk-DataTableCell__thumbnail {
.eupathdb-RecordOverview {
dl {
font-size: 1.4em;
row-gap: 0.2em;
margin: 0;
line-height: 1.3em;
}
dt {
justify-self: start;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,12 +46,16 @@ import betaImage from '@veupathdb/wdk-client/lib/Core/Style/images/beta2-30.png'
import { LinksPosition } from '@veupathdb/coreui/lib/components/inputs/checkboxes/CheckboxTree/CheckboxTree';
import { AlphaFoldRecordSection } from './AlphaFoldAttributeSection';
import { DEFAULT_TABLE_STATE } from '@veupathdb/wdk-client/lib/StoreModules/RecordStoreModule';
import { findAncestorFields } from '@veupathdb/wdk-client/lib/Components/AttributeFilter/AttributeFilterUtils';

/**
* Render thumbnails at eupathdb-GeneThumbnailsContainer
*/
export const RecordHeading = connect(
(state) => ({ categoryTree: state.record.categoryTree }),
(state) => ({
categoryTree: state.record.categoryTree,
navigationCategoriesExpanded: state.record.navigationCategoriesExpanded,
}),
RecordActions
)(
class GeneRecordHeading extends Component {
Expand All @@ -78,7 +82,19 @@ export const RecordHeading = connect(
}

handleThumbnailClick({ anchor }) {
const parentCategories = Category.getAncestors(
this.props.categoryTree,
anchor
).slice(1);
const parentCategoryIds = parentCategories.map(Category.getId);
const nextExpandedNavCats = Array.from(
new Set([
...this.props.navigationCategoriesExpanded,
...parentCategoryIds,
])
);
this.props.updateSectionVisibility(anchor, true);
this.props.updateNavigationCategoryExpansion(nextExpandedNavCats);
}

componentDidUpdate() {
Expand Down

0 comments on commit 9cfd746

Please sign in to comment.