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

Course outline block header enhance #2776

Open
wants to merge 4 commits into
base: trunk
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
24 changes: 24 additions & 0 deletions wp-content/themes/pub/wporg-learn-2024/src/course-outline/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,30 @@ import { Icon, drafts, lockOutline } from '@wordpress/icons';
import { renderToString } from '@wordpress/element';

document.addEventListener( 'DOMContentLoaded', () => {
/**
* Allow the entire header to toggle, giving users a larger area to interact with.
*/
document
.querySelectorAll( 'section.wp-block-sensei-lms-course-outline-module-bordered > header' )
.forEach( ( header ) => {
const button = header.querySelector( 'button' );
header.addEventListener( 'click', () => {
button.click();
} );

button.addEventListener( 'click', ( event ) => {
event.stopPropagation();
} );
} );

if ( ! wporgCourseOutlineData ) {
return;
}

/**
* Iterates over all course titles that are of status in-progress and adds icons
* to those courses in the course outline block.
*/
wporgCourseOutlineData[ 'in-progress' ]?.forEach( ( title ) => {
const lessonLinks = document.querySelectorAll( '.wp-block-sensei-lms-course-outline-lesson' );
lessonLinks.forEach( ( link ) => {
Expand All @@ -20,6 +40,10 @@ document.addEventListener( 'DOMContentLoaded', () => {
}
} );
} );
/**
* Iterates over all course titles that are of status locked and adds icons
* to those courses in the course outline block.
*/
wporgCourseOutlineData.locked?.forEach( ( title ) => {
const lessonLinks = document.querySelectorAll( '.wp-block-sensei-lms-course-outline-lesson' );
lessonLinks.forEach( ( link ) => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,7 @@ body.sensei {
background-color: var(--wp--preset--color--light-grey-2) !important;
color: var(--wp--preset--color--charcoal-1) !important;
padding: var(--wp--preset--spacing--20);
cursor: pointer;

h2 {
font-size: var(--wp--preset--font-size--heading-6);
Expand Down