Skip to content

Commit ab98147

Browse files
committed
fixup! fixup! feat: Syllabus page for learner MFE
1 parent 72ae54c commit ab98147

File tree

1 file changed

+8
-6
lines changed

1 file changed

+8
-6
lines changed

src/components/Syllabus.tsx

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,9 @@ const PrintSyllabus = ({blockData}) => {
1212
const blocks = blockData?.blocks;
1313
const rootBlock = blockData?.blocks[blockData.root];
1414
const makeList = (items: string[] | null) => {
15-
if (!items) { return ""; }
15+
if (!items) {
16+
return "";
17+
}
1618
const itemsList = items.filter(item => !!item).join("</li><li>");
1719
return itemsList
1820
? "<ul><li>" + items.filter(item => !!item).join("</li><li>") + "</li></ul>"
@@ -61,9 +63,10 @@ ${syllabusList}
6163
</html>
6264
`;
6365
return (
64-
<div>
66+
<div className="d-flex justify-content-end my-2">
6567
<iframe srcDoc={srcdoc} ref={iframeRef} className="d-none"></iframe>
66-
<Button onClick={() => iframeRef.current.contentWindow.print()}>Print</Button>
68+
<Button variant="outline-primary"
69+
onClick={() => iframeRef.current.contentWindow.print()}>Print</Button>
6770
</div>
6871
)
6972
}
@@ -112,7 +115,7 @@ export const Syllabus = () => {
112115
} = usePanels();
113116
useEffect(() => {
114117
if (blocks) {
115-
setOpenPanels(Object.fromEntries(Object.keys(blocks).map(blockId => [blockId, true])));
118+
setOpenPanels(Object.fromEntries(Object.keys(blocks).map(blockId => [blockId, false])));
116119
}
117120
}, [blocks, setOpenPanels]);
118121
const [query, setQuery] = useState('');
@@ -149,7 +152,6 @@ export const Syllabus = () => {
149152
: 'Expand all'}
150153
</Button>
151154
</div>
152-
{blockData && <PrintSyllabus blockData={blockData}/>}
153155
{rootBlock && iterMatches(rootBlock, (sectionId: UsageId) => (
154156
iterMatches(blocks[sectionId], (subsectionId: UsageId) => (
155157
iterMatches(blocks[subsectionId], (unitId: UsageId) => (
@@ -169,7 +171,7 @@ export const Syllabus = () => {
169171
))
170172
))
171173
), true)}
172-
174+
{blockData && <PrintSyllabus blockData={blockData}/>}
173175
</div>
174176
);
175177
};

0 commit comments

Comments
 (0)