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`] = `
8
8
<RelatedProgramsBanner
9
9
cardId = " test-card-id"
10
10
/>
11
- <CourseBanner
11
+ <CourseBannerSlot
12
12
cardId = " test-card-id"
13
13
/>
14
14
<EntitlementBanner
@@ -25,7 +25,7 @@ exports[`CourseCardBanners renders default CourseCardBanners 1`] = `
25
25
<RelatedProgramsBanner
26
26
cardId = " test-card-id"
27
27
/>
28
- <CourseBanner
28
+ <CourseBannerSlot
29
29
cardId = " test-card-id"
30
30
/>
31
31
<EntitlementBanner
Original file line number Diff line number Diff line change @@ -3,7 +3,7 @@ import PropTypes from 'prop-types';
3
3
4
4
import { reduxHooks } from 'hooks' ;
5
5
6
- import CourseBanner from './CourseBanner ' ;
6
+ import CourseBannerSlot from 'plugin-slots/CourseBannerSlot ' ;
7
7
import CertificateBanner from './CertificateBanner' ;
8
8
import CreditBanner from './CreditBanner' ;
9
9
import EntitlementBanner from './EntitlementBanner' ;
@@ -14,7 +14,7 @@ export const CourseCardBanners = ({ cardId }) => {
14
14
return (
15
15
< div className = "course-card-banners" data-testid = "CourseCardBanners" >
16
16
< RelatedProgramsBanner cardId = { cardId } />
17
- < CourseBanner cardId = { cardId } />
17
+ < CourseBannerSlot cardId = { cardId } />
18
18
< EntitlementBanner cardId = { cardId } />
19
19
{ isEnrolled && < CertificateBanner cardId = { cardId } /> }
20
20
{ 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