astro-accelerator 0.0.46 → 0.0.47
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +4 -4
- package/public/css/main.css +1 -1
- package/public/js/main.js +2 -0
- package/public/js/modules/input-type.js +53 -0
- package/src/config.ts +3 -0
package/package.json
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
{
|
|
2
|
-
"version": "0.0.
|
|
2
|
+
"version": "0.0.47",
|
|
3
3
|
"author": "Steve Fenton",
|
|
4
4
|
"name": "astro-accelerator",
|
|
5
5
|
"description": "A super-lightweight, accessible, SEO-friendly starter project for Astro",
|
|
@@ -25,13 +25,13 @@
|
|
|
25
25
|
},
|
|
26
26
|
"dependencies": {
|
|
27
27
|
"@squoosh/lib": "^0.4.0",
|
|
28
|
-
"astro": "^1.6.
|
|
29
|
-
"astro-accelerator-utils": "^0.2.
|
|
28
|
+
"astro": "^1.6.14",
|
|
29
|
+
"astro-accelerator-utils": "^0.2.12",
|
|
30
30
|
"hast-util-from-selector": "^2.0.0",
|
|
31
31
|
"remark-directive": "^2.0.1"
|
|
32
32
|
},
|
|
33
33
|
"devDependencies": {
|
|
34
|
-
"@playwright/test": "^1.
|
|
34
|
+
"@playwright/test": "^1.28.1"
|
|
35
35
|
},
|
|
36
36
|
"engines": {
|
|
37
37
|
"node": "*"
|
package/public/css/main.css
CHANGED
package/public/js/main.js
CHANGED
|
@@ -5,6 +5,7 @@ import { addStickyNavigation } from './modules/nav-sticky.js';
|
|
|
5
5
|
import { addMobileNav } from './modules/nav-mobile.js';
|
|
6
6
|
import { setClickableBlocks } from './modules/click-blocks.js';
|
|
7
7
|
import { setExternalLinkAttributes } from './modules/external-links.js';
|
|
8
|
+
import { monitorInputType } from './modules/input-type.js';
|
|
8
9
|
|
|
9
10
|
const resizedEventName = addResizedEvent();
|
|
10
11
|
|
|
@@ -14,6 +15,7 @@ addStickyNavigation('.site-header', '#site-nav', '#site-nav > ul', resizedEventN
|
|
|
14
15
|
addMobileNav(resizedEventName);
|
|
15
16
|
addIntersectionObserver('.anim-show-parent img, .anim-show-parent > *:not(h1, h2, h3, h4, h5, h6)');
|
|
16
17
|
addListImageIntersectionObserver('.post-list img');
|
|
18
|
+
monitorInputType();
|
|
17
19
|
|
|
18
20
|
// @ts-ignore
|
|
19
21
|
const f = site_features ?? {};
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
// @ts-check
|
|
2
|
+
|
|
3
|
+
let inputType = 'unknown';
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Sets the user input mode as a class
|
|
7
|
+
*/
|
|
8
|
+
function monitorInputType() {
|
|
9
|
+
window.addEventListener('keydown', event => {
|
|
10
|
+
const eventType = 'input-keyboard';
|
|
11
|
+
processInput(eventType);
|
|
12
|
+
});
|
|
13
|
+
|
|
14
|
+
window.addEventListener('mousemove', event => {
|
|
15
|
+
const eventType = 'input-mouse';
|
|
16
|
+
processInput(eventType);
|
|
17
|
+
});
|
|
18
|
+
|
|
19
|
+
window.addEventListener('touchstart', event => {
|
|
20
|
+
const eventType = 'input-touch';
|
|
21
|
+
processInput(eventType);
|
|
22
|
+
});
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
/**
|
|
26
|
+
* Processes the keyboard, mouse, or touch event
|
|
27
|
+
* @param {string} eventType
|
|
28
|
+
*/
|
|
29
|
+
function processInput(eventType) {
|
|
30
|
+
if (inputType !== eventType) {
|
|
31
|
+
removeClass(inputType);
|
|
32
|
+
inputType = eventType;
|
|
33
|
+
addClass(inputType);
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
/**
|
|
38
|
+
* Removes an input type class from the body
|
|
39
|
+
* @param {string} inputType
|
|
40
|
+
*/
|
|
41
|
+
function removeClass(inputType) {
|
|
42
|
+
document.body.classList.remove(inputType);
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
/**
|
|
46
|
+
* Adds an input type class to the body
|
|
47
|
+
* @param {string} inputType
|
|
48
|
+
*/
|
|
49
|
+
function addClass(inputType) {
|
|
50
|
+
document.body.classList.add(inputType);
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
export { monitorInputType };
|
package/src/config.ts
CHANGED