-
Notifications
You must be signed in to change notification settings - Fork 89
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
* feat: Add Recently Modified library section * feat: Add "View All" to library sections The "View All" action appears on sections that pass in a view all action and contain content that exceeds the defined preview limit, which defaults to 4. * feat: Use intl library section titles * test: Update tests
- Loading branch information
1 parent
6924591
commit f1389e3
Showing
8 changed files
with
226 additions
and
49 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
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,35 @@ | ||
import React from 'react'; | ||
import { useIntl } from '@edx/frontend-platform/i18n'; | ||
|
||
import { SearchContextProvider, useSearchContext } from '../search-manager'; | ||
import { SearchSortOption } from '../search-manager/data/api'; | ||
import LibraryComponents from './components/LibraryComponents'; | ||
import LibrarySection from './components/LibrarySection'; | ||
import messages from './messages'; | ||
|
||
const RecentlyModified: React.FC<{ libraryId: string }> = ({ libraryId }) => { | ||
const intl = useIntl(); | ||
const { totalHits: componentCount } = useSearchContext(); | ||
|
||
return componentCount > 0 | ||
? ( | ||
<LibrarySection | ||
title={intl.formatMessage(messages.recentlyModifiedTitle)} | ||
contentCount={componentCount} | ||
> | ||
<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
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,39 @@ | ||
/* eslint-disable react/require-default-props */ | ||
import React from 'react'; | ||
import { Card, ActionRow, Button } from '@openedx/paragon'; | ||
|
||
export const LIBRARY_SECTION_PREVIEW_LIMIT = 4; | ||
|
||
const LibrarySection: React.FC<{ | ||
title: string, | ||
viewAllAction?: () => void, | ||
contentCount: number, | ||
previewLimit?: number, | ||
children: React.ReactNode, | ||
}> = ({ | ||
title, | ||
viewAllAction, | ||
contentCount, | ||
previewLimit = LIBRARY_SECTION_PREVIEW_LIMIT, | ||
children, | ||
}) => ( | ||
<Card> | ||
<Card.Header | ||
title={title} | ||
actions={ | ||
viewAllAction | ||
&& contentCount > previewLimit | ||
&& ( | ||
<ActionRow> | ||
<Button variant="tertiary" onClick={viewAllAction}>View All</Button> | ||
</ActionRow> | ||
) | ||
} | ||
/> | ||
<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
Oops, something went wrong.