You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
- process / modify the script in a dedicated PHP class.
13
14
14
15
Additionally - has build in **ready-to-use** scripts:
15
-
- color scheme switching script (two states - light/dark)
16
-
- color scheme switching script (three states - light/dark/system)
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)_
17
18
-_more to come_
18
19
19
20
### Requirements
@@ -60,7 +61,7 @@ Use the custom Blade directive in your template to inline the scripts:
60
61
61
62
Done.
62
63
63
-
### What are Inline Scripts?
64
+
### What are inline scripts?
64
65
65
66
Inline scripts are JavaScript code blocks embedded directly into HTML documents. Traditionally, developers manually write these scripts as strings in the `<head>` section or at the end of the `<body>` section:
66
67
@@ -77,18 +78,22 @@ Inline scripts are JavaScript code blocks embedded directly into HTML documents.
77
78
78
79
This package makes it much more convenient by allowing you to keep inline scripts in separate JavaScript files, which enables ✨:
79
80
80
-
-**Complex script processing** using dedicated PHP classes _(see example below)_
81
-
-**Variable passing** from PHP to JavaScript _(see example below)_
82
-
-**Unit testing** your JavaScript code using tools like Vitest or Jest _(see bonus section below)_
83
-
-**Better code organization** and maintainability
84
-
-**IDE support** with syntax highlighting and error detection in dedicated JS files
-**Variable passing** : from PHP to JavaScript _(see [example bellow](#using-prepared-php-classes))_
83
+
-**Unit testing** : your JavaScript code using tools like Vitest or Jest _(see [bonus section](#bonus))_
84
+
-**IDE support** : with syntax highlighting and error detection in dedicated JS files _(see [example bellow](#using-js-code-directly))_
85
85
86
86
# Explanation Through Example: Color scheme switch script
87
87
88
88
Modern websites often provide users with the ability to switch between light and dark themes. In such cases, you might want to remember the user's choice using `localStorage` and apply the selected theme on page load. To avoid **FOUC** (Flash of Unstyled Content), you can use _inline script_ to set the theme before the page fully loads.
89
89
90
90
The folowing example demonstrates by using **two-state** color scheme switch script (light/dark).
**Three-state** (light/dark/system) is also available. Just replace `2-states- | ..TwoStates` with `3-states- | ..ThreeStates` in the commands and code below.
0 commit comments