Skip to content

Commit

Permalink
Fix/tools resources (#55)
Browse files Browse the repository at this point in the history
* sprting

* fix: basic tools colouring
  • Loading branch information
Delyc authored Nov 12, 2024
1 parent a52708f commit 1c63288
Show file tree
Hide file tree
Showing 8 changed files with 51 additions and 12 deletions.
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"
]
}

0 comments on commit 1c63288

Please sign in to comment.