@total_onion/onion-library 3.0.7 → 3.0.9
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/components/webc-post-filter-module/dev-content/dev-content.js +11 -2
- package/components/webc-post-filter-module/dev-content/dev-contentlocal.js +9 -0
- package/components/webc-post-filter-module/dev-content/remy-garden-contemplation.webp +0 -0
- package/createNewBlock.js +8 -4
- package/new-block-templates/template-block-json.js +35 -0
- package/package.json +1 -1
- package/removeBlock.js +42 -49
- package/new-block-templates/template-acf-pattern.js +0 -25
- package/new-block-templates/template-acf.js +0 -19
- package/new-block-templates/template-swiper.js +0 -125
- package/new-block-templates/template-vue.js +0 -58
|
@@ -30,6 +30,7 @@ import marthaOnMat from './martha-on-the-mat.webp';
|
|
|
30
30
|
import vanilleBass from './vanille-bass.webp';
|
|
31
31
|
import vanilleNap from './vanille-asleep.webp';
|
|
32
32
|
import mephyMice from './mephy-dreams-of-mice.webp';
|
|
33
|
+
import remyGardenContemplation from './remy-garden-contemplation.webp';
|
|
33
34
|
|
|
34
35
|
export const devContentPets = [
|
|
35
36
|
{
|
|
@@ -309,14 +310,22 @@ export const devContentPets = [
|
|
|
309
310
|
},
|
|
310
311
|
|
|
311
312
|
categories: [14, 10, 4, 1]
|
|
312
|
-
}
|
|
313
|
+
},
|
|
313
314
|
{
|
|
314
315
|
name: `Ramses <span class='font-secondary'>School Day</span>`,
|
|
315
316
|
link: 'https://totalonion.com',
|
|
316
317
|
images: {
|
|
317
318
|
post_image_src: ramsesSchoolDay
|
|
318
319
|
},
|
|
319
|
-
categories: [13, 3, 10, 5]
|
|
320
|
+
categories: [13, 3, 10, 5]
|
|
321
|
+
},
|
|
322
|
+
{
|
|
323
|
+
name: `Remy <span class='font-secondary'>Garden Contemplation</span>`,
|
|
324
|
+
link: 'https://totalonion.com',
|
|
325
|
+
images: {
|
|
326
|
+
post_image_src: remyGardenContemplation
|
|
327
|
+
},
|
|
328
|
+
categories: [13, 3, 10, 5]
|
|
320
329
|
}
|
|
321
330
|
];
|
|
322
331
|
|
|
@@ -44,6 +44,7 @@ const marthaOnMat =
|
|
|
44
44
|
const vanilleBass = '../webc-post-filter-module/dev-content/vanille-bass.webp';
|
|
45
45
|
const vanilleNap = '../webc-post-filter-module/dev-content/vanille-asleep.webp';
|
|
46
46
|
const mephyMice = './mephy-dreams-of-mice.webp';
|
|
47
|
+
const remyGardenContemplation = './remy-garden-contemplation.webp';
|
|
47
48
|
|
|
48
49
|
export const devContentPets = [
|
|
49
50
|
{
|
|
@@ -331,6 +332,14 @@ export const devContentPets = [
|
|
|
331
332
|
post_image_src: ramsesSchoolDay
|
|
332
333
|
},
|
|
333
334
|
|
|
335
|
+
categories: [13, 3, 10, 5]
|
|
336
|
+
},
|
|
337
|
+
{
|
|
338
|
+
name: `Remy <span class='font-secondary'>Garden Contemplation</span>`,
|
|
339
|
+
link: 'https://totalonion.com',
|
|
340
|
+
images: {
|
|
341
|
+
post_image_src: remyGardenContemplation
|
|
342
|
+
},
|
|
334
343
|
categories: [13, 3, 10, 5]
|
|
335
344
|
}
|
|
336
345
|
];
|
|
Binary file
|
package/createNewBlock.js
CHANGED
|
@@ -3,9 +3,7 @@ const fs = require('fs');
|
|
|
3
3
|
const {globSync} = require('glob');
|
|
4
4
|
const yargs = require('yargs');
|
|
5
5
|
const {exec} = require('child_process');
|
|
6
|
-
const
|
|
7
|
-
const vueTemplates = require('./new-block-templates/template-vue');
|
|
8
|
-
const acfTemplate = require('./new-block-templates/template-acf');
|
|
6
|
+
const acfTemplate = require('./new-block-templates/template-block-json');
|
|
9
7
|
const defaultTemplates = require('./new-block-templates/template-default');
|
|
10
8
|
|
|
11
9
|
const themePath =
|
|
@@ -132,8 +130,14 @@ fs.writeFileSync(
|
|
|
132
130
|
`${themePath}/views/blocks/${newBlockName}.twig`,
|
|
133
131
|
templateData
|
|
134
132
|
);
|
|
133
|
+
|
|
134
|
+
// Create block directory inside acf-blocks if it doesn't exist
|
|
135
|
+
if (!fs.existsSync(`${themePath}/inc/acf-blocks/${newBlockName}`)) {
|
|
136
|
+
fs.mkdirSync(`${themePath}/inc/acf-blocks/${newBlockName}`);
|
|
137
|
+
}
|
|
138
|
+
|
|
135
139
|
fs.writeFileSync(
|
|
136
|
-
`${themePath}/inc/acf-blocks/${newBlockName}.
|
|
140
|
+
`${themePath}/inc/acf-blocks/${newBlockName}/block.json`,
|
|
137
141
|
acfTemplate(newBlockName, projectName)
|
|
138
142
|
);
|
|
139
143
|
// fs.writeFileSync(
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
module.exports = function (newBlockName, projectName) {
|
|
2
|
+
const blockTitle =
|
|
3
|
+
newBlockName.charAt(0).toUpperCase() +
|
|
4
|
+
newBlockName.slice(1).replaceAll('-', ' ');
|
|
5
|
+
const namespace = projectName.toLowerCase().replaceAll(' ', '-');
|
|
6
|
+
|
|
7
|
+
return `{
|
|
8
|
+
"$schema": "https://schemas.wp.org/trunk/block.json",
|
|
9
|
+
"apiVersion": 3,
|
|
10
|
+
"name": "${namespace}/${newBlockName}",
|
|
11
|
+
"title": "${blockTitle}",
|
|
12
|
+
"category": "common",
|
|
13
|
+
"icon": "smiley",
|
|
14
|
+
"description": "${blockTitle} block",
|
|
15
|
+
"keywords": ["content", "text"],
|
|
16
|
+
"version": "1.0.0",
|
|
17
|
+
"textdomain": "${namespace}",
|
|
18
|
+
"supports": {
|
|
19
|
+
"anchor": true,
|
|
20
|
+
"align": false
|
|
21
|
+
},
|
|
22
|
+
"example": {
|
|
23
|
+
"attributes": {
|
|
24
|
+
"mode": "preview",
|
|
25
|
+
"data": {
|
|
26
|
+
"is_example": true
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
},
|
|
30
|
+
"acf": {
|
|
31
|
+
"mode": "preview",
|
|
32
|
+
"renderCallback": "core_block_render_post_object_v3"
|
|
33
|
+
}
|
|
34
|
+
}`;
|
|
35
|
+
};
|
package/package.json
CHANGED
package/removeBlock.js
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
require('dotenv').config();
|
|
2
2
|
const fs = require('fs');
|
|
3
3
|
const readline = require('readline');
|
|
4
|
-
const {
|
|
5
|
-
const themePath =
|
|
4
|
+
const {globSync} = require('glob');
|
|
5
|
+
const themePath =
|
|
6
|
+
process.env.THEME_PATH || 'web/wp-content/themes/global-theme';
|
|
6
7
|
|
|
7
8
|
const rl = readline.createInterface({
|
|
8
9
|
input: process.stdin,
|
|
@@ -16,68 +17,60 @@ const finalAnswer = {
|
|
|
16
17
|
let result = 'no';
|
|
17
18
|
|
|
18
19
|
function deleteBlockFiles(blockName) {
|
|
19
|
-
fs.unlink(
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
if (err) {
|
|
23
|
-
console.error(err);
|
|
24
|
-
}
|
|
20
|
+
fs.unlink(`${themePath}/assets/js/blocks/${blockName}.js`, (err) => {
|
|
21
|
+
if (err) {
|
|
22
|
+
console.error(err);
|
|
25
23
|
}
|
|
26
|
-
);
|
|
27
|
-
fs.unlink(
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
if (err) {
|
|
31
|
-
console.error(err);
|
|
32
|
-
}
|
|
24
|
+
});
|
|
25
|
+
fs.unlink(`${themePath}/assets/scss/blocks/${blockName}.scss`, (err) => {
|
|
26
|
+
if (err) {
|
|
27
|
+
console.error(err);
|
|
33
28
|
}
|
|
34
|
-
);
|
|
35
|
-
if(fs.existsSync(`${themePath}/assets/scss/blocks/${blockName}`)) {
|
|
36
|
-
fs.rmSync(`${themePath}/assets/scss/blocks/${blockName}`, {
|
|
29
|
+
});
|
|
30
|
+
if (fs.existsSync(`${themePath}/assets/scss/blocks/${blockName}`)) {
|
|
31
|
+
fs.rmSync(`${themePath}/assets/scss/blocks/${blockName}`, {
|
|
32
|
+
recursive: true
|
|
33
|
+
});
|
|
37
34
|
}
|
|
38
|
-
fs.unlink(
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
if (err) {
|
|
42
|
-
console.error(err);
|
|
43
|
-
}
|
|
35
|
+
fs.unlink(`${themePath}/views/blocks/${blockName}.twig`, (err) => {
|
|
36
|
+
if (err) {
|
|
37
|
+
console.error(err);
|
|
44
38
|
}
|
|
45
|
-
);
|
|
46
|
-
fs.unlink(
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
if (err) {
|
|
50
|
-
console.error(err);
|
|
51
|
-
}
|
|
39
|
+
});
|
|
40
|
+
fs.unlink(`${themePath}/assets/vue/blocks/${blockName}.vue`, (err) => {
|
|
41
|
+
if (err) {
|
|
42
|
+
console.error(err);
|
|
52
43
|
}
|
|
53
|
-
);
|
|
54
|
-
if(fs.existsSync(`${themePath}/assets/vue/blocks/${blockName}`)) {
|
|
55
|
-
fs.rmSync(`${themePath}/assets/vue/blocks/${blockName}`, {
|
|
44
|
+
});
|
|
45
|
+
if (fs.existsSync(`${themePath}/assets/vue/blocks/${blockName}`)) {
|
|
46
|
+
fs.rmSync(`${themePath}/assets/vue/blocks/${blockName}`, {
|
|
47
|
+
recursive: true
|
|
48
|
+
});
|
|
56
49
|
}
|
|
57
50
|
fs.unlink(`./cypress/e2e/components/${blockName}.cy.js`, (err) => {
|
|
58
51
|
if (err) {
|
|
59
52
|
console.error(err);
|
|
60
53
|
}
|
|
61
54
|
});
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
55
|
+
|
|
56
|
+
// Remove the block directory in acf-blocks (contains block.json)
|
|
57
|
+
if (fs.existsSync(`${themePath}/inc/acf-blocks/${blockName}`)) {
|
|
58
|
+
fs.rmSync(`${themePath}/inc/acf-blocks/${blockName}`, {
|
|
59
|
+
recursive: true
|
|
60
|
+
});
|
|
61
|
+
}
|
|
62
|
+
|
|
70
63
|
removeACFJson(blockName);
|
|
71
64
|
rl.close();
|
|
72
65
|
}
|
|
73
66
|
|
|
74
67
|
function removeACFJson(name) {
|
|
75
|
-
const existingAcfFiles = globSync(`${themePath}/acf-json/*.json`)
|
|
76
|
-
|
|
77
|
-
const assetKey = path
|
|
78
|
-
.replace('assets/js/blocks/', '');
|
|
68
|
+
const existingAcfFiles = globSync(`${themePath}/acf-json/*.json`).map(
|
|
69
|
+
(path) => {
|
|
70
|
+
const assetKey = path.replace('assets/js/blocks/', '');
|
|
79
71
|
return assetKey;
|
|
80
|
-
}
|
|
72
|
+
}
|
|
73
|
+
);
|
|
81
74
|
|
|
82
75
|
existingAcfFiles.forEach((file, index) => {
|
|
83
76
|
let rawdata = fs.readFileSync(file);
|
|
@@ -110,8 +103,8 @@ rl.question(
|
|
|
110
103
|
rl.close();
|
|
111
104
|
}
|
|
112
105
|
result = 'yes';
|
|
113
|
-
if(process.argv[2].indexOf(
|
|
114
|
-
deleteBlockFiles(process.argv[2].split(
|
|
106
|
+
if (process.argv[2].indexOf('block-') === 0) {
|
|
107
|
+
deleteBlockFiles(process.argv[2].split('block-')[1]);
|
|
115
108
|
}
|
|
116
109
|
}
|
|
117
110
|
);
|
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
module.exports = function (newBlockName, projectName) {
|
|
2
|
-
return `<?php
|
|
3
|
-
|
|
4
|
-
acf_register_block_type(
|
|
5
|
-
array(
|
|
6
|
-
'name' => '${newBlockName}',
|
|
7
|
-
'title' => __( '${
|
|
8
|
-
newBlockName.charAt(0).toUpperCase() +
|
|
9
|
-
newBlockName.slice(1).replaceAll('-', ' ')
|
|
10
|
-
}', '${projectName} Admin' ),
|
|
11
|
-
'render_callback' => 'core_block_render_post_object_v3',
|
|
12
|
-
'category' => 'child-patterns',
|
|
13
|
-
'icon' => get_svg_icon_content('green-brick.svg'),
|
|
14
|
-
'keywords' => array('content', 'text' ),
|
|
15
|
-
'mode' => 'preview',
|
|
16
|
-
'supports' => array( 'align' => false, 'anchor' => true ),
|
|
17
|
-
'example' => [
|
|
18
|
-
'attributes' => [
|
|
19
|
-
'mode' => 'preview',
|
|
20
|
-
'data' => ['is_example' => true]
|
|
21
|
-
]
|
|
22
|
-
]
|
|
23
|
-
)
|
|
24
|
-
);`;
|
|
25
|
-
};
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
module.exports = function (newBlockName, projectName) {
|
|
2
|
-
return `<?php
|
|
3
|
-
|
|
4
|
-
acf_register_block_type(
|
|
5
|
-
array(
|
|
6
|
-
'name' => '${newBlockName}',
|
|
7
|
-
'title' => __( '${
|
|
8
|
-
newBlockName.charAt(0).toUpperCase() +
|
|
9
|
-
newBlockName.slice(1).replaceAll('-', ' ')
|
|
10
|
-
}', '${projectName} Admin' ),
|
|
11
|
-
'render_callback' => 'core_block_render_post_object_v3',
|
|
12
|
-
'category' => 'common',
|
|
13
|
-
'icon' => get_svg_icon_content('brick.svg'),
|
|
14
|
-
'keywords' => array('content', 'text' ),
|
|
15
|
-
'mode' => 'preview',
|
|
16
|
-
'supports' => array( 'align' => false, 'anchor' => true ),
|
|
17
|
-
)
|
|
18
|
-
);`;
|
|
19
|
-
};
|
|
@@ -1,125 +0,0 @@
|
|
|
1
|
-
module.exports = {
|
|
2
|
-
templatejs: function () {
|
|
3
|
-
return `import {loadCss, getSwiperAssetsV2} from '@total_onion/onion-utils/onion-utils';
|
|
4
|
-
import('swiper/css/bundle');
|
|
5
|
-
|
|
6
|
-
export default function carouselmultilayoutJs(options = {}) {
|
|
7
|
-
try {
|
|
8
|
-
const {block} = options;
|
|
9
|
-
Promise.all([
|
|
10
|
-
getSwiperAssetsV2(),
|
|
11
|
-
loadCss(block.dataset.assetkey, options)
|
|
12
|
-
]).then((values) => {
|
|
13
|
-
const {
|
|
14
|
-
Swiper,
|
|
15
|
-
Navigation,
|
|
16
|
-
Pagination,
|
|
17
|
-
Lazy,
|
|
18
|
-
Autoplay,
|
|
19
|
-
EffectFade,
|
|
20
|
-
EffectCoverflow,
|
|
21
|
-
EffectCreative
|
|
22
|
-
} = values[0][0];
|
|
23
|
-
|
|
24
|
-
const dataAttributes = block.dataset;
|
|
25
|
-
const slidesDesktop = dataAttributes.desktopslides;
|
|
26
|
-
const autoplayCarousel = Number(dataAttributes.autoplay) === 1;
|
|
27
|
-
const centerActiveSlide =
|
|
28
|
-
Number(dataAttributes.centeractiveslide) === 1;
|
|
29
|
-
const delay = dataAttributes.transitiondelay * 1000;
|
|
30
|
-
const speed = Number(dataAttributes.transitionspeed);
|
|
31
|
-
const style =
|
|
32
|
-
dataAttributes.transitionstyle === 'default'
|
|
33
|
-
? ''
|
|
34
|
-
: dataAttributes.transitionstyle;
|
|
35
|
-
const carouselmultilayoutSwiper = new Swiper(
|
|
36
|
-
block.querySelector('.swiper'),
|
|
37
|
-
{
|
|
38
|
-
modules: [
|
|
39
|
-
Navigation,
|
|
40
|
-
Pagination,
|
|
41
|
-
Lazy,
|
|
42
|
-
Autoplay,
|
|
43
|
-
EffectFade,
|
|
44
|
-
EffectCoverflow,
|
|
45
|
-
EffectCreative
|
|
46
|
-
],
|
|
47
|
-
slidesPerView: 1,
|
|
48
|
-
loop: false,
|
|
49
|
-
preloadImages: true,
|
|
50
|
-
watchSlidesVisibility: true,
|
|
51
|
-
effect: style,
|
|
52
|
-
creativeEffect: {
|
|
53
|
-
prev: {
|
|
54
|
-
shadow: true,
|
|
55
|
-
translate: [0, 0, -400]
|
|
56
|
-
},
|
|
57
|
-
next: {
|
|
58
|
-
translate: ['100%', 0, 0]
|
|
59
|
-
}
|
|
60
|
-
},
|
|
61
|
-
coverflowEffect: {
|
|
62
|
-
rotate: 20,
|
|
63
|
-
depth: 50,
|
|
64
|
-
scale: 0.9,
|
|
65
|
-
modifier: 1,
|
|
66
|
-
slideShadows: true
|
|
67
|
-
},
|
|
68
|
-
fadeEffect: {
|
|
69
|
-
crossFade: true
|
|
70
|
-
},
|
|
71
|
-
lazy: {
|
|
72
|
-
loadPrevNext: true
|
|
73
|
-
},
|
|
74
|
-
speed,
|
|
75
|
-
autoplay: autoplayCarousel
|
|
76
|
-
? {
|
|
77
|
-
delay
|
|
78
|
-
}
|
|
79
|
-
: '',
|
|
80
|
-
watchOverflow: true,
|
|
81
|
-
breakpoints: {
|
|
82
|
-
1024: {
|
|
83
|
-
slidesPerView: slidesDesktop,
|
|
84
|
-
spaceBetween: 50,
|
|
85
|
-
centeredSlides: centerActiveSlide
|
|
86
|
-
}
|
|
87
|
-
},
|
|
88
|
-
navigation: {
|
|
89
|
-
nextEl: block.querySelector('.swiper-button-next'),
|
|
90
|
-
prevEl: block.querySelector('.swiper-button-prev')
|
|
91
|
-
},
|
|
92
|
-
pagination: {
|
|
93
|
-
el: block.querySelector('.swiper-pagination'),
|
|
94
|
-
type: 'bullets',
|
|
95
|
-
clickable: true
|
|
96
|
-
}
|
|
97
|
-
}
|
|
98
|
-
);
|
|
99
|
-
});
|
|
100
|
-
} catch (error) {
|
|
101
|
-
console.error(error);
|
|
102
|
-
}
|
|
103
|
-
}
|
|
104
|
-
`;
|
|
105
|
-
},
|
|
106
|
-
templatetwig: function (newBlockName) {
|
|
107
|
-
return `
|
|
108
|
-
<div class="swiper">
|
|
109
|
-
<div class="swiper-wrapper">
|
|
110
|
-
<div class="swiper-slide ${newBlockName}__slide">
|
|
111
|
-
{% set desktopImage = Image(fields.desktop_image) %}
|
|
112
|
-
{% set mobileImage = Image(fields.mobile_image) %}
|
|
113
|
-
{% set desktopSizes = '(min-width: 1440px) 100vw, (min-width: 1024px) 1024px, (min-width: 768px) 768px' %}
|
|
114
|
-
{% set mobileSizes = '(min-width: 768px) 768px, (min-width: 500px) 500px, 250px' %}
|
|
115
|
-
|
|
116
|
-
{{ include('components/responsive-image.twig', {fields : fields, block : block, blockClassName : blockClassName}, with_context = false) }}
|
|
117
|
-
</div>
|
|
118
|
-
</div>
|
|
119
|
-
<div class="swiper-pagination"></div>
|
|
120
|
-
<div class="swiper-button-prev"></div>
|
|
121
|
-
<div class="swiper-button-next"></div>
|
|
122
|
-
</div>
|
|
123
|
-
`;
|
|
124
|
-
}
|
|
125
|
-
};
|
|
@@ -1,58 +0,0 @@
|
|
|
1
|
-
module.exports = {
|
|
2
|
-
templatevuefile: function (newBlockName) {
|
|
3
|
-
return `
|
|
4
|
-
<template>
|
|
5
|
-
<div>
|
|
6
|
-
</div>
|
|
7
|
-
</template>
|
|
8
|
-
|
|
9
|
-
<script lang="javascript">
|
|
10
|
-
import animations from "@pernod-ricard-global-cms/jsanimations";
|
|
11
|
-
export default {
|
|
12
|
-
name: "${newBlockName}",
|
|
13
|
-
data() {
|
|
14
|
-
return {
|
|
15
|
-
allDrinks: [],
|
|
16
|
-
};
|
|
17
|
-
},
|
|
18
|
-
beforeMount() {
|
|
19
|
-
},
|
|
20
|
-
mounted() {
|
|
21
|
-
|
|
22
|
-
},
|
|
23
|
-
methods: {
|
|
24
|
-
|
|
25
|
-
},
|
|
26
|
-
computed: {
|
|
27
|
-
|
|
28
|
-
},
|
|
29
|
-
};
|
|
30
|
-
</script>
|
|
31
|
-
|
|
32
|
-
`;
|
|
33
|
-
},
|
|
34
|
-
templatejs: function (newBlockName) {
|
|
35
|
-
return `
|
|
36
|
-
import {loadCss} from '@total_onion/onion-utils/onion-utils';
|
|
37
|
-
';
|
|
38
|
-
import {createApp} from 'vue';
|
|
39
|
-
import ${newBlockName} from 'Assets/vue/blocks/${newBlockName}.vue';
|
|
40
|
-
|
|
41
|
-
export default function ${newBlockName.replaceAll('-', '')}Js ( options = {} ) {
|
|
42
|
-
try {
|
|
43
|
-
const { block } = options;
|
|
44
|
-
loadCss(block.dataset.assetkey, options).then(() => {
|
|
45
|
-
const mountElement = block.children[0];
|
|
46
|
-
createApp(${newBlockName}, {...mountElement.dataset}).mount(mountElement);
|
|
47
|
-
});
|
|
48
|
-
} catch ( error ) {
|
|
49
|
-
console.error( error );
|
|
50
|
-
}
|
|
51
|
-
}`;
|
|
52
|
-
},
|
|
53
|
-
templatetwig: function (newBlockName) {
|
|
54
|
-
return `
|
|
55
|
-
<div id="${newBlockName}"></div>
|
|
56
|
-
`;
|
|
57
|
-
}
|
|
58
|
-
};
|