Skip to content

Custom badges

Solved Customisation
  • @DownPW Something like this?

    879aa7c9-5e97-4c5f-bb82-014524653254-image.png

    CSS modifications

    .topic-owner-post [itemprop="author"] {
        float: left;
    }
    // Add these to (or edit) the existing classes you have
    .user-level-topic {
        float: none;
    }
    .group-label {
        margin-top: -1px;
    }
    .topic-owner-post [itemprop="author"]:after {
        margin-top: 1px;
        height: 18px;
    }
    
  • @phenomlab

    yep but I have not the same result as you with this code :

    24bc3b0a-29a3-45f7-8e6b-bc72f6248bda-image.png

    The username is after the userlevel badge 😒

  • @DownPW Can you put the code back to what I provided? I see you are making changes

  • @DownPW Thanks. Seems I forgot this

    [itemprop="author"] {
        float: left;
    }
    

    And this which will fix the overlap on the reply label

    .topic [component="post/parent"] {
        margin-left: 15px;
    }
    
  • @phenomlab Ha yes very good thanks dude 😉 You’re the best always 😉

  • @crazycells Let’s try this

    In /forum/admin/manage/groups/verified, remove the highlighted section

    1c9e1406-d641-4e6c-8a03-e452c9462768-image.png

    We are then left with no text, but a clearer looking icon

    149c24c4-c95c-4a6e-8dc4-52340e4d0bed-image.png

    Now remove the previous CSS blocks I provided here

    Add replacement CSS

    .post-header a[href*="/forum/groups/verified"] {
        margin-right: 3px;
        margin-top: 1px;
        border-radius: 50%;
        line-height: 20px;
        display: inline-block;
        vertical-align: middle;
        text-align: center;
        overflow: hidden;
    }
    small.label.group-label.inline-block i {
        margin-top: 1px;
        margin-left: 0px;
        vertical-align: middle;
        justify-content: center;
        display: flex;
    }
    .post-header a[href*="/forum/groups/verified"] .group-label {
        min-width: 20px;
        display: flex;
        justify-content: center;
    }
    .group-label {
        vertical-align: -6px;
    }
    
    

    You should land up with something like this

    16a50d49-f765-46c9-a480-344a592baf13-image.png

    As you can see, this forces the stars out of alignment, but I don’t think this is too much of a sacrifice, and could be remediated with additional targeted CSS if need be.

    Essentially, because NodeBB doesn’t provide an id field (which would be a lot easier), we have to use wildcard CSS such as .post-header a[href*="/forum/groups/verified"] but make it targeted in the sense that it will only fire if it is part of the post stream, hence .post-header at the beginning.

    We then use .post-header a[href*="/forum/groups/verified"] .group-label to target the actual label (but only when we have a wildcard match in the CSS) meaning we can set a minimum width so that the circle doesn’t look quashed (we need to validate this on Firefox though as additional CSS might be required due to how the webkit engine will render this in contrast to mozilla).

    Finally, we use .group-label to force alignment in terms of height to prevent it wandering out of the inline-block.

    This is already active on your forum, so nothing for you to do but (hopefully) admire 🙂

    Let me know.

  • phenomlabundefined phenomlab referenced this topic on
  • @phenomlab

    Just one things my friend.

    I search a css class for display groupname on group icons mouse over but don’t find it.
    if you have that in your hat I’m a taker 😉

  • @DownPW Mmmmm, yes, the fastest way to do that would be to use the title attribute. Bootstrap has native support for that

    8e9af7a4-b69c-4573-93cb-72dce2d8bcf3-image.png

    If you added this attribute then hovered over the element, you’d see this

    4cd5440b-649f-4817-be85-08ff54a8859b-image.png

    It’s possible to write jQuery to handle this - aside from that, you’d need to hack into the post template which I wouldn’t recommend. There isn’t any native CSS that will do this for you sadly, so the title="" attribute is the best way forward but won’t do anything without custom JS.

    EDIT - I actually have a requirement for this myself, so will probably write some code to do it over the coming days/weeks (really depending on how much free time I have).

  • @phenomlab thank you very much 🙂 it looks great!

  • crazycellsundefined crazycells has marked this topic as solved on
  • @phenomlab said in Custom badges:

    It’s possible to write jQuery to handle this - aside from that, you’d need to hack into the post template which I wouldn’t recommend. There isn’t any native CSS that will do this for you sadly, so the title=“” attribute is the best way forward but won’t do anything without custom JS.
    EDIT - I actually have a requirement for this myself, so will probably write some code to do it over the coming days/weeks (really depending on how much free time I have).

    very clever the addition of this “Title=” attribute, I would not have thought of it myself !! Cheer !!

    This is exactly the result I’m looking for !
    I don’t even know why, I’m not amazed at your prowess anymore 🙂

    Excellent 😉

  • @phenomlab lol verified badge changed here as well 🙂

    is there an easy CSS code to make it look more like a flower, rather than perfectly round? (just like the Twitter one)

  • @crazycells it’s possible, but would be very complex. Much less hassle to use either a direct image (which probably won’t look very good on scale) or use this SVG from Font Awesome which appears to be free 👍

    https://fontawesomeicons.com/svg/icons/twitter-verified-badge

  • @phenomlab since both admin and global moderator badges are close to purple/maroon color, you can change one to green (which I believe was the verified badge color)

  • @crazycells yes, I need to change that here. Was switched out on a whim.

  • @crazycells @DownPW something of a “fresher” approach. Have a look at the below

    5602e864-6de6-4a09-9dd1-eb33b2807774-image.png

    Using the messenger type view I created, it then becomes possible to place the “verified” group according to the style from the same view.

    This does mean some new CSS

    .self-post a[href*="/groups/verified"] .group-label {
        position: absolute !important;
        right: 51px;
        top: 44px;
    }
    .topic-response-post a[href*="/groups/verified"] .group-label {
        position: absolute !important;
        left: 20px;
        top: 44px;
    }
    .topic-response-post i[component="user/status"] {
        position: absolute;
        left: -1px;
    }
    

    And, more importantly, I found a more efficient way of adding classes in the messenger view js. The revised code is below

    // Target those elements already loaded in the DOM
    $(document).ready(function() {
        $(window).on('action:ajaxify.end', function(data) {
            $('li[component="post"]').each(function(i, obj) {
                if (!$(this).hasClass('self-post') || (!$(this).hasClass('self-post'))) {
                    console.log("Adding required classes for messenger type view");
                    $(this).addClass('topic-response-post');
                }
    
            });
        });
    });
    // Target elements dynamically added to the DOM on post load
    $(document).ready(function() {
        $(window).on('action:ajaxify.loaded', function(data) {
            $('li[component="post"]').each(function(i, obj) {
                if (!$(this).hasClass('self-post') || (!$(this).hasClass('self-post'))) {
                    console.log("Adding required classes for messenger type view");
                    $(this).addClass('topic-response-post');
                }
    
            });
        });
    });
    
  • @phenomlab this looks cooler than usual badges 👍 thanks for the codes…

    but, I believe it should be located slightly lower since there is already a status circle that is taking some space from the avatar, and now this is taking more 🙂 it feels like you are conversing with someone that has sunglasses, a scarf, and a hat 😄 I prefer to see their faces more clearly (well, in this case avatar 😄 )

  • @crazycells ha! Yes, I see your point. I guess it’s down to taste, and thanks to the absolute positioning, you can easily customise to suit taste.

    It’s also worth noting that on here at least, this will only trigger on larger monitors - it would look awful on mobile devices in my view.

  • @phenomlab yes 😄 I agree with you.

    How do you achieve the restriction? I cannot see any screen resolution definition…


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
  • CSS code customization for the link preview plugin

    Solved Customisation
    4
    3 Votes
    4 Posts
    597 Views

    @crazycells said in CSS code customization for the link preview plugin:

    does OGProxy show the pdf previews as well?

    Not yet, but it could with a bit of additional code.

  • Page control arrows for PWA

    Solved Customisation
    27
    25 Votes
    27 Posts
    1k Views

    @crazycells it is, yes - I think I’ll leave it as there is no specific PWA CSS classes I know of. Well, you could use something like the below, but this means multiple CSS files for different operating systems.

    /** * Determine the mobile operating system. * This function returns one of 'iOS', 'Android', 'Windows Phone', or 'unknown'. * * @returns {String} */ function getMobileOperatingSystem() { var userAgent = navigator.userAgent || navigator.vendor || window.opera; // Windows Phone must come first because its UA also contains "Android" if (/windows phone/i.test(userAgent)) { return "Windows Phone"; } if (/android/i.test(userAgent)) { return "Android"; } if (/iPad|iPhone|iPod/.test(userAgent) && !window.MSStream) { return "iOS"; } return "unknown"; // return “Android” - one should either handle the unknown or fallback to a specific platform, let’s say Android }

    Once you’re in that rabbit hole, it’s impossible to get out of it.

  • 3 Votes
    5 Posts
    335 Views

    @crazycells Agreed. It takes a more sensible approach. Nobody ever upvotes the first post - it’s usually much further down as the conversation progresses.

  • Nodebb design

    Solved General
    2
    1 Votes
    2 Posts
    282 Views

    @Panda said in Nodebb design:

    One negative is not being so good for SEO as more Server side rendered forums, if web crawlers dont run the JS to read the forum.

    From recollection, Google and Bing have the capability to read and process JS, although it’s not in the same manner as a physical person will consume content on a page. It will be seen as plain text, but will be indexed. However, it’s important to note that Yandex and Baidu will not render JS, although seeing as Google has a 90% share of the content available on the web in terms of indexing, this isn’t something you’ll likely lose sleep over.

    @Panda said in Nodebb design:

    The “write api” is preferred for server-to-server interactions.

    This is mostly based around overall security - you won’t typically want a client machine changing database elements or altering data. This is why you have “client-side” which could be DOM manipulation etc, and “server-side” which performs more complex operations as it can communicate directly with the database whereas the client cannot (and if it can, then you have a serious security flaw). Reading from the API is perfectly acceptable on the client-side, but not being able to write.

    A paradigm here would be something like SNMP. This protocol exists as a UDP (UDP is very efficient, as it is “fire and forget” and does not wait for a response like TCP does) based service which reads performance data from a remote source, thus enabling an application to parse that data for use in a monitoring application. In all cases, SNMP access should be “RO” (Read Only) and not RW (Read Write). It is completely feasible to assume complete control over a firewall for example by having RW access to SNMP and then exposing it to the entire internet with a weak passphrase.

    You wouldn’t do it (at least, I hope you wouldn’t) and the same ethic applies to server-side rendering and the execution of commands.

  • Email validation NodeBB

    Bugs
    21
    3 Votes
    21 Posts
    1k Views

    @Panda said in Email validation NodeBB:

    Did you configure that as a custom change to the usual quote icon. How do you do that?
    I notice on NodeBB site its a solid blue quotes

    Yes, I changed it. NodeBB by default users the free font awesome library whereas I use the pro (paid) version SDK have access to a wider set of icons, and at different thicknesses etc. The change of colour is just simple CSS.

  • The best css to customize our logo?

    Solved Customisation
    2
    1 Votes
    2 Posts
    448 Views

    @Sala This should look better

    .sidenav .navbar-brand { padding-top: 0.5rem; padding-bottom: 0.5rem; }

    e5cec20e-be36-4ee8-9129-fd11ad4656ac-image.png

    You can increase the top and bottom padding by increasing the values above.

  • [NodeBB] Custom fields plugin

    Unsolved Customisation
    5
    0 Votes
    5 Posts
    906 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 ?

  • [NodeBB] First post customization

    Solved Customisation
    5
    4 Votes
    5 Posts
    711 Views

    @phenomlab thanks 🙏