Skip to content

Instantly share code, notes, and snippets.

View felds's full-sized avatar
:shipit:

Luiz “Felds” Liscia felds

:shipit:
View GitHub Profile

Dark mode is not a feature — it’s a browser setting

It’s 2025, and we’re still building dark mode toggles with JavaScript like it’s 2019. This is a UX oversight. Mode preference — light or dark — is a personal, system-level setting, and browsers already know how to handle it. Yet, websites keep reinventing the wheel with janky toggles that often don’t persist, don’t sync with system changes, and can’t even influence CSS media queries. The result? Inconsistent UX, broken themes, and wasted developer time — all to replicate something that should be a native browser feature, just like zoom or autoplay controls.

There are plenty of practical and technical reasons why theme switching belongs in the browser, not in your app code. Here’s a breakdown of why this shift would be a win for users, developers, and the web platform as a whole:

1. Accessibility & UX Consistency

Native switches could be surfaced consistently across all sites, making them easier to find and use — especially for users relying on keyb

@felds
felds / index.html
Created March 17, 2024 22:51
TODO rapidinho com a M
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
<meta name="color-scheme" content="dark light">
<style>
* {
font-size: 32px;
@felds
felds / serializing.ts
Created October 6, 2023 23:13
Serializing/reviving objects in TS
class Point {
constructor(
public x: number,
public y: number,
) {}
serialize(): any {
return {__type: this.constructor.name, x: this.x, y: this.y}
}
toString() {
return `I'm a point: ${this.x}, ${this.y}`
@felds
felds / palette.scss
Created August 20, 2023 20:52
Sass Palette generator
@use "sass:color";
@use "sass:list";
@use "sass:math";
@use "sass:meta";
// Create a list of numbers
@function range($from, $to, $step: 1) {
// validation
@if meta.type-of($from) != "number" {
@error "$from must be a number.";
type SuspendStatus = "pending" | "success" | "error";
export function suspend<T>(promise: Promise<T>) {
let result: T;
let error: Error;
let status: SuspendStatus = "pending";
let suspender = promise.then(
(r) => {
status = "success";
result = r;
@felds
felds / form.html
Last active September 23, 2021 20:14
Remove validation and prompt when exiting unsaved form
<script>
const forms = Array.from(document.querySelectorAll("form"))
// disable browser validation
forms.forEach(el => el.noValidate = true)
// add unsaved data prompt
let unsaved = false;
window.addEventListener("beforeunload", (e) => {
if (unsaved) {
@felds
felds / cloudbuild.sample.yaml
Last active April 28, 2021 04:54
Cloud Build to GCE sample
# IMPORTANT:
# Dont forget to to replace the INSTANCE_NAME for the name
# of the instance we created on step 2
steps:
- name: gcr.io/cloud-builders/docker
args:
- build
- '-t'
@felds
felds / wp-config.php
Created July 12, 2020 05:16
Common settings for wp-config
<?php
/**
* common settings for wp-config
*/
// dont try to connect via ftp for updates
define( 'FS_METHOD', 'direct' );
// force urls
@felds
felds / README.md
Last active May 6, 2019 20:08
Instalação novo server WP (ubuntu 18.4)
  • Pra começar, atualize o sistema:

    sudo apt update
    sudo apt upgrade -y
  • Intale o MariaDB:

    sudo apt install -y mariadb-server
    sudo mysql_secure_installation
# EditorConfig is awesome: http://EditorConfig.org
# top-most EditorConfig file
root = true
[*]
charset = utf-8
end_of_line = lf
insert_final_newline = true
indent_style = space