GithubHelp home page GithubHelp logo

surjithctly / astro-color-scheme Goto Github PK

View Code? Open in Web Editor NEW
41.0 41.0 5.0 20 KB

Astro Color Scheme is a fully headless dark mode theme toggle for Astro.

Home Page: https://www.npmjs.com/package/astro-color-scheme

TypeScript 2.08% Astro 97.92%
astro astro-themes color-scheme dark-mode dark-theme headless

astro-color-scheme's Introduction

Hi Github ๐Ÿ‘‹



I'm Surjith. A freelance Web Designer & Developer from Kerala, India. I design and develop websites, landing pages and applications for startups and enterprises.

Contact me on Twitter or Send an Email


Visitors Counter

astro-color-scheme's People

Contributors

giacomocerquone avatar jlsnow301 avatar kilian avatar surjithctly avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

astro-color-scheme's Issues

[Bug]: clicking on the svg won't switch the theme

Hey there.
Using your playground https://stackblitz.com/edit/github-jpfnv9-ep5z59?file=src%2Fpages%2Findex.astro you will notice that if you start clicking exclusively on the icon, and not on the button, the theme won't switch.

Check the video:

Screenity.video.-.Mar.30.2024.mp4

That's because using e.target will give you the exact element the user has clicked on which might not be the button and, consequently, you'll lose the correct value of the value attribute you set.
You need to use e.currentTarget

system should listen to matchMedia changes

With system selected, having the prefers-color-scheme value change should also trigger an update of this package:

const match = window.matchMedia('(prefers-color-scheme:dark)');

match.addEventListener('change', (e) => {
  if (e.matches) {
    /* set theme to dark */
  } else {
    /* set theme to light */
  }
});

Change current page restart input state on switcher

Hi, i have this issue when use two pages "/" and "/en" for the same content but in English, when checkbox strategy it's used the check โ˜‘ mark will always reload and change the state, causing a desync on the value of the box and the current theme.

<ThemeSwitch strategy="checkbox" defaultTheme="system"> <div class="flex py-2"> <input type="checkbox" id="switch" name="switch" /> <label for="switch"></label> </div> </ThemeSwitch>
I am using Astro, so can I use the transition:persist? Could you give some example?

edit: when i change the page, the local storage value remains, but the theme actually doesn't sync, I can make some screens if you like

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.