GithubHelp home page GithubHelp logo

Comments (4)

timvisee avatar timvisee commented on June 26, 2024

Currently, it is not possible to force this (without code modifications). It chooses light or dark mode based on device preferences.

from send.

anon243 avatar anon243 commented on June 26, 2024

I tried to modify the main.css file, but it's not working.

from send.

l4rm4nd avatar l4rm4nd commented on June 26, 2024

The light or dark mode is chosen dynamically based on user preference.

The relevant code lies in tailwind.config.js. Here, the following line declares dark mode:

      dark: { raw: '(prefers-color-scheme: dark)' }

However, dark mode is only chosen, when a user explicitely uses the dark scheme preference. This is either an OS choice and the web browser adopts it; or the choice is solely defined in the user's web browser settings. If the user uses the scheme preference light or does not have a preference at all, the light theme will be used.

Since its tailwind, the CSS modifications will be fininshed as soon as the server is started. A modification during runtime is pain. Therefore, the tailwind config must be changed before the Docker image is started as a container. This requires said code modifications @timvisee explained.

If you want to force dark mode only, you would replace the displayed code line above with the following:

      dark: { raw: '(prefers-color-scheme: dark), (prefers-color-scheme: no-preference), (prefers-color-scheme: light)' } // Always active dark mode

I've forked this repository to test this. A GitHub action is building the Docker image for my forked repo and pushes it onto Dockerhub. I've also adjusted the docker-compose.yml in the fork to make use of the dark-mode-only Docker image as well as list some important environment variables.

Feel free to use it, if you want dark mode only. I'll try to keep the forked repo in sync to this one.

from send.

l4rm4nd avatar l4rm4nd commented on June 26, 2024

@timvisee you may provide two different tailwind configs. One default as of now for light/dark mode based on user preference and one for dark mode only with my changes.

Then conditionally load one of them depending on a new environment variable such as DARK_MODE_ONLY set to true.

You would implement this in the postcss.config.js file like follows:

const TailwindExtractor = content => {
  return content.match(/[A-Za-z0-9-_:/]+/g) || [];
};

let tailwindConfigFile = process.env.DARK_MODE_ONLY === 'true' ? './tailwind-dark.config.js' : './tailwind.config.js';

const options = {
  plugins: [
    require('postcss-preset-env'),
    require('tailwindcss')(tailwindConfigFile)
  ]
};

if (process.env.NODE_ENV === 'development') {
  options.map = { inline: true };
} else {
  options.plugins.push(
    require('@fullhuman/postcss-purgecss')({
      content: [
        './app/*.js',
        './app/ui/*.js',
        './android/*.js',
        './android/pages/*.js'
      ],
      extractors: [
        {
          extractor: TailwindExtractor,
          extensions: ['js']
        }
      ]
    })
  );
}

module.exports = options;

Just an idea.

Edit: Okay, does not make sense as the npm run build command is done during Docker image build and not later, when the image is run as container. Therefore, introducing new env variables won't work. Ignore this idea.

from send.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.