Pen Settings

HTML

CSS

CSS Base

Vendor Prefixing

Add External Stylesheets/Pens

Any URL's added here will be added as <link>s in order, and before the CSS in the editor. You can use the CSS from another Pen by using it's URL and the proper URL extention.

+ add another resource

JavaScript

Babel includes JSX processing.

Add External Scripts/Pens

Any URL's added here will be added as <script>s in order, and run before the JavaScript in the editor. You can use the URL of any other Pen and it will include the JavaScript from that Pen.

+ add another resource

Packages

Add Packages

Search for and use JavaScript packages from npm here. By selecting a package, an import statement will be added to the top of the JavaScript editor for this package.

Behavior

Save Automatically?

If active, Pens will autosave every 30 seconds after being saved once.

Auto-Updating Preview

If enabled, the preview panel updates automatically as you code. If disabled, use the "Run" button to update.

Format on Save

If enabled, your code will be formatted when you actively save your Pen. Note: your code becomes un-folded during formatting.

Editor Settings

Code Indentation

Want to change your Syntax Highlighting theme, Fonts and more?

Visit your global Editor Settings.

HTML

              
                <!-- The Dark Mode Toggle Element -->
<span class="dark-mode-toggle"><i class="fas fa-moon"></i> Dark Mode</span>




<!--
IMPLEMENTATION PROCEDURE

1. In your theme/child theme directory, create the folder 'learndash'.

2. Create another folder 'ld30' inside the "learndash folder".

3. Create another folder 'focus' inside the "ld30 folder"

4. Now open the 'sfwd-lms (LearnDash plugin) folder', open the 'themes' subfolder, then open 'ld30' subfolder , open 'templates' subfolder, now open 'focus' subfolder.

5. Now copy the the 'index.php' file inside that folder.

6. Paste the file inside your own initially created 'focus folder' at "your-theme/learndash/ld30/focus".

7. Once you have pasted the copied 'index.php' file inside the 'focus folder', open the 'index.php' file in a text editor.

8. Search for this line '<div class="ld-focus-main">', once you get there, copy and paste the The Dark Mode Toggle Element above exactly after that line above every other content withing that div such that it looks like this:

<div class="ld-focus-main">
     <span class="dark-mode-toggle"><i class="fas fa-moon"></i> Dark Mode</span>
     --------- every other content ---------
     ---------- every other content -----------
</div>

9. BOOM, save the file and test it out.
-->

<img src="https://developers.learndash.com/wp-content/uploads/2020/06/LearnDash-all-white-300x91.png" style="background: #1b2836; padding: 5px; border-radius: 5px">
<h1>Dark Mode for LearnDash Focus Mode</h1>

<h2>Problems with implementation? Ask questions <a href="https://web.facebook.com/100002099797457/videos/3301901589889802/?extid=bHS6Od7PAJdShwFb" target="_blank">here</a></h2>
              
            
!

CSS

              
                :root {
    /* Set you main accent color */
    --primary-color: #4f8c00; 
  
    /* Sets your preferred dark mode color */
    --dark-mode-color: #1b2836;
  
    /* Sets an alternative for your preferred dark mode color, usually a bit darker one */
    --dark-mode-color-alt: #141f2b;
  
    /* Sets a color for most texts in dark mode */
    --dark-mode-text-color: #ffffff;
}

/* Kindly delete this line when you implement */
body {
  text-align: center;
}
html.dark-mode {
  color: var(--dark-mode-text-color);
}
/*---------------------------------*/

/* Go below this line only if you know what you're doing */
.dark-mode-toggle {
    position: fixed;
    bottom: 30px;
    right: 30px;
    font-size: .8em;
    text-transform: uppercase;
    color: white;
    z-index: 1000;
    border-radius: .5em;
    background: var(--primary-color);
    padding: 10px;
    cursor: pointer;
}
.dark-mode-toggle svg {
    font-size: 1.5em;
    vertical-align: middle;
}
html.dark-mode,
html.dark-mode .learndash-wrapper .ld-focus .ld-focus-header,
html.dark-mode .learndash-wrapper .ld-focus .ld-focus-header .ld-brand-logo,
html.dark-mode .learndash-wrapper .ld-focus .ld-focus-sidebar,
html.dark-mode .learndash-wrapper .ld-status-incomplete.ld-status-icon,
html.dark-mode .learndash-wrapper .ld-focus .ld-focus-sidebar .ld-course-navigation .ld-topic-list.ld-table-list:before,
html.dark-mode .ld-in-focus-mode .learndash-wrapper,
html.dark-mode .learndash-wrapper .ld-course-navigation .ld-lesson-item-preview a.ld-lesson-item-preview-heading,
html.dark-mode .learndash-wrapper .ld-focus .ld-focus-sidebar .ld-course-navigation .ld-lesson-item {
    background: var(--dark-mode-color) !important;
}
html.dark-mode .learndash-wrapper .ld-focus .ld-focus-sidebar .ld-course-navigation .ld-topic-list.ld-table-list,
html.dark-mode .learndash-wrapper .ld-focus .ld-focus-sidebar .ld-course-navigation .ld-lesson-item-expanded .ld-table-list-items,
html.dark-mode .learndash-wrapper .ld-table-list a.ld-table-list-item-preview,
html.dark-mode .learndash-wrapper .ld-table-list .ld-table-list-items {
    background: var(--dark-mode-color-alt) !important;
}
html.dark-mode .ld-in-focus-mode .learndash-wrapper,
html.dark-mode .learndash-wrapper .ld-course-navigation .ld-lesson-item-preview a.ld-lesson-item-preview-heading,
html.dark-mode .learndash-wrapper .ld-focus .ld-focus-sidebar .ld-course-navigation .ld-lesson-item,
html.dark-mode .learndash-wrapper .ld-table-list a.ld-table-list-item-preview,
html.dark-mode .learndash-wrapper .ld-button .ld-text, 
html.dark-mode .learndash-wrapper .ld-button .ld-icon {
    color: var(--dark-mode-text-color) !important;
}
html.dark-mode .learndash-wrapper .ld-course-navigation .ld-status-icon.ld-status-in-progress {
    background: transparent !important;
}
html.dark-mode .learndash-wrapper .ld-breadcrumbs .ld-breadcrumbs-segments span:after {
    color: #000000;
}
@media (max-width: 768px) {
    html.dark-mode .learndash-wrapper .ld-focus .ld-focus-header .ld-content-actions {
        background: var(--dark-mode-color-alt) !important;
        border-bottom: 1px solid #efefef;
    }
}
html.dark-mode .learndash-wrapper .ld-focus .ld-focus-header .ld-mobile-nav span {
    background: #ffffff !important;
}
html.dark-mode .wpProQuiz_reviewQuestion li:not(.wpProQuiz_reviewQuestionTarget) {
    color: #000;
}
html.dark-mode .learndash-wrapper .ld-focus-comments .ld-focus-comments__comments {
    padding: .7em 1.5em;
    background: var(--dark-mode-color-alt);
    box-shadow: 0 .125rem .25rem rgba(0,0,0,.075) !important;
    border-radius: .3em;
}
html.dark-mode .learndash-wrapper .ld-focus-comment.bypostauthor > .ld-comment-wrapper, 
html.dark-mode .learndash-wrapper .ld-focus-comment.role-group_leader > .ld-comment-wrapper, 
html.dark-mode .learndash-wrapper .ld-focus-comment.role-administrator > .ld-comment-wrapper {
    background: var(--dark-mode-color) !important;
}
html.dark-mode .learndash-wrapper .ld-focus-comments #commentform textarea#comment {
    background: var(--dark-mode-color-alt) !important;
    color: #fff;
}
html.dark-mode .learndash-wrapper .ld-focus-comment .ld-comment-avatar .ld-comment-avatar-author .ld-comment-author-name {
    color: #728188;
}
              
            
!

JS

              
                const webpage = document.querySelector('html');
const darkModeBTN = document.querySelector('.dark-mode-toggle');

darkModeBTN.addEventListener('click', () => {
    // console.log('Button Clicked');
    if (Array.from(webpage.classList).includes('dark-mode')) {
        webpage.classList.remove('dark-mode');
        localStorage.setItem('LearningDarkMode', 'OFF');
        darkModeBTN.innerHTML = `<i class="fas fa-moon"></i> Dark Mode`;
    } else if (!Array.from(webpage.classList).includes('dark-mode')) {
        webpage.classList.add('dark-mode');
        localStorage.setItem('LearningDarkMode', 'ON');
        darkModeBTN.innerHTML = `<i class="fas fa-cloud-sun"></i> Light Mode`;
    }
    // console.log(`Dark Mode is ${localStorage.getItem('darkMode')}`);
});

if (localStorage.getItem('LearningDarkMode') && localStorage.getItem('LearningDarkMode') === 'ON') {
    webpage.classList.add('dark-mode');
    darkModeBTN.innerHTML = `<i class="fas fa-cloud-sun"></i> Light Mode`;
}
              
            
!
999px

Console