Skip to content

Commit

Permalink
fix spec helper
Browse files Browse the repository at this point in the history
  • Loading branch information
cycomachead committed Aug 15, 2024
1 parent 81d85c7 commit 59b1556
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 4 deletions.
26 changes: 23 additions & 3 deletions _includes/head_custom.html
Original file line number Diff line number Diff line change
Expand Up @@ -5,21 +5,41 @@
<link href="{{ site.baseurl }}/assets/vendor/fontawesome/css/solid.css" rel="stylesheet" />
<!-- <link href="{{ site.baseurl }}/assets/vendor/fontawesome/css/brands.css" rel="stylesheet" /> -->

<!-- TODO: Contribute to JtD. Needs a better location. -->
<script>
document.addEventListener("DOMContentLoaded", function() {
if (jtd && localStorage['jtd-theme']) {
if (!jtd) { return; }

// If the browser suggests a color scheme, and user hasn't saved/switch one yet..
if (window.matchMedia && !localStorage['jtd-theme']) {
if (window.matchMedia('(prefers-color-scheme: dark)').matches) {
jtd.setTheme('dark');
} else if (window.matchMedia('(prefers-color-scheme: light)').matches) {
jtd.setTheme('light');
}
} else if (localStorage['jtd-theme']) {
jtd.setTheme(localStorage['jtd-theme']);
}

const toggleDarkMode = document.querySelector('.js-toggle-dark-mode');
jtd.addEvent(toggleDarkMode, 'click', function() {
const toggleSchemeBtn = document.querySelector('.js-toggle-dark-mode');
jtd.addEvent(toggleSchemeBtn, 'click', function() {
if (jtd.getTheme() === 'dark') {
localStorage['jtd-theme'] = 'light';
jtd.setTheme('light');
toggleSchemeBtn.textContent = '🌙 Dark Mode';
toggleSchemeBtn.ariaLabel = 'Switch to Dark Mode';
} else {
jtd.setTheme('dark');
localStorage['jtd-theme'] = 'dark';
toggleSchemeBtn.textContent = '🔆 Light Mode';
toggleSchemeBtn.ariaLabel = 'Switch to Light Mode';
}
});

const unsetColorScheme = document.querySelector('.js-unset-color-scheme');
jtd.addEvent(unsetColorScheme, 'click', function() {
delete localStorage['jtd-theme'];
jtd.setTheme('default');
});
});
</script>
2 changes: 1 addition & 1 deletion spec/spec_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@
end

Capybara::Screenshot.register_filename_prefix_formatter(:rspec) do |example|
example.example_group.top_level_description.gsub(%r{^/}, '').gsub('/', '-').gsub(' is accessible', '')
page = example.example_group.top_level_description.gsub(%r{^/}, '').gsub('/', '-').gsub(' is accessible', '')
standards = example.description.split.last
"tmp/capybara/screenshot_#{page}_#{standards}"
end
Expand Down

0 comments on commit 59b1556

Please sign in to comment.