Alien Night Theme - A free Dark Theme for Discourse

28067 views 78 replies Created 2016-12-13 10:36
:discourse2: Summary Discourse Alien Night is a dark focused clean theme with the Dark/Light toggle component in mind to enhance your forum!
👓 Preview Preview on theme-creator.discourse.org
🛠️ Repository Link GitHub - B-iggy/alien-night-discourse-dark-theme: A night friendly dark Discourse theme - dark/light switcher inclusive
📖 New to Discourse Themes? Beginner’s guide to using Discourse Themes

Note: with the release 4.0.0 I redesigned/refactored the theme from ground up. It’s more contrast friendly, it uses CSS variables and is overall more slick.

Hi there 👋
I want to share a free dark theme for discourse called “Alien Night”.
I made it for my server game community.

Since I have people from all over the world playing on my servers and reading the forum at any time I wanted to have a dark and a bright theme people can choose from. Especially the night one should be eye friendly in the night.

Implemented Dark/Light Mode Toggle

Even though the component is labeled as broken, it works in my theme, if you follow some guidelines:

  1. Make the Light theme selectable for your users

  2. Select the Dark color here ( /admin/site_settings/category/all_results?filter=dark%20m )

  3. Include the Dark-Light-Toggle component for this theme and check the box at the bottom:

If everything set correctly, you have on a right sidebar the Dark/Light Toggle:

Enjoy and let me know if you have any feedback or questions. 🙂

Iggy

Very interested, share it please

Alright :smiley_cat:

Sorry in advance for not doing it the 100% professional way ( using custom js templates from discourse? ) but for now it works very good for me this way:

The main idea is basically to append a modifier class to the html DOM and nest the dark styles in proper way in the CSS and store the user choice in the local storage.

So my HTML looks like this:

<span class="theme-switcher">Switch Theme:</span>
  <a class="theme-switcher-attr theme-switcher-light" href="#">Light</a>
  <a class="theme-switcher-attr theme-switcher-dark" href="#">Dark</a>  

The theme switcher CSS and a snippet example with the modifier class

.theme-switcher-attr {
    color: #fff !important;
    font-weight: bold;
    padding: 5px;
    margin: 2px;
    display: inline-block;
}

.theme-switcher-light {
    background-color: #fff;
    color: #222 !important;
    border: 1px solid #333;
}

.theme-switcher-dark {
    background-color: #10161d;
    border: 1px solid #fff;
}

/*
CSS of the Dark Theme in combination with the modifier class from the theme switcher
 */
html.dark,
html.dark body {
    background-color: #10161d;
}

html.dark,
html.dark .top-navbar-links-title,
html.dark .nav-pills>li>a,
html.dark .topic-list a.title,
html.dark .topic-body .regular,
html.dark #topic-title h1 a,
html.dark #topic-title .topic-statuses,
html.dark .category-list tbody .category h3 a[href],
html.dark .timeline-container .topic-timeline .timeline-replies,
html.dark .discourse-no-touch .topic-body .actions .fade-out,
html.dark #suggested-topics,
html.dark .topic-list-bottom,
html.dark .user-main .nav-stacked li>a.active,
html.dark .theme-switcher,
html.dark div.poll li[data-poll-option-id],
html.dark aside.onebox header a[href],
html.dark .contents,
html.dark nav.post-controls button.create,
html.dark .directory .period-chooser,
html.dark .directory table,
html.dark .dashboard-stats table .title i.fa,
html.dark #topic-closing-info,
html.dark .content-list ul li a,
html.dark .topic-map .map .number, .topic-map .map i,
html.dark .topic-map h3,
html.dark .topic-map .buttons .btn:hover {
    color: #fff;
}

And the JS via async placed in the </head> customize field

<script async>
$(document).ready(function() {

    var darkTheme = localStorage.getItem("theme");

    if (darkTheme !== null){
        $('html').addClass('dark');
    }

    if (typeof(Storage) !== "undefined") {
        // Code for localStorage/sessionStorage.
        $('.theme-switcher-dark').on('click', function() {
            localStorage.setItem("theme", "dark");
            $('html').addClass('dark');
        });

        $('.theme-switcher-light').on('click', function() {
            localStorage.removeItem("theme");
            $('html').removeClass('dark');
        });

    } else {
        // Sorry! No Web Storage support..
        console.log('Upgrade to a better browser! Really!')
    }
});
</script>

I appreciate any feedback and for the complete package I updated the theme switcher also in Github and created an easy Release you can just download everything:

@B-iggy I find a little bug
When you enter a topic (sometimes, not always) the link in navigation bar change in
https://forum.empyrion-homeworld.net/#
instead to e.g.
https://forum.empyrion-homeworld.net/t/griefing-and-cheating-report/3520

So, when you try to go in another page, or return to the home page (clicking the logo), the site is not responding.

Or the link does not match the title of the topic, e.g.


I need to press Ctrl and F5 to refresh all.

It also happens on my forum from yesterday, since I enabled the switcher themes.

Removing the strings href="#" in Html code seems to resolve the problems.
Can you try and confirm please?

After few days I can confirm that this bug is fixed by deleting href="#" from the Html code, e.g.

  <a class="theme-switcher-attr theme-switcher-light">Light</a>
  <a class="theme-switcher-attr theme-switcher-dark">Dark</a>

If anyone is interested I changed the position and shape of the buttons making them “fixed” on the page, so users can change from dark to light (or viceversa) without going back to top.

On CSS I add:

#top-navbar {
    position: fixed;
    top: 90px;
    left: 0;
    z-index: 90000;
    width: 70px;
    overflow: hidden;
    margin: 0;
    text-align: center;
    box-shadow: 0px 0px 4px #070708;
    border-radius: 0px 10px 10px 0px;
}

according to my Html code.

and this line (both here .theme-switcher-light and here .theme-switcher-dark) to make the round buttons
border-radius: 100%;

In Html/Top:

<div id="top-navbar">
  <span class="theme-switcher">Tema:</span>
  <a class="theme-switcher-attr theme-switcher-light"><i class="fa fa-sun-o fa-lg"></i></a>
  <a class="theme-switcher-attr theme-switcher-dark"><i class="fa fa-moon-o fa-lg"></i></a> 
</div>

I preferred to use the FontAwesome’s icons instead of a text for buttons.

Image (690×283)

Hey @Trash,

just today I got feedback from the community regarding this too so I wanted to tackle it. Thank you for your fix. Will try it out. Nice to see it in action by someone else 🙂

Thanks for the terrific theme and switcher. This is perfect for my astronomy club.

Question - the background of the header bar (I’m using the default bar for now) does not change color when the dark theme is selected. It stays at the default white. Can the script be modified to include changing the header?

Thanks,
Alan

You don’t need to modify the script, but add some lines on your css:

html.dark .d-header {
    background: #1c1c1c;  /*change it with the hex color you want*/
}

to change the background color

Instead, to change the color of the title (if you need) add somenthing like this:

html.dark .extra-info-wrapper .topic-link {
    color: #ffffff;  /*change it with the hex color you want*/
}

The lines for the header work perfectly. Thanks!

Hi there @Trash and @B-iggy !

I’m trying to apply your brilliant dark theme with switch bar, but I’m afraid that I messed up something…
Dark theme is working, also I can se the switch buttons, but they are just not working… Also colour is fixed to white.

I’m not really sure where should I paste the HTML code (sorry about that, I’m greenhorn in that matter).
Should I put it in Head or Body? Or in all of it?


Thanks!

Hi! Thanks for reply!
Now I can switch between Dark And Darker 😃
This is happening when I’m clicking to the moon:

And this is after click to the sun:

I think it’s related to naming of dark and light theme?

@B-iggy I would like to move this to the #plugin:theme , was wondering if you can orgnaise the the theme per:

Cool, moving this to the theme category please update the first post :full_moon_with_face:

Hi!
After your update everything works just fine! Congrats!
I found just one minor bug, from time to time switcher just stops working. There’s no effect when you’re trying to change from one to another theme. Site refresh helps.

One more thing, is it possible to change colour of top of the page and the switcher to night mode, when it’s switched to night mode 😉 Now it’s white on night mode.

Hey @Pawel_Kosiorek,

glad it worked with the native theme installation 🙂
I will check why it is sometimes not working. Guess some internal JS call conflicts.

Yes, since I am using a background image for the header I left it accidentally white - will fix it.
Will adjust the color for the theme switcher too.

@here Keep in mind that the #4 post is not up to date anymore.

I’m using now a complete new method for the Theme Switcher. It’s nicely put in the Discourse Header now 🙂

(hopefully it has no issues with other Discourse Header components)

Could you share that switch as a seperate theme component? I’m looking for this feature for months.

Hey @Anatolia

I tried my best to make it happen 😃

Go here:

I added to our forum. Thank you so much :slightly_smiling_face:

There is something wrong in the header when you open the hamburger menu:

A part of the menu moves to the top right and partially covers the buttons on the header

However great rework!

Back from vacation. Sorry for the delay!
I fixed it now 🙂 (legacy from my own sub theme header component)
Thanks for the report!

Thanks for the theme. I like how you have both dark and light colors in the same stylesheet. I don’t know any other theme that does that.

There are lot of hard coded colors, I was wondering if you have any plans for making those customizable using color variables and functions?

There are some colors that do not change between dark and light mode resulting in low contrast such as the tags. it would be great if we could overwrite all colors in the UI so they are customizable as well.

Also if some users decide on different color palette, it would be easier to adjust the unwanted color variations.

I am working on a fork of Alien Night and replaced all hard coded colors with variables so they could be organized and possibly derived from the color_schemes.

If you find it beneficial I could post the color list here or as an issue or pr to your repo.

Thank you.

Out of curiosity, I see a large list of items whose colors are changed with the dark class, did you find the elements that needed a color change one by one or you used another strategy?

Hey @ahmadabdolsaheb

thanks for your feedback - appreciated!

Right, for now they are hardcoded “by eye and taste” 😉
Currently quite busy so can’t work on a customizable setup. I would like a Pull Request or whatever way you like to integrate it, so everyone can benefit from it.

Great theme!!!

@B-iggy

How can I get answers into container separately?

example

Welcome to the Forum and thanks for your feedback @AtakanYildirim1

I don’t know exactly what your request is though. Answers in a separate container?

Ah I see. You want to have kind of “Google Material Design” boxed style.
I will play around with it and let you know, once I’m done with it. Currently busy with christmas work.
Thanks for the suggestion!

Oooh, this is a nice theme!

I was gonna ask this too.

Well, since the purpose of this theme is to make it Dark, I didn’t think of an option to have it light as default 😉
Maybe I can implement a theme setting for that, even if it’s strange to me.

Alright, I have implemented your request. I like it myself that way, even though in the dark mode it’s not that visible that much due contrast.
Let me know your thoughts. In the light version it’s more noticeable.

Note: I went with the logic, that the topic owner does not have a material themed box, to highlight him within a conversation and make his topics like a “fundament”, if you know what I mean.
Let me know what you think about that as well please.

If you are using the Alien Night Theme, you should have got informed by now, that there is an update available.
So just click on Check for Updates and upgrade to the latest version.
image

@B-iggy
I know I’m asking a lot of questions 😦

How do I change the background of these pop-up answers. ?

Bir de varsayılan olarak light başlaması için bir yöntem var mı?

What background do you mean exactly?

@B-iggy
As you can see in the picture, clicking on 2 answers opens the answers. Can I change the background color of these pop-up responses?

Dropdown field Can I adjust the background?

Good point.
Highlight the Reply button was always on my list…

A new version is out. Please upgrade.

I considered your suggestion as following:

Currently not. I’ll add options for that

Hello @B-iggy I’m liking the theme. However, it does not like versatile banners. Also I have a random checkbox.
image


It also seems to not like this

image

Thanks for help when you can.

This is what I wanted, thanks!