Browse Source

Added "activeDataFile" parameter in hbs templates.

test-gpt-generated
Roman Axelrod 4 years ago
parent
commit
29734a6b94
  1. 4
      generators/block/index.cjs
  2. 1
      generators/block/templates/config/default.cjs
  3. 0
      generators/block/templates/src/scripts/template.js
  4. 4
      generators/block/templates/src/styles/template.scss
  5. 2
      generators/block/templates/src/template.template.hbs
  6. 4
      layouts/partials/head.hbs
  7. 3
      layouts/partials/scripts.hbs
  8. 2
      package.json
  9. 16
      server.js

4
generators/block/index.cjs

@ -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
generators/block/templates/config/default.cjs

@ -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 %>,

0
generators/block/templates/src/scripts/template.mjs → generators/block/templates/src/scripts/template.js

4
generators/block/templates/src/styles/template.scss

@ -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.
} }
} }

2
generators/block/templates/src/template.template.hbs

@ -1,4 +1,4 @@
<section class="<%= blockClassName %>"> <section class="<%= blockClassName %> <%= blockClassName %>--{{ activeDataFile }}">
{{! {{!
Remove Everything Below: Remove Everything Below:

4
layouts/partials/head.hbs

@ -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>

3
layouts/partials/scripts.hbs

@ -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>

2
package.json

@ -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",

16
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,8 +52,11 @@ 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(
JSON.parse(JSON.stringify(config)), // The entire config object.
{
projectDir, projectDir,
activeDataFile: jsonFileName,
dataFiles: dataFiles.map((name) => { dataFiles: dataFiles.map((name) => {
return { return {
name, name,
@ -62,9 +64,8 @@ app.get('/', async (req, res) => {
}; };
}), }),
remToPx: config.has('remToPx') ? config.get('remToPx') : 16, remToPx: config.has('remToPx') ? config.get('remToPx') : 16,
cssUrl: config.get('cssUrl'),
blockName: config.get('blockName')
} }
)
}); });
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)

Loading…
Cancel
Save