Skip to content

[NODEBB] CSS Style Sheets SelectBox

Locked Solved Customisation
  • @downpw Having looked at this, it will indeed require jQuery. Iโ€™m going to look further into this today hopefully.

  • @phenomlab

    Great man ๐Ÿ™‚

    On the default theme. All itโ€™s perfect !!!
    Thatโ€™s why I thought of a CSS problem. Like a variable that I would have forgotten for example

  • @downpw Yes, I saw that. Let me know when the server is available and Iโ€™ll have a look.

  • On 1 hour

  • @downpw Iโ€™ve been able to get somewhere near this with the below custom function Iโ€™ve written

    	    $(window).on('action:ajaxify.end', function(data) {
    	        // Detect if the theme dropdown has been clicked. If it has, change the color to #000000
    	        $("#switcher").on("click", function() {
    	            $("#switcher i").css("color", "#000000");
    	        });
    	        // Detect if the theme dropdown has lost focus (clicked something else). If it has, change the color to #FFFFFF
    	        $("#switcher").on("focusout", function() {
    	            $("#switcher i").css("color", "#ffffff");
    	        });
    	    });
    

    Test it and let me know ? Iโ€™ve already added it, so you donโ€™t need to do anything.

  • @phenomlab

    It seems to be better when dropdown ๐Ÿ˜‰
    But when I lost focus, sometimes the icon donโ€™t back again:

    Example here :
    0029c6f2-ae59-48ff-82a7-97e7e92fdb2d-image.png

    EDIT : see, I have recorded a gif

    The problem came on default theme too but itโ€™s normal because itโ€™s a javascript for all the site

    5c31ab54-4d9d-4183-8e97-80abd0850527-image.png https://imgur.com/a/2oSdcC3

  • @downpw thanks. Might need some tweaking to get it 100% but itโ€™s a start. Will have a more detailed look at this as time permits. Iโ€™m back at work as of Monday โ˜บ๏ธ

  • @phenomlab Of course it is a very good basis for work.

  • @downpw Small modification to address the default theme icon bug (displayed white when focus lost, when it should be black)

    // Bugfix theme switcher button when dropdown / Focus / Not focus
    $(window).on('action:ajaxify.end', function(data) {
        var whichTheme = localStorage.getItem("theme");
        if (whichTheme === '') {
            // Assume default theme and set icon color to #000000
            $("#switcher i").css("color", "#000000");
        }
        if (whichTheme !== '') {
            // Assume color theme and set icon color to #ffffff
            $("#switcher i").css("color", "#ffffff");
        }
        // Detect if the theme dropdown has been clicked. If it has, change the color to #000000
        $("#switcher").on("click", function() {
            $("#switcher i").css("color", "#000000");
        });
        // Detect if the theme dropdown has lost focus (clicked something else). If it has, change the color to #FFFFFF
        $("#switcher").on("focusout", function() {
            $("#switcher i").css("color", "#ffffff");
        });
    });
    

    Active now, and should also address the other bug you mentioned.

  • @phenomlab

    I have tested but sorry itโ€™s the same problem.

  • @downpw Can you reload the page and try again.

  • Yeah i delete cache and Ctrl + F5

    The problem come when I donโ€™t click on fa-fw but background.

    Like this :

    95b7fce2-8708-4e32-bdb9-6fbd107ddb5c-image.png

    On fa-fw = No problem

  • @downpw Ok, do the default theme issue is fixed, but you still see the white icon when clicking the background and not the icon itself ?

  • @downpw Try now

  • nope itโ€™s the same even on fa-fw and default theme

    but as you are connected you have to see it.

  • @downpw Right. I think I finally have this working ๐Ÿ™‚

    Iโ€™ve added this into your global CSS - donโ€™t delete it

    .themeon {
        color: #000000 !important;
    }
    .themeoff {
        color: #ffffff !important;
    }
    

    Final modified JS

    // Bugfix theme switcher button when dropdown / Focus / Not focus
    	$(document).ready(function () {
    	// First, detect which theme is in use
        var whichTheme = localStorage.getItem("theme");
        // Is the target dropdown expanded ? Use aria-expanded for this as it populates into the DOM on change making it easier to work with. 
        // If it is expanded, then we set the icon to WHITE with CSS class "themeon"
          if ($('#theme_dropdown').attr('aria-expanded') === "true") {
             $("#switcher i").addClass("themeon");
          }
        // If it is collapsed, then we set the icon to BLACK with CSS class "themeoff"
          if ($('#theme_dropdown').attr('aria-expanded') === "false") {
             $("#switcher i").addClass("themeoff");
          }
          // If we are using the default theme, deploy CSS "themeoff" and set the icon to BLACK
              if (whichTheme === '') {
          // If no other matches, assume the default theme, deploy CSS "themeoff" and set the icon to BLACK
             $("#switcher i").removeClass("themeoff");
        }
    });
    

    According to my testing, this works ๐Ÿ™‚

  • clear and simple explanations.
    Perfect ๐Ÿ˜‰

    I donโ€™t know if I should say this butโ€ฆ I love you ha ha ๐Ÿ˜†

  • @downpw Some last changes to address small bugs. The below CSS has been added

    /* DO NOT DELETE THESE LINES */
    [aria-expanded="true"] a #ticon {
        color: #000000;
    }
    
    .themeon {
        color: #ffffff !important;
    }
    .themeoff {
        color: #000000 !important;
    }
    
    
    

    And also to the mobile block

    /* DO NOT DELETE THESE LINES */
    [aria-expanded="true"] a #ticon {
        color: #ffffff;
    }
    .themeoff {
        color: #ffffff !important;
    }
    

    Finally, a new function

    // When hovering over the #switcher element, target the i class and add 'themeoff'
      $(document).on('mouseenter','#switcher', function() {
    		$('#switcher i').addClass("themeoff");
    });
    // When leaving the however state, target the i class and remove 'themeoff'
      $(document).on('mouseleave','#switcher', function() {
    		$('#switcher i').removeClass("themeoff");
    });
    

    This block should be deleted

    /*
    // Bugfix theme switcher button when dropdown / Focus / Not focus
    	$(document).ready(function () {
    	// First, detect which theme is in use
    	// Tout d'abord, on dรฉtecte quel thรจme est utilisรฉ
        var whichTheme = localStorage.getItem("theme");
        // Is the target dropdown expanded ? Use aria-expanded for this as it populates into the DOM on change making it easier to work with. 
        // If it is expanded, then we set the icon to WHITE with CSS  class "themeon"
        // On utilise "aria-expanded" pour savoir si le menu dรฉroulant est actif/dรฉvelopรฉ car la variable se remplit dans le DOM en cas de changement, ce qui facilite le travail avec.
        // Si le menu est actif/dรฉvelopรฉ, on dรฉfinit l'icรดne en BLANC avec la classe CSS "themeon"
          if ($('#theme_dropdown').attr('aria-expanded') === "true") {
             $("#switcher i").addClass("themeon");
          }
        // If it is collapsed, then we set the icon to BLACK with CSS  class "themeoff"
        // S'il est rรฉduit/non actif, nous dรฉfinissons l'icรดne sur NOIR avec la classe CSS "themeoff"
          if ($('#theme_dropdown').attr('aria-expanded') === "false") {
              console.log("Theme selector is not active");
             $("#switcher i").addClass("themeoff");
          }
          // If we are using the default theme, deploy CSS "themeoff" and set the icon to BLACK
          // Si on utilise le thรจme par dรฉfaut, on utilise le CSS "themeoff" et on dรฉfinit l'icรดne sur NOIR
              if (whichTheme === '') {
          // If no other matches, assume the default theme, deploy CSS  "themeoff" and set the icon to BLACK
          // Si rien ne correspond, on utilise le thรจme par dรฉfaut, on utilise le CSS "themeoff" et on dรฉfinit l'icรดne sur NOIR
             $("#switcher i").removeClass("themeoff");
        }
    });
    */
    
  • DownPWundefined DownPW referenced this topic on
  • @phenomlab

    Itโ€™s possible to add a reload at the end of the script ?

    Because, I just saw this:

    if certain CSSS variables are declared in one theme and not in the other, when I Switch themes, the CSS was applied but not correctly. If i refresh itโ€™s OK.

    I seem to have 2 solutions:

    • Declare all variables in each theme even if they are not used in others (with or without !important)

    • Reload the page after selecting a theme.

    Or maybe you have another solution.

  • @downpw in most cases, the best way to handle this is to strip one CSS file before you add the other. However, as your CSS file is actually an extension of the main theme (in the sense that stock theme provides default variables and your custom theme overrides these), this will not work as the required CSS for the site to run properly will be missing.

    Reloading the site will work, but itโ€™s not really the way to go as all the resources will need to be loaded again, and this defeats the purpose of jQuery in the sense that it is Ajax backed meaning the DOM should already contain the targets to be changed.

    If reloading solves the issue, then ok. Admittedly, we have to do this with the default theme when selected to ensure we strip all previously loaded CSS from the custom themes.


Did this solution help you?
Did you find the suggested solution useful? Why not buy me a coffee? It's a nice gesture, and a great way to show your appreciation ๐Ÿ’—

Related Topics
  • How to style tool tip of nodebb-plugin-user-level

    Solved Customisation
    4
    5 Votes
    4 Posts
    719 Views

    @DownPW thanks. I forgot about that.

  • Changing Background on NodeBB

    Solved Customisation
    4
    0 Votes
    4 Posts
    634 Views

    @cagatay Youโ€™d target the body tag and use the below line of CSS

    background: url(/assets/customcss/backgrounds/default/default.png) no-repeat center center fixed;

    Obviously, you need to change the path to suit where your image is being stored.

    More info around the background property can be found here

    https://www.w3schools.com/cssref/css3_pr_background.php

  • 9 Votes
    32 Posts
    3k Views

    @DownPW said in Bottom footer navbar button extend:

    Oh my god, itโ€™s beautiful mark

    I liked this design so much, Iโ€™ve implemented it here. I intend to do a lot more with the footer in due course, so hiding it makes a lot of sense. Thanks @DownPW for the idea and initial concept โ™ฅ

  • CSS3: Gradient Generator

    Development
    1
    1 Votes
    1 Posts
    220 Views
    No one has replied
  • Fontawesome 5

    Unsolved Customisation
    14
    1 Votes
    14 Posts
    894 Views

    @pwsincd hi. Just following up on this thread (I know itโ€™s old) but was curious to understand if itโ€™s still an issue or not ?

  • Multiple link on one ico non Navbar

    Solved Customisation
    7
    2 Votes
    7 Posts
    537 Views

    yeah youโ€™re right @phenomlab.
    Problem of NodeBB Version

  • NodeBB Design help

    Solved Customisation
    8
    2 Votes
    8 Posts
    965 Views

    @riekmedia Iโ€™ve applied some new CSS to your site. Can you reload the page and try again ?

    For the record, this is what I added

    #footer { background: #2d343e; border-top: 4px solid #2d343e; font-size: 0.9em; margin-top: 70px; padding: 80px 0 0; position: relative; clear: both; bottom: 0; left: 0; right: 0; z-index: 1000; margin-left: -15px; margin-right: -338px; }

    The /categories page seems a bit messed up, so looking at that currently

    EDIT - issued some override CSS in the CATEGORIES widget

    <!--- CSS fix for overspill on /categories page - DO NOT DELETE --> <style> #footer { margin-right: -45px; } </style>

    That should resolve the /categories issue.

  • CSS Help on my Flarum

    Solved Customisation
    5
    2 Votes
    5 Posts
    570 Views

    @mike-jones Yes, youโ€™ll typically see this type of behaviour if there is another style that has higher priority in the sense that yours will be overridden. Using !important will override the higher preference, but should be used sparingly rather than everywhere.