From 1f99f6163b65f085807534cd989e073b0232d572 Mon Sep 17 00:00:00 2001 From: Daniele Guido Date: Mon, 12 Feb 2024 11:10:48 +0100 Subject: [PATCH 1/9] move _redirects to public folder (netlify) --- .gitignore | 1 + _redirects => public/_redirects | 0 2 files changed, 1 insertion(+) rename _redirects => public/_redirects (100%) diff --git a/.gitignore b/.gitignore index a294589b..890a205a 100644 --- a/.gitignore +++ b/.gitignore @@ -9,3 +9,4 @@ node_modules .vscode/settings.json storybook-static # _redirects +journal-of-digital-history.code-workspace diff --git a/_redirects b/public/_redirects similarity index 100% rename from _redirects rename to public/_redirects From 14a26e88a54edda8cdc1a16b506ac421865f4f12 Mon Sep 17 00:00:00 2001 From: Daniele Guido Date: Mon, 12 Feb 2024 11:28:27 +0100 Subject: [PATCH 2/9] progressive loading articles page --- src/components/Articles/ArticlesFacets.js | 3 +- src/components/Articles/ArticlesGrid.js | 55 ++++++++++++++++------- src/components/Facets/Dimension.js | 11 ++++- src/components/Facets/Facets.js | 2 + src/pages/Articles.js | 12 ++--- 5 files changed, 61 insertions(+), 22 deletions(-) diff --git a/src/components/Articles/ArticlesFacets.js b/src/components/Articles/ArticlesFacets.js index 17849418..45e11c20 100644 --- a/src/components/Articles/ArticlesFacets.js +++ b/src/components/Articles/ArticlesFacets.js @@ -105,7 +105,7 @@ const Dimensions = [ }, ] -const ArticlesFacets = ({ items, onSelect, className }) => { +const ArticlesFacets = ({ items, onSelect, onShowMore, className }) => { return ( { onSelect={onSelect} onInit={(args) => console.debug('[ArticlesFacets] @init', args)} ShowMoreLabel={ShowMoreLabel} + onShowMore={onShowMore} className={className} /> ) diff --git a/src/components/Articles/ArticlesGrid.js b/src/components/Articles/ArticlesGrid.js index 2c06fe77..9ad27c32 100644 --- a/src/components/Articles/ArticlesGrid.js +++ b/src/components/Articles/ArticlesGrid.js @@ -23,10 +23,9 @@ import Article from '../../models/Article' import ArticlesFacets from '../Articles/ArticlesFacets' import Issue from '../Issue' import ArticleFingerprintTooltip from '../ArticleV2/ArticleFingerprintTooltip' - import groupBy from 'lodash/groupBy' import { Container, Row, Col } from 'react-bootstrap' -import { useSpring, config } from 'react-spring' +import { useSpring, config, a } from '@react-spring/web' import { useHistory } from 'react-router' import { useBoundingClientRect } from '../../hooks/graphics' @@ -39,6 +38,7 @@ const ArticlesGrid = ({ // tag ategories to keep categories = ['narrative', 'tool', 'issue'], }) => { + const facetsRef = useRef() const { t } = useTranslation() const [{ [OrderByQueryParam]: orderBy }, setQuery] = useQueryParams({ [OrderByQueryParam]: withDefault( @@ -64,6 +64,10 @@ const ArticlesGrid = ({ backgroundColor: 'var(--secondary)', config: config.stiff, })) + // animation properties to slide up and down the articleFacets block + const [facetsAnimatedProps, setFacetsAnimatedProps] = useSpring(() => ({ + height: 0, + })) const data = (items || []).map((d, idx) => new Article({ ...d, idx })) const articles = sort(data, AvailablesOrderByComparators[orderBy]) const { articlesByIssue, showFilters } = useMemo(() => { @@ -163,6 +167,15 @@ const ArticlesGrid = ({ selected, ) + useLayoutEffect(() => { + if (status === StatusSuccess) { + setFacetsAnimatedProps.start({ + height: facetsRef.current.scrollHeight, + delay: 1000, + }) + } + }, [status]) + return ( @@ -183,20 +196,32 @@ const ArticlesGrid = ({ - {showFilters && ( - - - {status === StatusSuccess && ( - - )} - - - )} + + + {status === StatusSuccess && ( + { + console.info('[ArticlesGrid] @showMore') + // eslint-disable-next-line + setTimeout(() => { + setFacetsAnimatedProps.set({ + height: facetsRef.current.firstChild.scrollHeight, + delay: 0, + }) + }, 0) + }} + onSelect={onFacetsSelectHandler} + className="Articles_facets " + /> + )} + + {orderBy === OrderByIssue && issues.map((issue) => { // const issue = articlesByIssue[id][0].issue diff --git a/src/components/Facets/Dimension.js b/src/components/Facets/Dimension.js index 0739cc8f..b98d8528 100644 --- a/src/components/Facets/Dimension.js +++ b/src/components/Facets/Dimension.js @@ -80,6 +80,7 @@ const Dimension = ({ onInit, onSelect, onMouseEnter, + onShowMore, children, ListItem = DimensionGroupListItem, }) => { @@ -174,7 +175,15 @@ const Dimension = ({ ))} {restGroups.length > 0 && (
  • -