+
diff --git a/includes/blocks/lcp-viewport/src/view.js b/includes/blocks/lcp-viewport/src/view.js
index e2a7ec6..04bbf1d 100644
--- a/includes/blocks/lcp-viewport/src/view.js
+++ b/includes/blocks/lcp-viewport/src/view.js
@@ -21,5 +21,4 @@
*/
/* eslint-disable no-console */
-console.log( 'Hello World! (from create-block-lcp-viewport block)' );
/* eslint-enable no-console */
diff --git a/package.json b/package.json
new file mode 100644
index 0000000..4f20e7d
--- /dev/null
+++ b/package.json
@@ -0,0 +1,10 @@
+{
+ "name": "localcontentpro",
+ "version": "0.0.1",
+ "scripts": {
+ "zip-theme": "node zip-theme.js"
+ },
+ "devDependencies": {
+ "archiver": "^5.3.2"
+ }
+}
diff --git a/script.js b/script.js
index 7e20078..20872e4 100644
--- a/script.js
+++ b/script.js
@@ -29,6 +29,7 @@ document.addEventListener('DOMContentLoaded', function () {
// Function to handle the scroll event
function handleScroll() {
+ document.documentElement.style.setProperty('--lcp--full-header--height', fullHeaderHeight + "px");
const scrolled = window.scrollY || document.documentElement.scrollTop;
@@ -36,7 +37,7 @@ document.addEventListener('DOMContentLoaded', function () {
if (scrolled >= headerHeight) {
// Add the 'lcp-fixed' class and set 'top' to 0 for side content
sideContent.classList.add('lcp-fixed');
- sideContent.style.top = fullHeaderHeight + 'px';
+ // sideContent.style.top = fullHeaderHeight + 'px';
// If the header has 'lcp-sticky-on-scroll', adjust height of side content to be 100vh - fullHeaderHeight
if (headerIsStickyOnScroll) {
@@ -44,7 +45,7 @@ document.addEventListener('DOMContentLoaded', function () {
// Add 'lcp-fixed' to the header
header.classList.add('lcp-fixed');
// Set the 'top' of the sideContent to the height of the header
- sideContent.style.top = `${fullHeaderHeight}px`;
+ // sideContent.style.top = `${fullHeaderHeight}px`;
} else if (headerIsSticky) {
// If the header is sticky but not 'sticky-on-scroll', keep the side content height adjusted
sideContent.style.height = `calc(100vh - ${fullHeaderHeight}px)`;
@@ -52,13 +53,13 @@ document.addEventListener('DOMContentLoaded', function () {
// Set side content height to 100vh when not sticky
sideContent.style.height = 'calc(100vh - 32px)';
- sideContent.style.top = '32px';
+ // sideContent.style.top = '32px';
}
} else {
// Remove the 'lcp-fixed' class from side content and header if scrolled back above the header
sideContent.classList.remove('lcp-fixed');
- sideContent.style.top = ''; // Reset the 'top' style
+ // sideContent.style.top = ''; // Reset the 'top' style
// Reset height to 100vh when not fixed
sideContent.style.height = `calc(100vh - ${fullHeaderHeight}px)` ;
diff --git a/style.css b/style.css
index 002699c..38f53f5 100644
--- a/style.css
+++ b/style.css
@@ -88,6 +88,10 @@ Version: 1.0
z-index: 3;
width: 100%
}
+#lcp-sidecontent {top:var(--lcp---header--height)}
+.admin-bar #lcp-sidecontent {
+ top: calc(var(--lcp--header--height) + 32px);
+}
#lcp-header-container.lcp-sticky {
position: fixed;
diff --git a/zip-theme.js b/zip-theme.js
new file mode 100644
index 0000000..b37fd9f
--- /dev/null
+++ b/zip-theme.js
@@ -0,0 +1,89 @@
+const fs = require('fs');
+const path = require('path');
+const archiver = require('archiver');
+
+// Path to the theme's style.css
+const styleCssPath = path.join(__dirname, 'style.css');
+
+// Directories to exclude
+const excludedDirs = [
+ 'node_modules',
+ 'src',
+ '.gitignore',
+ 'package.json',
+ 'package-lock.json',
+ 'theme.zip',
+ '.git'
+];
+
+// Helper function to check if a file or directory should be excluded
+const shouldExclude = (filePath) => {
+ return excludedDirs.some(exclude => filePath.includes(exclude));
+};
+
+// Read the style.css file and extract the theme name
+fs.readFile(styleCssPath, 'utf8', (err, data) => {
+ if (err) {
+ console.error('Error reading style.css:', err);
+ return;
+ }
+
+ // Regex to match the theme name in the header
+ const themeNameMatch = data.match(/\/\*[\s\S]*?Theme Name:\s*(.*?)\s*\*\//);
+
+ // Fallback to 'theme' if no theme name is found
+ const themeName = themeNameMatch && themeNameMatch[1] ? themeNameMatch[1].trim() : 'theme';
+
+ // Sanitize the theme name (remove spaces and convert to lowercase)
+ const sanitizedThemeName = themeName.replace(/\s+/g, '').toLowerCase();
+
+ // Define the output zip file path using the sanitized theme name
+ const output = fs.createWriteStream(path.join(__dirname, `${sanitizedThemeName}.zip`));
+
+ // Create an archiver instance
+ const archive = archiver('zip', {
+ zlib: { level: 9 } // Compression level
+ });
+
+ // Pipe the archive to the output file
+ archive.pipe(output);
+
+ // Recursively append all files in the theme directory except excluded ones
+ const addFilesRecursively = (directory) => {
+ const files = fs.readdirSync(directory);
+
+ files.forEach((file) => {
+ const filePath = path.join(directory, file);
+
+ // Exclude the file or directory if it matches the exclusion criteria
+ if (shouldExclude(filePath)) {
+ console.log(`Excluding: ${filePath}`);
+ return; // Skip this file/directory
+ }
+
+ const stat = fs.statSync(filePath);
+
+ if (stat.isDirectory()) {
+ // If it's a directory, recurse into it
+ addFilesRecursively(filePath);
+ } else {
+ // If it's a file, add it to the archive
+ archive.file(filePath, { name: path.relative(__dirname, filePath) });
+ }
+ });
+ };
+
+ // Start adding files from the theme directory
+ addFilesRecursively(__dirname);
+
+ // Finalize the archive
+ archive.finalize();
+
+ output.on('close', () => {
+ console.log(`Theme has been zipped into ${sanitizedThemeName}.zip`);
+ });
+
+ output.on('error', (err) => {
+ console.error('Error creating zip file:', err);
+ });
+});