Skip to content

Commit 1473b26

Browse files
committed
chore: REAMDE updated
1 parent 573039d commit 1473b26

File tree

1 file changed

+8
-5
lines changed

1 file changed

+8
-5
lines changed

README.md

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

99
Extra - build in **ready-to-use** scripts:
10-
- theme switching script
10+
- theme switching script (two states - light/dark)
1111
- _more coming later_
1212

1313
### Requirements
@@ -69,7 +69,7 @@ Inline scripts are JavaScript code blocks embedded directly into HTML documents.
6969
</head>
7070
```
7171

72-
This package makes it much more convenient by allowing you to keep inline scripts in separate JavaScript files, which enables:
72+
This package makes it much more convenient by allowing you to keep inline scripts in separate JavaScript files, which enables:
7373

7474
- **Complex script processing** using dedicated PHP classes _(see example below)_
7575
- **Variable passing** from PHP to JavaScript _(see example below)_
@@ -91,6 +91,8 @@ That will copy the scripts to `resources/js/theme-switch-two-states/[theme-init.
9191
`theme-init.js` - initializes the theme based on the user's previous choice stored in `localStorage`.
9292
`theme-switch.js` - a function to toggle between light and dark themes by hitting a selected KEY and saves the choice in `localStorage`.
9393

94+
They switch theme by adding/removing a CSS class to/from the `<html>` element.
95+
9496
**Step 2**: Register the scripts in your `AppServiceProvider`:
9597

9698
```php
@@ -132,13 +134,14 @@ You can create a custom PHP class to process or modify your JavaScript code befo
132134

133135
Create a custom PHP processor class implementing the `RenderableScript` or `ScriptWithPlaceholders` interface and register it using the `BladeInlineScripts::take()` method.
134136

135-
We have prepared abstract base implementations for each of the interfaces:
137+
I have prepared abstract base implementations for each of the interfaces:
136138
```php
137139
abstract class FromFile implements RenderableScript
140+
138141
abstract class FromFileWithPlaceholders implements ScriptWithPlaceholders
139142
```
140143

141-
To show them in action, we have created PHP processors extending the base classes for the theme switch scripts:
144+
To show them in action, I have created PHP processors extending the base classes for the theme switch scripts:
142145

143146
**Step 1**: Publish the built-in theme switch scripts with the PHP processor:
144147

@@ -167,7 +170,7 @@ class AppServiceProvider extends ServiceProvider
167170

168171
Now hit the `d` key to toggle theme.
169172

170-
## Extra - get the tests for the built-in scripts and PHP processors
173+
## Extra - get the unit tests for JS scripts and PHP processors
171174

172175
```bash
173176
php artisan vendor:publish --tag=theme-switch-2-states-js-tests

0 commit comments

Comments
 (0)