From 4393ff1a2a0d4b98d168092069175111a8cb8864 Mon Sep 17 00:00:00 2001 From: delyc Date: Thu, 31 Oct 2024 13:08:10 +0200 Subject: [PATCH 1/2] sprting --- src/components/Group.tsx | 30 ++++++++++++++++------- src/pages/case-studies-and-core-tools.tsx | 1 + src/utils/nodes.ts | 1 + 3 files changed, 23 insertions(+), 9 deletions(-) diff --git a/src/components/Group.tsx b/src/components/Group.tsx index b7ae9ea..e29e50f 100644 --- a/src/components/Group.tsx +++ b/src/components/Group.tsx @@ -3,7 +3,7 @@ import Block from "./Block"; const AdvancedResources = ({ data, - minifiedHeader + minifiedHeader, }: { data: Group; minifiedHeader?: boolean; @@ -11,21 +11,33 @@ const AdvancedResources = ({ return ( <>

- {data.title != "NO GROUP" && data.title} + {data.title !== "NO GROUP" && data.title}

{data.blocks.map((block, i) => { + // Sort entries based on "CO-DESIGN LEVEL" + const sortedEntries = block.entries.sort((b, a) => { + const levelA = a.PARSED_MANUAL_TAGS["CO-DESIGN LEVEL"] || ""; + const levelB = b.PARSED_MANUAL_TAGS["CO-DESIGN LEVEL"] || ""; + + // Assuming "CO-DESIGN LEVEL" is alphanumeric, adjust comparison logic accordingly + if (levelA < levelB) return -1; + if (levelA > levelB) return 1; + return 0; + }); + return ( - +
+ +
); })}
diff --git a/src/pages/case-studies-and-core-tools.tsx b/src/pages/case-studies-and-core-tools.tsx index ef4f44d..f1623ce 100644 --- a/src/pages/case-studies-and-core-tools.tsx +++ b/src/pages/case-studies-and-core-tools.tsx @@ -9,6 +9,7 @@ const caseStudiesAndCoreTools = () => {
{groups?.map((data, index) => { + console.log("tesss") return ( { const coDesignLevel = data.PARSED_MANUAL_TAGS?.["CO-DESIGN LEVEL"]; + console.log("lebveellllss", coDesignLevel) if (Array.isArray(coDesignLevel)) return coDesignLevel[0]; return coDesignLevel; }; From c20b019ec1f84c5cc30a3224414e97f438f02645 Mon Sep 17 00:00:00 2001 From: delyc Date: Tue, 12 Nov 2024 09:58:06 +0200 Subject: [PATCH 2/2] fix: basic tools colouring --- src/components/Group.tsx | 4 ++++ src/components/cards/Node.tsx | 11 +++++++---- src/data/basic-tools/index.ts | 10 +++++++--- src/pages/index.tsx | 1 + src/types/interfaces.ts | 1 + src/utils/helpers.ts | 5 +++++ src/utils/nodes.ts | 12 +++++++++++- tsconfig.json | 23 ++++++++++++++++++----- 8 files changed, 54 insertions(+), 13 deletions(-) diff --git a/src/components/Group.tsx b/src/components/Group.tsx index e29e50f..8876d00 100644 --- a/src/components/Group.tsx +++ b/src/components/Group.tsx @@ -47,3 +47,7 @@ const AdvancedResources = ({ }; export default AdvancedResources; + + + + diff --git a/src/components/cards/Node.tsx b/src/components/cards/Node.tsx index de0d6cd..4054d3d 100644 --- a/src/components/cards/Node.tsx +++ b/src/components/cards/Node.tsx @@ -1,6 +1,6 @@ import Star from "@/components/icons/Star"; import { useHighlight } from "@/hooks/useHighlight"; -import { getBgColorClassName, getColorByAccess, getLevel } from "@/utils/nodes"; +import { getBgColorClassName, getColorByAccess, getLevel, getNodeBgColorClassName } from "@/utils/nodes"; import { useMemo } from "react"; import { Handle } from "reactflow"; import "reactflow/dist/style.css"; @@ -14,8 +14,7 @@ export function NodeCard({ const highlighted = useHighlight(data); const { className, access, starColor, summary } = useMemo(() => { - const level = getLevel(data); - const bgColor = getBgColorClassName(level); + const bgColor = getNodeBgColorClassName(data); const access = data?.PARSED_MANUAL_TAGS?.ACCESS?.[0]; const starColor = getColorByAccess(access); const summary = data.Notes?.replace(/<[^>]*>?/gm, ""); @@ -30,11 +29,14 @@ export function NodeCard({ window?.open(data?.url, "_blank")?.focus(); }; + return (
-
+
+ {data.title &&

{data.title}

} {data.authors &&

{data.authors}

} {(access === "Institutional Access" || @@ -45,6 +47,7 @@ export function NodeCard({
)}
+ {data.authors && (

Author(s): {data.authors} diff --git a/src/data/basic-tools/index.ts b/src/data/basic-tools/index.ts index d964fe7..315de1a 100644 --- a/src/data/basic-tools/index.ts +++ b/src/data/basic-tools/index.ts @@ -2,12 +2,16 @@ import output from "@/data/zotero"; import { Block, Entry } from "@/types/interfaces"; import { approaches } from "./approaches"; import { toolsData } from "./tools-data"; +import { isBasicTool } from "@/utils/helpers"; const toolData = toolsData["BASIC TOOLS"]; -const entries = output.filter( - (entry) => entry?.PARSED_MANUAL_TAGS && "BASIC TOOLS" in entry.PARSED_MANUAL_TAGS -) as unknown as Entry[]; +const entries = output + .filter((entry) => isBasicTool(entry)) + .map((entry) => ({ + ...entry, + isBasicTool: true, + })) as unknown as Entry[]; const groups: Block[] = [ { diff --git a/src/pages/index.tsx b/src/pages/index.tsx index 8f4eae3..26d8b89 100644 --- a/src/pages/index.tsx +++ b/src/pages/index.tsx @@ -1,5 +1,6 @@ import Group from "@/components/Group"; import resources from "@/data/resources/advanced-resources"; +// import Grou diff --git a/src/types/interfaces.ts b/src/types/interfaces.ts index 5fd6e70..7376dd9 100644 --- a/src/types/interfaces.ts +++ b/src/types/interfaces.ts @@ -22,6 +22,7 @@ export interface Entry { tags: string; PARSED_MANUAL_TAGS: ParsedManualTags; PARSED_RELATES_TO?: string[]; + isBasicTool?: Boolean } export type Entries = Entry[]; diff --git a/src/utils/helpers.ts b/src/utils/helpers.ts index f084c1a..5e3fa9d 100644 --- a/src/utils/helpers.ts +++ b/src/utils/helpers.ts @@ -1,3 +1,5 @@ +import { Entry } from "@/types/interfaces"; + export const hasTag = (entry: any, name: any, value: any) => { const attributeValues = entry?.PARSED_MANUAL_TAGS?.[name]; if (Array.isArray(attributeValues)) return attributeValues.includes(value); @@ -86,3 +88,6 @@ export const getRandomColor = () => { return hexColor; }; + + +export const isBasicTool = (entry: any) => entry?.PARSED_MANUAL_TAGS && "BASIC TOOLS" in entry.PARSED_MANUAL_TAGS \ No newline at end of file diff --git a/src/utils/nodes.ts b/src/utils/nodes.ts index 938fcd8..c37bd33 100644 --- a/src/utils/nodes.ts +++ b/src/utils/nodes.ts @@ -1,4 +1,6 @@ +import { Entry } from "@/types/interfaces"; import classNames from "classnames"; +import { isBasicTool } from "./helpers"; export function getColorByAccess(accessType: string) { switch (accessType) { @@ -15,7 +17,6 @@ export function getColorByAccess(accessType: string) { export const getLevel = (data: any) => { const coDesignLevel = data.PARSED_MANUAL_TAGS?.["CO-DESIGN LEVEL"]; - console.log("lebveellllss", coDesignLevel) if (Array.isArray(coDesignLevel)) return coDesignLevel[0]; return coDesignLevel; }; @@ -36,3 +37,12 @@ export const getBgColorClassName = (level: any) => { ); } }; + +export const getNodeBgColorClassName = (entry: Entry) => { + console.log(entry) + + if(entry.isBasicTool) return classNames("bg-[#f8cecc] border-[#b85450]"); + + const level = getLevel(entry); + return getBgColorClassName(level); +}; diff --git a/tsconfig.json b/tsconfig.json index fb68dc1..388376c 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -1,6 +1,10 @@ { "compilerOptions": { - "lib": ["dom", "dom.iterable", "esnext"], + "lib": [ + "dom", + "dom.iterable", + "esnext" + ], "allowJs": true, "skipLibCheck": true, "strict": true, @@ -13,9 +17,18 @@ "jsx": "preserve", "incremental": true, "paths": { - "@/*": ["./src/*"] - } + "@/*": [ + "./src/*" + ] + }, + "target": "ES2017" }, - "include": ["next-env.d.ts", "**/*.ts", "**/*.tsx"], - "exclude": ["node_modules"] + "include": [ + "next-env.d.ts", + "**/*.ts", + "**/*.tsx" + ], + "exclude": [ + "node_modules" + ] }