@total_onion/onion-library 2.0.93 → 2.0.94
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/entry-animation-observer.js +20 -0
- package/package.json +1 -1
- package/createNewChildBlock.js +0 -85
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
export const options = {
|
|
2
|
+
// root: document.querySelector('#scrollArea'),
|
|
3
|
+
rootMargin: "0px",
|
|
4
|
+
scrollMargin: "0px",
|
|
5
|
+
threshold: 1,
|
|
6
|
+
};
|
|
7
|
+
export function triggerEntryAnimation(element, loaderOptions) {
|
|
8
|
+
const intersectionCallback = (entries) => {
|
|
9
|
+
entries.forEach((entry) => {
|
|
10
|
+
if (entry.isIntersecting) {
|
|
11
|
+
let elem = entry.target;
|
|
12
|
+
|
|
13
|
+
elem.classList.add("trigger-animation");
|
|
14
|
+
}
|
|
15
|
+
});
|
|
16
|
+
};
|
|
17
|
+
const observer = new IntersectionObserver(intersectionCallback, options);
|
|
18
|
+
|
|
19
|
+
observer.observe(element);
|
|
20
|
+
}
|
package/package.json
CHANGED
package/createNewChildBlock.js
DELETED
|
@@ -1,85 +0,0 @@
|
|
|
1
|
-
require('dotenv').config();
|
|
2
|
-
const fs = require('fs');
|
|
3
|
-
const {globSync} = require('glob');
|
|
4
|
-
const {exec} = require('child_process');
|
|
5
|
-
const acfTemplate = require('./new-block-templates/template-acf-pattern');
|
|
6
|
-
const yaml = require('js-yaml');
|
|
7
|
-
const axios = require('axios');
|
|
8
|
-
|
|
9
|
-
const themePath =
|
|
10
|
-
process.env.THEME_PATH || 'web/wp-content/themes/global-theme';
|
|
11
|
-
|
|
12
|
-
const yamlData = yaml.load(fs.readFileSync('../../../../.lando.yml', 'utf8'));
|
|
13
|
-
const siteName = yamlData.config.site;
|
|
14
|
-
const parentURL = process.env.DESIGN_MULTIDEV
|
|
15
|
-
? `${process.env.DESIGN_MULTIDEV}/wp-admin/admin-ajax.php`
|
|
16
|
-
: `http://${siteName}.lndo.site/wp-admin/admin-ajax.php`;
|
|
17
|
-
|
|
18
|
-
let projectName = 'Global Theme';
|
|
19
|
-
const projectJson = JSON.parse(fs.readFileSync('./package.json'));
|
|
20
|
-
if (projectJson) {
|
|
21
|
-
projectName = projectJson.name;
|
|
22
|
-
if (projectName.slice(0, 3) === 'the') {
|
|
23
|
-
const prefix =
|
|
24
|
-
projectName.slice(0, 3).charAt(0).toUpperCase() +
|
|
25
|
-
projectName.slice(0, 3).slice(1);
|
|
26
|
-
projectName = `${prefix} ${
|
|
27
|
-
projectName.slice(3).charAt(0).toUpperCase() +
|
|
28
|
-
projectName.slice(3).slice(1)
|
|
29
|
-
}`;
|
|
30
|
-
} else {
|
|
31
|
-
projectName = `${
|
|
32
|
-
projectName.charAt(0).toUpperCase() + projectName.slice(1)
|
|
33
|
-
}`;
|
|
34
|
-
}
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
const dynamicEntryPoints = globSync(`${themePath}/assets/js/blocks/*.js`).map(
|
|
38
|
-
(path) => {
|
|
39
|
-
const assetKey = path
|
|
40
|
-
.replace('assets/js/blocks/', '')
|
|
41
|
-
.replace('.js', '');
|
|
42
|
-
return assetKey;
|
|
43
|
-
}
|
|
44
|
-
);
|
|
45
|
-
const newBlockName = process.argv[2]?.toLowerCase();
|
|
46
|
-
const patternID = process.argv[3];
|
|
47
|
-
|
|
48
|
-
if (!newBlockName) {
|
|
49
|
-
return console.log('Did you forget to give the new block a name?');
|
|
50
|
-
}
|
|
51
|
-
if (!patternID) {
|
|
52
|
-
return console.log('Did you forget to supply the pattern ID?');
|
|
53
|
-
}
|
|
54
|
-
if (dynamicEntryPoints.indexOf(newBlockName) !== -1) {
|
|
55
|
-
return console.log(
|
|
56
|
-
`Alas! There is already a block called ${newBlockName} :( You'll have to try something else..`
|
|
57
|
-
);
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
fs.writeFileSync(
|
|
61
|
-
`${themePath}/inc/acf-blocks/${newBlockName}.php`,
|
|
62
|
-
acfTemplate(newBlockName, projectName)
|
|
63
|
-
);
|
|
64
|
-
|
|
65
|
-
let data = new FormData();
|
|
66
|
-
data.append('action', 'get_pattern_block');
|
|
67
|
-
data.append('postID', patternID);
|
|
68
|
-
|
|
69
|
-
const headers = {
|
|
70
|
-
headers: {
|
|
71
|
-
'user-agent':
|
|
72
|
-
'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/137.0.0.0 Safari/537.36'
|
|
73
|
-
}
|
|
74
|
-
};
|
|
75
|
-
|
|
76
|
-
axios.post(parentURL, data, headers).then(function (response) {
|
|
77
|
-
fs.writeFileSync(
|
|
78
|
-
`${themePath}/views/blocks/${newBlockName}.twig`,
|
|
79
|
-
response.data.html
|
|
80
|
-
);
|
|
81
|
-
});
|
|
82
|
-
|
|
83
|
-
console.log(
|
|
84
|
-
`👑 👑 👑 Hurrah! You made a new child block called ${newBlockName} 👑 👑 👑`
|
|
85
|
-
);
|