Skip to content

Commit

Permalink
Occupations (#8)
Browse files Browse the repository at this point in the history
* support occupations

* update youtube links

* video toast

* move type

* remove unused

* Occupation map

* Fix video

Co-authored-by: Orlando Groppo <[email protected]>
  • Loading branch information
mshd and ogroppo authored Aug 3, 2021
1 parent 4b248d1 commit a94553e
Show file tree
Hide file tree
Showing 26 changed files with 1,505 additions and 116 deletions.
9 changes: 0 additions & 9 deletions .babelrc
Original file line number Diff line number Diff line change
Expand Up @@ -21,15 +21,6 @@
}
]
]
},
"test": {
"presets": ["env", "react"],
"plugins": [
[
"babel-plugin-styled-components",
{ "displayName": true, "fileName": true }
]
]
}
}
}
1 change: 1 addition & 0 deletions jest.config.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
module.exports = {
setupFilesAfterEnv: ["./test/jest.setup.ts"],
moduleDirectories: ["node_modules", "src"],
};
8 changes: 3 additions & 5 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,29 +15,28 @@
"dependencies": {
"@reduxjs/toolkit": "1.5.1",
"@types/axios": "0.14.0",
"@types/d3-hierarchy": "2.0.0",
"@types/luxon": "1.26.5",
"@types/wikidata-sdk": "6.1.0",
"axios": "0.21.1",
"babel-plugin-macros": "3.1.0",
"bootstrap": "4.6.0",
"clsx": "1.1.1",
"d3-hierarchy": "2.0.0",
"entitree-flex": "*",
"jsonp-promise": "0.1.2",
"local-storage": "2.0.0",
"luxon": "1.27.0",
"nanoid": "3.1.23",
"next": "10.1.3",
"next-redux-wrapper": "6.0.2",
"next": "10.1.3",
"ordinalize": "1.0.2",
"react": "17.0.2",
"react-bootstrap": "1.6.0",
"react-div-100vh": "0.6.0",
"react-dom": "17.0.2",
"react-draggable": "4.4.3",
"react-ga": "3.3.0",
"react-icons": "4.2.0",
"react-redux": "7.2.4",
"react": "17.0.2",
"react-share": "4.4.0",
"react-zoom-pan-pinch": "2.1.1",
"redux": "4.1.0",
Expand All @@ -56,7 +55,6 @@
"@types/styled-components": "5.1.9",
"@typescript-eslint/eslint-plugin": "4.22.0",
"@typescript-eslint/parser": "4.22.0",
"babel-jest": "26.6.3",
"babel-plugin-styled-components": "1.12.0",
"eslint": "7.25.0",
"eslint-config-airbnb": "18.2.1",
Expand Down
65 changes: 18 additions & 47 deletions src/components/EntityNodeCard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,6 @@ import {
NICKNAME_ID,
} from "constants/properties";
import { Button, OverlayTrigger, Tooltip } from "react-bootstrap";
import {
CHILD_BOOKMARK_SYMBOL,
PARENT_BOOKMARK_SYMBOL,
SIBLING_BOOKMARK_SYMBOL,
SPOUSE_BOOKMARK_SYMBOL,
} from "constants/bookmarks";
import { FaEye, FaFemale, FaMale, FaUser } from "react-icons/fa";
import {
FiChevronDown,
Expand All @@ -25,17 +19,13 @@ import {
import { GiBigDiamondRing, GiPerson } from "react-icons/gi";
import React, { memo, useEffect, useState } from "react";
import { RiGroupLine, RiParentLine } from "react-icons/ri";
import styled, { css, useTheme } from "styled-components";
import {
preloadChildren,
preloadParents,
preloadSiblings,
preloadSpouses,
toggleChildren,
toggleParents,
toggleSiblings,
toggleSpouses,
} from "actions/treeActions";
import styled, { css, useTheme } from "styled-components";

import { BsImage } from "react-icons/bs";
import DetailsModal from "modals/DetailsModal";
Expand All @@ -53,47 +43,19 @@ import getGeniProfile from "services/geniService";
import { isProperyId } from "helpers/isPropertyId";
import { isValidImage } from "helpers/isValidImage";
import { useAppSelector } from "store";
import useBookmarks from "hooks/useBookmarks";
import { useDispatch } from "react-redux";
import { useRouter } from "next/router";
import usePreload from "hooks/usePreload";
import useRootExpanded from "hooks/useRootExpanded";
import useVideoOverlay from "hooks/useVideoOverlay";

export default memo(({ node }: { node: EntityNode }) => {
const dispatch = useDispatch();

const router = useRouter();
useEffect(() => {
//preload connected nodes
if (!node.isRoot) {
dispatch(preloadChildren(node));
dispatch(preloadParents(node));
dispatch(preloadSiblings(node));
dispatch(preloadSpouses(node));
}

//Make sure root is expanded by default
if (node.isRoot) {
dispatch(toggleChildren(node, { followNavigation: false }));
dispatch(toggleParents(node, { followNavigation: false }));
dispatch(toggleSiblings(node, { followNavigation: false }));
dispatch(toggleSpouses(node, { followNavigation: false }));
}

//Expand bookmarks, applies only to non-root
const bookmark = router.query?.[node.treeId!];
if (bookmark && !node.isRoot) {
if (bookmark?.indexOf(CHILD_BOOKMARK_SYMBOL) > -1) {
dispatch(toggleChildren(node, { followNavigation: false }));
}
if (bookmark?.indexOf(PARENT_BOOKMARK_SYMBOL) > -1) {
dispatch(toggleParents(node, { followNavigation: false }));
}
if (bookmark?.indexOf(SIBLING_BOOKMARK_SYMBOL) > -1) {
dispatch(toggleSiblings(node, { followNavigation: false }));
}
if (bookmark?.indexOf(SPOUSE_BOOKMARK_SYMBOL) > -1) {
dispatch(toggleSpouses(node, { followNavigation: false }));
}
}
}, []);
usePreload(node);
useRootExpanded(node);
useBookmarks(node);
useVideoOverlay(node);

const [showModal, setShowModal] = useState(false);
const [lifeSpanInYears, setLifeSpanInYears] = useState(node.lifeSpanInYears);
Expand Down Expand Up @@ -395,6 +357,15 @@ export default memo(({ node }: { node: EntityNode }) => {
</span>
</>
)}
{settings.showExtraInfo &&
settings.extraInfo === "occupation" &&
node.occupations && (
<div className="occupation">
{node.occupations.map((entry) => (
<span title={entry.itemLabel}>{entry.emoji}</span>
))}
</div>
)}
</div>
<div className="dates">
{node.lifeSpan || lifeSpanInYears
Expand Down
Loading

0 comments on commit a94553e

Please sign in to comment.