Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: update UnitTitleSlot to wrap unit title #1414

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -23,16 +23,17 @@ exports[`Unit component output snapshot: not bookmarked, do not show content 1`]
<div
className="mb-0"
>
<h3
className="h3"
>
unit-title
</h3>
<UnitTitleSlot
courseId="test-course-id"
unitId="test-props-id"
unitTitle="unit-title"
/>
>
<h3
className="h3"
>
unit-title
</h3>
</UnitTitleSlot>
</div>
<h2
className="sr-only"
Expand Down
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;
Loading