From 41e6b6ac1259a21f69c9438d2392f5449f8625d3 Mon Sep 17 00:00:00 2001 From: Avior Date: Mon, 19 Aug 2024 17:22:50 +0200 Subject: [PATCH 1/3] add default class to the layout --- src/.Layout.astro | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/.Layout.astro b/src/.Layout.astro index 47ba225..e5fb613 100644 --- a/src/.Layout.astro +++ b/src/.Layout.astro @@ -1,9 +1,13 @@ --- export type { Props } from './index.d.ts' -// extract and remove the size shortcut +// extract and remove special parameters const size = Astro.props.size +const cls = Astro.props.class +const name = Astro.props.iconName delete Astro.props.size +delete Astro.props.class +delete Astro.props.iconName // allow the user's props to redefine our defaults const props = Object.assign({ @@ -17,9 +21,8 @@ const props = Object.assign({ 'fill': 'none', 'viewBox': '0 0 24 24' }, Astro.props) - --- - + From ce9454b93521e52aa03c32f27986c5d2356fd1c2 Mon Sep 17 00:00:00 2001 From: Avior Date: Mon, 19 Aug 2024 17:25:13 +0200 Subject: [PATCH 2/3] add icon-name to template --- src/Template.astro | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Template.astro b/src/Template.astro index 3c1ac11..3d630ba 100644 --- a/src/Template.astro +++ b/src/Template.astro @@ -3,6 +3,6 @@ import Layout from './.Layout.astro' export type { Props } from './index.d.ts' --- - + - \ No newline at end of file + From 07ae1dda19d36c1d7b4f5dbd744ccd1ba9d94e80 Mon Sep 17 00:00:00 2001 From: Avior Date: Mon, 19 Aug 2024 17:27:34 +0200 Subject: [PATCH 3/3] add name to build system --- src/build.js | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/src/build.js b/src/build.js index 9488a0b..ae178d1 100644 --- a/src/build.js +++ b/src/build.js @@ -10,11 +10,16 @@ await fs.mkdir('./dist') const template = await fs.readFile('./src/Template.astro', 'utf8') // funciton tht fill the template with the icon SVG -function fillTemplate(icon) { - return template.replace( - '', - icon.replace(/((?:.|\n)*)<\/svg>/gm, '$1').replace(/ /g, '\t').trim() - ) +function fillTemplate(name, icon) { + return template + .replace( + '', + name + ) + .replace( + '', + icon.replace(/((?:.|\n)*)<\/svg>/gm, '$1').replace(/ /g, '\t').trim() + ) } // copy the base layout @@ -41,7 +46,7 @@ try { const filePath = `./dist/${fullName}.astro`; // compile the icon and write it out - await fs.writeFile(filePath, fillTemplate(icon), "utf-8"); + await fs.writeFile(filePath, fillTemplate(name, icon), "utf-8"); // add the icon to the index index += `export { default as ${fullName} } from './${fullName}.astro'\n` @@ -53,4 +58,4 @@ try { } catch (e) { console.error('Error building the Library', e) process.exit(1) -} \ No newline at end of file +}