Added "activeDataFile" parameter in hbs templates.
This commit is contained in:
@@ -60,8 +60,8 @@ module.exports = class extends Generator {
|
|||||||
);
|
);
|
||||||
|
|
||||||
this.fs.copyTpl(
|
this.fs.copyTpl(
|
||||||
this.templatePath('src/scripts/template.mjs'),
|
this.templatePath('src/scripts/template.js'),
|
||||||
this.destinationPath(path.join(pathDist, 'src', 'scripts', data.blockFilename + '.mjs')),
|
this.destinationPath(path.join(pathDist, 'src', 'scripts', data.blockFilename + '.js')),
|
||||||
data
|
data
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
module.exports = {
|
module.exports = {
|
||||||
cssUrl: "https://",
|
cssUrl: "https://",
|
||||||
|
jsUrl: "https://",
|
||||||
blockName: "<%= blockFilename %>",
|
blockName: "<%= blockFilename %>",
|
||||||
baseView: "<%= baseView %>",
|
baseView: "<%= baseView %>",
|
||||||
remToPx: <%= remToPx %>,
|
remToPx: <%= remToPx %>,
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
/**
|
/**
|
||||||
* Use "rem" instead of pixels. 1rem = 16pixels
|
* Use "rem" instead of pixels. 1rem = <%= remToPx %>pixels
|
||||||
* No need to use rem in situations of "1px". (usually used for borders width).
|
* No need to use rem in situations of "1px". (usually used for borders width).
|
||||||
*
|
*
|
||||||
* Use BEM naming system for class names: http://getbem.com/naming/
|
* Use BEM naming system for class names: http://getbem.com/naming/
|
||||||
@@ -25,7 +25,7 @@
|
|||||||
|
|
||||||
&__visual {
|
&__visual {
|
||||||
&-image {
|
&-image {
|
||||||
// Example of BEM usage.
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
<section class="<%= blockClassName %>">
|
<section class="<%= blockClassName %> <%= blockClassName %>--{{ activeDataFile }}">
|
||||||
|
|
||||||
{{!
|
{{!
|
||||||
Remove Everything Below:
|
Remove Everything Below:
|
||||||
|
|||||||
@@ -2,8 +2,8 @@
|
|||||||
<meta charset="UTF-8">
|
<meta charset="UTF-8">
|
||||||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||||
|
|
||||||
<link rel="stylesheet" href="{{ config.cssUrl }}">
|
{{#if config.cssUrl }}<link rel="stylesheet" href="{{ config.cssUrl }}">
|
||||||
<link rel="stylesheet" href="styles/page--main.css">
|
{{/if}}<link rel="stylesheet" href="styles/page--main.css">
|
||||||
<link rel="stylesheet" href="styles/{{ config.blockName }}.min.css">
|
<link rel="stylesheet" href="styles/{{ config.blockName }}.min.css">
|
||||||
<link rel="stylesheet" href="https://unpkg.com/swiper@8/swiper-bundle.min.css"/>
|
<link rel="stylesheet" href="https://unpkg.com/swiper@8/swiper-bundle.min.css"/>
|
||||||
</head>
|
</head>
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
<script src="https://code.jquery.com/jquery-3.4.1.min.js"></script>
|
<script src="https://code.jquery.com/jquery-3.4.1.min.js"></script>
|
||||||
<script src="https://unpkg.com/swiper@8/swiper-bundle.min.js"></script>
|
<script src="https://unpkg.com/swiper@8/swiper-bundle.min.js"></script>
|
||||||
<script src="scripts/page--toolbar.js"></script>
|
<script src="scripts/page--toolbar.js"></script>{{#if config.jsUrl }}
|
||||||
|
<script src="{{ config.jsUrl }}"></script>{{/if}}
|
||||||
<script src="scripts/{{ config.blockName }}.min.js"></script>
|
<script src="scripts/{{ config.blockName }}.min.js"></script>
|
||||||
|
|||||||
+1
-1
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "create-block-dev-tool",
|
"name": "create-block-dev-tool",
|
||||||
"version": "1.0.2",
|
"version": "1.0.3",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"start": "component-dev",
|
"start": "component-dev",
|
||||||
"dev": "NODE_ENV=development node server.js",
|
"dev": "NODE_ENV=development node server.js",
|
||||||
|
|||||||
@@ -20,8 +20,7 @@ import fs from "fs/promises";
|
|||||||
|
|
||||||
const isDev = config.has('mode') && config.get('mode') === 'development';
|
const isDev = config.has('mode') && config.get('mode') === 'development';
|
||||||
const modulePath = 'node_modules/create-block-dev-tool/';
|
const modulePath = 'node_modules/create-block-dev-tool/';
|
||||||
const projectDir = isDev ? '' : modulePath;
|
const projectDir = modulePath;
|
||||||
console.log('Development Mode:', isDev);
|
|
||||||
|
|
||||||
const sass = gulpSass(dartSass);
|
const sass = gulpSass(dartSass);
|
||||||
|
|
||||||
@@ -53,18 +52,20 @@ app.get('/', async (req, res) => {
|
|||||||
const data = await fsExtra.readJson(`./data/${jsonFileName}.json`);
|
const data = await fsExtra.readJson(`./data/${jsonFileName}.json`);
|
||||||
|
|
||||||
Object.assign(data, {
|
Object.assign(data, {
|
||||||
config: {
|
config: Object.assign(
|
||||||
projectDir,
|
JSON.parse(JSON.stringify(config)), // The entire config object.
|
||||||
dataFiles: dataFiles.map((name) => {
|
{
|
||||||
return {
|
projectDir,
|
||||||
name,
|
activeDataFile: jsonFileName,
|
||||||
active: jsonFileName === name,
|
dataFiles: dataFiles.map((name) => {
|
||||||
};
|
return {
|
||||||
}),
|
name,
|
||||||
remToPx: config.has('remToPx') ? config.get('remToPx') : 16,
|
active: jsonFileName === name,
|
||||||
cssUrl: config.get('cssUrl'),
|
};
|
||||||
blockName: config.get('blockName')
|
}),
|
||||||
}
|
remToPx: config.has('remToPx') ? config.get('remToPx') : 16,
|
||||||
|
}
|
||||||
|
)
|
||||||
});
|
});
|
||||||
|
|
||||||
data.helpers = {
|
data.helpers = {
|
||||||
@@ -159,8 +160,3 @@ function prepareListOfDataFiles(dataFiles) {
|
|||||||
})
|
})
|
||||||
.sort();
|
.sort();
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO:
|
|
||||||
// Breakpoints and data options will come from backend server.
|
|
||||||
// [v] Top Panel with options to switch data (select input)
|
|
||||||
// - Options to resize the page and test Responsiveness (select input)
|
|
||||||
|
|||||||
Reference in New Issue
Block a user