Skip to content

Custom badges

Solved Customisation
103 4 25.6k 2
  • @DownPW said in Custom badges:

    good job @crazycells

    I wonder if we could do it for each badge without changing the color of course and keep the color of the original badges.

    Curious to see what it would look like ๐Ÿ˜‰

    no, this does not work. the overlap of a wavy edge circle and a circle becomes a circle. so, you cannot detect any flower shape with this method. The way that I achieved this was by removing the background color (making it transparent by CSS although there is an assigned color for it in ACP) and then creating a new flower shape on top of it by CSS.

    @crazycells just thinking about this. Wouldnโ€™t it be easier to just use font awesome?

    https://fontawesome.com/icons/badge-check?f=classic&s=solid

    Screenshot_2023-05-29-23-46-30-51_e4424258c8b8649f6e67d283a50a2cbc.jpg

  • @crazycells just thinking about this. Wouldnโ€™t it be easier to just use font awesome?

    https://fontawesome.com/icons/badge-check?f=classic&s=solid

    Screenshot_2023-05-29-23-46-30-51_e4424258c8b8649f6e67d283a50a2cbc.jpg

    @phenomlab said in Custom badges:

    @crazycells just thinking about this. Wouldnโ€™t it be easier to just use font awesome?

    https://fontawesome.com/icons/badge-check?f=classic&s=solid

    Screenshot_2023-05-29-23-46-30-51_e4424258c8b8649f6e67d283a50a2cbc.jpg

    as far as I remember, we discussed this before and you mentioned that that badge is not in the free tier.

  • @phenomlab said in Custom badges:

    @crazycells just thinking about this. Wouldnโ€™t it be easier to just use font awesome?

    https://fontawesome.com/icons/badge-check?f=classic&s=solid

    Screenshot_2023-05-29-23-46-30-51_e4424258c8b8649f6e67d283a50a2cbc.jpg

    as far as I remember, we discussed this before and you mentioned that that badge is not in the free tier.

  • @phenomlab said in Custom badges:

    @crazycells just thinking about this. Wouldnโ€™t it be easier to just use font awesome?

    https://fontawesome.com/icons/badge-check?f=classic&s=solid

    Screenshot_2023-05-29-23-46-30-51_e4424258c8b8649f6e67d283a50a2cbc.jpg

    as far as I remember, we discussed this before and you mentioned that that badge is not in the free tier.

    @crazycells This intrigued me somewhat, I wonโ€™t lie ๐Ÿ™‚ I decided to take a stab at this myself.

    HTML

    <!DOCTYPE html>
    <html>
    <head>
    <script src="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.4.0/js/all.min.js" integrity="sha512-fD9DI5bZwQxOi7MhYWnnNPlvXdp/2Pj3XSTRrFs5FQa4mizyGLnJcN6tuvUS6LbmgN1ut+XGSABKvjN0H6Aoow==" crossorigin="anonymous" referrerpolicy="no-referrer"></script>
    <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.4.0/css/all.min.css" integrity="sha512-iecdLmaskl7CVkqkXNQ/ZH/XLlvWZOJyj7Yy7tcenmpD1ypASozpmT/E0iPtmFIB46ZmdtAc9eNBvH0H/ZpiBw==" crossorigin="anonymous" referrerpolicy="no-referrer" />
    <meta charset=utf-8 />
    <title>JS Bin</title>
    </head>
    <body>
      <div class="base"></div>
      <div class="inner"><i class="check fa-solid fa-check"></i></div>
    </body>
    </html>
    

    CSS

    .base {
      left: 100px;
      top: 100px;
      height: 80px;
      width: 80px;
      background: #067acc;
      position: absolute;
      border-radius: 10px;
    }
    .base:before {
      height: 80px;
      width: 80px;
      background: #067acc;
      content:"";
      position: absolute;
      transform: rotate(-30deg);
      border-radius: 10px;
    }
    .base:after {
      padding-top: 10px;
      text-align: center;
      vertical-align: middle;
      height: 70px;
      width: 80px;
      background: #067acc;
      content: "";
      position: absolute;
      transform: rotate(30deg);
      border-radius: 10px;
    }
    .inner {
      color: #000000;
      left: 95px;
      top: 95px;
      position: absolute;
      text-align:center;
      padding-top: 25px;
      width: 90px;
      height: 65px;
      background: #067acc;
      border-radius: 50px;
      background: #067acc; /* Old browsers */
    }
    .check {
      font-size: 36px;
      color: #ffffff;
    }
    

    Hereโ€™s the result

    https://codepen.io/sudonix/pen/qBJGMRL

  • @crazycells This intrigued me somewhat, I wonโ€™t lie ๐Ÿ™‚ I decided to take a stab at this myself.

    HTML

    <!DOCTYPE html>
    <html>
    <head>
    <script src="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.4.0/js/all.min.js" integrity="sha512-fD9DI5bZwQxOi7MhYWnnNPlvXdp/2Pj3XSTRrFs5FQa4mizyGLnJcN6tuvUS6LbmgN1ut+XGSABKvjN0H6Aoow==" crossorigin="anonymous" referrerpolicy="no-referrer"></script>
    <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.4.0/css/all.min.css" integrity="sha512-iecdLmaskl7CVkqkXNQ/ZH/XLlvWZOJyj7Yy7tcenmpD1ypASozpmT/E0iPtmFIB46ZmdtAc9eNBvH0H/ZpiBw==" crossorigin="anonymous" referrerpolicy="no-referrer" />
    <meta charset=utf-8 />
    <title>JS Bin</title>
    </head>
    <body>
      <div class="base"></div>
      <div class="inner"><i class="check fa-solid fa-check"></i></div>
    </body>
    </html>
    

    CSS

    .base {
      left: 100px;
      top: 100px;
      height: 80px;
      width: 80px;
      background: #067acc;
      position: absolute;
      border-radius: 10px;
    }
    .base:before {
      height: 80px;
      width: 80px;
      background: #067acc;
      content:"";
      position: absolute;
      transform: rotate(-30deg);
      border-radius: 10px;
    }
    .base:after {
      padding-top: 10px;
      text-align: center;
      vertical-align: middle;
      height: 70px;
      width: 80px;
      background: #067acc;
      content: "";
      position: absolute;
      transform: rotate(30deg);
      border-radius: 10px;
    }
    .inner {
      color: #000000;
      left: 95px;
      top: 95px;
      position: absolute;
      text-align:center;
      padding-top: 25px;
      width: 90px;
      height: 65px;
      background: #067acc;
      border-radius: 50px;
      background: #067acc; /* Old browsers */
    }
    .check {
      font-size: 36px;
      color: #ffffff;
    }
    

    Hereโ€™s the result

    https://codepen.io/sudonix/pen/qBJGMRL

    @phenomlab is there a problem in the forum?

    Screen Shot 2023-05-30 at 11.30.13.png

    I refreshed several times, nothing changedโ€ฆ

  • @phenomlab is there a problem in the forum?

    Screen Shot 2023-05-30 at 11.30.13.png

    I refreshed several times, nothing changedโ€ฆ

    @crazycells Sorry, yes. Fixed that now.

  • @crazycells Sorry, yes. Fixed that now.

    @phenomlab it looks very nice ๐Ÿ™‚ but I guess one needs a subscription to use this, right?

    I am looking forward to seeing that on the avatars as โ€œverified badgeโ€, please do not forget to share your CSS code for its position ๐Ÿ˜† when you implement it.

  • @phenomlab it looks very nice ๐Ÿ™‚ but I guess one needs a subscription to use this, right?

    I am looking forward to seeing that on the avatars as โ€œverified badgeโ€, please do not forget to share your CSS code for its position ๐Ÿ˜† when you implement it.

    @crazycells said in Custom badges:

    it looks very nice but I guess one needs a subscription to use this, right?

    No, thereโ€™s no subscription - what do you see ? The CodePen should be public?

  • @crazycells said in Custom badges:

    it looks very nice but I guess one needs a subscription to use this, right?

    No, thereโ€™s no subscription - what do you see ? The CodePen should be public?

    @phenomlab yes I can see it very well:

    Screen Shot 2023-05-30 at 11.48.30.png

    since your code has โ€œ/font-awesome/6.4.0/โ€ in it, I assumed you are using pro version.

  • @phenomlab yes I can see it very well:

    Screen Shot 2023-05-30 at 11.48.30.png

    since your code has โ€œ/font-awesome/6.4.0/โ€ in it, I assumed you are using pro version.

    @crazycells No, itโ€™s the free version

    https://cdnjs.com/libraries/font-awesome

    You only need the check mark itself ๐Ÿ™‚

  • @crazycells No, itโ€™s the free version

    https://cdnjs.com/libraries/font-awesome

    You only need the check mark itself ๐Ÿ™‚

    @phenomlab great then, are you planning to implement it on this forum?

    I need to tailor the code for my forumโ€ฆ

  • @phenomlab great then, are you planning to implement it on this forum?

    I need to tailor the code for my forumโ€ฆ

    @crazycells Yes, I think I probably will.

  • @phenomlab great then, are you planning to implement it on this forum?

    I need to tailor the code for my forumโ€ฆ

    @crazycells Ok, so, I found some time to look at this properly today.

    Hereโ€™s the result

    d735ea48-7d38-444f-9e8b-822196b3c877-image.png

    Notice the โ€œTwitter-esqueโ€ verified badge?

    I found this

    https://commons.wikimedia.org/wiki/File:Twitter_Verified_Badge.svg and downloaded it, then uploaded it to /assets/public/images

    Then, I used the below CSS code

        li[component="post"] a[href*="/groups/verified"] {
            position: absolute !important;
            left: 2px;
            z-index: 2;
            margin-top: 1px;
            border-radius: 999px !important;
            line-height: 14px;
            display: block;
            height: auto;
            margin-left: 0px !important;
            background: transparent !important;
            width: auto;
        }
    
        li[component=post] a[href*="/groups/verified"]:before {
            background: url(https://sudonix.org/assets/images/Twitter_Verified_Badge.svg) !important;
            content: "";
            height: 22px;
            width: 22px;
            display: block;
        }
        li[component=post] a[href*="/groups/verified"]:after {
            background: #ffffff !important;
            height: 9px;
            width: 9px;
            content: "";
            display: block;
            top: 10px;
            position: absolute;
            z-index: -1;
            left: 12px;
        }
    

    Some points to consider

    • The CSS code extensively uses :before and :after pseudo elements. Essentially, :before adds the SVG icon and positions it, and :after adds a smaller โ€œwhite squareโ€ which is conveniently positioned behind the :before element using z:-index: -1;

    The purpose of the โ€œwhite squareโ€ is to provide a dirty way to fill in the transparency which is present in the SVG so it looks right.

    This is pretty tough to display on mobile viewports, so itโ€™s best to hide it completely using this code

    @media (max-width: 767px) {
        li[component="post"] a[href*="/groups/verified"].badge, .account a[href*="/groups/verified"].badge {
                display: none !important;
            }
    

    EDIT: Just realised that this icon (being a group) is also displayed on the userโ€™s profile page, so weโ€™ll need CSS to make that look good tooโ€ฆ

    7744fb9d-2994-4159-9732-d4a717511af0-image.png
    Iโ€™ve absolutely no idea who this guy isโ€ฆ ๐Ÿ™‚

    Here it is

        .account a[href*="/groups/verified"] {
            position: absolute !important;
            z-index: 2;
            background: transparent !important;
            margin-left: -10px;
        }
        .account a[href*="/groups/verified"]:after {
            background: #ffffff !important;
            height: 9px;
            width: 10px;
            content: "";
            display: block;
            top: 10px;
            position: absolute;
            z-index: -1;
            left: 12px;
        }
        .account a[href*="/groups/verified"]:before {
            background: url(https://sudonix.org/assets/images/Twitter_Verified_Badge.svg) !important;
            content: "";
            height: 22px;
            width: 22px;
            display: block;
        }
    

    Enjoy.

  • hello @phenomlab

    I am trying to apply your code for the โ€œallโ€ group which all my members are part of.

    43c6f309-bbfe-41ae-891b-b52a28d04fdd-image.png

    I downlaod the image of the twitter badge in full resolution and upload in the same place and I access it correctly.

    On the other hand it would seem that the badge is displayed badly (cut on the right for the first on the screen) then transparent for the second and on the 3rd it is not displayed aps.

    An idea ?

    image.png

  • hello @phenomlab

    I am trying to apply your code for the โ€œallโ€ group which all my members are part of.

    43c6f309-bbfe-41ae-891b-b52a28d04fdd-image.png

    I downlaod the image of the twitter badge in full resolution and upload in the same place and I access it correctly.

    On the other hand it would seem that the badge is displayed badly (cut on the right for the first on the screen) then transparent for the second and on the 3rd it is not displayed aps.

    An idea ?

    image.png

    @DownPW itโ€™s really hard to see that image. Iโ€™ll need to look at your dev server directly to see whatโ€™s happening here.

  • I just found some answers @phenomlab

    It is absolutely necessary that the user is displaying the badge of the group in his profile:

    18ac2ada-5234-4848-a00b-59e6d3ef1116-image.png

    That the question, How to force put the user in a group ?
    For the rest of the display bugs, I have not yet found.

  • I just found some answers @phenomlab

    It is absolutely necessary that the user is displaying the badge of the group in his profile:

    18ac2ada-5234-4848-a00b-59e6d3ef1116-image.png

    That the question, How to force put the user in a group ?
    For the rest of the display bugs, I have not yet found.

    @DownPW said in Custom badges:

    It is absolutely necessary that the user is displaying the badge of the group in his profile:

    Yes, it wonโ€™t display without that. I donโ€™t know of a way to force it either.

  • If I apply light themes we see better.
    In fact, ther badge is cut on the right and we have the dexcription badge below :

    image.png

  • If I apply light themes we see better.
    In fact, ther badge is cut on the right and we have the dexcription badge below :

    image.png

    @DownPW yes, thatโ€™s just going to be positioning. Remember we are using position: absolute; and your CSS is likely to differ so you may need to tweak the positioning slightly to suit.

  • @crazycells Ok, so, I found some time to look at this properly today.

    Hereโ€™s the result

    d735ea48-7d38-444f-9e8b-822196b3c877-image.png

    Notice the โ€œTwitter-esqueโ€ verified badge?

    I found this

    https://commons.wikimedia.org/wiki/File:Twitter_Verified_Badge.svg and downloaded it, then uploaded it to /assets/public/images

    Then, I used the below CSS code

        li[component="post"] a[href*="/groups/verified"] {
            position: absolute !important;
            left: 2px;
            z-index: 2;
            margin-top: 1px;
            border-radius: 999px !important;
            line-height: 14px;
            display: block;
            height: auto;
            margin-left: 0px !important;
            background: transparent !important;
            width: auto;
        }
    
        li[component=post] a[href*="/groups/verified"]:before {
            background: url(https://sudonix.org/assets/images/Twitter_Verified_Badge.svg) !important;
            content: "";
            height: 22px;
            width: 22px;
            display: block;
        }
        li[component=post] a[href*="/groups/verified"]:after {
            background: #ffffff !important;
            height: 9px;
            width: 9px;
            content: "";
            display: block;
            top: 10px;
            position: absolute;
            z-index: -1;
            left: 12px;
        }
    

    Some points to consider

    • The CSS code extensively uses :before and :after pseudo elements. Essentially, :before adds the SVG icon and positions it, and :after adds a smaller โ€œwhite squareโ€ which is conveniently positioned behind the :before element using z:-index: -1;

    The purpose of the โ€œwhite squareโ€ is to provide a dirty way to fill in the transparency which is present in the SVG so it looks right.

    This is pretty tough to display on mobile viewports, so itโ€™s best to hide it completely using this code

    @media (max-width: 767px) {
        li[component="post"] a[href*="/groups/verified"].badge, .account a[href*="/groups/verified"].badge {
                display: none !important;
            }
    

    EDIT: Just realised that this icon (being a group) is also displayed on the userโ€™s profile page, so weโ€™ll need CSS to make that look good tooโ€ฆ

    7744fb9d-2994-4159-9732-d4a717511af0-image.png
    Iโ€™ve absolutely no idea who this guy isโ€ฆ ๐Ÿ™‚

    Here it is

        .account a[href*="/groups/verified"] {
            position: absolute !important;
            z-index: 2;
            background: transparent !important;
            margin-left: -10px;
        }
        .account a[href*="/groups/verified"]:after {
            background: #ffffff !important;
            height: 9px;
            width: 10px;
            content: "";
            display: block;
            top: 10px;
            position: absolute;
            z-index: -1;
            left: 12px;
        }
        .account a[href*="/groups/verified"]:before {
            background: url(https://sudonix.org/assets/images/Twitter_Verified_Badge.svg) !important;
            content: "";
            height: 22px;
            width: 22px;
            display: block;
        }
    

    Enjoy.

    hi @phenomlab, we should be able to download thisโ€ฆ

    https://commons.wikimedia.org/wiki/File:Twitter_Verified_Badge.svg

    โ€ฆand recolor it accordingly and upload it to the forum the same way, right? These colors are reminding everyone โ€œtwitterโ€ , I believe it would be nicer if it is changed according to the personality of the forum, so it will look more original while maintaining โ€œmeaningโ€โ€ฆ

    I think here on this forum, โ€œsudonix orangeโ€ color would look cooler than โ€œtwitter blueโ€


Did this solution help you?
Did you find the suggested solution useful? Support ๐Ÿ’— Sudonix with a coffee โ˜•
If your organisation needs deeper expertise around infrastructure, security, or technology leadership, learn more about Phenomlab Ltd. Many of the deeper technical guides behind Sudonix are published there.

Related Topics
  • Custom Page - nodebb

    Solved Customisation custom-pages nodebb
    13
    2
    5 Votes
    13 Posts
    137 Views
    Iโ€™m happy to see this
  • how to hide "moved" badge with CSS?

    Solved Customisation nodebb
    12
    1
    3 Votes
    12 Posts
    2k Views
    @crazycells ah, I see. That makes sense.
  • 1 Votes
    1 Posts
    725 Views
    No one has replied
  • The best css to customize our logo?

    Solved Customisation css
    2
    1 Votes
    2 Posts
    1k Views
    @Sala This should look better .sidenav .navbar-brand { padding-top: 0.5rem; padding-bottom: 0.5rem; } [image: 1669026666905-e5cec20e-be36-4ee8-9129-fd11ad4656ac-image.png] You can increase the top and bottom padding by increasing the values above.
  • Gettin Erors NodeBB

    Solved Configure nodebb eror
    7
    0 Votes
    7 Posts
    1k Views
    @phenomlab no forum is working goods. there is no eror message since yestarday.
  • How to downgrade plugin version on NodeBB

    Solved Customisation downgrade nodebb
    11
    3 Votes
    11 Posts
    2k Views
    @cagatay no problems
  • NodeBB templates

    Locked Chitchat themes templates nodebb
    12
    4 Votes
    12 Posts
    3k Views
    Placing this here for reference https://sudonix.com/topic/216/nodebb-js-script-css-theme-switcher Further information and posts can be found at this link
  • [NODEBB] Help for my custom CSS

    Solved Customisation nodebb css bugfix
    237
    49 Votes
    237 Posts
    80k Views
    @baris said: You should change your selectors so it doesnโ€™t look at the entire document. You probably only want to apply fancybox to stuff inside the #content element which is what changes when the user navigates around the page. So use $('#content a').... for your selectors then the forum logo in the header wonโ€™t be selected. I modified the JS Fancybox code now and this code and it seem better // --------------------------------------------- // Fancybox Media Reader (Without Website Logo) // --------------------------------------------- if (top.location.pathname !== '/login') { $(window).on('action:posts.loaded', function(data) { console.log("Polling DOM for lazyLoaded images to apply Fancybox"); $(document).ready(function() { $('#content a').not('.forum-logo').not(".avatar").not(".emoji").not(".bmac-noanimate").each(function() { $('#content a[href*=".jpg"], #content a[href*=".jpeg"], #content a[href*=".png"], #content a[href*=".gif"], #content a[href*=".webp"]').addClass("noanimate"); }); }); }); } if (top.location.pathname !== '/login') { $(document).ready(function() { $(window).on('action:ajaxify.end', function(data) { $('#content a').not('.logo').not(".avatar").not(".emoji").not(".bmac-noanimate").each(function() { $('#content a[href*=".jpg"], #content a[href*=".jpeg"], #content a[href*=".png"], #content a[href*=".gif"], #content a[href*=".webp"]').addClass("noanimate"); data.preventDefault() // Strip out the images contained inside blockquotes as this looks nasty :) $('#content blockquote img').remove(); }); Fancybox.bind( '#content a[href*=".jpg"], #content a[href*=".jpeg"], #content a[href*=".png"], #content a[href*=".gif"], #content a[href*=".webp"]', { groupAll: true, } ); }); }); } // Chat fancybox - fires when chat module loaded and AJAX calls new chat $(document).ready(function() { $(window).on('action:chat.loaded', function(data) { // >>> Se limiter au contenu principal uniquement <<< $('#content img').not('.forum-logo').not(".avatar").not(".emoji").not(".bmac-noanimate").each(function() { var newHref = $(this).attr("src"); $(this).wrap("<a class='fancybox' href='" + newHref + "'/>"); $('#content a[href*=".jpg"], #content a[href*=".jpeg"], #content a[href*=".png"], #content a[href*=".gif"], #content a[href*=".webp"]').addClass("noanimate"); data.preventDefault(); // Strip out the images contained inside blockquotes as this looks nasty :) $('#content blockquote img').remove(); }); Fancybox.bind( '#content a[href*=".jpg"], #content a[href*=".jpeg"], #content a[href*=".png"], #content a[href*=".gif"], #content a[href*=".webp"]', { groupAll: true, } ); }); }); For the logo, I must use overflow: visible !important; on [component="brand/logo"] /* --- Logo --- */ [component="brand/logo"] { max-height: 50px; width: auto; height: auto; max-width: 100%; display: block; object-fit: contain; object-position: left center; overflow: visible !important; } Better result !!