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

Improve Doc Node Example Layout #1946

Merged
merged 3 commits into from
Jul 17, 2023
Merged
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
89 changes: 39 additions & 50 deletions src/renderer/components/NodeDocumentation/NodeDocs.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { NeverType, Type } from '@chainner/navi';
import {
Box,
Center,
Code,
Divider,
Flex,
Expand Down Expand Up @@ -331,15 +332,15 @@ export const NodeDocs = memo(() => {

const schema = schemata.schemata;
const selectedSchema = schemata.get(selectedSchemaId ?? schema[0].schemaId);
const selectedFunctionDefinition = functionDefinitions.get(
selectedSchemaId ?? schema[0].schemaId
);

const selectedAccentColor = getCategoryAccentColor(categories, selectedSchema.category);

const [isLargerThan1200] = useMediaQuery('(min-width: 1200px)');

const hasIteratorHelperNodes =
selectedSchema.defaultNodes && selectedSchema.defaultNodes.length > 0;
const nodeDocsToShow = [
selectedSchema,
...(selectedSchema.defaultNodes?.map((n) => schemata.get(n.schemaId)) ?? []),
];

return (
<Box
Expand All @@ -348,9 +349,7 @@ export const NodeDocs = memo(() => {
w="full"
>
<Box w="full">
<Flex
direction={isLargerThan1200 ? 'row' : 'column'}
gap={4}
<Box
left={0}
maxH="full"
overflowY="scroll"
Expand All @@ -368,54 +367,44 @@ export const NodeDocs = memo(() => {
textAlign="left"
w="full"
>
<SingleNodeInfo
accentColor={selectedAccentColor}
functionDefinition={selectedFunctionDefinition}
schema={selectedSchema}
/>
{hasIteratorHelperNodes &&
selectedSchema.defaultNodes.map((defaultNode) => {
const nodeSchema = schemata.get(defaultNode.schemaId);
const nodeFunctionDefinition = functionDefinitions.get(
defaultNode.schemaId
);
return (
{nodeDocsToShow.map((nodeSchema) => {
const nodeFunctionDefinition = functionDefinitions.get(
nodeSchema.schemaId
);
return (
<Flex
direction={isLargerThan1200 ? 'row' : 'column'}
gap={4}
>
<SingleNodeInfo
accentColor={selectedAccentColor}
functionDefinition={nodeFunctionDefinition}
key={defaultNode.schemaId}
key={nodeSchema.schemaId}
schema={nodeSchema}
/>
);
})}
<Center
h="full"
position="relative"
verticalAlign="top"
>
<Box
maxW="fit-content"
mr={6}
position="relative"
w="auto"
>
<NodeExample
accentColor={selectedAccentColor}
key={nodeSchema.schemaId}
selectedSchema={nodeSchema}
/>
</Box>
</Center>
</Flex>
);
})}
</VStack>
<Box
h="full"
position="relative"
>
<VStack
alignItems="left"
mr={6}
position="relative"
>
<NodeExample
accentColor={selectedAccentColor}
selectedSchema={selectedSchema}
/>
{hasIteratorHelperNodes &&
selectedSchema.defaultNodes.map((defaultNode) => {
const nodeSchema = schemata.get(defaultNode.schemaId);
return (
<NodeExample
accentColor={selectedAccentColor}
key={defaultNode.schemaId}
selectedSchema={nodeSchema}
/>
);
})}
</VStack>
</Box>
</Flex>
</Box>
</Box>
</Box>
);
Expand Down
2 changes: 0 additions & 2 deletions src/renderer/components/NodeDocumentation/NodeExample.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,6 @@ export const NodeExample = memo(({ accentColor, selectedSchema }: NodeExamplePro
<Center
key={selectedSchema.schemaId}
pointerEvents="none"
w="auto"
>
<Center
bg="var(--node-bg-color)"
Expand All @@ -115,7 +114,6 @@ export const NodeExample = memo(({ accentColor, selectedSchema }: NodeExamplePro
minWidth="240px"
overflow="hidden"
transition="0.15s ease-in-out"
w="full"
>
<VStack
spacing={0}
Expand Down