Hi All,
I thought that seeing as I’ve been quiet for a while that I’d start a new thread that will detail the journey Sudonix is taking to reach BS5, v3 of NodeBB, and the adoption of the Harmony theme. I’ve been playing with the “Nord” theme, and am pleased to report that the CSS needed since the move from standard CSS
to LESS / SCSS
has been remarkably reduced. Presently, I’m at 324 lines - a huge difference to the 4,479 (yes, that’s right…) currently in use here.
And no doubt you’re curious as to what v3.beta1
of NodeBB looks like, combined with Harmony, and the theme I’m working on?
Here’s what the standard iteration looks like via https://community.nodebb.org
And here’s what the Nord
theme on https://sudonix.dev looks like
WARNING: Extreme sexiness ahead
The Swatch script is also functional
Interestingly, this differs heavily from v2 (mostly because the jump from BS3 to BS5 is significant). Currently, it looks like this in v2
// ------------------------------------------
// Swatch Applet
// ------------------------------------------
$(document).ready(function() {
function generateRandomString(length) {
var text = "";
var possible = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789";
for (var i = 0; i < length; i++) {
text += possible.charAt(Math.floor(Math.random() * possible.length));
}
return text;
}
var string = generateRandomString(10);
$("#random_string").text(string);
var whichTheme = localStorage.getItem("theme");
var activeTheme = localStorage.getItem("activeTheme");
// If no theme is detected (for example, a new visitor), then set this to default
if (!whichTheme) {
// dark-mode media query matched or not
let matched = window.matchMedia('(prefers-color-scheme: dark)').matches;
//var override = getUrlParameter('override');
if (matched) {
// Offer the mifnight theme by default
whichTheme = "midnight";
activeTheme = "/assets/customcss/midnight.css?version=" + string;
//$("link[rel=stylesheet]").attr('href' , thishref + "?version=" + string + "");
} else {
// Leave the default theme intact
whichTheme = "default";
activeTheme = "/assets/customcss/daylight.css?version=" + string;
}
// See if override has been enabled
if (whichTheme === 'default') {
// Sudonix is overriding operating system settings and will force dark scheme
activeTheme = "/assets/customcss/daylight.css?version=" + string;
}
if (whichTheme === 'daylight') {
// $('[component="post"]').addClass("background");
$('li.self-post .content:not(.isSolved [component="post/content"]').addClass("response");
} else {
// Nothing to do :)
}
}
/*$(".forum-logo").attr("src","/assets/uploads/system/sl_" + whichTheme + ".webp?version=" + string + ""); */
var panel = $('<li id="switcher" class="dropdown"> \
<a title="" data-original-title="Swatch" class="navigation-link dropdown-toggle" href="#" role="button" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false"> \
<i id="ticon" class="fa fa-light fa-swatchbook" data-content="" aria-hidden="true"></i> \
<span class="visible-xs-inline">Swatch</span> \
<i class="fa fa-caret-down" aria-hidden="true"></i> \
</a> \
<ul id="theme" class="dropdown-menu"> \
<li><a id="default" href="#" rel="/assets/customcss/daylight.css">Default</a></li> \
<li><a id="anthracite" href="#" rel="/assets/customcss/anthracite.css">Anthracite</a></li> \
<li><a id="darkly" href="#" rel="/assets/customcss/darkly.css">Darkly</a></li> \
<li><a id="daylight" href="#" rel="/assets/customcss/daylight.css">Daylight</a></li> \
<li><a id="facetube" href="#" rel="/assets/customcss/facetube.css">FaceTube</a></li> \
<li><a id="greybird" href="#" rel="/assets/customcss/greybird.css">Greybird</a></li> \
<li><a id="midnight" href="#" rel="/assets/customcss/midnight.css">Midnight</a></li> \
<li><a id="nord" href="#" rel="/assets/customcss/nord.css">Nord</a></li> \
<li><a id="slate" href="#" rel="/assets/customcss/slate.css">Slate</a></li> \
<li><a id="superhero" href="#" rel="/assets/customcss/superhero.css">Superhero</a></li> \
<li><a id="tempest" href="#" rel="/assets/customcss/tempest.css">Tempest</a></li> \
<li><a id="twitter" href="#" rel="/assets/customcss/twitter.css">Twitter</a></li> \
</ul> \
</li> \
</div> \
');
if (whichTheme) {
$.get(activeTheme, function(css) {
$('<style type="text/css"></style>')
.html(css)
.appendTo("head");
});
} else {}
$('#main-nav').append(panel);
if (utils.findBootstrapEnvironment() === 'xs') {
$('#main-nav').append(panel);
}
$(document).ready(function() {
$("body").on("click change", "#theme li a", function() {
var thishref = $(this).attr('rel') + '?version=' + string;
$.get(thishref, function(css) {
$('<style type="text/css"></style>')
.html(css)
.appendTo("head");
});
console.log("Applying swatch " + thishref);
//location.reload();
var selected = $(this).attr("id");
var theTheme = $(this).attr("rel");
if (selected === 'default') {
localStorage.setItem("theme", selected);
localStorage.setItem("activeTheme", "/assets/customcss/daylight.css?version=" + string);
//location.reload();
} else {
localStorage.setItem("theme", selected);
localStorage.setItem("activeTheme", theTheme);
}
return false;
});
});
});
Now in v3, it looks VERY different
var mobiledropdown = $('<li class="nav-item dropend" title="Swatch"> \
<a class="nav-link nav-btn navigation-link px-3 py-2 dropdown-toggle" href="#" role="button" data-bs-toggle="collapse" data-bs-target="#theme" onclick="event.stopPropagation();"> \
<span class="d-inline-flex justify-content-between align-items-center w-100"> \
<span class="text-nowrap truncate-open"> \
<i class="fa fa-fw fa-painbrush" data-content="" aria-hidden="true"></i>
<span class="nav-text visible-open px-2 fw-semibold">More</span>
</span>
<span component="navigation/count" class="visible-open badge rounded-1 bg-primary hidden"></span>
</span>
</a>
<div class="ps-3">
<ul id="theme" class="collapse list-unstyled ps-3"> \
<li><a id="default" class="dropdown-item rounded-1" href="#" rel="/assets/customcss/daylight.css">Default</a></li> \
<li><a id="anthracite" class="dropdown-item rounded-1" href="#" rel="/assets/customcss/anthracite.css">Anthracite</a></li> \
<li><a id="darkly" class="dropdown-item rounded-1" href="#" rel="/assets/customcss/darkly.css">Darkly</a></li> \
<li><a id="daylight" class="dropdown-item rounded-1" href="#" rel="/assets/customcss/daylight.css">Daylight</a></li> \
<li><a id="facetube" class="dropdown-item rounded-1" href="#" rel="/assets/customcss/facetube.css">FaceTube</a></li> \
<li><a id="greybird" class="dropdown-item rounded-1" href="#" rel="/assets/customcss/greybird.css">Greybird</a></li> \
<li><a id="midnight" class="dropdown-item rounded-1" href="#" rel="/assets/customcss/midnight.css">Midnight</a></li> \
<li><a id="nord" class="dropdown-item rounded-1" href="#" rel="/assets/customcss/nord.css">Nord</a></li> \
<li><a id="slate" class="dropdown-item rounded-1" href="#" rel="/assets/customcss/slate.css">Slate</a></li> \
<li><a id="superhero" class="dropdown-item rounded-1" href="#" rel="/assets/customcss/superhero.css">Superhero</a></li> \
<li><a id="tempest" class="dropdown-item rounded-1" href="#" rel="/assets/customcss/tempest.css">Tempest</a></li> \
<li><a id="twitter" class="dropdown-item rounded-1" href="#" rel="/assets/customcss/twitter.css">Twitter</a></li> \
</ul>
</div>
</li>
');
var desktopnavbar = $('<li id="switcher" class="nav-item mx-2 dropend" title="Swatch"> \
<a class="nav-link nav-btn navigation-link d-flex gap-2 justify-content-between align-items-center dropdown-toggle" href="#" role="button" data-bs-toggle="dropdown" aria-haspopup="true" aria-expanded="false"> \
<span class="d-flex gap-2 align-items-center text-nowrap truncate-open"> \
<span class="position-relative"> \
<i class="fa fa-fw fa-paintbrush" data-content="" aria-hidden="true"></i> \
<span component="navigation/count" class="visible-closed position-absolute top-0 start-100 translate-middle badge rounded-1 bg-primary hidden"></span> \
</span> \
<span class="nav-text small visible-open fw-semibold text-truncate">Swatch</span> \
</span> \
<span component="navigation/count" class="visible-open badge rounded-1 bg-primary hidden"></span> \
</a> \
<ul id="theme" class="dropdown-menu overflow-auto" data-popper-placement="right-end"> \
<li><a id="default" class="dropdown-item rounded-1" href="#" rel="/assets/customcss/daylight.css">Default</a></li> \
<li><a id="anthracite" class="dropdown-item rounded-1" href="#" rel="/assets/customcss/anthracite.css">Anthracite</a></li> \
<li><a id="darkly" class="dropdown-item rounded-1" href="#" rel="/assets/customcss/darkly.css">Darkly</a></li> \
<li><a id="daylight" class="dropdown-item rounded-1" href="#" rel="/assets/customcss/daylight.css">Daylight</a></li> \
<li><a id="facetube" class="dropdown-item rounded-1" href="#" rel="/assets/customcss/facetube.css">FaceTube</a></li> \
<li><a id="greybird" class="dropdown-item rounded-1" href="#" rel="/assets/customcss/greybird.css">Greybird</a></li> \
<li><a id="midnight" class="dropdown-item rounded-1" href="#" rel="/assets/customcss/midnight.css">Midnight</a></li> \
<li><a id="nord" class="dropdown-item rounded-1" href="#" rel="/assets/customcss/nord.css">Nord</a></li> \
<li><a id="slate" class="dropdown-item rounded-1" href="#" rel="/assets/customcss/slate.css">Slate</a></li> \
<li><a id="superhero" class="dropdown-item rounded-1" href="#" rel="/assets/customcss/superhero.css">Superhero</a></li> \
<li><a id="tempest" class="dropdown-item rounded-1" href="#" rel="/assets/customcss/tempest.css">Tempest</a></li> \
<li><a id="twitter" class="dropdown-item rounded-1" href="#" rel="/assets/customcss/twitter.css">Twitter</a></li> \
</ul> \
</li> \
</div> \
');
I’ve yet to decide how many of the v2 swatches will make their way into v3 on Sudonix -likely candidates will be
- Anthracite
- Darkly
- Facetube
- Midnight
- Nord
- Slate
- Superhero
- Tempest
- Twitter
Also, the “conversational / messenger view” is destined to be scrapped. It looked good at the time, and I know a number of you adopted it for your own forums, but it’s not really “today’s standard” - and, a LOT of effort to code for very little cosmetic return.
Stay tuned for more updates