From fed10bc07c594c531858e85c87b9525b8e8fb353 Mon Sep 17 00:00:00 2001 From: James Acklin Date: Tue, 18 May 2021 14:42:59 -0400 Subject: [PATCH] permalinks; conditional addtional rows, dependent on graph type --- .../src/views/apps/permalinks/embed.tsx | 65 +++++++++++++------ 1 file changed, 44 insertions(+), 21 deletions(-) diff --git a/pkg/interface/src/views/apps/permalinks/embed.tsx b/pkg/interface/src/views/apps/permalinks/embed.tsx index 7f2196a78..7df0ad8f8 100644 --- a/pkg/interface/src/views/apps/permalinks/embed.tsx +++ b/pkg/interface/src/views/apps/permalinks/embed.tsx @@ -1,6 +1,7 @@ import { BaseAnchor, Box, Center, Col, Icon, Row, Text } from "@tlon/indigo-react"; import { Association, GraphNode, resourceFromPath, GraphConfig } from '@urbit/api'; import React, { useCallback, useEffect, useState } from "react"; +import _ from 'lodash'; import { useHistory, useLocation } from 'react-router-dom'; import GlobalApi from '~/logic/api/global'; import { @@ -13,22 +14,44 @@ import useMetadataState from "~/logic/state/metadata"; import { GroupLink } from "~/views/components/GroupLink"; import { TranscludedNode } from "./TranscludedNode"; -function Placeholder() { +function Placeholder(type) { + const lines = (type) => { + switch (type) { + case 'publish': + return 5; + case 'post': + return 3; + default: + return 1; + } + } return ( - - - - + <> + + + + + {_.times(lines(type), () => ( + + + + ))} + ); } @@ -131,8 +154,8 @@ function GraphPermalink( navigate(e); }} > - {loading && Placeholder()} - {showTransclusion && index && ( + {loading && association && Placeholder(association.metadata.config.graph)} + {showTransclusion && index && !loading && ( )} - {association && !isInSameResource && ( + {association && !isInSameResource && !loading && ( )} - {association && isInSameResource && transcluded === 2 && ( + {association && isInSameResource && transcluded === 2 && !loading && ( )} - {isInSameResource && transcluded !== 2 && } - {!association && ( + {isInSameResource && transcluded !== 2 && } + {!association && !loading && (