Skip to content

Commit

Permalink
feat: update UnitTitleSlot to wrap unit title
Browse files Browse the repository at this point in the history
  • Loading branch information
brian-smith-tcril committed Jul 2, 2024
1 parent c7a81fe commit 7432a4e
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 6 deletions.
5 changes: 3 additions & 2 deletions src/courseware/course/sequence/Unit/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,9 @@ const Unit = ({
return (
<div className="unit">
<div className="mb-0">
<h3 className="h3">{unit.title}</h3>
<UnitTitleSlot courseId={courseId} unitId={id} unitTitle={unit.title} />
<UnitTitleSlot courseId={courseId} unitId={id} unitTitle={unit.title}>
<h3 className="h3">{unit.title}</h3>
</UnitTitleSlot>
</div>
<h2 className="sr-only">{formatMessage(messages.headerPlaceholder)}</h2>
<BookmarkButton
Expand Down
5 changes: 3 additions & 2 deletions src/plugin-slots/UnitTitleSlot/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

## Description

This slot is used for adding content after the Unit title.
This slot is used for adding content around the Unit title.

## Example

Expand All @@ -22,6 +22,7 @@ import { DIRECT_PLUGIN, PLUGIN_OPERATIONS } from '@openedx/frontend-plugin-frame
const config = {
pluginSlots: {
unit_title_slot: {
keepDefault: true,
plugins: [
{
// Insert custom content after unit title
Expand All @@ -33,7 +34,7 @@ const config = {
<>
<p>📚: {courseId}</p>
<p>📙: {unitId}</p>
<p>📙: {unitTitle}</p>
<p>🎩: {unitTitle}</p>
</>
),
},
Expand Down
Binary file modified src/plugin-slots/UnitTitleSlot/images/post_unit_title.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
9 changes: 7 additions & 2 deletions src/plugin-slots/UnitTitleSlot/index.jsx
Original file line number Diff line number Diff line change
@@ -1,21 +1,26 @@
import PropTypes from 'prop-types';
import { PluginSlot } from '@openedx/frontend-plugin-framework';

const UnitTitleSlot = ({ courseId, unitId, unitTitle }) => (
const UnitTitleSlot = ({
courseId, unitId, unitTitle, children,
}) => (
<PluginSlot
id="unit_title_slot"
pluginProps={{
courseId,
unitId,
unitTitle,
}}
/>
>
{children}
</PluginSlot>
);

UnitTitleSlot.propTypes = {
courseId: PropTypes.string.isRequired,
unitId: PropTypes.string.isRequired,
unitTitle: PropTypes.string.isRequired,
children: PropTypes.element.isRequired,
};

export default UnitTitleSlot;

0 comments on commit 7432a4e

Please sign in to comment.