From 5e0ba7e8976c3f6fe7cae35b1b87099b0510b13c Mon Sep 17 00:00:00 2001 From: Eric Fennis Date: Fri, 5 Jan 2024 17:32:51 +0100 Subject: [PATCH 1/8] fix aliases property in asterisk-square --- icons/asterisk-square.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/icons/asterisk-square.json b/icons/asterisk-square.json index 8bbb671c3..e90657303 100644 --- a/icons/asterisk-square.json +++ b/icons/asterisk-square.json @@ -21,7 +21,7 @@ "maths", "development" ], - "alaias": [ + "aliases": [ "square-asterisk" ] -} \ No newline at end of file +} From ea43df6431468531971fa2a4271573639182785a Mon Sep 17 00:00:00 2001 From: Jakob Guddas Date: Fri, 5 Jan 2024 17:36:55 +0100 Subject: [PATCH 2/8] Manually optimized folder-sync (#1745) * Update folder-sync.svg * Update folder-sync.svg * Update folder-sync.json * Update folder-sync.svg --------- Co-authored-by: Eric Fennis --- icons/folder-sync.json | 5 +++-- icons/folder-sync.svg | 6 +++--- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/icons/folder-sync.json b/icons/folder-sync.json index ef05514c7..d928a6a17 100644 --- a/icons/folder-sync.json +++ b/icons/folder-sync.json @@ -1,7 +1,8 @@ { "$schema": "../icon.schema.json", "contributors": [ - "danielbayley" + "danielbayley", + "jguddas" ], "tags": [ "directory", @@ -16,4 +17,4 @@ "files", "arrows" ] -} \ No newline at end of file +} diff --git a/icons/folder-sync.svg b/icons/folder-sync.svg index 398faa298..f627e318d 100644 --- a/icons/folder-sync.svg +++ b/icons/folder-sync.svg @@ -9,9 +9,9 @@ stroke-linecap="round" stroke-linejoin="round" > - + - + - + From d2152b3cdd3826bf1c79026cdc0a288ca0537ac2 Mon Sep 17 00:00:00 2001 From: Tyrone Tudehope Date: Sun, 7 Jan 2024 01:13:25 +0200 Subject: [PATCH 3/8] Rename between-horizontal-* icons (#1781) --- ...{between-horizonal-end.json => between-horizontal-end.json} | 3 +++ .../{between-horizonal-end.svg => between-horizontal-end.svg} | 0 ...ween-horizonal-start.json => between-horizontal-start.json} | 3 +++ ...etween-horizonal-start.svg => between-horizontal-start.svg} | 0 4 files changed, 6 insertions(+) rename icons/{between-horizonal-end.json => between-horizontal-end.json} (90%) rename icons/{between-horizonal-end.svg => between-horizontal-end.svg} (100%) rename icons/{between-horizonal-start.json => between-horizontal-start.json} (90%) rename icons/{between-horizonal-start.svg => between-horizontal-start.svg} (100%) diff --git a/icons/between-horizonal-end.json b/icons/between-horizontal-end.json similarity index 90% rename from icons/between-horizonal-end.json rename to icons/between-horizontal-end.json index add7ca723..507eca95c 100644 --- a/icons/between-horizonal-end.json +++ b/icons/between-horizontal-end.json @@ -31,5 +31,8 @@ "design", "tools", "account" + ], + "aliases": [ + "between-horizonal-end" ] } diff --git a/icons/between-horizonal-end.svg b/icons/between-horizontal-end.svg similarity index 100% rename from icons/between-horizonal-end.svg rename to icons/between-horizontal-end.svg diff --git a/icons/between-horizonal-start.json b/icons/between-horizontal-start.json similarity index 90% rename from icons/between-horizonal-start.json rename to icons/between-horizontal-start.json index d9d1e6435..c9d171ab6 100644 --- a/icons/between-horizonal-start.json +++ b/icons/between-horizontal-start.json @@ -31,5 +31,8 @@ "design", "tools", "account" + ], + "aliases": [ + "between-horizonal-start" ] } diff --git a/icons/between-horizonal-start.svg b/icons/between-horizontal-start.svg similarity index 100% rename from icons/between-horizonal-start.svg rename to icons/between-horizontal-start.svg From b72cea639949e4a9ebff9f4811c42054a335e6e7 Mon Sep 17 00:00:00 2001 From: Daniel Bayley Date: Sat, 6 Jan 2024 23:16:44 +0000 Subject: [PATCH 4/8] Add `notebook`/`pad`[`-*`] icons & optimise/rename `*-edit` icons (#1363) * Add `notebook` icon * Add `notebook-tabs` (contacts variant) icon * Add `notebook-text` icon * Add `notepad-text` icon * Add `notebook-pen` icon * Optimise `file-edit` icon * Rename `file-edit` to `file-pen` * Optimise `clipboard-edit` icon * Rename `clipboard-edit` to `clipboard-pen` * Optimise `folder-edit` icon * Rename `folder-edit` to `folder-pen` * Optimise `file-signature` icon * Rename `file-signature` to `file-pen-line` * Optimise `clipboard-signature` icon * Rename `clipboard-signature` to `clipboard-pen-line` * Add `notepad-text-dashed` (draft/template) icon --------- Co-authored-by: Eric Fennis --- ...signature.json => clipboard-pen-line.json} | 6 ++- ...d-signature.svg => clipboard-pen-line.svg} | 4 +- ...clipboard-edit.json => clipboard-pen.json} | 4 +- .../{clipboard-edit.svg => clipboard-pen.svg} | 4 +- ...file-signature.json => file-pen-line.json} | 6 ++- .../{file-signature.svg => file-pen-line.svg} | 2 +- icons/{file-edit.json => file-pen.json} | 4 +- icons/{file-edit.svg => file-pen.svg} | 4 +- icons/{folder-edit.json => folder-pen.json} | 4 +- icons/{folder-edit.svg => folder-pen.svg} | 4 +- icons/notebook-pen.json | 37 +++++++++++++++++ icons/notebook-pen.svg | 18 +++++++++ icons/notebook-tabs.json | 34 ++++++++++++++++ icons/notebook-tabs.svg | 21 ++++++++++ icons/notebook-text.json | 37 +++++++++++++++++ icons/notebook-text.svg | 20 ++++++++++ icons/notebook.json | 40 +++++++++++++++++++ icons/notebook.svg | 18 +++++++++ icons/notepad-text-dashed.json | 25 ++++++++++++ icons/notepad-text-dashed.svg | 25 ++++++++++++ icons/notepad-text.json | 37 +++++++++++++++++ icons/notepad-text.svg | 19 +++++++++ 22 files changed, 357 insertions(+), 16 deletions(-) rename icons/{clipboard-signature.json => clipboard-pen-line.json} (74%) rename icons/{clipboard-signature.svg => clipboard-pen-line.svg} (70%) rename icons/{clipboard-edit.json => clipboard-pen.json} (81%) rename icons/{clipboard-edit.svg => clipboard-pen.svg} (68%) rename icons/{file-signature.json => file-pen-line.json} (74%) rename icons/{file-signature.svg => file-pen-line.svg} (78%) rename icons/{file-edit.json => file-pen.json} (80%) rename icons/{file-edit.svg => file-pen.svg} (69%) rename icons/{folder-edit.json => folder-pen.json} (81%) rename icons/{folder-edit.svg => folder-pen.svg} (52%) create mode 100644 icons/notebook-pen.json create mode 100644 icons/notebook-pen.svg create mode 100644 icons/notebook-tabs.json create mode 100644 icons/notebook-tabs.svg create mode 100644 icons/notebook-text.json create mode 100644 icons/notebook-text.svg create mode 100644 icons/notebook.json create mode 100644 icons/notebook.svg create mode 100644 icons/notepad-text-dashed.json create mode 100644 icons/notepad-text-dashed.svg create mode 100644 icons/notepad-text.json create mode 100644 icons/notepad-text.svg diff --git a/icons/clipboard-signature.json b/icons/clipboard-pen-line.json similarity index 74% rename from icons/clipboard-signature.json rename to icons/clipboard-pen-line.json index d6f9249a9..d66b2dbc3 100644 --- a/icons/clipboard-signature.json +++ b/icons/clipboard-pen-line.json @@ -5,11 +5,13 @@ "ericfennis" ], "tags": [ - "paste", - "signature" + "paste" ], "categories": [ "text", "account" + ], + "aliases": [ + "clipboard-signature" ] } \ No newline at end of file diff --git a/icons/clipboard-signature.svg b/icons/clipboard-pen-line.svg similarity index 70% rename from icons/clipboard-signature.svg rename to icons/clipboard-pen-line.svg index 64b7c4a91..fef6be762 100644 --- a/icons/clipboard-signature.svg +++ b/icons/clipboard-pen-line.svg @@ -9,9 +9,9 @@ stroke-linecap="round" stroke-linejoin="round" > - + - + diff --git a/icons/clipboard-edit.json b/icons/clipboard-pen.json similarity index 81% rename from icons/clipboard-edit.json rename to icons/clipboard-pen.json index 9afa62e9b..97ae9d294 100644 --- a/icons/clipboard-edit.json +++ b/icons/clipboard-pen.json @@ -5,11 +5,13 @@ "ericfennis" ], "tags": [ - "edit", "paste", "signature" ], "categories": [ "text" + ], + "aliases": [ + "clipboard-edit" ] } \ No newline at end of file diff --git a/icons/clipboard-edit.svg b/icons/clipboard-pen.svg similarity index 68% rename from icons/clipboard-edit.svg rename to icons/clipboard-pen.svg index 0c0ce759c..0af81acd3 100644 --- a/icons/clipboard-edit.svg +++ b/icons/clipboard-pen.svg @@ -9,8 +9,8 @@ stroke-linecap="round" stroke-linejoin="round" > - - + + diff --git a/icons/file-signature.json b/icons/file-pen-line.json similarity index 74% rename from icons/file-signature.json rename to icons/file-pen-line.json index 1ba62d2f2..145204b7d 100644 --- a/icons/file-signature.json +++ b/icons/file-pen-line.json @@ -5,10 +5,12 @@ "jguddas" ], "tags": [ - "edit", - "signature" + "edit" ], "categories": [ "files" + ], + "aliases": [ + "file-signature" ] } \ No newline at end of file diff --git a/icons/file-signature.svg b/icons/file-pen-line.svg similarity index 78% rename from icons/file-signature.svg rename to icons/file-pen-line.svg index b4cd452ad..fc1036bcf 100644 --- a/icons/file-signature.svg +++ b/icons/file-pen-line.svg @@ -11,5 +11,5 @@ > - + diff --git a/icons/file-edit.json b/icons/file-pen.json similarity index 80% rename from icons/file-edit.json rename to icons/file-pen.json index 56ae70da7..7b9f65f8d 100644 --- a/icons/file-edit.json +++ b/icons/file-pen.json @@ -4,10 +4,12 @@ "karsa-mistmere" ], "tags": [ - "edit", "signature" ], "categories": [ "files" + ], + "aliases": [ + "file-edit" ] } \ No newline at end of file diff --git a/icons/file-edit.svg b/icons/file-pen.svg similarity index 69% rename from icons/file-edit.svg rename to icons/file-pen.svg index 805577a8b..50c6620dc 100644 --- a/icons/file-edit.svg +++ b/icons/file-pen.svg @@ -10,6 +10,6 @@ stroke-linejoin="round" > - - + + diff --git a/icons/folder-edit.json b/icons/folder-pen.json similarity index 81% rename from icons/folder-edit.json rename to icons/folder-pen.json index 9f0bae22b..3dcc9debb 100644 --- a/icons/folder-edit.json +++ b/icons/folder-pen.json @@ -5,10 +5,12 @@ ], "tags": [ "directory", - "edit", "rename" ], "categories": [ "files" + ], + "aliases": [ + "folder-edit" ] } \ No newline at end of file diff --git a/icons/folder-edit.svg b/icons/folder-pen.svg similarity index 52% rename from icons/folder-edit.svg rename to icons/folder-pen.svg index 05d306bb6..6f3f1b7d7 100644 --- a/icons/folder-edit.svg +++ b/icons/folder-pen.svg @@ -9,6 +9,6 @@ stroke-linecap="round" stroke-linejoin="round" > - - + + diff --git a/icons/notebook-pen.json b/icons/notebook-pen.json new file mode 100644 index 000000000..53b245585 --- /dev/null +++ b/icons/notebook-pen.json @@ -0,0 +1,37 @@ +{ + "$schema": "../icon.schema.json", + "contributors": [ + "danielbayley" + ], + "tags": [ + "pencil", + "notepad", + "notes", + "noted", + "stationery", + "sketchbook", + "organizer", + "organiser", + "planner", + "diary", + "journal", + "writing", + "write", + "written", + "reading", + "high school", + "university", + "college", + "academy", + "student", + "study", + "research", + "homework", + "eraser", + "rubber" + ], + "categories": [ + "text", + "social" + ] +} \ No newline at end of file diff --git a/icons/notebook-pen.svg b/icons/notebook-pen.svg new file mode 100644 index 000000000..7b7da3311 --- /dev/null +++ b/icons/notebook-pen.svg @@ -0,0 +1,18 @@ + + + + + + + + diff --git a/icons/notebook-tabs.json b/icons/notebook-tabs.json new file mode 100644 index 000000000..423031aac --- /dev/null +++ b/icons/notebook-tabs.json @@ -0,0 +1,34 @@ +{ + "$schema": "../icon.schema.json", + "contributors": [ + "danielbayley" + ], + "tags": [ + "notepad", + "notes", + "people", + "family", + "friends", + "acquaintances", + "contacts", + "details", + "addresses", + "phone numbers", + "directory", + "listing", + "networking", + "alphabetical", + "a-z", + "organizer", + "organiser", + "planner", + "diary", + "stationery" + ], + "categories": [ + "account", + "connectivity", + "communication", + "social" + ] +} \ No newline at end of file diff --git a/icons/notebook-tabs.svg b/icons/notebook-tabs.svg new file mode 100644 index 000000000..2da7e3abd --- /dev/null +++ b/icons/notebook-tabs.svg @@ -0,0 +1,21 @@ + + + + + + + + + + + diff --git a/icons/notebook-text.json b/icons/notebook-text.json new file mode 100644 index 000000000..053303996 --- /dev/null +++ b/icons/notebook-text.json @@ -0,0 +1,37 @@ +{ + "$schema": "../icon.schema.json", + "contributors": [ + "danielbayley" + ], + "tags": [ + "notepad", + "notes", + "pages", + "paper", + "stationery", + "sketchbook", + "organizer", + "organiser", + "planner", + "diary", + "journal", + "writing", + "write", + "written", + "reading", + "high school", + "university", + "college", + "academy", + "student", + "study", + "research", + "homework", + "lines", + "opened" + ], + "categories": [ + "text", + "social" + ] +} \ No newline at end of file diff --git a/icons/notebook-text.svg b/icons/notebook-text.svg new file mode 100644 index 000000000..208dafebd --- /dev/null +++ b/icons/notebook-text.svg @@ -0,0 +1,20 @@ + + + + + + + + + + diff --git a/icons/notebook.json b/icons/notebook.json new file mode 100644 index 000000000..e088145bb --- /dev/null +++ b/icons/notebook.json @@ -0,0 +1,40 @@ +{ + "$schema": "../icon.schema.json", + "contributors": [ + "danielbayley" + ], + "tags": [ + "notepad", + "notes", + "stationery", + "sketchbook", + "moleskine", + "closure", + "strap", + "band", + "elastic", + "organizer", + "organiser", + "planner", + "diary", + "journal", + "writing", + "written", + "writer", + "reading", + "high school", + "university", + "college", + "academy", + "student", + "study", + "homework", + "research" + ], + "categories": [ + "text", + "communication", + "social", + "design" + ] +} \ No newline at end of file diff --git a/icons/notebook.svg b/icons/notebook.svg new file mode 100644 index 000000000..090fe2b74 --- /dev/null +++ b/icons/notebook.svg @@ -0,0 +1,18 @@ + + + + + + + + diff --git a/icons/notepad-text-dashed.json b/icons/notepad-text-dashed.json new file mode 100644 index 000000000..e5e8160c6 --- /dev/null +++ b/icons/notepad-text-dashed.json @@ -0,0 +1,25 @@ +{ + "$schema": "../icon.schema.json", + "contributors": [ + "danielbayley" + ], + "tags": [ + "notebook", + "notes", + "pages", + "paper", + "stationery", + "diary", + "journal", + "writing", + "write", + "written", + "draft", + "template", + "lines" + ], + "categories": [ + "text", + "social" + ] +} \ No newline at end of file diff --git a/icons/notepad-text-dashed.svg b/icons/notepad-text-dashed.svg new file mode 100644 index 000000000..27b64d19c --- /dev/null +++ b/icons/notepad-text-dashed.svg @@ -0,0 +1,25 @@ + + + + + + + + + + + + + + + diff --git a/icons/notepad-text.json b/icons/notepad-text.json new file mode 100644 index 000000000..f10cf3743 --- /dev/null +++ b/icons/notepad-text.json @@ -0,0 +1,37 @@ +{ + "$schema": "../icon.schema.json", + "contributors": [ + "danielbayley" + ], + "tags": [ + "notebook", + "notes", + "pages", + "paper", + "stationery", + "sketchbook", + "organizer", + "organiser", + "planner", + "diary", + "journal", + "writing", + "write", + "written", + "reading", + "high school", + "university", + "college", + "academy", + "student", + "study", + "homework", + "research", + "lines", + "opened" + ], + "categories": [ + "text", + "social" + ] +} \ No newline at end of file diff --git a/icons/notepad-text.svg b/icons/notepad-text.svg new file mode 100644 index 000000000..1a2274b9a --- /dev/null +++ b/icons/notepad-text.svg @@ -0,0 +1,19 @@ + + + + + + + + + From ef89510a479ded8110c1d31af78d5a5a9b5953b2 Mon Sep 17 00:00:00 2001 From: Eric Fennis Date: Sun, 7 Jan 2024 15:59:19 +0100 Subject: [PATCH 5/8] Implement deprecated block comment (#1765) * Implement deprecate comment lucide-react * Add export template with comment * Add block comment to Lucide Svelte * Add blockcomment to lucide-angular * Add block comment to lucide-static * revert runtime change build:tags * Fix failed tests * Remove optional property in icon schema --- icon.schema.json | 4 ++ icons/chrome.json | 3 +- icons/codepen.json | 3 +- icons/codesandbox.json | 3 +- icons/dribbble.json | 3 +- icons/facebook.json | 3 +- icons/figma.json | 3 +- icons/framer.json | 3 +- icons/github.json | 3 +- icons/gitlab.json | 3 +- icons/instagram.json | 3 +- icons/pocket.json | 3 +- icons/slack.json | 3 +- icons/trello.json | 3 +- icons/twitch.json | 3 +- icons/twitter.json | 3 +- icons/youtube.json | 3 +- .../lucide-angular/scripts/exportTemplate.mjs | 26 ++++++-- .../lucide-preact/scripts/exportTemplate.mjs | 21 ++++++- .../scripts/exportTemplate.mjs | 21 ++++++- .../lucide-react/scripts/exportTemplate.mjs | 19 ++---- .../scripts/getAliasesEntryNames.mjs | 4 +- packages/lucide-react/src/createLucideIcon.ts | 6 +- .../lucide-solid/scripts/exportTemplate.mjs | 21 ++++++- packages/lucide-static/package.json | 16 ++++- packages/lucide-static/rollup.config.mjs | 59 +++++++++++++++++++ packages/lucide-static/scripts/buildLib.mjs | 18 ------ .../lucide-static/scripts/exportTemplate.mjs | 32 ++++++++++ packages/lucide-static/src/lucide-static.ts | 2 + packages/lucide-static/tsconfig.json | 17 ++++++ packages/lucide-svelte/scripts/addLicense.mjs | 31 +++++++++- .../lucide-svelte/scripts/exportTemplate.mjs | 24 +++++++- .../scripts/exportTemplate.mjs | 21 ++++++- .../lucide-vue/scripts/exportTemplate.mjs | 25 +++++++- ...ateVueComponent.ts => createLucideIcon.ts} | 0 packages/lucide/scripts/exportTemplate.mjs | 20 ++++++- pnpm-lock.yaml | 18 +++++- .../building/generateAliasesFile.mjs | 4 +- .../building/generateIconFiles.mjs | 4 +- tools/build-icons/index.mjs | 2 +- tools/build-icons/main.mjs | 9 +-- tools/build-icons/utils/base64SVG.mjs | 11 ++++ .../{getAliases.mjs => getIconMetaData.mjs} | 4 +- 43 files changed, 402 insertions(+), 85 deletions(-) create mode 100644 packages/lucide-static/rollup.config.mjs create mode 100644 packages/lucide-static/scripts/exportTemplate.mjs create mode 100644 packages/lucide-static/src/lucide-static.ts create mode 100644 packages/lucide-static/tsconfig.json rename packages/lucide-vue/src/{createVueComponent.ts => createLucideIcon.ts} (100%) create mode 100644 tools/build-icons/utils/base64SVG.mjs rename tools/build-icons/utils/{getAliases.mjs => getIconMetaData.mjs} (85%) diff --git a/icon.schema.json b/icon.schema.json index 2adb2c700..075930077 100644 --- a/icon.schema.json +++ b/icon.schema.json @@ -47,6 +47,10 @@ }, "minItems": 1, "uniqueItems": true + }, + "deprecated": { + "type": "boolean", + "default": false } }, "description": "A JSON Schema for icons defined by Lucide Icons." diff --git a/icons/chrome.json b/icons/chrome.json index ff9515a4c..e07964cf5 100644 --- a/icons/chrome.json +++ b/icons/chrome.json @@ -1,5 +1,6 @@ { "$schema": "../icon.schema.json", + "deprecated": true, "contributors": [ "colebemis", "ericfennis" @@ -11,4 +12,4 @@ "categories": [ "brands" ] -} \ No newline at end of file +} diff --git a/icons/codepen.json b/icons/codepen.json index e0e8fa2ba..05382b3df 100644 --- a/icons/codepen.json +++ b/icons/codepen.json @@ -1,5 +1,6 @@ { "$schema": "../icon.schema.json", + "deprecated": true, "contributors": [ "colebemis", "ericfennis" @@ -11,4 +12,4 @@ "brands", "development" ] -} \ No newline at end of file +} diff --git a/icons/codesandbox.json b/icons/codesandbox.json index 68ae126d6..e09a3e3c4 100644 --- a/icons/codesandbox.json +++ b/icons/codesandbox.json @@ -1,5 +1,6 @@ { "$schema": "../icon.schema.json", + "deprecated": true, "contributors": [ "colebemis", "csandman", @@ -12,4 +13,4 @@ "brands", "development" ] -} \ No newline at end of file +} diff --git a/icons/dribbble.json b/icons/dribbble.json index 0179199c0..41b57423f 100644 --- a/icons/dribbble.json +++ b/icons/dribbble.json @@ -1,5 +1,6 @@ { "$schema": "../icon.schema.json", + "deprecated": true, "contributors": [ "ahtohbi4", "karsa-mistmere" @@ -13,4 +14,4 @@ "social", "design" ] -} \ No newline at end of file +} diff --git a/icons/facebook.json b/icons/facebook.json index 03db54294..67852e58f 100644 --- a/icons/facebook.json +++ b/icons/facebook.json @@ -1,5 +1,6 @@ { "$schema": "../icon.schema.json", + "deprecated": true, "contributors": [ "colebemis", "csandman", @@ -14,4 +15,4 @@ "social", "brands" ] -} \ No newline at end of file +} diff --git a/icons/figma.json b/icons/figma.json index 2c452b3c4..b75bf2ba0 100644 --- a/icons/figma.json +++ b/icons/figma.json @@ -1,5 +1,6 @@ { "$schema": "../icon.schema.json", + "deprecated": true, "contributors": [ "colebemis", "csandman", @@ -15,4 +16,4 @@ "brands", "design" ] -} \ No newline at end of file +} diff --git a/icons/framer.json b/icons/framer.json index 2c452b3c4..b75bf2ba0 100644 --- a/icons/framer.json +++ b/icons/framer.json @@ -1,5 +1,6 @@ { "$schema": "../icon.schema.json", + "deprecated": true, "contributors": [ "colebemis", "csandman", @@ -15,4 +16,4 @@ "brands", "design" ] -} \ No newline at end of file +} diff --git a/icons/github.json b/icons/github.json index 935104a20..0111ffd98 100644 --- a/icons/github.json +++ b/icons/github.json @@ -1,5 +1,6 @@ { "$schema": "../icon.schema.json", + "deprecated": true, "contributors": [ "colebemis", "csandman", @@ -14,4 +15,4 @@ "brands", "development" ] -} \ No newline at end of file +} diff --git a/icons/gitlab.json b/icons/gitlab.json index 935104a20..0111ffd98 100644 --- a/icons/gitlab.json +++ b/icons/gitlab.json @@ -1,5 +1,6 @@ { "$schema": "../icon.schema.json", + "deprecated": true, "contributors": [ "colebemis", "csandman", @@ -14,4 +15,4 @@ "brands", "development" ] -} \ No newline at end of file +} diff --git a/icons/instagram.json b/icons/instagram.json index 8e8c9364e..f8f9dc404 100644 --- a/icons/instagram.json +++ b/icons/instagram.json @@ -1,5 +1,6 @@ { "$schema": "../icon.schema.json", + "deprecated": true, "contributors": [ "colebemis", "csandman", @@ -15,4 +16,4 @@ "social", "photography" ] -} \ No newline at end of file +} diff --git a/icons/pocket.json b/icons/pocket.json index b23a8cf0d..f2df830a5 100644 --- a/icons/pocket.json +++ b/icons/pocket.json @@ -1,5 +1,6 @@ { "$schema": "../icon.schema.json", + "deprecated": true, "contributors": [ "colebemis", "csandman", @@ -13,4 +14,4 @@ "brands", "development" ] -} \ No newline at end of file +} diff --git a/icons/slack.json b/icons/slack.json index d3aa1068c..93a1ff1aa 100644 --- a/icons/slack.json +++ b/icons/slack.json @@ -1,5 +1,6 @@ { "$schema": "../icon.schema.json", + "deprecated": true, "contributors": [ "colebemis", "ashygee", @@ -17,4 +18,4 @@ "brands", "development" ] -} \ No newline at end of file +} diff --git a/icons/trello.json b/icons/trello.json index 9d41a4a2b..bdda0eeff 100644 --- a/icons/trello.json +++ b/icons/trello.json @@ -1,5 +1,6 @@ { "$schema": "../icon.schema.json", + "deprecated": true, "contributors": [ "bdbch", "csandman", @@ -15,4 +16,4 @@ "brands", "development" ] -} \ No newline at end of file +} diff --git a/icons/twitch.json b/icons/twitch.json index f3d6e502d..fe163ceb1 100644 --- a/icons/twitch.json +++ b/icons/twitch.json @@ -1,5 +1,6 @@ { "$schema": "../icon.schema.json", + "deprecated": true, "contributors": [ "ahtohbi4", "johnletey" @@ -14,4 +15,4 @@ "account", "gaming" ] -} \ No newline at end of file +} diff --git a/icons/twitter.json b/icons/twitter.json index 0f81517a5..52003f200 100644 --- a/icons/twitter.json +++ b/icons/twitter.json @@ -1,5 +1,6 @@ { "$schema": "../icon.schema.json", + "deprecated": true, "contributors": [ "colebemis", "csandman", @@ -15,4 +16,4 @@ "social", "account" ] -} \ No newline at end of file +} diff --git a/icons/youtube.json b/icons/youtube.json index cea2740af..ead7e1d03 100644 --- a/icons/youtube.json +++ b/icons/youtube.json @@ -1,5 +1,6 @@ { "$schema": "../icon.schema.json", + "deprecated": true, "contributors": [ "colebemis", "csandman", @@ -20,4 +21,4 @@ "text", "brands" ] -} \ No newline at end of file +} diff --git a/packages/lucide-angular/scripts/exportTemplate.mjs b/packages/lucide-angular/scripts/exportTemplate.mjs index 67ecb12d5..064d70ecb 100644 --- a/packages/lucide-angular/scripts/exportTemplate.mjs +++ b/packages/lucide-angular/scripts/exportTemplate.mjs @@ -1,8 +1,26 @@ -export default ({ componentName, children }) => ` +/* eslint-disable import/no-extraneous-dependencies */ +import base64SVG from '@lucide/build-icons/utils/base64SVG.mjs'; + +export default ({ componentName, iconName, children, getSvg, deprecated }) => { + const svgContents = getSvg(); + const svgBase64 = base64SVG(svgContents); + + return `\ import { LucideIconData } from './types'; -/* eslint-disable no-shadow-restricted-names */ -const ${componentName}: LucideIconData = ${JSON.stringify(children)}; +/** + * @component @name ${componentName} + * @description Lucide SVG icon component, renders SVG Element with children. + * + * @preview ![img](data:image/svg+xml;base64,${svgBase64}) - https://lucide.dev/icons/${iconName} + * @see https://lucide.dev/guide/packages/lucide-vue-next - Documentation + * + * @param {Object} props - Lucide icons props and any valid SVG attribute + * @returns {FunctionalComponent} Vue component + * ${deprecated ? '@deprecated' : ''} +*/ +const ${componentName}: LucideIconData = ${JSON.stringify(children)}; //eslint-disable-line no-shadow-restricted-names export default ${componentName}; -`; +` +}; diff --git a/packages/lucide-preact/scripts/exportTemplate.mjs b/packages/lucide-preact/scripts/exportTemplate.mjs index ee09feaab..857ce67cc 100644 --- a/packages/lucide-preact/scripts/exportTemplate.mjs +++ b/packages/lucide-preact/scripts/exportTemplate.mjs @@ -1,7 +1,26 @@ -export default ({ componentName, children }) => ` +/* eslint-disable import/no-extraneous-dependencies */ +import base64SVG from '@lucide/build-icons/utils/base64SVG.mjs'; + +export default ({ componentName, iconName, children, getSvg, deprecated }) => { + const svgContents = getSvg(); + const svgBase64 = base64SVG(svgContents); + + return ` import createLucideIcon from '../createLucideIcon'; +/** + * @component @name ${componentName} + * @description Lucide SVG icon component, renders SVG Element with children. + * + * @preview ![img](data:image/svg+xml;base64,${svgBase64}) - https://lucide.dev/icons/${iconName} + * @see https://lucide.dev/guide/packages/lucide-preact - Documentation + * + * @param {Object} props - Lucide icons props and any valid SVG attribute + * @returns {JSX.Element} JSX Element + * ${deprecated ? '@deprecated' : ''} + */ const ${componentName} = createLucideIcon('${componentName}', ${JSON.stringify(children)}); export default ${componentName}; `; +}; diff --git a/packages/lucide-react-native/scripts/exportTemplate.mjs b/packages/lucide-react-native/scripts/exportTemplate.mjs index ee09feaab..ad1051c2a 100644 --- a/packages/lucide-react-native/scripts/exportTemplate.mjs +++ b/packages/lucide-react-native/scripts/exportTemplate.mjs @@ -1,7 +1,26 @@ -export default ({ componentName, children }) => ` +/* eslint-disable import/no-extraneous-dependencies */ +import base64SVG from '@lucide/build-icons/utils/base64SVG.mjs'; + +export default ({ componentName, iconName, children, getSvg, deprecated }) => { + const svgContents = getSvg(); + const svgBase64 = base64SVG(svgContents); + + return ` import createLucideIcon from '../createLucideIcon'; +/** + * @component @name ${componentName} + * @description Lucide SVG icon component, renders SVG Element with children. + * + * @preview ![img](data:image/svg+xml;base64,${svgBase64}) - https://lucide.dev/icons/${iconName} + * @see https://lucide.dev/guide/packages/lucide-react-native - Documentation + * + * @param {Object} props - Lucide icons props and any valid SVG attribute + * @returns {JSX.Element} JSX Element + * ${deprecated ? '@deprecated' : ''} + */ const ${componentName} = createLucideIcon('${componentName}', ${JSON.stringify(children)}); export default ${componentName}; `; +}; diff --git a/packages/lucide-react/scripts/exportTemplate.mjs b/packages/lucide-react/scripts/exportTemplate.mjs index b9c3d35af..7ccb638e7 100644 --- a/packages/lucide-react/scripts/exportTemplate.mjs +++ b/packages/lucide-react/scripts/exportTemplate.mjs @@ -1,16 +1,9 @@ -export default ({ componentName, iconName, children, getSvg }) => { +/* eslint-disable import/no-extraneous-dependencies */ +import base64SVG from '@lucide/build-icons/utils/base64SVG.mjs'; + +export default ({ componentName, iconName, children, getSvg, deprecated }) => { const svgContents = getSvg(); - - const svgBase64 = Buffer.from( - svgContents - .replace('\n', '') - .replace( - 'stroke="currentColor"', - 'stroke="#000" style="background-color: #fff; border-radius: 2px"', - ), - ).toString('base64'); - - // declarationFileContent += `\ + const svgBase64 = base64SVG(svgContents); return ` import createLucideIcon from '../createLucideIcon'; @@ -24,7 +17,7 @@ import createLucideIcon from '../createLucideIcon'; * * @param {Object} props - Lucide icons props and any valid SVG attribute * @returns {JSX.Element} JSX Element - * + * ${deprecated ? '@deprecated' : ''} */ const ${componentName} = createLucideIcon('${componentName}', ${JSON.stringify(children)}); diff --git a/packages/lucide-react/scripts/getAliasesEntryNames.mjs b/packages/lucide-react/scripts/getAliasesEntryNames.mjs index 0930d61fa..e67c535ab 100644 --- a/packages/lucide-react/scripts/getAliasesEntryNames.mjs +++ b/packages/lucide-react/scripts/getAliasesEntryNames.mjs @@ -1,11 +1,11 @@ import path from 'path'; // eslint-disable-next-line import/no-extraneous-dependencies -import getAliases from '@lucide/build-icons/utils/getAliases.mjs'; +import getIconMetaData from '@lucide/build-icons/utils/getIconMetaData.mjs'; const ICONS_DIR = path.resolve(process.cwd(), '../../icons'); export default async function getAliasesEntryNames() { - const metaJsonFiles = await getAliases(ICONS_DIR); + const metaJsonFiles = await getIconMetaData(ICONS_DIR); const iconWithAliases = Object.values(metaJsonFiles).filter(({ aliases }) => aliases != null); diff --git a/packages/lucide-react/src/createLucideIcon.ts b/packages/lucide-react/src/createLucideIcon.ts index daf73e7e3..b7c2b7c1f 100644 --- a/packages/lucide-react/src/createLucideIcon.ts +++ b/packages/lucide-react/src/createLucideIcon.ts @@ -35,8 +35,9 @@ export const toKebabCase = (string: string) => const createLucideIcon = (iconName: string, iconNode: IconNode): LucideIcon => { const Component = forwardRef( - ({ color = 'currentColor', size = 24, strokeWidth = 2, absoluteStrokeWidth, className = '', children, ...rest }, ref) => - createElement( + ({ color = 'currentColor', size = 24, strokeWidth = 2, absoluteStrokeWidth, className = '', children, ...rest }, ref) =>{ + + return createElement( 'svg', { ref, @@ -53,6 +54,7 @@ const createLucideIcon = (iconName: string, iconNode: IconNode): LucideIcon => { ...(Array.isArray(children) ? children : [children]), ] ) + } ); Component.displayName = `${iconName}`; diff --git a/packages/lucide-solid/scripts/exportTemplate.mjs b/packages/lucide-solid/scripts/exportTemplate.mjs index 715f47719..72385eb33 100644 --- a/packages/lucide-solid/scripts/exportTemplate.mjs +++ b/packages/lucide-solid/scripts/exportTemplate.mjs @@ -1,12 +1,31 @@ -export default ({ componentName, children }) => ` +/* eslint-disable import/no-extraneous-dependencies */ +import base64SVG from '@lucide/build-icons/utils/base64SVG.mjs'; + +export default ({ componentName, iconName, children, getSvg, deprecated }) => { + const svgContents = getSvg(); + const svgBase64 = base64SVG(svgContents); + + return ` import Icon from '../Icon'; import type { IconNode, LucideProps } from '../types'; const iconNode: IconNode = ${JSON.stringify(children)}; +/** + * @component @name ${componentName} + * @description Lucide SVG icon component, renders SVG Element with children. + * + * @preview ![img](data:image/svg+xml;base64,${svgBase64}) - https://lucide.dev/icons/${iconName} + * @see https://lucide.dev/guide/packages/lucide-solid - Documentation + * + * @param {Object} props - Lucide icons props and any valid SVG attribute + * @returns {JSX.Element} JSX Element + * ${deprecated ? '@deprecated' : ''} + */ const ${componentName} = (props: LucideProps) => ( ) export default ${componentName}; `; +}; diff --git a/packages/lucide-static/package.json b/packages/lucide-static/package.json index 6723e5325..f3aacac13 100644 --- a/packages/lucide-static/package.json +++ b/packages/lucide-static/package.json @@ -22,17 +22,27 @@ "Fontawesome", "Font Awesome" ], - "main": "lib/index.js", + "source": "src/lucide-static.js", + "main": "dist/cjs/lucide-static.js", + "module": "dist/esm/lucide-static.js", + "typings": "dist/lucide-static.d.ts", + "sideEffects": false, "scripts": { "copy:license": "cp ../../LICENSE ./LICENSE", + "build": "pnpm clean && pnpm copy:license && pnpm build:icons && pnpm build:bundles && pnpm build:lib && pnpm build:tags", "build:tags": "node ../../scripts/migrateIconsToTags.mjs", - "build": "pnpm clean && pnpm copy:license && pnpm build:lib && pnpm build:tags", + "build:icons": "build-icons --output=./src --templateSrc=./scripts/exportTemplate.mjs --iconFileExtension=.ts --withAliases --aliasNamesOnly --aliasesFileExtension=.ts --exportFileName=index.ts", "build:lib": "node ./scripts/buildLib.mjs", + "build:bundles": "rollup -c rollup.config.mjs", "clean": "rm -rf lib && rm -rf build && rm -rf icons && rm -f sprite.svg", "version": "pnpm version --git-tag-version=false" }, "devDependencies": { "prettier": "^2.3.2", - "svgson": "^5.2.1" + "svgson": "^5.2.1", + "@lucide/build-icons": "workspace:*", + "@lucide/rollup-plugins": "workspace:*", + "rollup": "^4.9.2", + "rollup-plugin-dts": "^6.1.0" } } diff --git a/packages/lucide-static/rollup.config.mjs b/packages/lucide-static/rollup.config.mjs new file mode 100644 index 000000000..fd90a5299 --- /dev/null +++ b/packages/lucide-static/rollup.config.mjs @@ -0,0 +1,59 @@ +import plugins from '@lucide/rollup-plugins'; +import dts from 'rollup-plugin-dts'; +import pkg from './package.json' assert { type: 'json' }; + +const outputFileName = pkg.name; +const outputDir = 'dist'; +const inputs = ['src/lucide-static.ts']; +const bundles = [ + { + format: 'cjs', + inputs, + outputDir, + }, + { + format: 'esm', + inputs, + outputDir, + preserveModules: true, + }, +]; + +const configs = bundles + .map(({ inputs, outputDir, format, minify, preserveModules }) => + inputs.map(input => ({ + input, + plugins: plugins(pkg, minify), + output: { + name: outputFileName, + ...(preserveModules + ? { + dir: `${outputDir}/${format}`, + } + : { + file: `${outputDir}/${format}/${outputFileName}${minify ? '.min' : ''}.js`, + }), + format, + sourcemap: true, + preserveModules, + }, + })), + ) + .flat(); + +const typesFileConfig = { + input: inputs[0], + output: [ + { + file: `${outputDir}/${outputFileName}.d.ts`, + format: 'esm', + }, + ], + plugins: [ + dts({ + include: ['src'], + }), + ], +}; + +export default [...configs, typesFileConfig]; diff --git a/packages/lucide-static/scripts/buildLib.mjs b/packages/lucide-static/scripts/buildLib.mjs index aa28c6169..7c5beb08b 100644 --- a/packages/lucide-static/scripts/buildLib.mjs +++ b/packages/lucide-static/scripts/buildLib.mjs @@ -5,9 +5,7 @@ import getArgumentOptions from 'minimist'; import { parseSync } from 'svgson'; import { - appendFile, readSvgDirectory, - toCamelCase, getCurrentDirPath, } from '../../../scripts/helpers.mjs'; import readSvgs from './readSvgs.mjs'; @@ -39,22 +37,6 @@ createDirectory(ICON_MODULE_DIR); const svgFiles = readSvgDirectory(ICONS_DIR); const svgs = readSvgs(svgFiles, ICONS_DIR); -const jsLicense = `/**\n * ${license}\n */\n`; - -appendFile(jsLicense, `index.js`, LIB_DIR); - -svgs.forEach(({ name, contents }) => { - const componentName = toCamelCase(name); - const importString = `module.exports.${componentName} = require('./icons/${name}');\n`; - appendFile(importString, `index.js`, LIB_DIR); - - const svgContent = contents.replace(' ({ name, contents, diff --git a/packages/lucide-static/scripts/exportTemplate.mjs b/packages/lucide-static/scripts/exportTemplate.mjs new file mode 100644 index 000000000..42e7a5f5f --- /dev/null +++ b/packages/lucide-static/scripts/exportTemplate.mjs @@ -0,0 +1,32 @@ +/* eslint-disable import/no-extraneous-dependencies */ +import base64SVG from '@lucide/build-icons/utils/base64SVG.mjs'; + +export default ({ componentName, iconName, children, getSvg, deprecated }) => { + let svgContents = getSvg(); + const svgBase64 = base64SVG(svgContents); + + svgContents = svgContents.replace( + ' {/; + + if (exportClassRegex.test(newContents)) { + newContents = newContents.replace(exportClassRegex, `${blockComment}\nexport default class $1 extends SvelteComponentTyped<$2> {`); + } + } + } + + if(newContents !== contents) { + await writeFile(filepath, newContents, { encoding: 'utf-8' }); } } @@ -48,8 +73,8 @@ function getJSBanner() { } function getSvelteBanner() { - return ` \n`; } diff --git a/packages/lucide-svelte/scripts/exportTemplate.mjs b/packages/lucide-svelte/scripts/exportTemplate.mjs index ec40bdd8e..6b76f64bc 100644 --- a/packages/lucide-svelte/scripts/exportTemplate.mjs +++ b/packages/lucide-svelte/scripts/exportTemplate.mjs @@ -1,6 +1,11 @@ -// eslint-disable-next-line import/no-extraneous-dependencies -export default ({ iconName, children }) => - `\ +/* eslint-disable import/no-extraneous-dependencies */ +import base64SVG from '@lucide/build-icons/utils/base64SVG.mjs'; + +export default ({ iconName, children, componentName, getSvg, deprecated }) => { + const svgContents = getSvg(); + const svgBase64 = base64SVG(svgContents); + + return `\ `; +}; diff --git a/packages/lucide-vue-next/scripts/exportTemplate.mjs b/packages/lucide-vue-next/scripts/exportTemplate.mjs index 97b973100..1c22ec9b1 100644 --- a/packages/lucide-vue-next/scripts/exportTemplate.mjs +++ b/packages/lucide-vue-next/scripts/exportTemplate.mjs @@ -1,7 +1,26 @@ -export default ({ componentName, children }) => ` +/* eslint-disable import/no-extraneous-dependencies */ +import base64SVG from '@lucide/build-icons/utils/base64SVG.mjs'; + +export default ({ componentName, iconName, children, getSvg, deprecated }) => { + const svgContents = getSvg(); + const svgBase64 = base64SVG(svgContents); + + return ` import createLucideIcon from '../createLucideIcon'; +/** + * @component @name ${componentName} + * @description Lucide SVG icon component, renders SVG Element with children. + * + * @preview ![img](data:image/svg+xml;base64,${svgBase64}) - https://lucide.dev/icons/${iconName} + * @see https://lucide.dev/guide/packages/lucide-vue-next - Documentation + * + * @param {Object} props - Lucide icons props and any valid SVG attribute + * @returns {FunctionalComponent} Vue component + * ${deprecated ? '@deprecated' : ''} + */ const ${componentName} = createLucideIcon('${componentName}Icon', ${JSON.stringify(children)}); export default ${componentName}; `; +}; diff --git a/packages/lucide-vue/scripts/exportTemplate.mjs b/packages/lucide-vue/scripts/exportTemplate.mjs index 650b41782..b58291f79 100644 --- a/packages/lucide-vue/scripts/exportTemplate.mjs +++ b/packages/lucide-vue/scripts/exportTemplate.mjs @@ -1,7 +1,26 @@ -export default ({ componentName, children }) => ` -import createVueComponent from '../createVueComponent'; +/* eslint-disable import/no-extraneous-dependencies */ +import base64SVG from '@lucide/build-icons/utils/base64SVG.mjs'; -const ${componentName} = createVueComponent('${componentName}Icon', ${JSON.stringify(children)}); +export default ({ componentName, iconName, children, getSvg, deprecated }) => { + const svgContents = getSvg(); + const svgBase64 = base64SVG(svgContents); + + return ` +import createLucideIcon from '../createLucideIcon'; + +/** + * @component @name ${componentName} + * @description Lucide SVG icon component, renders SVG Element with children. + * + * @preview ![img](data:image/svg+xml;base64,${svgBase64}) - https://lucide.dev/icons/${iconName} + * @see https://lucide.dev/guide/packages/lucide-vue - Documentation + * + * @param {Object} props - Lucide icons props and any valid SVG attribute + * @returns {Component} Vue Component + * ${deprecated ? '@deprecated' : ''} + */ +const ${componentName} = createLucideIcon('${componentName}Icon', ${JSON.stringify(children)}); export default ${componentName}; `; +}; diff --git a/packages/lucide-vue/src/createVueComponent.ts b/packages/lucide-vue/src/createLucideIcon.ts similarity index 100% rename from packages/lucide-vue/src/createVueComponent.ts rename to packages/lucide-vue/src/createLucideIcon.ts diff --git a/packages/lucide/scripts/exportTemplate.mjs b/packages/lucide/scripts/exportTemplate.mjs index 282b62bae..bcd2ee942 100644 --- a/packages/lucide/scripts/exportTemplate.mjs +++ b/packages/lucide/scripts/exportTemplate.mjs @@ -1,7 +1,24 @@ -export default ({ componentName, children }) => ` +/* eslint-disable import/no-extraneous-dependencies */ +import base64SVG from '@lucide/build-icons/utils/base64SVG.mjs'; + +export default ({ componentName, iconName, children, getSvg, deprecated }) => { + const svgContents = getSvg(); + const svgBase64 = base64SVG(svgContents); + + return ` import defaultAttributes from '../defaultAttributes'; import type { IconNode } from '../types'; +/** + * @name ${iconName} + * @description Lucide SVG icon node. + * + * @preview ![img](data:image/svg+xml;base64,${svgBase64}) - https://lucide.dev/icons/${iconName} + * @see https://lucide.dev/guide/packages/lucide - Documentation + * + * @returns {Array} + * ${deprecated ? '@deprecated' : ''} + */ const ${componentName}: IconNode = [ 'svg', defaultAttributes, @@ -10,3 +27,4 @@ const ${componentName}: IconNode = [ export default ${componentName}; `; +}; diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 71775bf47..35e4ddbdf 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -547,9 +547,21 @@ importers: packages/lucide-static: devDependencies: + '@lucide/build-icons': + specifier: workspace:* + version: link:../../tools/build-icons + '@lucide/rollup-plugins': + specifier: workspace:* + version: link:../../tools/rollup-plugins prettier: specifier: ^2.3.2 version: 2.8.8 + rollup: + specifier: ^4.9.2 + version: 4.9.2 + rollup-plugin-dts: + specifier: ^6.1.0 + version: 6.1.0(rollup@4.9.2)(typescript@4.9.5) svgson: specifier: ^5.2.1 version: 5.3.1 @@ -13790,8 +13802,8 @@ packages: duplexer: 0.1.2 dev: true - /h3-nightly@1.10.0-1701948668.39f9434: - resolution: {integrity: sha512-ZgDOpzAr8BO/sFzWYvLZLhg3d/NRbDeff+rA6vnoog0530NPEVfO3nIzCwY3nT+Z0faROooaiCyKaAPYbo7b9A==} + /h3-nightly@1.10.1-1704400265.ae91fc8: + resolution: {integrity: sha512-R2kWa+PpzYWLel4wSyJxS3DH8GSOs515uf72bW10uo5rbR0qvLw3esTnSYQLgDiOaqiFRP56kFFK7ClTfqko0g==} dependencies: cookie-es: 1.0.0 defu: 6.1.3 @@ -16817,7 +16829,7 @@ packages: fs-extra: 11.2.0 globby: 13.2.2 gzip-size: 7.0.0 - h3: /h3-nightly@1.10.0-1701948668.39f9434 + h3: /h3-nightly@1.10.1-1704400265.ae91fc8 hookable: 5.5.3 httpxy: 0.1.5 is-primitive: 3.0.1 diff --git a/tools/build-icons/building/generateAliasesFile.mjs b/tools/build-icons/building/generateAliasesFile.mjs index 47e7a3181..73517281c 100644 --- a/tools/build-icons/building/generateAliasesFile.mjs +++ b/tools/build-icons/building/generateAliasesFile.mjs @@ -10,7 +10,7 @@ export default async function generateAliasesFile({ outputDirectory, fileExtension, iconFileExtension = '.js', - aliases, + iconMetaData, aliasImportFileExtension, aliasNamesOnly = false, separateAliasesFile = false, @@ -27,7 +27,7 @@ export default async function generateAliasesFile({ await Promise.all( icons.map(async (iconName, index) => { const componentName = toPascalCase(iconName); - const iconAliases = aliases[iconName]?.aliases; + const iconAliases = iconMetaData[iconName]?.aliases; let importString = ''; diff --git a/tools/build-icons/building/generateIconFiles.mjs b/tools/build-icons/building/generateIconFiles.mjs index 954043293..b4f04b6bd 100644 --- a/tools/build-icons/building/generateIconFiles.mjs +++ b/tools/build-icons/building/generateIconFiles.mjs @@ -11,6 +11,7 @@ export default ({ iconFileExtension = '.js', pretty = true, iconsDir, + iconMetaData, }) => { const icons = Object.keys(iconNodes); const iconsDistDirectory = path.join(outputDirectory, `icons`); @@ -27,8 +28,9 @@ export default ({ children = children.map(({ name, attributes }) => [name, attributes]); const getSvg = () => readSvg(`${iconName}.svg`, iconsDir); + const { deprecated = false } = iconMetaData[iconName]; - const elementTemplate = template({ componentName, iconName, children, getSvg }); + const elementTemplate = template({ componentName, iconName, children, getSvg, deprecated }); const output = pretty ? prettier.format(elementTemplate, { singleQuote: true, diff --git a/tools/build-icons/index.mjs b/tools/build-icons/index.mjs index 923e98a8c..3f7ddaca9 100644 --- a/tools/build-icons/index.mjs +++ b/tools/build-icons/index.mjs @@ -1,2 +1,2 @@ // eslint-disable-next-line import/prefer-default-export -export { default as getAliases } from './utils/getAliases.mjs'; +export { default as getIconMetaData } from './utils/getIconMetaData.mjs'; diff --git a/tools/build-icons/main.mjs b/tools/build-icons/main.mjs index ff0e34b46..a5143ac2c 100755 --- a/tools/build-icons/main.mjs +++ b/tools/build-icons/main.mjs @@ -9,7 +9,7 @@ import generateExportsFile from './building/generateExportsFile.mjs'; import { readSvgDirectory, getCurrentDirPath } from '../../scripts/helpers.mjs'; import generateAliasesFile from './building/generateAliasesFile.mjs'; -import getAliases from './utils/getAliases.mjs'; +import getIconMetaData from './utils/getIconMetaData.mjs'; import generateDynamicImports from './building/generateDynamicImports.mjs'; const cliArguments = getArgumentOptions(process.argv.slice(2)); @@ -50,6 +50,8 @@ async function buildIcons() { const { default: iconFileTemplate } = await import(path.resolve(process.cwd(), templateSrc)); + const iconMetaData = await getIconMetaData(ICONS_DIR); + // Generates iconsNodes files for each icon generateIconFiles({ iconNodes: icons, @@ -59,14 +61,13 @@ async function buildIcons() { iconFileExtension, pretty: JSON.parse(pretty), iconsDir: ICONS_DIR, + iconMetaData, }); if (withAliases) { - const aliases = await getAliases(ICONS_DIR); - await generateAliasesFile({ iconNodes: icons, - aliases, + iconMetaData, aliasNamesOnly, iconFileExtension, outputDirectory: OUTPUT_DIR, diff --git a/tools/build-icons/utils/base64SVG.mjs b/tools/build-icons/utils/base64SVG.mjs new file mode 100644 index 000000000..b883d0fff --- /dev/null +++ b/tools/build-icons/utils/base64SVG.mjs @@ -0,0 +1,11 @@ +const base64SVG = (svgContents) => + Buffer.from( + svgContents + .replace('\n', '') + .replace( + 'stroke="currentColor"', + 'stroke="#000" style="background-color: #fff; border-radius: 2px"', + ), + ).toString('base64'); + +export default base64SVG; diff --git a/tools/build-icons/utils/getAliases.mjs b/tools/build-icons/utils/getIconMetaData.mjs similarity index 85% rename from tools/build-icons/utils/getAliases.mjs rename to tools/build-icons/utils/getIconMetaData.mjs index 91cc37989..e1ae610b0 100644 --- a/tools/build-icons/utils/getAliases.mjs +++ b/tools/build-icons/utils/getIconMetaData.mjs @@ -1,7 +1,7 @@ import path from 'path'; import { readSvgDirectory } from '../../../scripts/helpers.mjs'; -async function getAliases(iconDirectory) { +async function getIconMetaData(iconDirectory) { const iconJsons = readSvgDirectory(iconDirectory, '.json'); const aliasesEntries = await Promise.all( iconJsons.map(async (jsonFile) => { @@ -13,4 +13,4 @@ async function getAliases(iconDirectory) { return Object.fromEntries(aliasesEntries); } -export default getAliases +export default getIconMetaData From 05f209cb04cdc0c9339f1686ff9aee10f72d487b Mon Sep 17 00:00:00 2001 From: Eric Fennis Date: Sun, 7 Jan 2024 15:59:33 +0100 Subject: [PATCH 6/8] Fix icon preview comment workflow (#1775) * Add helpers * fix preview script * refactor markup to javascript * test * Add escaping * Try alternative escaping * test comment markup * update comment markup * Revert comment markup step * revert escaping * Test with markup file instead of GITHUB_OUTPUT var --- .github/workflows/pull-request.yml | 168 ++---------------- scripts/generateChangedIconsCommentMarkup.mjs | 98 ++++++++++ scripts/helpers.mjs | 28 ++- 3 files changed, 135 insertions(+), 159 deletions(-) create mode 100644 scripts/generateChangedIconsCommentMarkup.mjs diff --git a/.github/workflows/pull-request.yml b/.github/workflows/pull-request.yml index 19924b755..1def57c29 100644 --- a/.github/workflows/pull-request.yml +++ b/.github/workflows/pull-request.yml @@ -6,6 +6,7 @@ on: - 'icons/*.svg' branches: - main + - fix-icon-preview jobs: lint-contributors: @@ -46,184 +47,43 @@ jobs: # Example for the previous substitution # input: +++ b/icons/accessibility.json%0A@@ -2,0 +3 @@%0A+ "contributors": ["hi"],%0A@@ -13 +14 @@%0A+}%0A # output: ::$ANNOTATION_SEVERITY file=icons/accessibility.json,line=2,endLine=3,title=$ANNOTATION_TITLE::$ANNOTATION_DESCRIPTION%0A%0A+ "contributors": ["hi"],%0A@@ -13 +14 @@%0A+}%0A - # - name: Fail if contributors have changed - # run: git diff --exit-code -- icons/*.json - generate-changed-icons-comment-data: - if: github.repository == 'lucide-icons/lucide' + generate-changed-icons-comment: runs-on: ubuntu-latest permissions: contents: read - outputs: - generate-1px-stroke-width: ${{ steps.generate-1px-stroke-width.outputs.body }} - generate-2px-stroke-width: ${{ steps.generate-2px-stroke-width.outputs.body }} - generate-3px-stroke-width: ${{ steps.generate-3px-stroke-width.outputs.body }} - generate-24px-dpi-preview: ${{ steps.generate-24px-dpi-preview.outputs.body }} - generate-cohesion-check-random: ${{ steps.generate-cohesion-check-random.outputs.body }} - generate-cohesion-check-squares: ${{ steps.generate-cohesion-check-squares.outputs.body }} - generate-x-rays: ${{ steps.generate-x-rays.outputs.body }} + pull-requests: write steps: - uses: actions/checkout@v4 with: fetch-depth: 0 ref: refs/pull/${{ github.event.pull_request.number }}/merge + - name: Get changed files id: changed-files uses: tj-actions/changed-files@v41 with: files: icons/*.svg - - name: Generate 24px dpi preview - id: generate-24px-dpi-preview - env: - CHANGED_FILES: ${{ steps.changed-files.outputs.all_changed_files }} - run: | - delimiter="$(openssl rand -hex 8)" - echo "body<<$delimiter" >> $GITHUB_OUTPUT - while IFS= read -r file; do - cat "$file" | # get file content - tr '\n' ' ' | # remove line breaks - sed -e 's/]*>//g' | # remove attributes from svg element - base64 -w 0 | # encode svg - sed "s|.*|\"$file\" |" - done <<< "$CHANGED_FILES" | tr '\n' ' ' >> $GITHUB_OUTPUT - echo >> $GITHUB_OUTPUT - echo "$delimiter" >> $GITHUB_OUTPUT - - name: Generate cohesion check random - id: generate-cohesion-check-random - env: - CHANGED_FILES: ${{ steps.changed-files.outputs.all_changed_files }} - run: | - delimiter="$(openssl rand -hex 8)" - echo "body<<$delimiter" >> $GITHUB_OUTPUT - for file in $(printf "%s\\n" icons/*.svg | shuf | head -n$(awk -F' ' '{print NF}' <<< '${{ steps.changed-files.outputs.all_changed_files }}')); do - cat "$file" | # get file content - tr '\n' ' ' | # remove line breaks - sed -e 's/]*>//g' | # remove attributes from svg element - base64 -w 0 | # encode svg - sed "s|.*|\"$file\" |" - done <<< "$CHANGED_FILES" | tr '\n' ' ' >> $GITHUB_OUTPUT - echo >> $GITHUB_OUTPUT - echo "$delimiter" >> $GITHUB_OUTPUT - - name: Generate cohesion check squares - id: generate-cohesion-check-squares - env: - CHANGED_FILES: ${{ steps.changed-files.outputs.all_changed_files }} - run: | - delimiter="$(openssl rand -hex 8)" - echo "body<<$delimiter" >> $GITHUB_OUTPUT - for file in $(printf "%s\\n" icons/*square*.svg | shuf | head -n$(awk -F' ' '{print NF}' <<< '${{ steps.changed-files.outputs.all_changed_files }}')); do - cat "$file" | # get file content - tr '\n' ' ' | # remove line breaks - sed -e 's/]*>//g' | # remove attributes from svg element - base64 -w 0 | # encode svg - sed "s|.*|\"$file\" |" - done <<< "$CHANGED_FILES" | tr '\n' ' ' >> $GITHUB_OUTPUT - echo >> $GITHUB_OUTPUT - echo "$delimiter" >> $GITHUB_OUTPUT - - name: Generate 1px stroke-width - id: generate-1px-stroke-width - env: - CHANGED_FILES: ${{ steps.changed-files.outputs.all_changed_files }} - run: | - delimiter="$(openssl rand -hex 8)" - echo "body<<$delimiter" >> $GITHUB_OUTPUT - while IFS= read -r file; do - cat "$file" | # get file content - tr '\n' ' ' | # remove line breaks - sed -e 's/]*>//g' | # remove attributes from svg element - base64 -w 0 | # encode svg - sed "s|.*|\"$file\" |" - done <<< "$CHANGED_FILES" | tr '\n' ' ' >> $GITHUB_OUTPUT - echo >> $GITHUB_OUTPUT - echo "$delimiter" >> $GITHUB_OUTPUT - - name: Generate 2px stroke-width - id: generate-2px-stroke-width - env: - CHANGED_FILES: ${{ steps.changed-files.outputs.all_changed_files }} - run: | - delimiter="$(openssl rand -hex 8)" - echo "body<<$delimiter" >> $GITHUB_OUTPUT - while IFS= read -r file; do - cat "$file" | # get file content - tr '\n' ' ' | # remove line breaks - sed -e 's/]*>//g' | # remove attributes from svg element - base64 -w 0 | # encode svg - sed "s|.*|\"$file\" |" - done <<< "$CHANGED_FILES" | tr '\n' ' ' >> $GITHUB_OUTPUT - echo >> $GITHUB_OUTPUT - echo "$delimiter" >> $GITHUB_OUTPUT - - name: Generate 3px stroke-width - id: generate-3px-stroke-width - run: | - delimiter="$(openssl rand -hex 8)" - echo "body<<$delimiter" >> $GITHUB_OUTPUT - while IFS= read -r file; do - cat "$file" | # get file content - tr '\n' ' ' | # remove line breaks - sed -e 's/]*>//g' | # remove attributes from svg element - base64 -w 0 | # encode svg - sed "s|.*|\"$file\" |" - done <<< "$CHANGED_FILES" | tr '\n' ' ' >> $GITHUB_OUTPUT - echo >> $GITHUB_OUTPUT - echo "$delimiter" >> $GITHUB_OUTPUT - - name: Generate X-rays - id: generate-x-rays - env: - CHANGED_FILES: ${{ steps.changed-files.outputs.all_changed_files }} - run: | - delimiter="$(openssl rand -hex 8)" - echo "body<<$delimiter" >> $GITHUB_OUTPUT - while IFS= read -r file; do - cat "$file" | # get file content - tr '\n' ' ' | # remove line breaks - sed -e 's/]*>//g' | # remove attributes from svg element - base64 -w 0 | # encode svg - sed "s|.*|\"$file\" |" - done <<< "$CHANGED_FILES" | tr '\n' ' ' >> $GITHUB_OUTPUT - echo >> $GITHUB_OUTPUT - echo "$delimiter" >> $GITHUB_OUTPUT - add-changed-icons-comment: - if: github.repository == 'lucide-icons/lucide' - runs-on: ubuntu-latest - permissions: - pull-requests: write - needs: [generate-changed-icons-comment-data] - steps: - name: Find Comment uses: peter-evans/find-comment@v2 - id: fc + id: pr-comment with: issue-number: ${{ github.event.pull_request.number }} comment-author: 'github-actions[bot]' body-includes: Added or changed icons + + - name: Generate comment markup + run: node ./scripts/generateChangedIconsCommentMarkup.mjs >> comment-markup.md + id: comment-markup + env: + CHANGED_FILES: ${{ steps.changed-files.outputs.all_changed_files }} + - name: Create or update comment uses: peter-evans/create-or-update-comment@v3 with: - comment-id: ${{ steps.fc.outputs.comment-id }} + comment-id: ${{ steps.pr-comment.outputs.comment-id }} issue-number: ${{ github.event.pull_request.number }} - body: | - ### Added or changed icons - ${{ needs.generate-changed-icons-comment-data.outputs.generate-2px-stroke-width }}
-
- Preview cohesion - ${{ needs.generate-changed-icons-comment-data.outputs.generate-cohesion-check-squares }}
- ${{ needs.generate-changed-icons-comment-data.outputs.generate-2px-stroke-width }}
- ${{ needs.generate-changed-icons-comment-data.outputs.generate-cohesion-check-random }}
-
-
- Preview stroke widths - ${{ needs.generate-changed-icons-comment-data.outputs.generate-1px-stroke-width }}
- ${{ needs.generate-changed-icons-comment-data.outputs.generate-2px-stroke-width }}
- ${{ needs.generate-changed-icons-comment-data.outputs.generate-3px-stroke-width }}
-
-
- DPI Preview (24px) - ${{ needs.generate-changed-icons-comment-data.outputs.generate-24px-dpi-preview }} -
-
- Icon X-rays - ${{ needs.generate-changed-icons-comment-data.outputs.generate-x-rays }} -
+ body-path: ./comment-markup.md edit-mode: replace diff --git a/scripts/generateChangedIconsCommentMarkup.mjs b/scripts/generateChangedIconsCommentMarkup.mjs new file mode 100644 index 000000000..593bf037d --- /dev/null +++ b/scripts/generateChangedIconsCommentMarkup.mjs @@ -0,0 +1,98 @@ +import fs from 'fs'; +import path from 'path'; +import { shuffle, readSvgDirectory, getCurrentDirPath } from './helpers.mjs'; + +const currentDir = getCurrentDirPath(import.meta.url); +const ICONS_DIR = path.resolve(currentDir, '../icons'); +const BASE_URL = 'https://lucide.dev/api/gh-icon'; + +const changedFilesPathString = process.env.CHANGED_FILES; + +const changedFiles = changedFilesPathString + .split(' ') + .map((file) => file.replace('.json', '.svg')) + .filter((file, idx, arr) => arr.indexOf(file) === idx); + +const getImageTagsByFiles = (files, getBaseUrl, width) => + files + .map((file) => { + const svgContent = fs.readFileSync(path.join(process.cwd(), file), 'utf-8'); + const strippedAttrsSVG = svgContent + .replace(/]*>/, '') + .replaceAll(/\n| {2}|\t/g, ''); + + const base64 = Buffer.from(strippedAttrsSVG).toString('base64'); + const url = getBaseUrl(file); + const widthAttr = width ? `width="${width}"` : ''; + + return `${file}`; + }) + .join(''); + +const svgFiles = readSvgDirectory(ICONS_DIR).map((file) => `icons/${file}`); + +const iconsFilteredByName = (search) => svgFiles.filter((file) => file.includes(search)); + +const cohesionRandomImageTags = getImageTagsByFiles( + shuffle(svgFiles).slice(0, changedFiles.length), + () => `${BASE_URL}/stroke-width/2`, +); + +const cohesionSquaresImageTags = getImageTagsByFiles( + shuffle(iconsFilteredByName('square')).slice(0, changedFiles.length), + () => `${BASE_URL}/stroke-width/2`, +); + +const changeFiles1pxStrokeImageTags = getImageTagsByFiles( + changedFiles, + () => `${BASE_URL}/stroke-width/1`, +); + +const changeFiles2pxStrokeImageTags = getImageTagsByFiles( + changedFiles, + () => `${BASE_URL}/stroke-width/2`, +); + +const changeFiles3pxStrokeImageTags = getImageTagsByFiles( + changedFiles, + () => `${BASE_URL}/stroke-width/3`, +); + +const changeFilesLowDPIImageTags = getImageTagsByFiles(changedFiles, () => `${BASE_URL}/dpi/24`); + +const changeFilesXRayImageTags = getImageTagsByFiles( + changedFiles, + (file) => { + const iconName = path.basename(file, '.svg'); + + return `${BASE_URL}/${iconName}`; + }, + 400, +); + +const commentMarkup = `\ +### Added or changed icons +${changeFiles2pxStrokeImageTags} +
+Preview cohesion +${cohesionSquaresImageTags}
+${changeFiles2pxStrokeImageTags}
+${cohesionRandomImageTags}
+
+
+Preview stroke widths +${changeFiles1pxStrokeImageTags}
+${changeFiles2pxStrokeImageTags}
+${changeFiles3pxStrokeImageTags}
+
+
+DPI Preview (24px) +${changeFilesLowDPIImageTags}
+
+
+Icon X-rays +${changeFilesXRayImageTags} +
+`; + +console.log(commentMarkup); diff --git a/scripts/helpers.mjs b/scripts/helpers.mjs index e0cfc0f8f..214d5763e 100644 --- a/scripts/helpers.mjs +++ b/scripts/helpers.mjs @@ -90,12 +90,13 @@ export const writeFileIfNotExists = (content, fileName, outputDirectory) => { * @returns {object} A map of icon or category metadata */ export const readAllMetadata = (directory) => - fs.readdirSync(directory).filter((file) => path.extname(file) === '.json').reduce( - (acc, fileName, i) => { + fs + .readdirSync(directory) + .filter((file) => path.extname(file) === '.json') + .reduce((acc, fileName, i) => { acc[path.basename(fileName, '.json')] = readMetadata(fileName, directory); return acc; - }, {} - ); + }, {}); /** * Reads metadata for an icon or category @@ -111,7 +112,7 @@ export const readMetadata = (fileName, directory) => * reads the icon directory * * @param {string} directory - * @returns {array} An array of file paths containig svgs + * @returns {array} An array of file paths containing svgs */ export const readSvgDirectory = (directory, fileExtension = '.svg') => fs.readdirSync(directory).filter((file) => path.extname(file) === fileExtension); @@ -189,4 +190,21 @@ export const mergeArrays = (a, b) => { return a; }; +/** + * @param {string} currentPath + * @returns {string} + */ export const getCurrentDirPath = (currentPath) => path.dirname(fileURLToPath(currentPath)); + +/** + * @param {array} array + * @returns {array} + */ +export const shuffle = (array) => { + // eslint-disable-next-line no-plusplus + for (let i = array.length - 1; i > 0; i--) { + const j = Math.floor(Math.random() * (i + 1)); + [array[i], array[j]] = [array[j], array[i]]; + } + return array; +}; From bc5efd7f0da3b69142ced264771df0c610023aad Mon Sep 17 00:00:00 2001 From: Jakob Guddas Date: Sun, 7 Jan 2024 17:15:49 +0100 Subject: [PATCH 7/8] feat(ci): added filename lint job (#1782) --- .github/workflows/pull-request.yml | 20 ++++++++++++++++++++ scripts/lintFilenames.mjs | 24 ++++++++++++++++++++++++ 2 files changed, 44 insertions(+) create mode 100644 scripts/lintFilenames.mjs diff --git a/.github/workflows/pull-request.yml b/.github/workflows/pull-request.yml index 1def57c29..9c9ba2163 100644 --- a/.github/workflows/pull-request.yml +++ b/.github/workflows/pull-request.yml @@ -9,6 +9,26 @@ on: - fix-icon-preview jobs: + lint-filenames: + if: github.repository == 'lucide-icons/lucide' + runs-on: ubuntu-latest + permissions: + contents: read + steps: + - uses: actions/checkout@v4 + with: + fetch-depth: 0 + ref: refs/pull/${{ github.event.pull_request.number }}/merge + - name: Get changed files + id: changed-files + uses: tj-actions/changed-files@v41 + with: + files: icons/* + - name: Generate annotations + run: node ./scripts/lintFilenames.mjs + env: + CHANGED_FILES: ${{ steps.changed-files.outputs.all_changed_files }} + lint-contributors: if: github.repository == 'lucide-icons/lucide' runs-on: ubuntu-latest diff --git a/scripts/lintFilenames.mjs b/scripts/lintFilenames.mjs new file mode 100644 index 000000000..053e16650 --- /dev/null +++ b/scripts/lintFilenames.mjs @@ -0,0 +1,24 @@ +import { spawn } from 'child_process'; + +const regex = /(?[^:]+):(?\d+):(?\d+)\s-\s+(?.+)/; +const fileList = (process.env.CHANGED_FILES || '').split(' '); + +const cspell = spawn('npx', ['cspell', 'stdin'], { stdio: ['pipe', 'pipe', 'inherit'] }); +cspell.stdin.write(fileList.join('\n')); +cspell.stdin.end(); + +cspell.stdout.on('data', (data) => { + console.log(data.toString()); + data + .toString() + .split('\n') + .forEach((line) => { + const match = line.match(regex); + if (match) { + const { line, message } = match.groups; + console.log(`::error file=${fileList[line - 1]},line=1,column=1::${message}`); + } + }); +}); + +cspell.on('exit', process.exit); From 4473df5ad5fb106d71780a1effe1cc0963694630 Mon Sep 17 00:00:00 2001 From: Eric Fennis Date: Sun, 7 Jan 2024 17:26:15 +0100 Subject: [PATCH 8/8] Export all types from lucide-svelte (#1779) * Export all types from lucide-svelte * Export all types --- packages/lucide-svelte/src/lucide-svelte.ts | 2 +- packages/lucide-svelte/src/types.ts | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/packages/lucide-svelte/src/lucide-svelte.ts b/packages/lucide-svelte/src/lucide-svelte.ts index 1c5c45707..77e474d30 100644 --- a/packages/lucide-svelte/src/lucide-svelte.ts +++ b/packages/lucide-svelte/src/lucide-svelte.ts @@ -2,4 +2,4 @@ export * from './icons/index.js'; export * as icons from './icons/index.js'; export * from './aliases.js'; export { default as defaultAttributes } from './defaultAttributes.js'; -export type { Icon } from './types.js'; +export * from './types.js'; diff --git a/packages/lucide-svelte/src/types.ts b/packages/lucide-svelte/src/types.ts index b5e86eb16..fed0f6341 100644 --- a/packages/lucide-svelte/src/types.ts +++ b/packages/lucide-svelte/src/types.ts @@ -13,11 +13,11 @@ export interface IconProps extends Attrs { class?: string; } -type IconEvents = { +export type IconEvents = { [evt: string]: CustomEvent; }; -type IconSlots = { +export type IconSlots = { default: {}; };