{"id":15653986,"url":"https://github.com/richtabor/dark-mode-toggle-block","last_synced_at":"2025-04-14T12:42:33.633Z","repository":{"id":237792577,"uuid":"794783853","full_name":"richtabor/dark-mode-toggle-block","owner":"richtabor","description":"A WordPress block to add a toggle between light and dark mode on a site.","archived":false,"fork":false,"pushed_at":"2024-11-21T15:53:31.000Z","size":443,"stargazers_count":39,"open_issues_count":7,"forks_count":10,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-03-28T01:53:27.955Z","etag":null,"topics":["wordpress","wordpress-block","wordpress-plugin"],"latest_commit_sha":null,"homepage":"https://rich.blog/dark-mode-toggle-block","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/richtabor.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2024-05-02T00:13:57.000Z","updated_at":"2025-02-12T10:23:42.000Z","dependencies_parsed_at":"2024-05-03T07:00:00.444Z","dependency_job_id":"1f6c29dc-a557-4a6d-8917-045a4f1ebea7","html_url":"https://github.com/richtabor/dark-mode-toggle-block","commit_stats":null,"previous_names":["richtabor/dark-mode-toggle-block"],"tags_count":6,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/richtabor%2Fdark-mode-toggle-block","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/richtabor%2Fdark-mode-toggle-block/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/richtabor%2Fdark-mode-toggle-block/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/richtabor%2Fdark-mode-toggle-block/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/richtabor","download_url":"https://codeload.github.com/richtabor/dark-mode-toggle-block/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248883188,"owners_count":21177174,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["wordpress","wordpress-block","wordpress-plugin"],"created_at":"2024-10-03T12:48:40.704Z","updated_at":"2025-04-14T12:42:33.603Z","avatar_url":"https://github.com/richtabor.png","language":"JavaScript","readme":"# Dark Mode Toggle Block\n\n[![Create Release and Deploy to WordPress.org](https://github.com/richtabor/dark-mode-toggle-block/actions/workflows/create-release-and-deploy.yml/badge.svg)](https://github.com/richtabor/dark-mode-toggle-block/actions/workflows/create-release-and-deploy.yml)\n\nA WordPress block to add a toggle between light and dark appearances, as seen on [my blog](https://rich.blog). Adds a `theme-dark` class to the body element, when toggled on. The user's preference is then saved in local storage. \n\n[Read about it on my blog →](https://rich.blog/dark-mode-toggle-block/)\n\n### Visual\n\nhttps://github.com/richtabor/dark-mode-toggle-block/assets/1813435/f7255865-6328-4f54-8284-6bb2432d8ab2\n\n### How it works\nWhen toggled, the block will add a `.theme-dark` class to the body of the site. You can add CSS variables to target dark styles. \n\nI did it this way on [my blog](https://rich.blog), which uses the theme.json `settings.custom.color` values for each color, unless there is a color created within the Site Editor with corresponding slug (i.e. `theme-1-dark`). I used this method so that a user could manipulate any given color without having to modify theme.json.\n\n```\n/* Dark styles */\n.theme-dark body {\n    --wp--preset--color--theme-1: var(--wp--preset--color--custom-theme-1-dark, var(--wp--custom--color--theme-1-dark));\n    --wp--preset--color--theme-2: var(--wp--preset--color--custom-theme-2-dark, var(--wp--custom--color--theme-2-dark));\n    --wp--preset--color--theme-3: var(--wp--preset--color--custom-theme-3-dark, var(--wp--custom--color--theme-3-dark));\n    --wp--preset--color--theme-4: var(--wp--preset--color--custom-theme-4-dark, var(--wp--custom--color--theme-4-dark));\n    --wp--preset--color--theme-5: var(--wp--preset--color--custom-theme-5-dark, var(--wp--custom--color--theme-5-dark));\n    --wp--preset--color--theme-6: var(--wp--preset--color--custom-theme-6-dark, var(--wp--custom--color--theme-6-dark));\n}\n```\n\n### Development\n\n1. Clone the repository into your WordPress plugins directory.\n2. Run `npm install` to install dependencies.\n3. Run `npm start` to start the development server.\n4. Activate the plugin on your local WordPress site.\n5. Add the block to a post or page.\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frichtabor%2Fdark-mode-toggle-block","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Frichtabor%2Fdark-mode-toggle-block","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frichtabor%2Fdark-mode-toggle-block/lists"}