forked from openedx/frontend-app-authoring
-
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.
feat: Add Recently Modified library section
- Loading branch information
1 parent
9cd428e
commit 9625b38
Showing
5 changed files
with
72 additions
and
30 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 |
---|---|---|
@@ -0,0 +1,29 @@ | ||
import React from 'react'; | ||
|
||
import { SearchContextProvider, useSearchContext } from '../search-manager'; | ||
import { SearchSortOption } from '../search-manager/data/api'; | ||
import LibraryComponents from './components/LibraryComponents'; | ||
import LibrarySection from './components/LibrarySection'; | ||
|
||
const RecentlyModified: React.FC<{ libraryId: string }> = ({ libraryId }) => { | ||
const { totalHits: componentCount } = useSearchContext(); | ||
|
||
return componentCount > 0 | ||
? ( | ||
<LibrarySection title="Recently Modified"> | ||
<LibraryComponents libraryId={libraryId} variant="preview" /> | ||
</LibrarySection> | ||
) | ||
: null; | ||
}; | ||
|
||
const LibraryRecentlyModified: React.FC<{ libraryId: string }> = ({ libraryId }) => ( | ||
<SearchContextProvider | ||
extraFilter={`context_key = "${libraryId}"`} | ||
overrideSearchSortOrder={SearchSortOption.RECENTLY_MODIFIED} | ||
> | ||
<RecentlyModified libraryId={libraryId} /> | ||
</SearchContextProvider> | ||
); | ||
|
||
export default LibraryRecentlyModified; |
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,15 @@ | ||
import React from 'react'; | ||
import { Card } from '@openedx/paragon'; | ||
|
||
const LibrarySection = ({ title, children } : { title: string, children: React.ReactNode }) => ( | ||
<Card> | ||
<Card.Header | ||
title={title} | ||
/> | ||
<Card.Section> | ||
{children} | ||
</Card.Section> | ||
</Card> | ||
); | ||
|
||
export default LibrarySection; |
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