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

Added support for dark mode in twitter timeline widget in Footer Element closes #1242 #1256

Closed
Closed
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
1 change: 0 additions & 1 deletion Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ GEM
eventmachine (1.2.7)
eventmachine (1.2.7-x64-mingw32)
ffi (1.15.5)
ffi (1.15.5-x64-mingw32)
forwardable-extended (2.6.0)
google-protobuf (3.21.12)
http_parser.rb (0.8.0)
Expand Down
26 changes: 25 additions & 1 deletion _includes/footer.html
Original file line number Diff line number Diff line change
Expand Up @@ -141,14 +141,38 @@ <h2><a {% if column.new_window %}target="_blank" {% endif %}
document.body.classList.toggle("dark-mode")
let layer5Logos = document.querySelectorAll("#layer5-logo");
let allLogos = document.querySelectorAll("#logo-dark-light");
let twitterTimeline = document.querySelector(".twitter-timeline");
let parentTwitterTimeline = twitterTimeline.parentNode;
// console.log(allLogos)
if (document.body.classList.contains("dark-mode")) {
layer5Logos.forEach(e => e.src = '../assets/images/company-logo/layer5-dark-mode-logo.svg')
allLogos.forEach(e => e.src = e.dataset.logoForDark)
twitterTimeline.dataset.theme = "dark";
} else {
layer5Logos.forEach(e => e.src = '../assets/images/company-logo/layer5-no-trim.svg')
allLogos.forEach(e => e.src = e.dataset.logoForLight)
twitterTimeline.dataset.theme = "light";
}

parentTwitterTimeline.removeChild(twitterTimeline);

// Create a new Twitter timeline element
let newTimeline = document.createElement('a');
newTimeline.innerHTML = 'Tweets by Meshery';
newTimeline.setAttribute('class', 'twitter-timeline');
newTimeline.setAttribute('data-width', '320');
newTimeline.setAttribute('data-height', '320');
newTimeline.setAttribute('data-theme', twitterTimeline.dataset.theme);
newTimeline.setAttribute('data-link-color', '#62ACCD');
newTimeline.setAttribute('data-chrome', 'nofooter circularborders noscrollbar');
newTimeline.setAttribute('href', 'https://twitter.com/mesheryio');

// Append the new Twitter timeline element to the parent
parentTwitterTimeline.appendChild(newTimeline);

// Load the Twitter widget for the new timeline
window.twttr.widgets.load();

if (document.body.classList.contains("dark-mode")) {
localStorage.setItem("mode", "dark-mode")
} else {
Expand Down Expand Up @@ -244,4 +268,4 @@ <h2><a {% if column.new_window %}target="_blank" {% endif %}
</script>
</body>

</html>
</html>