-
Notifications
You must be signed in to change notification settings - Fork 228
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: update outline sidebar hooks for plugins (#1586)
* fix: update outline sidebar hooks for plugins * docs: explain UnitLinkWrapper
- Loading branch information
1 parent
911c765
commit 3cbbb02
Showing
9 changed files
with
172 additions
and
101 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
42 changes: 42 additions & 0 deletions
42
src/courseware/course/sidebar/sidebars/course-outline/components/UnitLinkWrapper.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
import React from 'react'; | ||
import { Link } from 'react-router-dom'; | ||
|
||
import { useCourseOutlineSidebar } from '../hooks'; | ||
|
||
interface Props { | ||
courseId: string; | ||
sequenceId: string; | ||
activeUnitId: string; | ||
id: string; | ||
children?: React.ReactNode; | ||
} | ||
|
||
/* | ||
* UnitLinkWrapper is necessary for unit navigation within the OutlineTrayPlugin. | ||
* import { Link } from 'react-router-dom' throws errors inside the plugin | ||
* because the package tries to load two versions of 'react-router-dom' or a | ||
* route can not be found. This component abstracts the import into a wrapper | ||
* component that can be imported into plugins without a render error. | ||
*/ | ||
|
||
const UnitLinkWrapper: React.FC<Props> = ({ | ||
sequenceId, | ||
activeUnitId, | ||
id, | ||
courseId, | ||
children, | ||
}) => { | ||
const { handleUnitClick } = useCourseOutlineSidebar(); | ||
|
||
return ( | ||
<Link | ||
to={`/course/${courseId}/${sequenceId}/${id}`} | ||
className="row w-100 m-0 d-flex align-items-center text-gray-700" | ||
onClick={() => handleUnitClick({ sequenceId, activeUnitId, id })} | ||
> | ||
{children} | ||
</Link> | ||
); | ||
}; | ||
|
||
export default UnitLinkWrapper; |
Oops, something went wrong.