-
Notifications
You must be signed in to change notification settings - Fork 106
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Update progress bar color * Update the position of "All my courses" * Update the position of the progress bar and its label * Update progress bar label color * Update progress bar height * Update course outline module header style * do not display lesson title * Update status color * Update the course completed checking function * render in progress status by half-filled-circle * Update the styles of the lesson without a module * Add locked icon * fix sign in button style * Add border-radius * Move js files into src. * add comments * fix unstarted course icon border thickness * update styles - reduce space between lessons - give unstarted course a thicker border * Update the color of the progress bar on My Courses * Use icons from wordpress library. * update comments and remove the use of sensei icon * Fix linting errors * fix preview button style * change to use @wordpress/element * make code more concise * Fix logged out not displaying icon error * fix styles of moduled lesson items * update style value
- Loading branch information
Showing
11 changed files
with
292 additions
and
17 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
3 changes: 3 additions & 0 deletions
3
wp-content/themes/pub/wporg-learn-2024/src/course-outline/block.json
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,3 @@ | ||
{ | ||
"script": "file:./index.js" | ||
} |
28 changes: 28 additions & 0 deletions
28
wp-content/themes/pub/wporg-learn-2024/src/course-outline/index.js
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,28 @@ | ||
/* global wporgCourseOutlineData */ | ||
|
||
import { Icon, drafts, lockOutline } from '@wordpress/icons'; | ||
import { renderToString } from '@wordpress/element'; | ||
|
||
document.addEventListener( 'DOMContentLoaded', () => { | ||
wporgCourseOutlineData[ 'in-progress' ]?.forEach( ( title ) => { | ||
const lessonLinks = document.querySelectorAll( '.wp-block-sensei-lms-course-outline-lesson' ); | ||
lessonLinks.forEach( ( link ) => { | ||
const span = link.querySelector( 'span' ); | ||
if ( span && span.textContent.trim() === title ) { | ||
const statusIcon = link.querySelector( '.wp-block-sensei-lms-course-outline-lesson__status' ); | ||
if ( statusIcon ) { | ||
statusIcon.outerHTML = renderToString( <Icon icon={ drafts } transform={ 'scale(1.5)' } /> ); | ||
} | ||
} | ||
} ); | ||
} ); | ||
wporgCourseOutlineData.locked?.forEach( ( title ) => { | ||
const lessonLinks = document.querySelectorAll( '.wp-block-sensei-lms-course-outline-lesson' ); | ||
lessonLinks.forEach( ( link ) => { | ||
const span = link.querySelector( 'span' ); | ||
if ( span && span.textContent.trim() === title ) { | ||
span.insertAdjacentHTML( 'afterend', renderToString( <Icon icon={ lockOutline } /> ) ); | ||
} | ||
} ); | ||
} ); | ||
} ); |
69 changes: 69 additions & 0 deletions
69
wp-content/themes/pub/wporg-learn-2024/src/course-outline/index.php
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,69 @@ | ||
<?php | ||
|
||
/** | ||
* Enqueue scripts and styles. | ||
*/ | ||
function enqueue_assets() { | ||
$script_asset_path = get_stylesheet_directory() . '/build/course-outline/index.asset.php'; | ||
if ( ! file_exists( $script_asset_path ) ) { | ||
wp_die( 'You need to run `yarn start` or `yarn build` to build the required assets.' ); | ||
} | ||
|
||
$script_asset = require( $script_asset_path ); | ||
wp_enqueue_script( | ||
'wporg-learn-2024-course-outline', | ||
get_stylesheet_directory_uri() . '/build/course-outline/index.js', | ||
$script_asset['dependencies'], | ||
$script_asset['version'], | ||
true | ||
); | ||
|
||
if ( is_singular( 'course' ) ) { | ||
$lesson_data = get_lesson_data(); | ||
wp_localize_script( | ||
'wporg-learn-2024-course-outline', | ||
'wporgCourseOutlineData', | ||
$lesson_data | ||
); | ||
} | ||
} | ||
add_action( 'wp_enqueue_scripts', 'enqueue_assets' ); | ||
|
||
/** | ||
* Get the titles of specific status lessons. | ||
* | ||
* The returned array $lesson_data has the following structure: | ||
* [ | ||
* 'in-progress' => [ (string) The title of the lesson, ... ], | ||
* 'locked' => [ (string) The title of the lesson, ... ], | ||
* ] | ||
* | ||
* @return array $lesson_data Array of lesson data. | ||
*/ | ||
function get_lesson_data() { | ||
$lesson_data = array(); | ||
$lesson_ids = Sensei()->course->course_lessons( get_the_ID(), 'publish', 'ids' ); | ||
|
||
foreach ( $lesson_ids as $lesson_id ) { | ||
$user_lesson_status = Sensei_Utils::user_lesson_status( $lesson_id, get_current_user_id() ); | ||
$lesson_title = get_the_title( $lesson_id ); | ||
$is_preview_lesson = Sensei_Utils::is_preview_lesson( $lesson_id ); | ||
|
||
// Add in-progress lesson title to lesson data | ||
if ( $user_lesson_status ) { | ||
$lesson_status = $user_lesson_status->comment_approved; | ||
if ( 'in-progress' === $lesson_status ) { | ||
$lesson_data['in-progress'][] = $lesson_title; | ||
} | ||
} | ||
|
||
// Add previewable and prerequisite-required lesson title to lesson data | ||
if ( ( ! $is_preview_lesson && ! Sensei_Course::is_user_enrolled( get_the_ID() ) ) | ||
|| ! Sensei_Lesson::is_prerequisite_complete( $lesson_id, get_current_user_id() ) | ||
) { | ||
$lesson_data['locked'][] = $lesson_title; | ||
} | ||
} | ||
|
||
return $lesson_data; | ||
} |
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
Oops, something went wrong.