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

Fix/tools resources #55

Merged
merged 4 commits into from
Nov 12, 2024
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
11 changes: 11 additions & 0 deletions src/components/Group.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,17 @@ const Group = ({
className={`p-4 grid grid-cols-10 grid-flow-row-dense gap-3 text-sm w-full`}
>
{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 (
<Block
key={`${data.title}-${block.title}-${i}`}
Expand Down
11 changes: 7 additions & 4 deletions src/components/cards/Node.tsx
Original file line number Diff line number Diff line change
@@ -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";
Expand All @@ -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, "");
Expand All @@ -30,11 +29,14 @@ export function NodeCard({
window?.open(data?.url, "_blank")?.focus();
};


return (
<div className="group cursor-pointer">
<Handle type="target" position={targetPosition} id={data.key} />
<div onClick={onClick} className={className}>
<div onClick={onClick} className={className}
>
<div className="relative">

{data.title && <p className="z-10">{data.title}</p>}
{data.authors && <p className="z-10">{data.authors}</p>}
{(access === "Institutional Access" ||
Expand All @@ -45,6 +47,7 @@ export function NodeCard({
</div>
)}
<div className="absolute hidden group-hover:block bg-white border p-4 mt-2 z-20">

{data.authors && (
<p>
<strong>Author(s)</strong>: {data.authors}
Expand Down
10 changes: 7 additions & 3 deletions src/data/basic-tools/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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[] = [
{
Expand Down
1 change: 1 addition & 0 deletions src/pages/case-studies-and-core-tools.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ const caseStudiesAndCoreTools = () => {
<HighlightMenuCard />
</div>
{groups?.map((data, index) => {
console.log("tesss")
return (
<Group
key={`case-studies-and-core-tools-${data.title}-${index}`}
Expand Down
1 change: 1 addition & 0 deletions src/pages/index.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import Group from "@/components/Group";
import resources from "@/data/resources/advanced-resources";
// import Grou



Expand Down
1 change: 1 addition & 0 deletions src/types/interfaces.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ export interface Entry {
tags: string;
PARSED_MANUAL_TAGS: ParsedManualTags;
PARSED_RELATES_TO?: string[];
isBasicTool?: Boolean
}

export type Entries = Entry[];
Expand Down
5 changes: 5 additions & 0 deletions src/utils/helpers.ts
Original file line number Diff line number Diff line change
@@ -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);
Expand Down Expand Up @@ -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
11 changes: 11 additions & 0 deletions src/utils/nodes.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
import { Entry } from "@/types/interfaces";
import classNames from "classnames";
import { isBasicTool } from "./helpers";

export function getColorByAccess(accessType: string) {
switch (accessType) {
Expand Down Expand Up @@ -35,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);
};
23 changes: 18 additions & 5 deletions tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
{
"compilerOptions": {
"lib": ["dom", "dom.iterable", "esnext"],
"lib": [
"dom",
"dom.iterable",
"esnext"
],
"allowJs": true,
"skipLibCheck": true,
"strict": true,
Expand All @@ -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"
]
}