-
Notifications
You must be signed in to change notification settings - Fork 246
/
Copy pathindex.jsx
56 lines (51 loc) · 1.59 KB
/
index.jsx
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
import PropTypes from 'prop-types';
import { PluginSlot } from '@openedx/frontend-plugin-framework';
import { useIntl } from '@edx/frontend-platform/i18n';
import { BookmarkButton } from '@src/courseware/course/bookmark';
import messages from '@src/courseware/course/sequence/messages';
const UnitTitleSlot = ({
unitId,
unit,
isEnabledOutlineSidebar,
renderUnitNavigation,
}) => {
const { formatMessage } = useIntl();
const isProcessing = unit.bookmarkedUpdateState === 'loading';
return (
<PluginSlot
id="org.openedx.frontend.learning.unit_title.v1"
idAliases={['unit_title_slot']}
pluginProps={{
unitId,
unit,
isEnabledOutlineSidebar,
renderUnitNavigation,
}}
>
<div className="d-flex justify-content-between">
<div className="mb-0">
<h3 className="h3">{unit.title}</h3>
</div>
{isEnabledOutlineSidebar && renderUnitNavigation(true)}
</div>
<p className="sr-only">{formatMessage(messages.headerPlaceholder)}</p>
<BookmarkButton
unitId={unit.id}
isBookmarked={unit.bookmarked}
isProcessing={isProcessing}
/>
</PluginSlot>
);
};
UnitTitleSlot.propTypes = {
unitId: PropTypes.string.isRequired,
unit: PropTypes.shape({
id: PropTypes.string.isRequired,
bookmarked: PropTypes.bool.isRequired,
title: PropTypes.string.isRequired,
bookmarkedUpdateState: PropTypes.string.isRequired,
}).isRequired,
isEnabledOutlineSidebar: PropTypes.bool.isRequired,
renderUnitNavigation: PropTypes.func.isRequired,
};
export default UnitTitleSlot;