Skip to content

Commit 3b7dba4

Browse files
authored
Merge pull request #1593 from kianamcc/PORTALS-3376
PORTALS-3376: [CCKP Homepage_V1] New Portal home page search component
2 parents 37c1cdd + 9c97d26 commit 3b7dba4

File tree

5 files changed

+239
-5
lines changed

5 files changed

+239
-5
lines changed

apps/portals/cancercomplexity/src/config/routesConfig.tsx

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,9 @@ import {
2323
onPointClick,
2424
} from './synapseConfigs/onPointClick'
2525
import { searchPageChildRoutes } from 'src/pages/CCKPSearchPage'
26+
import CancerComplexityHeader from '@sage-bionetworks/synapse-portal-framework/components/cancercomplexity/CancerComplexityHeader'
27+
28+
const showHeaderWithSearch = false
2629

2730
const routes: RouteObject[] = [
2831
{
@@ -34,7 +37,7 @@ const routes: RouteObject[] = [
3437
index: true,
3538
element: (
3639
<>
37-
<Header />
40+
{showHeaderWithSearch ? <CancerComplexityHeader /> : <Header />}
3841
<div className={'home-bg-dark'}>
3942
<SectionLayout
4043
title={'Portal Goals'}
Lines changed: 123 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,123 @@
1+
import {
2+
Box,
3+
Stack,
4+
SxProps,
5+
Typography,
6+
Button,
7+
lighten,
8+
useTheme,
9+
} from '@mui/material'
10+
import PortalFullTextSearchField from './PortalSearch/PortalFullTextSearchField'
11+
import { spreadSx } from 'synapse-react-client/theme/spreadSx'
12+
import { useSearchParams } from 'react-router'
13+
14+
type HeaderSearchBoxProps = {
15+
searchPlaceholder?: string
16+
searchExampleTerms?: string[]
17+
path?: string
18+
sx?: SxProps
19+
}
20+
21+
const HeaderSearchBox = ({
22+
searchPlaceholder,
23+
searchExampleTerms,
24+
path,
25+
sx,
26+
}: HeaderSearchBoxProps) => {
27+
const [, setSearchParams] = useSearchParams()
28+
const theme = useTheme()
29+
30+
const handleTermClick = (term: string) => {
31+
const trimmedTerm = term.trim()
32+
setSearchParams({ FTS_SEARCH_TERM: trimmedTerm })
33+
if (path) {
34+
window.location.pathname = `${path}`
35+
}
36+
}
37+
38+
return (
39+
<Box
40+
sx={spreadSx(sx, {
41+
padding: { xs: '40px', lg: '40px 80px 40px 0' },
42+
width: '100%',
43+
})}
44+
>
45+
<Stack
46+
sx={theme => ({
47+
padding: '40px',
48+
gap: '30px',
49+
borderRadius: '6px',
50+
backdropFilter: 'blur(15px)',
51+
[theme.breakpoints.up('lg')]: {
52+
minWidth: '660px',
53+
},
54+
})}
55+
>
56+
<Box
57+
sx={{
58+
display: 'flex',
59+
gap: '20px',
60+
alignItems: 'center',
61+
height: '48px',
62+
}}
63+
>
64+
<PortalFullTextSearchField
65+
placeholder={searchPlaceholder}
66+
path={path}
67+
sx={{
68+
margin: 0,
69+
height: '100%',
70+
borderRadius: '3px',
71+
'.MuiInputBase-root': {
72+
height: '100%',
73+
borderRadius: '3px',
74+
},
75+
}}
76+
/>
77+
</Box>
78+
<Stack sx={{ gap: '8px' }}>
79+
<Typography sx={{ color: 'grey.900', fontWeight: 700 }}>
80+
Example searches
81+
</Typography>
82+
<Box
83+
sx={{
84+
display: 'flex',
85+
flexWrap: 'wrap',
86+
gap: '8px 6px;',
87+
}}
88+
>
89+
{searchExampleTerms &&
90+
searchExampleTerms.map(term => (
91+
<Button
92+
variant="contained"
93+
onClick={() => handleTermClick(term)}
94+
sx={{
95+
borderRadius: '30px',
96+
border: '1px solid',
97+
borderColor: lighten(theme.palette.primary.main, 0.9),
98+
padding: '7px 9px',
99+
textDecoration: 'none !important',
100+
backgroundColor: lighten(theme.palette.primary.main, 0.8),
101+
'&:hover': {
102+
background: lighten(theme.palette.primary.main, 0.7),
103+
},
104+
}}
105+
>
106+
<Typography
107+
sx={{
108+
color: 'grey.800',
109+
fontSize: '16px',
110+
}}
111+
>
112+
{term}
113+
</Typography>
114+
</Button>
115+
))}
116+
</Box>
117+
</Stack>
118+
</Stack>
119+
</Box>
120+
)
121+
}
122+
123+
export default HeaderSearchBox

apps/synapse-portal-framework/src/components/PortalSearch/PortalFullTextSearchField.tsx

Lines changed: 23 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,35 @@
11
import { useState } from 'react'
22
import SearchIcon from '@mui/icons-material/Search'
3-
import { InputAdornment, TextField, TextFieldProps } from '@mui/material'
3+
import {
4+
InputAdornment,
5+
TextField,
6+
TextFieldProps,
7+
useTheme,
8+
} from '@mui/material'
49
import { useSearchParams } from 'react-router'
510
import { FTS_SEARCH_TERM } from 'synapse-react-client/utils/functions/SqlFunctions'
611

7-
export function PortalFullTextSearchField(props: TextFieldProps) {
12+
type PortalFullTextSearchFieldProps = TextFieldProps & {
13+
placeholder?: string
14+
path?: string
15+
}
16+
17+
export function PortalFullTextSearchField({
18+
placeholder = 'Search by keyword',
19+
path,
20+
...props
21+
}: PortalFullTextSearchFieldProps) {
822
const [searchParams, setSearchParams] = useSearchParams()
923
const [searchInput, setSearchInput] = useState(
1024
searchParams.get(FTS_SEARCH_TERM),
1125
)
26+
const theme = useTheme()
1227

1328
return (
1429
<TextField
1530
{...props}
1631
size={'small'}
17-
placeholder="Search by keyword"
32+
placeholder={placeholder}
1833
value={searchInput}
1934
onChange={event => {
2035
setSearchInput(event.target.value)
@@ -23,12 +38,15 @@ export function PortalFullTextSearchField(props: TextFieldProps) {
2338
if (event.key === 'Enter') {
2439
const trimmedInput = event.target.value.trim()
2540
setSearchParams({ FTS_SEARCH_TERM: trimmedInput })
41+
if (path) {
42+
window.location.pathname = `${path}`
43+
}
2644
}
2745
}}
2846
InputProps={{
2947
startAdornment: (
3048
<InputAdornment position="start">
31-
<SearchIcon />
49+
<SearchIcon sx={{ color: theme.palette.primary.main }} />
3250
</InputAdornment>
3351
),
3452
}}
@@ -41,6 +59,7 @@ export function PortalFullTextSearchField(props: TextFieldProps) {
4159
backgroundColor: 'white',
4260
},
4361
mb: '20px',
62+
...props.sx,
4463
}}
4564
/>
4665
)
Lines changed: 87 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,87 @@
1+
import { Box, Typography } from '@mui/material'
2+
import HeaderSearchBox from '../HeaderSearchBox'
3+
4+
const CancerComplexityHeader = () => {
5+
const searchPlaceholder = 'Search for cancer related data and resources'
6+
const searchExampleTerms = [
7+
'Justo Turpis',
8+
'Nostra',
9+
'Fames',
10+
'Rhoncus',
11+
'Pharetra enim',
12+
'Aliquet',
13+
'Ridiculus',
14+
'Penatibus',
15+
'Accumsan quisque',
16+
'Patient Advocacy',
17+
]
18+
const content = (
19+
<>
20+
<Box
21+
sx={{
22+
margin: 0,
23+
color: '#FFFF',
24+
}}
25+
>
26+
<Typography
27+
variant="headline1"
28+
sx={{
29+
fontSize: { xs: '42px', md: '48px' },
30+
fontWeight: 'bold',
31+
marginBottom: '15px',
32+
lineHeight: '54px',
33+
}}
34+
>
35+
Welcome to the Cancer Complexity Knowledge Portal
36+
</Typography>
37+
<Typography
38+
variant="body1"
39+
sx={{ fontSize: '18px', lineHeight: '144%' }}
40+
>
41+
The NCI Division of Cancer Biology supports multiple research programs
42+
composed of interdisciplinary communities of scientists who aim to
43+
integrate approaches, data, and tools to address important questions
44+
in basic and translational cancer research. Discover and download
45+
datasets, publications, and other resources generated by these
46+
programs.
47+
</Typography>
48+
</Box>
49+
</>
50+
)
51+
return (
52+
<header id="header">
53+
<Box
54+
sx={{
55+
display: 'flex',
56+
flexDirection: { xs: 'column', lg: 'row' },
57+
justifyContent: 'center',
58+
alignItems: 'center',
59+
padding: '20px 0',
60+
}}
61+
>
62+
<Box
63+
sx={{
64+
margin: 0,
65+
flex: 1,
66+
padding: { xs: '40px', lg: '40px 80px' },
67+
}}
68+
>
69+
{content}
70+
</Box>
71+
<HeaderSearchBox
72+
searchExampleTerms={searchExampleTerms}
73+
searchPlaceholder={searchPlaceholder}
74+
path="/Search"
75+
sx={{
76+
flex: 1,
77+
'& > :first-child': {
78+
background: 'rgba(184, 204, 226, 0.60)',
79+
},
80+
}}
81+
/>
82+
</Box>
83+
</header>
84+
)
85+
}
86+
87+
export default CancerComplexityHeader

apps/synapse-portal-framework/src/components/index.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ import ARKWelcomePage from './arkportal/ARKWelcomePage'
2222

2323
import ExploreWrapper from './Explore/ExploreWrapper'
2424
import GenieHomePageHeader from './genie/GenieHomePageHeader'
25+
import CancerComplexityHeader from './cancercomplexity/CancerComplexityHeader'
2526
import Header from './Header'
2627
import Image from './Image'
2728
import NFBrowseToolsPage from './nf/NFBrowseToolsPage'
@@ -56,6 +57,7 @@ const PortalComponents = {
5657
ELSupportedByNIH,
5758
ARKWelcomePage,
5859
GenieHomePageHeader,
60+
CancerComplexityHeader,
5961
TabbedSynapseObjects,
6062
Header,
6163
ChallengeParticipantGoogleMap,

0 commit comments

Comments
 (0)