Coder Social home page Coder Social logo

is-dark-theme's Introduction

is-dark-theme

License

Description

is-dark-theme is a utility to help investigate the feasibility of detecting pages in dark mode. In order to do so, the code checks the computed background color and compute the perceived brightness to determine if the color is dark or light. This utility was developed to potentially be used for WKWebview based browsers.

Getting Started

To run this POC, ensure you have Node.js installed on your machine. Then, follow these steps:

  1. Clone the repo.
  2. Navigate to the project directory and install dependencies with:
npm i && npx playwright install
  1. To run the tests, execute:
npm test

How It Works

The node script at index.js will start a browser and navigate to different websites sepecified in the code. It will extract features from the website and attempt to determine if the website is in dark or light mode. After all tests finish, the code will output:

  • a screenshot folder with screenshots of the websites in dark and light modes.
  • a website_theme_support.csv that contains an analysis of the run.

GitHub Actions Workflow

To enhance the functionality and documentation of is-dark-theme, a GitHub Actions workflow automates the generation of CSV data and screenshots that document the detection process in various scenarios.

How to read the table below ?

  • The Screenshots Match column shows whether the screenshots taken in dark and light mode matched. A matching screenshot means that the website doesn't have built-in dark theme support ( or at least not controlled by the system theme ).
  • The DM Detected in System DM column shows if a dark themed website was detected when the system theme was set to dark.
  • The DM Detected in System LM column shows if a dark themed website was detected when the system theme was set to light.
  • The Expected shows whether the result for that website is expected or not.

Test Results (Auto generated)

Website Screenshots Match DM Detected in System DM DM Detected in System LM Expected
https://duckduckgo.com No Yes No
https://reddit.com No Yes No
https://openai.com/ No Yes No
https://docs.github.com/en No Yes No
https://twitter.com No Yes No
https://cnn.com Yes No No
https://google.com Yes No No
https://playwright.dev/ No Yes No
https://docs.amplify.aws/ No Yes No
https://usehooks-ts.com/ No Yes No
https://picocss.com/ No Yes No
https://nextjs.org/ No Yes No
https://hurl.dev/ No Yes No
https://joshwcomeau.com No Yes No

Screenshots

Screenshots available here.

is-dark-theme's People

Contributors

issammani avatar

Watchers

 avatar

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.