| 1 |
// -------------------------------------------------------------------------- |
| 2 |
// --- Icons Gallery Generator |
| 3 |
// -------------------------------------------------------------------------- |
| 4 |
|
| 5 |
const path = require('path'); |
| 6 |
const icons = require(path.resolve( process.argv[2] )); |
| 7 |
const index = []; |
| 8 |
const sections = {}; |
| 9 |
|
| 10 |
// --- Indexing & Sectioning ----------------------------------------- |
| 11 |
|
| 12 |
for ( var name in icons ) { |
| 13 |
const icon = icons[name]; |
| 14 |
const section = icon.section || "Others" ; |
| 15 |
if (section != "Others" && index.indexOf(section) < 0) index.push( section ); |
| 16 |
var content = sections[section] ; |
| 17 |
if (!content) sections[section] = content = [] ; |
| 18 |
content.push(name) ; |
| 19 |
} |
| 20 |
|
| 21 |
index.sort(); |
| 22 |
if (sections["Others"]) index.push("Others"); |
| 23 |
|
| 24 |
console.log( `<div id="main">` ); |
| 25 |
|
| 26 |
// --- Gallery (per section) ----------------------------------------- |
| 27 |
|
| 28 |
console.log( `<div id="content">` ); |
| 29 |
console.log( `<div id="page">` ); |
| 30 |
console.log( ` <h1 class="page-title">Icons Gallery</h1>` ); |
| 31 |
|
| 32 |
for ( var s = 0 ; s < index.length ; s++ ) { |
| 33 |
const section = index[s] ; |
| 34 |
console.log( `<section>` ); |
| 35 |
console.log( `<article><h4 id="SECTION.${section}">${section}</h4>` ); |
| 36 |
console.log( ` <div class="database">` ); |
| 37 |
|
| 38 |
const content = sections[section] ; |
| 39 |
content.sort(); |
| 40 |
|
| 41 |
for( var k = 0 ; k < content.length ; k++ ) { |
| 42 |
const name = content[k]; |
| 43 |
const icon = icons[name]; |
| 44 |
const title = icon.title || name ; |
| 45 |
console.log( ` <div class="icon-block" onclick="window.location.href='#ICON.${name}'" title="${title}">`); |
| 46 |
console.log( ` <div class="icon-name refname" id="ICON.${name}">${name}</div>` ); |
| 47 |
console.log( ` <svg class="icon-svg" viewBox="${icon.viewBox}">` ); |
| 48 |
console.log( ` <path d="${icon.path}"/>`); |
| 49 |
console.log( ` </svg>` ); |
| 50 |
console.log( ` </div>` ); |
| 51 |
} |
| 52 |
console.log( ` </div>` ); |
| 53 |
console.log( `</article>` ); |
| 54 |
console.log( `</section>` ); |
| 55 |
} |
| 56 |
|
| 57 |
console.log( `</div>` ); // #content |
| 58 |
console.log( `</div>` ); // #page |
| 59 |
|
| 60 |
// --- Navigation Bar ------------------------------------------------ |
| 61 |
|
| 62 |
console.log( `<div id="index">` ); |
| 63 |
console.log( `<nav>` ); |
| 64 |
console.log( `<h2><a href="index.html">Dome</a></h2>` ); |
| 65 |
console.log( `<h3>Classes</h3>` ); |
| 66 |
console.log( `<ul><li><a href="module-dome_controls_icons.Icon.html">Icon (Component)</a></li>` ); |
| 67 |
for ( var s=0; s < index.length ; s++ ) { |
| 68 |
const section = index[s]; |
| 69 |
console.log( ` <li><a href="#SECTION.${section}">${section}</a></li>` ); |
| 70 |
} |
| 71 |
console.log( `</ul>` ); |
| 72 |
console.log( `<h3>Icons</h3><ul>` ); |
| 73 |
for( var name in icons ) { |
| 74 |
console.log( `<li><a href="#ICON.${name}">${name}</a></li>` ); |
| 75 |
} |
| 76 |
console.log( `</ul>`); |
| 77 |
console.log( `</nav>` ); |
| 78 |
console.log( `</div>` ); // #index |
| 79 |
|
| 80 |
console.log( `</div>` ); // #main |
| 81 |
|
| 82 |
// ------------------------------------------------------------------- |