Skip to content

Commit

Permalink
Fix import for form contact sales
Browse files Browse the repository at this point in the history
  • Loading branch information
alexcarol committed Dec 16, 2024
1 parent 89869f7 commit 9f298f9
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 15 deletions.
9 changes: 5 additions & 4 deletions tools/importer/import.js
Original file line number Diff line number Diff line change
Expand Up @@ -881,9 +881,9 @@ function inlineIcons(main, html) {

icon.removeAttribute('class');

const iconHash = hashCode(icon.outerHTML);
let iconName = findIcon(icon);
if (!iconName) {
const iconHash = hashCode(icon.outerHTML);
console.error('Unknown icon hash', iconHash, icon);
iconName = `pending-${iconHash}`;
notFoundIcons.push({
Expand Down Expand Up @@ -1154,16 +1154,17 @@ export default {
preprocess: ({ document, url, html }) => {
const { pathname } = new URL(url);

report = {
locale: pathname.split('/')[1],
};

const main = document.querySelector('main');
inlineIcons(main, html);
form(main, pathname);
},
transform: ({ document, url, html }) => {
const { pathname } = new URL(url);

report = {
locale: pathname.split('/')[1],
};
fragmentPages = [];

const main = document.querySelector('main');
Expand Down
29 changes: 18 additions & 11 deletions tools/importer/svg_collector.js
Original file line number Diff line number Diff line change
@@ -1,26 +1,33 @@
const process = require('process');
const fs = require('fs');
const path = require('path');
import { readdir, readFileSync } from 'fs';
import { extname, join, basename } from 'path';
import { stdout } from 'process';

const directoryPath = './svgs'; // Replace with your folder path
const directoryPath = './tools/importer/svgs'; // Replace with your folder path

fs.readdir(directoryPath, (err, files) => {
const additionalSvgs = [
{
name: 'contact-email-48',
contents: '<svg id="icon-ui-svg" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 48 48"><path style="fill:#48E2CB;" d="M26.508 34.149H4.433l13.092-12.484 5.483 4.92 5.481-4.918 5.222 4.988c.288-.1.581-.189.879-.267l-5.503-5.257L42.108 9.445v17.518c.272.12.54.247.8.386v-18.8l-.004-.449H3.508l-.4.049v26.8h23.194c.061-.27.126-.538.206-.8zm15.01-25.25l-18.51 16.612L4.498 8.9zm-37.61.546l13.02 11.685-13.02 12.414zm33.6 19.537a8.518 8.518 0 1 0 0 17.036v-.8a7.718 7.718 0 1 1 7.718-7.718v2.03a1.63 1.63 0 0 1-3.26 0v-6.765h-.799v2.199a4.455 4.455 0 1 0 .045 5.013 2.427 2.427 0 0 0 4.814-.448V37.5a8.527 8.527 0 0 0-8.518-8.518zm0 12.177a3.659 3.659 0 1 1 3.659-3.659 3.663 3.663 0 0 1-3.659 3.659z" id="icon-ui-svg--base"></path></svg>',
},
];

readdir(directoryPath, (err, files) => {
if (err) {
console.log(`Unable to scan directory: ${err}`);
return;
}

const svgFiles = files.filter((file) => path.extname(file) === '.svg');
const svgArray = [];
const svgFiles = files.filter((file) => extname(file) === '.svg');
const svgArray = additionalSvgs;

svgFiles.forEach((file) => {
const filePath = path.join(directoryPath, file);
const fileContents = fs.readFileSync(filePath, 'utf8');
const fileName = path.basename(file, '.svg');
const filePath = join(directoryPath, file);
const fileContents = readFileSync(filePath, 'utf8');
const fileName = basename(file, '.svg');
svgArray.push({ name: fileName, contents: fileContents });
});

// write to stdout as js
const jsDataStr = `export default ${JSON.stringify(svgArray, null, 2)}\n`;
process.stdout.write(jsDataStr);
stdout.write(jsDataStr);
});
4 changes: 4 additions & 0 deletions tools/importer/svgs.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
export default [
{
"name": "contact-email-48",
"contents": "<svg id=\"icon-ui-svg\" xmlns=\"http://www.w3.org/2000/svg\" viewBox=\"0 0 48 48\"><path style=\"fill:#48E2CB;\" d=\"M26.508 34.149H4.433l13.092-12.484 5.483 4.92 5.481-4.918 5.222 4.988c.288-.1.581-.189.879-.267l-5.503-5.257L42.108 9.445v17.518c.272.12.54.247.8.386v-18.8l-.004-.449H3.508l-.4.049v26.8h23.194c.061-.27.126-.538.206-.8zm15.01-25.25l-18.51 16.612L4.498 8.9zm-37.61.546l13.02 11.685-13.02 12.414zm33.6 19.537a8.518 8.518 0 1 0 0 17.036v-.8a7.718 7.718 0 1 1 7.718-7.718v2.03a1.63 1.63 0 0 1-3.26 0v-6.765h-.799v2.199a4.455 4.455 0 1 0 .045 5.013 2.427 2.427 0 0 0 4.814-.448V37.5a8.527 8.527 0 0 0-8.518-8.518zm0 12.177a3.659 3.659 0 1 1 3.659-3.659 3.663 3.663 0 0 1-3.659 3.659z\" id=\"icon-ui-svg--base\"></path></svg>"
},
{
"name": "2-5d-mesh-48",
"contents": "<svg id=\"icon-ui-svg\" xmlns=\"http://www.w3.org/2000/svg\" viewBox=\"0 0 48 48\"><path d=\"M40.71 6.209l-.566-.566L43.5 2.287l3.356 3.356-.565.566L43.9 3.818V16h-.8V3.818zM23.75 43.322L9.1 35.946V24h.005l7.995-3.997V7.75l8.651-4.194L40.9 10.997v23.7zM40.1 11.395l-8.2 3.859v12.235l-8 3.765v11.098l16.2-8.148zm-21.695-3.39l13.1 6.55 7.572-3.563L25.75 4.445zM17.9 19.75l13.2 6.373V15.247l-13.2-6.6zM10.895 24l12.867 6.434 7.308-3.439-13.313-6.427zM23.1 30.997l-13.2-6.6v11.057L23.1 42.1zm-18-13.18V30h.8V17.818l2.39 2.391.566-.566L5.5 16.287l-3.356 3.356.565.566zM43 33.407v.883l2.091.978L24 46.094 2.885 35.254 7 33.198v-.894l-5.885 2.942L24 46.992l22.909-11.759z\" id=\"icon-ui-svg--base\"/></svg>"
Expand Down

0 comments on commit 9f298f9

Please sign in to comment.