File tree Expand file tree Collapse file tree 6 files changed +74
-4
lines changed
containers/CourseCard/components/CourseCardBanners
plugin-slots/CourseBannerSlot Expand file tree Collapse file tree 6 files changed +74
-4
lines changed Original file line number Diff line number Diff line change @@ -8,7 +8,7 @@ exports[`CourseCardBanners render with isEnrolled false 1`] = `
88 <RelatedProgramsBanner
99 cardId = " test-card-id"
1010 />
11- <CourseBanner
11+ <CourseBannerSlot
1212 cardId = " test-card-id"
1313 />
1414 <EntitlementBanner
@@ -25,7 +25,7 @@ exports[`CourseCardBanners renders default CourseCardBanners 1`] = `
2525 <RelatedProgramsBanner
2626 cardId = " test-card-id"
2727 />
28- <CourseBanner
28+ <CourseBannerSlot
2929 cardId = " test-card-id"
3030 />
3131 <EntitlementBanner
Original file line number Diff line number Diff line change @@ -3,7 +3,7 @@ import PropTypes from 'prop-types';
33
44import { reduxHooks } from 'hooks' ;
55
6- import CourseBanner from './CourseBanner ' ;
6+ import CourseBannerSlot from 'plugin-slots/CourseBannerSlot ' ;
77import CertificateBanner from './CertificateBanner' ;
88import CreditBanner from './CreditBanner' ;
99import EntitlementBanner from './EntitlementBanner' ;
@@ -14,7 +14,7 @@ export const CourseCardBanners = ({ cardId }) => {
1414 return (
1515 < div className = "course-card-banners" data-testid = "CourseCardBanners" >
1616 < RelatedProgramsBanner cardId = { cardId } />
17- < CourseBanner cardId = { cardId } />
17+ < CourseBannerSlot cardId = { cardId } />
1818 < EntitlementBanner cardId = { cardId } />
1919 { isEnrolled && < CertificateBanner cardId = { cardId } /> }
2020 { isEnrolled && < CreditBanner cardId = { cardId } /> }
Original file line number Diff line number Diff line change 1+ # Course Card Action Slot
2+
3+ ### Slot ID: ` course_banner_slot `
4+ ### Props:
5+ * ` cardId `
6+
7+ ## Description
8+
9+ This slot is used for replacing or adding content for the ` CourseBanner ` component. This banner is rendered as a child of the ` CourseCard ` .
10+
11+ The default CourseBanner looks like this when audit access has expired for the course:
12+ ![ Screenshot of the default CourseBanner when audit access has expired] ( ./images/course_banner_slot_default.png )
13+
14+ ## Example
15+
16+ The following ` env.config.jsx ` will render a custom implemenation of a CourseBanner under every ` CourseCard ` .
17+
18+ ![ Screenshot of custom banner added under CourseCard] ( ./images/course_banner_slot_default.png )
19+
20+ ``` js
21+ import { DIRECT_PLUGIN , PLUGIN_OPERATIONS } from ' @openedx/frontend-plugin-framework' ;
22+
23+ const config = {
24+ pluginSlots: {
25+ course_banner_slot: {
26+ keepDefault: false ,
27+ plugins: [
28+ {
29+ op: PLUGIN_OPERATIONS .Insert ,
30+ widget: {
31+ id: ' custom_course_banner' ,
32+ type: DIRECT_PLUGIN ,
33+ priority: 60 ,
34+ RenderWidget : ({ cardId }) => (
35+ < Alert variant= " info" className= " mb-0" >
36+ Course banner for course with {cardId}
37+ < / Alert>
38+ ),
39+ },
40+ },
41+ ],
42+ },
43+ },
44+ }
45+
46+ export default config ;
47+ ```
Original file line number Diff line number Diff line change 1+ import React from 'react' ;
2+ import PropTypes from 'prop-types' ;
3+ import { PluginSlot } from '@openedx/frontend-plugin-framework' ;
4+ import CourseBanner from 'containers/CourseCard/components/CourseCardBanners/CourseBanner' ;
5+
6+ const CourseBannerSlot = ( { cardId } ) => (
7+ < PluginSlot
8+ id = "course_banner_slot"
9+ pluginProps = { {
10+ cardId,
11+ } }
12+ >
13+ < CourseBanner
14+ cardId = { cardId }
15+ />
16+ </ PluginSlot >
17+ ) ;
18+
19+ CourseBannerSlot . propTypes = {
20+ cardId : PropTypes . string . isRequired ,
21+ } ;
22+
23+ export default CourseBannerSlot ;
You can’t perform that action at this time.
0 commit comments