From 2dd7f7049f702413086f6e8ed1436173b2810978 Mon Sep 17 00:00:00 2001 From: ren <18050944+renintw@users.noreply.github.com> Date: Thu, 1 Aug 2024 05:59:27 +0900 Subject: [PATCH 1/7] Remove extra screen reader text. --- .../themes/pub/wporg-learn-2024/functions.php | 1 + .../src/sensei-lesson-actions-a11y/block.json | 4 ++ .../src/sensei-lesson-actions-a11y/index.php | 40 +++++++++++++++++++ .../src/sensei-lesson-actions-a11y/view.js | 14 +++++++ 4 files changed, 59 insertions(+) create mode 100644 wp-content/themes/pub/wporg-learn-2024/src/sensei-lesson-actions-a11y/block.json create mode 100644 wp-content/themes/pub/wporg-learn-2024/src/sensei-lesson-actions-a11y/index.php create mode 100644 wp-content/themes/pub/wporg-learn-2024/src/sensei-lesson-actions-a11y/view.js diff --git a/wp-content/themes/pub/wporg-learn-2024/functions.php b/wp-content/themes/pub/wporg-learn-2024/functions.php index d8058d1ee..9af43d142 100644 --- a/wp-content/themes/pub/wporg-learn-2024/functions.php +++ b/wp-content/themes/pub/wporg-learn-2024/functions.php @@ -13,6 +13,7 @@ require_once __DIR__ . '/src/learning-pathway-cards/index.php'; require_once __DIR__ . '/src/learning-pathway-header/index.php'; require_once __DIR__ . '/src/lesson-grid/index.php'; +require_once __DIR__ . '/src/sensei-lesson-actions-a11y/index.php'; require_once __DIR__ . '/src/search-results-context/index.php'; require_once __DIR__ . '/src/sensei-progress-bar/index.php'; require_once __DIR__ . '/src/sidebar-meta-list/index.php'; diff --git a/wp-content/themes/pub/wporg-learn-2024/src/sensei-lesson-actions-a11y/block.json b/wp-content/themes/pub/wporg-learn-2024/src/sensei-lesson-actions-a11y/block.json new file mode 100644 index 000000000..f22a32f84 --- /dev/null +++ b/wp-content/themes/pub/wporg-learn-2024/src/sensei-lesson-actions-a11y/block.json @@ -0,0 +1,4 @@ +{ + "name": "wporg-learn/sensei-lesson-actions-a11y", + "viewScript": "file:./view.js" +} diff --git a/wp-content/themes/pub/wporg-learn-2024/src/sensei-lesson-actions-a11y/index.php b/wp-content/themes/pub/wporg-learn-2024/src/sensei-lesson-actions-a11y/index.php new file mode 100644 index 000000000..3c2b2d77e --- /dev/null +++ b/wp-content/themes/pub/wporg-learn-2024/src/sensei-lesson-actions-a11y/index.php @@ -0,0 +1,40 @@ + true ) ); + $metadata['file'] = $metadata_file; + + $script_handle = register_block_script_handle( $metadata, 'viewScript', 0 ); + + // Enqueue the assets when the single lesson content pattern is on the page. + add_action( + 'render_block_core/pattern', + function( $block_content, $block ) use ( $script_handle ) { + if ( isset( $block['attrs']['slug'] ) && 'wporg-learn-2024/single-lesson-content' === $block['attrs']['slug'] ) { + wp_enqueue_script( $script_handle ); + } + return $block_content; + }, + 10, + 2 + ); +} diff --git a/wp-content/themes/pub/wporg-learn-2024/src/sensei-lesson-actions-a11y/view.js b/wp-content/themes/pub/wporg-learn-2024/src/sensei-lesson-actions-a11y/view.js new file mode 100644 index 000000000..04cad8983 --- /dev/null +++ b/wp-content/themes/pub/wporg-learn-2024/src/sensei-lesson-actions-a11y/view.js @@ -0,0 +1,14 @@ +function init() { + /** + * Enhance the accessibility of the sensei lesson actions. + * + * Because there are additional visible buttons, the extra screen reader text is removed. + */ + const footerElement = document.querySelector( '.sensei-lesson-footer' ); + const screenReaderText = footerElement.parentElement.querySelector( '.screen-reader-text' ); + if ( screenReaderText ) { + screenReaderText.remove(); + } +} + +document.addEventListener( 'DOMContentLoaded', init ); From 89400f3451aa21b416bd42e1bcd0870241c558c0 Mon Sep 17 00:00:00 2001 From: ren <18050944+renintw@users.noreply.github.com> Date: Thu, 1 Aug 2024 06:49:36 +0900 Subject: [PATCH 2/7] Add previous lesson button. --- .../patterns/sensei-lesson-actions.php | 38 ++++++++++++------- 1 file changed, 24 insertions(+), 14 deletions(-) diff --git a/wp-content/themes/pub/wporg-learn-2024/patterns/sensei-lesson-actions.php b/wp-content/themes/pub/wporg-learn-2024/patterns/sensei-lesson-actions.php index 18c6cc4c0..d859f2ea7 100644 --- a/wp-content/themes/pub/wporg-learn-2024/patterns/sensei-lesson-actions.php +++ b/wp-content/themes/pub/wporg-learn-2024/patterns/sensei-lesson-actions.php @@ -7,6 +7,11 @@ * Original source: https://github.com/Automattic/sensei/blob/af62fb1115daf2063bc56331a7d8b1b3ea805866/themes/sensei-course-theme/templates/default/lesson.php */ +$prev_next_lessons = sensei_get_prev_next_lessons( get_the_ID() ); +$prev_url = $prev_next_lessons['previous']['url'] ?? null; +$next_url = $prev_next_lessons['next']['url'] ?? null; +$is_completed = Sensei_Utils::user_completed_lesson( get_the_ID() ); + ?> @@ -28,21 +33,26 @@ - -
From 4d465ec31e01ca936f71a92cd5e30f7ad6c0f4e6 Mon Sep 17 00:00:00 2001 From: ren <18050944+renintw@users.noreply.github.com> Date: Thu, 1 Aug 2024 22:48:29 +0900 Subject: [PATCH 3/7] Add lesson complete indicator --- .../patterns/sensei-lesson-actions.php | 37 ++++++++++++------- .../wporg-learn-2024/src/style/_sensei.scss | 8 +--- .../pub/wporg-learn-2024/src/style/style.scss | 6 +++ 3 files changed, 32 insertions(+), 19 deletions(-) diff --git a/wp-content/themes/pub/wporg-learn-2024/patterns/sensei-lesson-actions.php b/wp-content/themes/pub/wporg-learn-2024/patterns/sensei-lesson-actions.php index d859f2ea7..ccd203c7c 100644 --- a/wp-content/themes/pub/wporg-learn-2024/patterns/sensei-lesson-actions.php +++ b/wp-content/themes/pub/wporg-learn-2024/patterns/sensei-lesson-actions.php @@ -36,19 +36,30 @@ diff --git a/wp-content/themes/pub/wporg-learn-2024/src/style/_sensei.scss b/wp-content/themes/pub/wporg-learn-2024/src/style/_sensei.scss index 7c395d3cd..7c6034cdf 100644 --- a/wp-content/themes/pub/wporg-learn-2024/src/style/_sensei.scss +++ b/wp-content/themes/pub/wporg-learn-2024/src/style/_sensei.scss @@ -102,12 +102,8 @@ body.sensei { } @media screen and (max-width: 782px) { - .sensei-lesson-footer .wp-block-sensei-lms-button-lesson-completed { - display: flex; - - .wp-block-button__link { - flex: 1; - } + .sensei-lesson-footer .sensei-lesson-actions-nav { + width: 100%; } } diff --git a/wp-content/themes/pub/wporg-learn-2024/src/style/style.scss b/wp-content/themes/pub/wporg-learn-2024/src/style/style.scss index 1f58987a4..2d4ce0e02 100644 --- a/wp-content/themes/pub/wporg-learn-2024/src/style/style.scss +++ b/wp-content/themes/pub/wporg-learn-2024/src/style/style.scss @@ -51,3 +51,9 @@ body { padding-top: unset !important; } } + +.disabled { + color: var(--wp--preset--color--charcoal-5) !important; + border-color: var(--wp--preset--color--charcoal-5) !important; + pointer-events: none; +} From 15a7907bebd46ebeda558be48f643b302f770913 Mon Sep 17 00:00:00 2001 From: ren <18050944+renintw@users.noreply.github.com> Date: Fri, 2 Aug 2024 02:21:47 +0900 Subject: [PATCH 4/7] Revert "Remove extra screen reader text." This reverts commit 2dd7f7049f702413086f6e8ed1436173b2810978. --- .../themes/pub/wporg-learn-2024/functions.php | 1 - .../src/sensei-lesson-actions-a11y/block.json | 4 -- .../src/sensei-lesson-actions-a11y/index.php | 40 ------------------- .../src/sensei-lesson-actions-a11y/view.js | 14 ------- 4 files changed, 59 deletions(-) delete mode 100644 wp-content/themes/pub/wporg-learn-2024/src/sensei-lesson-actions-a11y/block.json delete mode 100644 wp-content/themes/pub/wporg-learn-2024/src/sensei-lesson-actions-a11y/index.php delete mode 100644 wp-content/themes/pub/wporg-learn-2024/src/sensei-lesson-actions-a11y/view.js diff --git a/wp-content/themes/pub/wporg-learn-2024/functions.php b/wp-content/themes/pub/wporg-learn-2024/functions.php index 9af43d142..d8058d1ee 100644 --- a/wp-content/themes/pub/wporg-learn-2024/functions.php +++ b/wp-content/themes/pub/wporg-learn-2024/functions.php @@ -13,7 +13,6 @@ require_once __DIR__ . '/src/learning-pathway-cards/index.php'; require_once __DIR__ . '/src/learning-pathway-header/index.php'; require_once __DIR__ . '/src/lesson-grid/index.php'; -require_once __DIR__ . '/src/sensei-lesson-actions-a11y/index.php'; require_once __DIR__ . '/src/search-results-context/index.php'; require_once __DIR__ . '/src/sensei-progress-bar/index.php'; require_once __DIR__ . '/src/sidebar-meta-list/index.php'; diff --git a/wp-content/themes/pub/wporg-learn-2024/src/sensei-lesson-actions-a11y/block.json b/wp-content/themes/pub/wporg-learn-2024/src/sensei-lesson-actions-a11y/block.json deleted file mode 100644 index f22a32f84..000000000 --- a/wp-content/themes/pub/wporg-learn-2024/src/sensei-lesson-actions-a11y/block.json +++ /dev/null @@ -1,4 +0,0 @@ -{ - "name": "wporg-learn/sensei-lesson-actions-a11y", - "viewScript": "file:./view.js" -} diff --git a/wp-content/themes/pub/wporg-learn-2024/src/sensei-lesson-actions-a11y/index.php b/wp-content/themes/pub/wporg-learn-2024/src/sensei-lesson-actions-a11y/index.php deleted file mode 100644 index 3c2b2d77e..000000000 --- a/wp-content/themes/pub/wporg-learn-2024/src/sensei-lesson-actions-a11y/index.php +++ /dev/null @@ -1,40 +0,0 @@ - true ) ); - $metadata['file'] = $metadata_file; - - $script_handle = register_block_script_handle( $metadata, 'viewScript', 0 ); - - // Enqueue the assets when the single lesson content pattern is on the page. - add_action( - 'render_block_core/pattern', - function( $block_content, $block ) use ( $script_handle ) { - if ( isset( $block['attrs']['slug'] ) && 'wporg-learn-2024/single-lesson-content' === $block['attrs']['slug'] ) { - wp_enqueue_script( $script_handle ); - } - return $block_content; - }, - 10, - 2 - ); -} diff --git a/wp-content/themes/pub/wporg-learn-2024/src/sensei-lesson-actions-a11y/view.js b/wp-content/themes/pub/wporg-learn-2024/src/sensei-lesson-actions-a11y/view.js deleted file mode 100644 index 04cad8983..000000000 --- a/wp-content/themes/pub/wporg-learn-2024/src/sensei-lesson-actions-a11y/view.js +++ /dev/null @@ -1,14 +0,0 @@ -function init() { - /** - * Enhance the accessibility of the sensei lesson actions. - * - * Because there are additional visible buttons, the extra screen reader text is removed. - */ - const footerElement = document.querySelector( '.sensei-lesson-footer' ); - const screenReaderText = footerElement.parentElement.querySelector( '.screen-reader-text' ); - if ( screenReaderText ) { - screenReaderText.remove(); - } -} - -document.addEventListener( 'DOMContentLoaded', init ); From fa117b4be5afcb54439e0638c199ff5ab8e4edc5 Mon Sep 17 00:00:00 2001 From: ren <18050944+renintw@users.noreply.github.com> Date: Fri, 2 Aug 2024 02:42:08 +0900 Subject: [PATCH 5/7] Remove lesson completed --- .../patterns/sensei-lesson-actions.php | 45 +++++++------------ 1 file changed, 17 insertions(+), 28 deletions(-) diff --git a/wp-content/themes/pub/wporg-learn-2024/patterns/sensei-lesson-actions.php b/wp-content/themes/pub/wporg-learn-2024/patterns/sensei-lesson-actions.php index ccd203c7c..fc5079168 100644 --- a/wp-content/themes/pub/wporg-learn-2024/patterns/sensei-lesson-actions.php +++ b/wp-content/themes/pub/wporg-learn-2024/patterns/sensei-lesson-actions.php @@ -33,36 +33,25 @@ - - - From 2899198302c26a50ce1368b888370bd7be01781a Mon Sep 17 00:00:00 2001 From: ren <18050944+renintw@users.noreply.github.com> Date: Fri, 2 Aug 2024 02:55:36 +0900 Subject: [PATCH 6/7] Do not display screen reader text. --- .../patterns/sensei-lesson-columns.php | 8 ++++---- .../patterns/sensei-lesson-standalone.php | 8 ++++---- .../wporg-learn-2024/src/style/_sensei.scss | 20 ++++++++++++------- 3 files changed, 21 insertions(+), 15 deletions(-) diff --git a/wp-content/themes/pub/wporg-learn-2024/patterns/sensei-lesson-columns.php b/wp-content/themes/pub/wporg-learn-2024/patterns/sensei-lesson-columns.php index 2bae0ff70..f4e742060 100644 --- a/wp-content/themes/pub/wporg-learn-2024/patterns/sensei-lesson-columns.php +++ b/wp-content/themes/pub/wporg-learn-2024/patterns/sensei-lesson-columns.php @@ -29,12 +29,12 @@ - -