feat: course banner slot (#559)
This commit is contained in:
@@ -8,7 +8,7 @@ exports[`CourseCardBanners render with isEnrolled false 1`] = `
|
||||
<RelatedProgramsBanner
|
||||
cardId="test-card-id"
|
||||
/>
|
||||
<CourseBanner
|
||||
<CourseBannerSlot
|
||||
cardId="test-card-id"
|
||||
/>
|
||||
<EntitlementBanner
|
||||
@@ -25,7 +25,7 @@ exports[`CourseCardBanners renders default CourseCardBanners 1`] = `
|
||||
<RelatedProgramsBanner
|
||||
cardId="test-card-id"
|
||||
/>
|
||||
<CourseBanner
|
||||
<CourseBannerSlot
|
||||
cardId="test-card-id"
|
||||
/>
|
||||
<EntitlementBanner
|
||||
|
||||
@@ -3,7 +3,7 @@ import PropTypes from 'prop-types';
|
||||
|
||||
import { reduxHooks } from 'hooks';
|
||||
|
||||
import CourseBanner from './CourseBanner';
|
||||
import CourseBannerSlot from 'plugin-slots/CourseBannerSlot';
|
||||
import CertificateBanner from './CertificateBanner';
|
||||
import CreditBanner from './CreditBanner';
|
||||
import EntitlementBanner from './EntitlementBanner';
|
||||
@@ -14,7 +14,7 @@ export const CourseCardBanners = ({ cardId }) => {
|
||||
return (
|
||||
<div className="course-card-banners" data-testid="CourseCardBanners">
|
||||
<RelatedProgramsBanner cardId={cardId} />
|
||||
<CourseBanner cardId={cardId} />
|
||||
<CourseBannerSlot cardId={cardId} />
|
||||
<EntitlementBanner cardId={cardId} />
|
||||
{isEnrolled && <CertificateBanner cardId={cardId} />}
|
||||
{isEnrolled && <CreditBanner cardId={cardId} />}
|
||||
|
||||
47
src/plugin-slots/CourseBannerSlot/README.md
Normal file
47
src/plugin-slots/CourseBannerSlot/README.md
Normal file
@@ -0,0 +1,47 @@
|
||||
# Course Card Action Slot
|
||||
|
||||
### Slot ID: `course_banner_slot`
|
||||
### Props:
|
||||
* `cardId`
|
||||
|
||||
## Description
|
||||
|
||||
This slot is used for replacing or adding content for the `CourseBanner` component. This banner is rendered as a child of the `CourseCard`.
|
||||
|
||||
The default CourseBanner looks like this when audit access has expired for the course:
|
||||

|
||||
|
||||
## Example
|
||||
|
||||
The following `env.config.jsx` will render a custom implemenation of a CourseBanner under every `CourseCard`.
|
||||
|
||||

|
||||
|
||||
```js
|
||||
import { DIRECT_PLUGIN, PLUGIN_OPERATIONS } from '@openedx/frontend-plugin-framework';
|
||||
|
||||
const config = {
|
||||
pluginSlots: {
|
||||
course_banner_slot: {
|
||||
keepDefault: false,
|
||||
plugins: [
|
||||
{
|
||||
op: PLUGIN_OPERATIONS.Insert,
|
||||
widget: {
|
||||
id: 'custom_course_banner',
|
||||
type: DIRECT_PLUGIN,
|
||||
priority: 60,
|
||||
RenderWidget: ({ cardId }) => (
|
||||
<Alert variant="info" className="mb-0">
|
||||
Course banner for course with {cardId}
|
||||
</Alert>
|
||||
),
|
||||
},
|
||||
},
|
||||
],
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
export default config;
|
||||
```
|
||||
Binary file not shown.
|
After Width: | Height: | Size: 90 KiB |
Binary file not shown.
|
After Width: | Height: | Size: 87 KiB |
23
src/plugin-slots/CourseBannerSlot/index.jsx
Normal file
23
src/plugin-slots/CourseBannerSlot/index.jsx
Normal file
@@ -0,0 +1,23 @@
|
||||
import React from 'react';
|
||||
import PropTypes from 'prop-types';
|
||||
import { PluginSlot } from '@openedx/frontend-plugin-framework';
|
||||
import CourseBanner from 'containers/CourseCard/components/CourseCardBanners/CourseBanner';
|
||||
|
||||
const CourseBannerSlot = ({ cardId }) => (
|
||||
<PluginSlot
|
||||
id="course_banner_slot"
|
||||
pluginProps={{
|
||||
cardId,
|
||||
}}
|
||||
>
|
||||
<CourseBanner
|
||||
cardId={cardId}
|
||||
/>
|
||||
</PluginSlot>
|
||||
);
|
||||
|
||||
CourseBannerSlot.propTypes = {
|
||||
cardId: PropTypes.string.isRequired,
|
||||
};
|
||||
|
||||
export default CourseBannerSlot;
|
||||
Reference in New Issue
Block a user