-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
153 changed files
with
3,716 additions
and
437 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,127 @@ | ||
/** | ||
* Compile scss files. | ||
* | ||
* @param {string} from - Path to a folder or file. | ||
* @param {string} to - String to prefix, suffix or replace the current file name. | ||
* @param {object} options - Object | ||
* | ||
* Example config object: { | ||
* | ||
* color-scheme: [ | ||
* { | ||
* entry: path.resolve("resources/sass/color-scheme-variables.scss"), | ||
* dest: path.resolve(outputFolder, "assets/css/color_scheme.min.css"), | ||
* options: { | ||
* includePaths, | ||
* sourceMap: "file", | ||
* }, | ||
* }, | ||
* ], | ||
*/ | ||
|
||
const sass = require("sass"); | ||
const path = require("path"); | ||
const fs = require("fs"); | ||
const postcss = require("postcss"); | ||
const cssnano = require("cssnano"); | ||
const prefixer = require("postcss-prefix-selector"); | ||
const autoprefixer = require("autoprefixer"); | ||
|
||
const getPlugins = (options) => { | ||
const plugins = []; | ||
|
||
plugins.push(autoprefixer({ grid: "no-autoplace" })); | ||
|
||
if (options.minify) { | ||
plugins.push(cssnano({ safe: true })); | ||
} | ||
|
||
return plugins; | ||
}; | ||
|
||
const buildColorScheme = (entry, dest, options) => { | ||
const plugins = getPlugins(options); | ||
|
||
let postcssSourceMap = false; | ||
if (options.sourceMap === true) { | ||
postcssSourceMap = true; // inline | ||
} else if (options.sourceMap === "file") { | ||
postcssSourceMap = options.sourceMap; // as a file | ||
} | ||
|
||
// Read contents of the entry file and the base color scheme SCSS file | ||
const entryVariables = fs.readFileSync(entry, "utf8"); | ||
const imports = fs.readFileSync( | ||
path.resolve( | ||
...(options.includePaths || []), | ||
"@openeuropa/bcl-theme-default/src/scss/color-scheme.scss" | ||
), | ||
"utf8" | ||
); | ||
const generator = fs.readFileSync( | ||
path.resolve( | ||
...(options.includePaths || []), | ||
"@openeuropa/bcl-theme-default/src/scss/color_scheme/generator.scss" | ||
), | ||
"utf8" | ||
); | ||
|
||
// Concatenate the contents | ||
const scssContent = imports + "\n" + entryVariables + "\n" + generator; | ||
|
||
const sassResult = sass.renderSync({ | ||
data: scssContent, | ||
outFile: dest, | ||
noErrorCss: true, | ||
outputStyle: "expanded", | ||
sourceMap: options.sourceMap !== false, | ||
sourceMapContents: options.sourceMap === true, | ||
sourceMapEmbed: options.sourceMap === true, | ||
includePaths: [ | ||
path.resolve(process.cwd(), "node_modules"), | ||
...(options.includePaths || []), | ||
], | ||
}); | ||
|
||
postcss(plugins) | ||
.use( | ||
prefixer({ | ||
prefix: options.prefix ? options.prefix : "", | ||
|
||
transform: function ( | ||
prefix, | ||
selector, | ||
prefixedSelector, | ||
filePath, | ||
rule | ||
) { | ||
if (prefix) { | ||
return prefixedSelector; | ||
} else { | ||
return selector; | ||
} | ||
}, | ||
}) | ||
) | ||
.process(sassResult.css, { | ||
map: | ||
postcssSourceMap === "file" | ||
? { inline: false, prev: sassResult.map.toString() } | ||
: postcssSourceMap, | ||
from: entry, | ||
to: dest, | ||
}) | ||
.then((postcssResult) => { | ||
fs.mkdirSync(path.dirname(dest), { recursive: true }); | ||
fs.writeFileSync(dest, postcssResult.css); | ||
|
||
if (postcssResult.map) { | ||
fs.writeFileSync(`${dest}.map`, postcssResult.map.toString()); | ||
} | ||
}); | ||
}; | ||
|
||
module.exports = { | ||
getPlugins, | ||
buildColorScheme, | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
{ | ||
"version": "1.3.0", | ||
"version": "1.4.0", | ||
"npmClient": "yarn", | ||
"useWorkspaces": true, | ||
"changelog": { | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
diff --git a/src/index.js b/src/index.js | ||
index 3197dc8..406abfe 100644 | ||
--- a/node_modules/drupal-attribute/src/index.js | ||
+++ b/node_modules/drupal-attribute/src/index.js | ||
@@ -100,6 +100,44 @@ class DrupalAttribute extends Map { | ||
|
||
return result; | ||
} | ||
+ | ||
+ /** | ||
+ * Merge another DrupalAttribute instance into this one. | ||
+ * @param {DrupalAttribute} collection | ||
+ * @returns {DrupalAttribute} | ||
+ */ | ||
+ merge(collection) { | ||
+ // Convert both the current attributes and the input collection's attributes to plain objects. | ||
+ let currentAttributes = Object.fromEntries(this); | ||
+ let newAttributes = Object.fromEntries(collection); | ||
+ | ||
+ // Perform a deep merge. | ||
+ let mergedAttributes = this.mergeDeep(currentAttributes, newAttributes); | ||
+ | ||
+ // Clear the current Map and set the merged attributes. | ||
+ this.clear(); | ||
+ for (let key in mergedAttributes) { | ||
+ this.set(key, mergedAttributes[key]); | ||
+ } | ||
+ | ||
+ return this; | ||
+ } | ||
+ | ||
+ // Helper function for deep merging. | ||
+ mergeDeep(target, source) { | ||
+ for (let key in source) { | ||
+ if (source[key] instanceof Array) { | ||
+ if (!target[key]) target[key] = []; | ||
+ target[key] = Array.from(new Set(target[key].concat(source[key]))); | ||
+ } else if (source[key] instanceof Object) { | ||
+ if (!target[key]) target[key] = {}; | ||
+ Object.assign(source[key], this.mergeDeep(target[key], source[key])); | ||
+ } else { | ||
+ target[key] = source[key]; | ||
+ } | ||
+ } | ||
+ return target; | ||
+ } | ||
} | ||
|
||
-module.exports = DrupalAttribute; | ||
\ No newline at end of file | ||
+module.exports = DrupalAttribute; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
348e20b
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🎉 Published on https://oelibrary.netlify.app as production
🚀 Deployed on https://66b5ec6b8dae3cf32c906a44--oelibrary.netlify.app
348e20b
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🚀 Deployed on https://v1-4-0--oelibrary.netlify.app