From e006582d0c2aaf3ace37cd4a2e8537a3d398aaec Mon Sep 17 00:00:00 2001 From: Allen Jeffrey Date: Fri, 20 Oct 2023 10:53:48 +0800 Subject: [PATCH 1/8] add Home button --- components/Drawer.tsx | 17 +++++++++++++++-- components/Header.tsx | 1 + 2 files changed, 16 insertions(+), 2 deletions(-) diff --git a/components/Drawer.tsx b/components/Drawer.tsx index 42ff31ca..6a7b3809 100644 --- a/components/Drawer.tsx +++ b/components/Drawer.tsx @@ -23,7 +23,8 @@ interface Props { } const URL_APPLY = "/apply"; -const URL_HOME = "https://advisory.sg/"; +const URL_HOME = "/"; +const URL_MAIN = "https://advisory.sg/"; const URL_FAQ = "/faq"; const URL_MENTORS = "/mentors/0"; @@ -39,6 +40,15 @@ const ResponsiveDrawer = (props: Props) => { return (
+ + + + + { - + Advisory @@ -91,6 +101,9 @@ const ResponsiveDrawer = (props: Props) => { style={{ justifyContent: "flex-end" }} sx={{ display: { xs: "none", sm: "flex", md: "flex" } }} > + diff --git a/components/Header.tsx b/components/Header.tsx index b9274818..1721383d 100644 --- a/components/Header.tsx +++ b/components/Header.tsx @@ -2,6 +2,7 @@ import Box from "@mui/material/Box"; import ResponsiveDrawer from "./Drawer"; import "../styles/Header.css"; +import React from "react"; const Header = () => (
From a885739a0921aaec13ecebfb872d14528dc4b756 Mon Sep 17 00:00:00 2001 From: Allen Jeffrey Date: Fri, 20 Oct 2023 16:22:13 +0800 Subject: [PATCH 2/8] change search highlighting --- components/ResultView.tsx | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/components/ResultView.tsx b/components/ResultView.tsx index a1897f04..17445f1f 100644 --- a/components/ResultView.tsx +++ b/components/ResultView.tsx @@ -61,8 +61,13 @@ const fillHighlights = (snippet: string | null, full: string): string => { return full; } - const snippetRaw = htmlToText(snippet, { wordwrap: false }); - return full.replace(snippetRaw, snippet); + // Replace any existing tags from the snippet to tag + const boldSnippet = snippet.replace( + /(.*?)<\/em>/g, + "$1" + ); + const snippetRaw = htmlToText(boldSnippet, { wordwrap: false }); + return full.replace(snippetRaw, boldSnippet); }; const COLORS = [ From e81aeb538e57d0bfe0933c8fb13cb9bc8cb6d390 Mon Sep 17 00:00:00 2001 From: "M. Allen Jeffrey" Date: Sat, 21 Oct 2023 15:36:16 +0800 Subject: [PATCH 3/8] improve highlighting of search result --- components/ResultView.tsx | 13 +++++------ components/ResultViewList.tsx | 42 ++++++++++++++++++++++++++++++----- 2 files changed, 42 insertions(+), 13 deletions(-) diff --git a/components/ResultView.tsx b/components/ResultView.tsx index 17445f1f..b563b344 100644 --- a/components/ResultView.tsx +++ b/components/ResultView.tsx @@ -61,13 +61,12 @@ const fillHighlights = (snippet: string | null, full: string): string => { return full; } - // Replace any existing tags from the snippet to tag - const boldSnippet = snippet.replace( - /(.*?)<\/em>/g, - "$1" + const snippetRaw = htmlToText(snippet, { wordwrap: false }); + const styledSnippet = snippet.replace( + //g, + '' ); - const snippetRaw = htmlToText(boldSnippet, { wordwrap: false }); - return full.replace(snippetRaw, boldSnippet); + return full.replace(snippetRaw, styledSnippet); }; const COLORS = [ @@ -113,7 +112,7 @@ const ResultView = ({ result }: { result: SearchResult }) => { } = result; const displayName = - name && name.raw ? fillHighlights(name.snippet, name.raw) : null; + name && name.raw ? fillHighlights(name.snippet, name.raw.bold()) : null; const thumbnailImageUrl = thumbnail_image_url && thumbnail_image_url.raw diff --git a/components/ResultViewList.tsx b/components/ResultViewList.tsx index 011fc3ba..d6d5d044 100644 --- a/components/ResultViewList.tsx +++ b/components/ResultViewList.tsx @@ -31,7 +31,12 @@ const ResultViewList = ({ {displayName && ( ]*>/g, + '' + ), + }} /> )}
@@ -56,7 +61,12 @@ const ResultViewList = ({ ]*>/g, + '' + ), + }} /> )} {displayRole && displayOrganisation && ( @@ -69,7 +79,12 @@ const ResultViewList = ({ ]*>/g, + '' + ), + }} /> )} @@ -80,7 +95,12 @@ const ResultViewList = ({ ]*>/g, + '' + ), + }} /> )} @@ -90,7 +110,12 @@ const ResultViewList = ({ ]*>/g, + '' + ), + }} /> )} @@ -100,7 +125,12 @@ const ResultViewList = ({ ]*>/g, + '' + ), + }} /> )} From a2a24b3c9112d51bc45897b0558dd29e64f12706 Mon Sep 17 00:00:00 2001 From: "M. Allen Jeffrey" Date: Sat, 28 Oct 2023 11:10:44 +0800 Subject: [PATCH 4/8] add padding to navbar --- components/Drawer.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/components/Drawer.tsx b/components/Drawer.tsx index 6a7b3809..fd89284d 100644 --- a/components/Drawer.tsx +++ b/components/Drawer.tsx @@ -89,7 +89,7 @@ const ResponsiveDrawer = (props: Props) => { }; return ( - + From 0a07934fef10690b1c34e71b7ad0683fe3a764a0 Mon Sep 17 00:00:00 2001 From: "M. Allen Jeffrey" Date: Sat, 28 Oct 2023 11:14:24 +0800 Subject: [PATCH 5/8] Revert "add padding to navbar" This reverts commit a2a24b3c9112d51bc45897b0558dd29e64f12706. --- components/Drawer.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/components/Drawer.tsx b/components/Drawer.tsx index fd89284d..6a7b3809 100644 --- a/components/Drawer.tsx +++ b/components/Drawer.tsx @@ -89,7 +89,7 @@ const ResponsiveDrawer = (props: Props) => { }; return ( - + From 3d84f5fe6f69c4a5875b95337b5942c972a2dc6c Mon Sep 17 00:00:00 2001 From: "M. Allen Jeffrey" Date: Wed, 8 Nov 2023 16:23:40 +0800 Subject: [PATCH 6/8] lazy loading the mentors grid --- components/ResultView.tsx | 10 +++++++--- components/ResultViewGrid.tsx | 11 ++++++++--- 2 files changed, 15 insertions(+), 6 deletions(-) diff --git a/components/ResultView.tsx b/components/ResultView.tsx index b563b344..6bed565a 100644 --- a/components/ResultView.tsx +++ b/components/ResultView.tsx @@ -1,4 +1,4 @@ -import React from "react"; +import React, { lazy, Suspense } from "react"; import { red, @@ -17,7 +17,7 @@ import { import { SearchResult } from "@elastic/search-ui"; import { htmlToText } from "html-to-text"; -import ResultViewGrid from "./ResultViewGrid"; +const LazyResultViewGrid = lazy(() => import("./ResultViewGrid")); import ResultViewList from "./ResultViewList"; // Performs intelligent snippet truncation by removing leading/trailing periods and @@ -162,7 +162,11 @@ const ResultView = ({ result }: { result: SearchResult }) => { thumbnailImageUrl, }; - return ; + return ( + + + + ); }; export default ResultView; diff --git a/components/ResultViewGrid.tsx b/components/ResultViewGrid.tsx index 65247af5..f726c58d 100644 --- a/components/ResultViewGrid.tsx +++ b/components/ResultViewGrid.tsx @@ -1,8 +1,8 @@ -import React, { useState, useEffect } from "react"; +import React, { useState, useEffect, lazy, Suspense } from "react"; import { Modal, Button, CardActionArea } from "@mui/material"; import type { DisplayResult } from "./ResultView"; -import ResultViewList from "./ResultViewList"; +const LazyResultViewList = lazy(() => import("./ResultViewList")); import Card from "@mui/material/Card"; import CardActions from "@mui/material/CardActions"; @@ -126,7 +126,12 @@ const ResultViewGrid = ({ overflow: "auto", }} > - + + + ); From 25d4ea62eeea17fe8a76ee436be404f6b71a7b26 Mon Sep 17 00:00:00 2001 From: "M. Allen Jeffrey" Date: Wed, 8 Nov 2023 16:37:01 +0800 Subject: [PATCH 7/8] fix lazy loading mentors grid --- components/Drawer.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/components/Drawer.tsx b/components/Drawer.tsx index 6a7b3809..fd89284d 100644 --- a/components/Drawer.tsx +++ b/components/Drawer.tsx @@ -89,7 +89,7 @@ const ResponsiveDrawer = (props: Props) => { }; return ( - + From 503d7235554c669ab0295f730d1de748ce9f69c2 Mon Sep 17 00:00:00 2001 From: "M. Allen Jeffrey" Date: Wed, 8 Nov 2023 19:14:49 +0800 Subject: [PATCH 8/8] remove overlapping commits for [MPT-45] --- components/Drawer.tsx | 2 +- components/ResultView.tsx | 8 ++----- components/ResultViewList.tsx | 42 +++++------------------------------ 3 files changed, 9 insertions(+), 43 deletions(-) diff --git a/components/Drawer.tsx b/components/Drawer.tsx index fd89284d..6a7b3809 100644 --- a/components/Drawer.tsx +++ b/components/Drawer.tsx @@ -89,7 +89,7 @@ const ResponsiveDrawer = (props: Props) => { }; return ( - + diff --git a/components/ResultView.tsx b/components/ResultView.tsx index 6bed565a..fc90f0e2 100644 --- a/components/ResultView.tsx +++ b/components/ResultView.tsx @@ -62,11 +62,7 @@ const fillHighlights = (snippet: string | null, full: string): string => { } const snippetRaw = htmlToText(snippet, { wordwrap: false }); - const styledSnippet = snippet.replace( - //g, - '' - ); - return full.replace(snippetRaw, styledSnippet); + return full.replace(snippetRaw, snippet); }; const COLORS = [ @@ -112,7 +108,7 @@ const ResultView = ({ result }: { result: SearchResult }) => { } = result; const displayName = - name && name.raw ? fillHighlights(name.snippet, name.raw.bold()) : null; + name && name.raw ? fillHighlights(name.snippet, name.raw) : null; const thumbnailImageUrl = thumbnail_image_url && thumbnail_image_url.raw diff --git a/components/ResultViewList.tsx b/components/ResultViewList.tsx index d6d5d044..011fc3ba 100644 --- a/components/ResultViewList.tsx +++ b/components/ResultViewList.tsx @@ -31,12 +31,7 @@ const ResultViewList = ({ {displayName && ( ]*>/g, - '' - ), - }} + dangerouslySetInnerHTML={{ __html: displayName }} /> )}
@@ -61,12 +56,7 @@ const ResultViewList = ({ ]*>/g, - '' - ), - }} + dangerouslySetInnerHTML={{ __html: displayRole }} /> )} {displayRole && displayOrganisation && ( @@ -79,12 +69,7 @@ const ResultViewList = ({ ]*>/g, - '' - ), - }} + dangerouslySetInnerHTML={{ __html: displayOrganisation }} /> )} @@ -95,12 +80,7 @@ const ResultViewList = ({ ]*>/g, - '' - ), - }} + dangerouslySetInnerHTML={{ __html: displayCourseOfStudy }} /> )} @@ -110,12 +90,7 @@ const ResultViewList = ({ ]*>/g, - '' - ), - }} + dangerouslySetInnerHTML={{ __html: displaySchool }} /> )} @@ -125,12 +100,7 @@ const ResultViewList = ({ ]*>/g, - '' - ), - }} + dangerouslySetInnerHTML={{ __html: displayFullBio }} /> )}