Skip to content

Commit c9b6b66

Browse files
committed
feat: REAMDE updated
1 parent 051a4b5 commit c9b6b66

File tree

2 files changed

+18
-5
lines changed

2 files changed

+18
-5
lines changed

README.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,8 @@ Allows ✨:
1313
- process / modify the script in a dedicated PHP class.
1414

1515
Additionally - has build in **ready-to-use** scripts:
16-
- two states - light / dark - color scheme switching script _(+ view with icons)_
17-
- three states - light / dark / system - color scheme switching script _(+ view with icons)_
16+
- [two states](scrips/ColorSchemeSwitchThreeStates/README.md) - light / dark - color scheme switching script _(+ view with icons)_
17+
- [three states](scrips/ColorSchemeSwitchThreeStates/README.md) - light / dark / system - color scheme switching script _(+ view with icons)_
1818
- _more to come_
1919

2020
### Requirements
@@ -89,11 +89,11 @@ Modern websites often provide users with the ability to switch between light and
8989

9090
The folowing example demonstrates by using **two-state** color scheme switch script (light/dark).
9191

92-
**Three-state** (light/dark/system) is also available. Just replace `2-states- | ..TwoStates` with `3-states- | ..ThreeStates` in the commands and code below.
93-
9492
> **Icons used** (from [HeroIcons](https://heroicons.com)):
9593
>
96-
> ![View](assets/3-states-hero-icons.gif)
94+
> ![View](assets/2-states-hero-icons.gif)
95+
96+
**Three-state** (light/dark/system) is also available. Just replace `2-states- | ..TwoStates` with `3-states- | ..ThreeStates` in the commands and code below.
9797

9898

9999
### Using prepared PHP classes

scripts/ColorSchemeSwitchTwoStates/README.md

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -160,6 +160,19 @@ You can use it, for example, in a button click handler:
160160
</button>
161161
```
162162

163+
## Custom event: colorSchemeChanged
164+
165+
The script dispatches a custom event whenever the theme changes, which you can listen to:
166+
167+
```javascript
168+
document.addEventListener('colorSchemeChanged', (event) => {
169+
console.log('Previous scheme:', event.detail.previousScheme);
170+
console.log('Current scheme:', event.detail.currentScheme);
171+
});
172+
```
173+
174+
This is useful if you need to perform additional actions when the theme changes.
175+
163176
## File structure
164177

165178
```

0 commit comments

Comments
 (0)