generated from eea/volto-addon-template
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
e72fef3
commit 341bb5e
Showing
10 changed files
with
95 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,15 @@ | ||
import BasicSearchApp from './BasicSearchApp'; | ||
|
||
function LandingPageView(props) { | ||
const { appConfig, registry } = props; | ||
|
||
const InitialViewComponent = | ||
appConfig.initialView?.factory && | ||
registry.resolve[appConfig.initialView.factory].component; | ||
|
||
return <InitialViewComponent {...props} />; | ||
} | ||
|
||
export default function LandingPageApp(props) { | ||
return <div>Landing page</div>; | ||
return <BasicSearchApp {...props} searchViewComponent={LandingPageView} />; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
import { useViews, useSearchContext } from '@eeacms/search/lib/hocs'; | ||
|
||
import BasicSearchApp from './BasicSearchApp'; | ||
|
||
function SearchResultsView(props) { | ||
const { appConfig, registry } = props; | ||
|
||
const searchContext = useSearchContext(); | ||
const { results = [] } = searchContext; | ||
const { resultViews } = appConfig; | ||
const { activeViewId } = useViews(); | ||
|
||
const itemViewProps = appConfig[`${activeViewId}ViewParams`]; | ||
const listingViewDef = resultViews.filter((v) => v.id === activeViewId)[0]; | ||
|
||
const Item = registry.resolve[listingViewDef?.factories?.item]?.component; | ||
|
||
const NoResultsComponent = | ||
appConfig.noResultsView?.factory && | ||
registry.resolve[appConfig.noResultsView?.factory]?.component; | ||
|
||
const ContentBodyView = | ||
registry.resolve[appConfig['contentBodyComponent'] || 'DefaultContentView'] | ||
.component; | ||
|
||
return NoResultsComponent ? ( | ||
results.length ? ( | ||
<ContentBodyView {...props}> | ||
{results.map((result, i) => ( | ||
<Item key={`${i}-${result.id}`} result={result} {...itemViewProps} /> | ||
))} | ||
</ContentBodyView> | ||
) : ( | ||
<NoResultsComponent {...props} /> | ||
) | ||
) : ( | ||
<ContentBodyView {...props}> | ||
{results.map((result, i) => ( | ||
<Item key={`${i}-${result.id}`} result={result} {...itemViewProps} /> | ||
))} | ||
</ContentBodyView> | ||
); | ||
} | ||
|
||
export default function LandingPageApp(props) { | ||
return <BasicSearchApp {...props} searchViewComponent={SearchResultsView} />; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,8 @@ | ||
import React from 'react'; | ||
import { LandingPageApp } from '@eeacms/search'; | ||
|
||
function LandingPageView(props) { | ||
return null; | ||
return <LandingPageApp {...props} />; | ||
} | ||
|
||
export default LandingPageView; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
import { BodyClass } from '@plone/volto/helpers'; | ||
import { SearchResultsApp } from '@eeacms/search'; | ||
|
||
const overlayStyle = { | ||
position: 'absolute', | ||
width: '100%', | ||
height: '100%', | ||
zIndex: '100', | ||
}; | ||
|
||
export default function SearchResultsView(props) { | ||
const { appName, mode } = props; | ||
|
||
return ( | ||
<BodyClass className={`${appName}-view searchlib-page`}> | ||
<div className="searchlib-block"> | ||
{mode !== 'view' && ( | ||
<div className="overlay" style={overlayStyle}></div> | ||
)} | ||
<SearchResultsApp {...props} /> | ||
</div> | ||
</BodyClass> | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
export FullView from './FullView'; | ||
export LandingPageView from './LandingPageView'; | ||
export SearchInputView from './SearchInputView'; | ||
export SearchResultsView from './SearchResultsView'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters