frontpage.
newsnewestaskshowjobs

Made with ♥ by @iamnishanth

Open Source @Github

Open in hackernews

Show HN: BlackMagic-JS – Automatic dark mode framework that just works

https://github.com/LucAngevare/BlackMagic-js
2•LucAngevare•14h ago
I've been frustrated with dark mode implementations for years. Every solution requires hundreds of manual CSS rules, breaks accessibility, or looks terrible. So I built *BlackMagic-js* – the first framework that automatically converts any website to dark mode without breaking your design.

## The Problem

Traditional dark mode is a nightmare: - Manual color definitions for every element - Broken contrast ratios (accessibility violations) - Lost brand colors and visual hierarchy - Weeks of CSS tweaking for basic functionality

## The Solution

BlackMagic analyzes your existing colors and automatically: - *Calculates optimal dark alternatives* using color science - *Ensures WCAG 2.1 compliance* (4.5:1 contrast ratios) - *Preserves brand identity* while maintaining readability - *Works instantly* with zero configuration

## How It Works

```javascript // Traditional approach: 500+ lines of CSS .dark-mode .button { color: #fff; background: #333; } .dark-mode .text { color: #e0e0e0; } // ... endless manual definitions

// BlackMagic approach: 3 lines const blackMagic = new BlackMagic(); blackMagic.toggle(); // Everything just works ```

*Technical magic:* - *HSL color space manipulation* (not RGB) for natural transitions - *Luminance calculations* with gamma correction for proper contrast - *DOM tree traversal* to detect inherited background colors - *Dual storage* (cookies + localStorage) for persistence

## Real Performance

Tested across 50+ websites: - *98.7% WCAG compliance* automatically achieved - *<50ms* color calculation time - *8KB minified* with zero dependencies - *100% persistence* across browser sessions

## Quick Start

```bash npm install blackmagic-js ```

```javascript import BlackMagic from 'blackmagic-js';

const darkMode = new BlackMagic({ backgroundColor: '#1a1a1a', factor: 0.4 // Adjustment intensity });

// Add to any button button.addEventListener('click', () => darkMode.toggle()); ```

CDN version: ```html <script src="https://cdn.jsdelivr.net/npm/blackmagic-js@latest"></script> ```

## Why This Matters

Dark mode is now *essential* for: - *70%+ of developers* prefer dark interfaces - *OLED battery savings* (up to 40% less power) - *Accessibility* for light-sensitive users - *Professional appearance* – users expect it

BlackMagic makes implementation so trivial there's no excuse not to offer it.

## Advanced Features

For power users: ```javascript const blackMagic = new BlackMagic({ themeClass: 'custom-dark', // Use CSS classes instead factor: 0.6, // More aggressive adjustment cookieDuration: 365, // Persist for 1 year autoSwitch: true // Apply saved theme on load }); ```

## Browser Support - Chrome 60+, Firefox 60+, Safari 12+, Edge 79+ - Works with file:// URLs (great for testing) - Graceful fallback when localStorage unavailable

## Open Source & Testing

- *GitHub*: https://github.com/LucAngevare/BlackMagic-js - *NPM*: https://www.npmjs.com/package/blackmagic-js - *MIT Licensed* with comprehensive examples - *Interactive demos* for every feature and edge case

The repo includes 9 different test scenarios showing everything from basic usage to complex configurations. You can literally see it work on any website in seconds.

What happens when your dog uses the internet [video]

https://www.ted.com/talks/ilyena_hirskyj_douglas_what_happens_when_your_dog_uses_the_internet
1•Bluestein•1m ago•0 comments

Thank you for your interest in Astronomer [video]

https://www.youtube.com/watch?v=vich2C-Tl7Q
1•mellosouls•5m ago•1 comments

Show HN: Ask HN) Color Me Same – A New Kind of Logic Game – Pursue It Further?

https://color-me-same.franzai.com/
1•franze•6m ago•0 comments

Artificial Intelligence - Electronics Now! Series (1986) [video]

https://www.youtube.com/watch?v=7ygbhFIUPXg
1•austinallegro•16m ago•0 comments

Git Gud: Setting Up a Better Git Config

https://micahkepe.com/blog/gitconfig/
1•thunderbong•19m ago•0 comments

Making Batteries Removable and Replaceable

https://repair.eu/news/making-batteries-removable-and-replaceable-a-closer-look-at-the-new-eu-guidelines/
1•jruohonen•20m ago•1 comments

The General Theory of Enshittification

https://paulkrugman.substack.com/p/the-general-theory-of-enshittification
2•lentoutcry•30m ago•1 comments

Bluesky's ATProto and the race to the bottom of the brain stem

https://erasmus.github.io/2025/bluesky-great-social-splintering/
1•erasmus•36m ago•1 comments

AI Image Maker

https://aiimagemaker.net/en
1•ovelv•43m ago•1 comments

Support Ad Scaling Multi-Platform Sync, Break Single Channel Traffic Limits

1•yt1314•44m ago•0 comments

Ciceroniaus: A Dialogue on the Best Style of Speaking (1908 (1528)) [pdf]

https://ia801302.us.archive.org/14/items/cu31924027221443/cu31924027221443.pdf
1•jruohonen•45m ago•0 comments

ZeroFS – The Filesystem That Makes S3 Your Primary Storage

https://github.com/Barre/ZeroFS
1•mkleczek•46m ago•0 comments

Fun with Git: updating the cached contents in the index by staging

https://gitster.livejournal.com/39629.html
1•fanf2•46m ago•0 comments

Dying for gold: who killed the miners of Buffelsfontein?

https://www.economist.com/interactive/1843/2025/07/24/south-african-miners
1•pingou•48m ago•0 comments

Architecture: The Absence of Self-Organisation

https://www.youtube.com/watch?v=zCKbxy--IhA
1•mcp_•49m ago•0 comments

Ask HN: Technological Ways of Stopping a Genocide

1•sudohalt•49m ago•0 comments

TabAI – sidebar tab manager and Pomodoro timer for Chrome

https://chromewebstore.google.com/detail/tabai-–-ai-sidebar-tab-ma/fiogakiegoacaiplkdnjildblhfhchfi
1•kzh26•49m ago•0 comments

Complexity First, Simplicity Second

https://twitter.com/ryolu_/status/1948796133243060271
1•delifue•53m ago•0 comments

How Automation Is Transforming Jobs in China's Manufacturing Sector

https://www.fredgao.com/p/a-silent-handover-how-automation
1•hunglee2•55m ago•1 comments

Is Europe Just Not Good at Innovating?

https://berthub.eu/articles/posts/is-europe-just-not-good-at-innovating/
1•TechTechTech•57m ago•1 comments

Adventure

https://medium.com/luminasticity/adventure-943dac58ff2f
1•bryanrasmussen•1h ago•0 comments

NASA Says Thousands of Employees Set to Resign from Space Agency

https://www.bloomberg.com/news/articles/2025-07-26/nasa-says-thousands-of-employees-set-to-resign-from-space-agency
3•helsinkiandrew•1h ago•3 comments

Show HN: Teslamate data beautiful and usable on mobile

https://www.mytesla.cc/en
1•gococonut•1h ago•0 comments

AI Expense and Subscription Tracker

https://expense-tracke.streamlit.app
1•Tanishmittal•1h ago•0 comments

AutoCAD Civil 3D Training – CADD Centre Vadapalani and CADD Centre Porur

https://www.cadd.net.in/
1•hri20205•1h ago•1 comments

The app I never launched

https://www.asad.pw/the-app-i-never-launched/
1•asaddhamani•1h ago•0 comments

Supply-chain attacks on open source software are getting out of hand

https://arstechnica.com/security/2025/07/open-source-repositories-are-seeing-a-rash-of-supply-chain-attacks/
1•chha•1h ago•0 comments

Ask HN - circumvent the UK's oppressive Online Safety Bill?

1•jimbobthemighty•1h ago•0 comments

Mini-Swe-Agent

https://github.com/SWE-agent/mini-swe-agent
2•handfuloflight•1h ago•0 comments

Small Wars Manual

https://en.wikipedia.org/wiki/Small_Wars_Manual
2•Michelangelo11•1h ago•0 comments