diff --git a/README.md b/README.md
index 3b9273d74..5f3b41707 100644
--- a/README.md
+++ b/README.md
@@ -202,6 +202,12 @@ Icons from these sources are then converted to Vue components by our custom prec
yarn run precompile-svgs
```
+You can also regenerate just the custom icons which is faster:
+
+```bash
+yarn run precompile-custom-svgs
+```
+
We don't expose all icons in our KDS public API. Only icons defined in [the icons definitions file](lib/KIcon/iconDefinitions.js) are exposed, and we use our custom aliases for them.
#### reStructuredText replacement strings
diff --git a/custom-icons/computerScience.svg b/custom-icons/computerScience.svg
new file mode 100644
index 000000000..b2fb4d72d
--- /dev/null
+++ b/custom-icons/computerScience.svg
@@ -0,0 +1,3 @@
+
diff --git a/custom-icons/currentEvents.svg b/custom-icons/currentEvents.svg
new file mode 100644
index 000000000..a0c4cc027
--- /dev/null
+++ b/custom-icons/currentEvents.svg
@@ -0,0 +1,3 @@
+
diff --git a/custom-icons/diversity.svg b/custom-icons/diversity.svg
new file mode 100644
index 000000000..49df05312
--- /dev/null
+++ b/custom-icons/diversity.svg
@@ -0,0 +1,5 @@
+
diff --git a/custom-icons/entrepreneurship.svg b/custom-icons/entrepreneurship.svg
new file mode 100644
index 000000000..4f709c1e6
--- /dev/null
+++ b/custom-icons/entrepreneurship.svg
@@ -0,0 +1,3 @@
+
diff --git a/custom-icons/environment.svg b/custom-icons/environment.svg
new file mode 100644
index 000000000..7a3416db3
--- /dev/null
+++ b/custom-icons/environment.svg
@@ -0,0 +1,3 @@
+
diff --git a/custom-icons/financialLiteracy.svg b/custom-icons/financialLiteracy.svg
new file mode 100644
index 000000000..bb13c3abf
--- /dev/null
+++ b/custom-icons/financialLiteracy.svg
@@ -0,0 +1,14 @@
+
diff --git a/custom-icons/history.svg b/custom-icons/history.svg
new file mode 100644
index 000000000..0110ee032
--- /dev/null
+++ b/custom-icons/history.svg
@@ -0,0 +1,5 @@
+
diff --git a/custom-icons/learningSkills.svg b/custom-icons/learningSkills.svg
new file mode 100644
index 000000000..30dc7b64b
--- /dev/null
+++ b/custom-icons/learningSkills.svg
@@ -0,0 +1,3 @@
+
diff --git a/custom-icons/literacy.svg b/custom-icons/literacy.svg
new file mode 100644
index 000000000..c546b41f8
--- /dev/null
+++ b/custom-icons/literacy.svg
@@ -0,0 +1,3 @@
+
diff --git a/custom-icons/logicCriticalThinking.svg b/custom-icons/logicCriticalThinking.svg
new file mode 100644
index 000000000..60266d7a7
--- /dev/null
+++ b/custom-icons/logicCriticalThinking.svg
@@ -0,0 +1,4 @@
+
diff --git a/custom-icons/math.svg b/custom-icons/math.svg
new file mode 100644
index 000000000..9da76c95d
--- /dev/null
+++ b/custom-icons/math.svg
@@ -0,0 +1,5 @@
+
diff --git a/custom-icons/mentalHealth.svg b/custom-icons/mentalHealth.svg
new file mode 100644
index 000000000..2bb9f319d
--- /dev/null
+++ b/custom-icons/mentalHealth.svg
@@ -0,0 +1,3 @@
+
diff --git a/custom-icons/readingWriting.svg b/custom-icons/readingWriting.svg
new file mode 100644
index 000000000..f3419f2c0
--- /dev/null
+++ b/custom-icons/readingWriting.svg
@@ -0,0 +1,3 @@
+
diff --git a/custom-icons/science.svg b/custom-icons/science.svg
new file mode 100644
index 000000000..6eb998e43
--- /dev/null
+++ b/custom-icons/science.svg
@@ -0,0 +1,3 @@
+
diff --git a/custom-icons/skills.svg b/custom-icons/skills.svg
new file mode 100644
index 000000000..37e012d04
--- /dev/null
+++ b/custom-icons/skills.svg
@@ -0,0 +1,3 @@
+
diff --git a/docs/pages/icons/IconTable.vue b/docs/pages/icons/IconTable.vue
index 911b32973..39987ad8b 100644
--- a/docs/pages/icons/IconTable.vue
+++ b/docs/pages/icons/IconTable.vue
@@ -2,40 +2,55 @@
-
- General aliases
+
+
+ General use
-
+
+
Aliases with default colors
-
+
Learning activities
+
+
+ Resource categories
+
+
+
+
+
@@ -105,22 +120,30 @@
return termList(this.filterText);
},
general() {
- return sortedIconAliases(getIconGroups(this.blackIconFilter));
- },
- displayedGeneral() {
- return this.general.filter(this.termFilter);
+ return sortedIconAliases(
+ getIconGroups(alias => {
+ return (
+ !KolibriIcons[alias].defaultColor &&
+ !KolibriIcons[alias].learningActivity &&
+ !KolibriIcons[alias].resourceCategory
+ );
+ })
+ ).filter(this.termFilter);
},
withColor() {
- return sortedIconAliases(getIconGroups(this.iconWithDefaultColorFilter));
+ return sortedIconAliases(
+ getIconGroups(alias => Boolean(KolibriIcons[alias].defaultColor))
+ ).filter(this.termFilter);
},
- displayedWithColor() {
- return this.withColor.filter(this.termFilter);
+ learningActivities() {
+ return sortedIconAliases(
+ getIconGroups(alias => Boolean(KolibriIcons[alias].learningActivity))
+ ).filter(this.termFilter);
},
- withLearningActivity() {
- return sortedIconAliases(getIconGroups(this.learningActivityIconFilter));
- },
- displayedLearningActivity() {
- return this.withLearningActivity.filter(this.termFilter);
+ resourceCategories() {
+ return sortedIconAliases(
+ getIconGroups(alias => Boolean(KolibriIcons[alias].resourceCategory))
+ ).filter(this.termFilter);
},
},
methods: {
@@ -132,15 +155,6 @@
}
return false;
},
- blackIconFilter(alias) {
- return !KolibriIcons[alias].defaultColor && !KolibriIcons[alias].learningActivity;
- },
- iconWithDefaultColorFilter(alias) {
- return Boolean(KolibriIcons[alias].defaultColor);
- },
- learningActivityIconFilter(alias) {
- return KolibriIcons[alias].learningActivity;
- },
},
};
diff --git a/docs/rstIconReplacements.txt b/docs/rstIconReplacements.txt
index ff95810c9..5653a1e4b 100644
--- a/docs/rstIconReplacements.txt
+++ b/docs/rstIconReplacements.txt
@@ -3,6 +3,7 @@
.. |allActivities| replace:: :raw-html:``
.. |alternativeRoute| replace:: :raw-html:``
.. |app| replace:: :raw-html:``
+.. |artsResource| replace:: :raw-html:``
.. |audio| replace:: :raw-html:``
.. |back| replace:: :raw-html:``
.. |bookmarkEmpty| replace:: :raw-html:``
@@ -22,17 +23,21 @@
.. |coach| replace:: :raw-html:``
.. |collapseAll| replace:: :raw-html:``
.. |collection| replace:: :raw-html:``
+.. |computerScienceResource| replace:: :raw-html:``
.. |copy| replace:: :raw-html:``
.. |correct| replace:: :raw-html:``
.. |createShaded| replace:: :raw-html:``
.. |createSolid| replace:: :raw-html:``
.. |crop| replace:: :raw-html:``
+.. |currentEventsResource| replace:: :raw-html:``
.. |dashboard| replace:: :raw-html:``
.. |data| replace:: :raw-html:``
.. |delete| replace:: :raw-html:``
.. |deviceInfo| replace:: :raw-html:``
.. |device| replace:: :raw-html:``
+.. |digitalLiteracyResource| replace:: :raw-html:``
.. |disconnected| replace:: :raw-html:``
+.. |diversityResource| replace:: :raw-html:``
.. |document| replace:: :raw-html:``
.. |done| replace:: :raw-html:``
.. |dot| replace:: :raw-html:``
@@ -43,19 +48,25 @@
.. |edit| replace:: :raw-html:``
.. |email| replace:: :raw-html:``
.. |emptyTopic| replace:: :raw-html:``
+.. |entrepreneurshipResource| replace:: :raw-html:``
+.. |environmentResource| replace:: :raw-html:``
.. |error| replace:: :raw-html:``
.. |exercise| replace:: :raw-html:``
.. |facility| replace:: :raw-html:``
.. |filterList| replace:: :raw-html:``
+.. |filter| replace:: :raw-html:``
+.. |financialLiteracyResource| replace:: :raw-html:``
.. |forwardRounded| replace:: :raw-html:``
.. |forward| replace:: :raw-html:``
.. |fullscreen_exit| replace:: :raw-html:``
.. |fullscreen| replace:: :raw-html:``
.. |generateThumbnail| replace:: :raw-html:``
.. |group| replace:: :raw-html:``
+.. |guidesResource| replace:: :raw-html:``
.. |helpNeeded| replace:: :raw-html:``
.. |help| replace:: :raw-html:``
.. |hint| replace:: :raw-html:``
+.. |historyResource| replace:: :raw-html:``
.. |history| replace:: :raw-html:``
.. |home| replace:: :raw-html:``
.. |html5| replace:: :raw-html:``
@@ -64,24 +75,34 @@
.. |incorrectReport| replace:: :raw-html:``
.. |incorrect| replace:: :raw-html:``
.. |indeterminateCheck| replace:: :raw-html:``
+.. |infoOutline| replace:: :raw-html:``
.. |infoPrimary| replace:: :raw-html:``
.. |info| replace:: :raw-html:``
.. |interactShaded| replace:: :raw-html:``
.. |interactSolid| replace:: :raw-html:``
.. |language| replace:: :raw-html:``
+.. |learningSkillsResource| replace:: :raw-html:``
.. |learn| replace:: :raw-html:``
+.. |lessonPlansResource| replace:: :raw-html:``
.. |lesson| replace:: :raw-html:``
+.. |library| replace:: :raw-html:``
.. |listenShaded| replace:: :raw-html:``
.. |listenSolid| replace:: :raw-html:``
.. |list| replace:: :raw-html:``
+.. |literacyResource| replace:: :raw-html:``
+.. |logicCriticalThinkingResource| replace:: :raw-html:``
.. |login| replace:: :raw-html:``
.. |logout| replace:: :raw-html:``
.. |mastered| replace:: :raw-html:``
+.. |mathResource| replace:: :raw-html:``
+.. |mediaLiteracyResource| replace:: :raw-html:``
+.. |mentalHealthResource| replace:: :raw-html:``
.. |menu| replace:: :raw-html:``
.. |minus| replace:: :raw-html:``
.. |move| replace:: :raw-html:``
.. |myLocation| replace:: :raw-html:``
.. |notStarted| replace:: :raw-html:``
+.. |numeracyResource| replace:: :raw-html:``
.. |onDevice| replace:: :raw-html:``
.. |openNewTab| replace:: :raw-html:``
.. |optionsHorizontal| replace:: :raw-html:``
@@ -99,12 +120,14 @@
.. |print| replace:: :raw-html:``
.. |profile| replace:: :raw-html:``
.. |projects| replace:: :raw-html:``
+.. |publicHealthResource| replace:: :raw-html:``
.. |question| replace:: :raw-html:``
.. |quiz| replace:: :raw-html:``
.. |radioSelected| replace:: :raw-html:``
.. |radioUnselected| replace:: :raw-html:``
.. |readShaded| replace:: :raw-html:``
.. |readSolid| replace:: :raw-html:``
+.. |readingWritingResource| replace:: :raw-html:``
.. |recommended| replace:: :raw-html:``
.. |rectified| replace:: :raw-html:``
.. |redo| replace:: :raw-html:``
@@ -119,10 +142,13 @@
.. |restart| replace:: :raw-html:``
.. |save| replace:: :raw-html:``
.. |schedule| replace:: :raw-html:``
+.. |scienceResource| replace:: :raw-html:``
.. |search| replace:: :raw-html:``
.. |settings| replace:: :raw-html:``
.. |sidebar| replace:: :raw-html:``
+.. |skillsResource| replace:: :raw-html:``
.. |slideshow| replace:: :raw-html:``
+.. |socialScienceResource| replace:: :raw-html:``
.. |starBorder| replace:: :raw-html:``
.. |star| replace:: :raw-html:``
.. |superadmin| replace:: :raw-html:``
diff --git a/lib/KIcon/iconDefinitions.js b/lib/KIcon/iconDefinitions.js
index 922d7c893..5b608c590 100644
--- a/lib/KIcon/iconDefinitions.js
+++ b/lib/KIcon/iconDefinitions.js
@@ -177,6 +177,7 @@ const KolibriIcons = {
defaultColor: themeTokens().success,
},
info: { icon: require('./precompiled-icons/material-icons/info/baseline.vue').default },
+ infoOutline: { icon: require('./precompiled-icons/material-icons/info/outline.vue').default },
// infoPrimary is Primarily in place for use in RST docs as we cannot change the fill dynamically in RST
infoPrimary: {
icon: require('./precompiled-icons/material-icons/info/baseline.vue').default,
@@ -251,6 +252,7 @@ const KolibriIcons = {
settings: { icon: require('./precompiled-icons/material-icons/settings/baseline.vue').default },
// SettingsButton
tune: { icon: require('./precompiled-icons/material-icons/tune/baseline.vue').default },
+ filter: { icon: require('./precompiled-icons/material-icons/tune/baseline.vue').default },
// TocButton
list: { icon: require('./precompiled-icons/material-icons/list/baseline.vue').default },
// TopBar (and likely others?)
@@ -356,6 +358,103 @@ const KolibriIcons = {
resourceList: {
icon: require('./precompiled-icons/material-icons/menu_book/baseline.vue').default,
},
+ library: {
+ icon: require('./precompiled-icons/material-icons/manage_search/baseline.vue').default,
+ },
+
+ // Resource category icons
+ socialScienceResource: {
+ icon: require('./precompiled-icons/material-icons/groups/baseline.vue').default,
+ resourceCategory: true,
+ },
+ artsResource: {
+ icon: require('./precompiled-icons/material-icons/brush/baseline.vue').default,
+ resourceCategory: true,
+ },
+ publicHealthResource: {
+ icon: require('./precompiled-icons/material-icons/local_hospital/outline.vue').default,
+ resourceCategory: true,
+ },
+ mediaLiteracyResource: {
+ icon: require('./precompiled-icons/material-icons/phone_android/baseline.vue').default,
+ resourceCategory: true,
+ },
+ numeracyResource: {
+ icon: require('./precompiled-icons/material-icons/calculate/baseline.vue').default,
+ resourceCategory: true,
+ },
+ digitalLiteracyResource: {
+ icon: require('./precompiled-icons/material-icons/devices/baseline.vue').default,
+ resourceCategory: true,
+ },
+ guidesResource: {
+ icon: require('./precompiled-icons/material-icons/menu_book/baseline.vue').default,
+ resourceCategory: true,
+ },
+ lessonPlansResource: {
+ icon: require('./precompiled-icons/material-icons/menu_book/baseline.vue').default,
+ resourceCategory: true,
+ },
+ mathResource: {
+ icon: require('./precompiled-icons/le/math.vue').default,
+ resourceCategory: true,
+ },
+ scienceResource: {
+ icon: require('./precompiled-icons/le/science.vue').default,
+ resourceCategory: true,
+ },
+ readingWritingResource: {
+ icon: require('./precompiled-icons/le/readingWriting.vue').default,
+ resourceCategory: true,
+ },
+ historyResource: {
+ icon: require('./precompiled-icons/le/history.vue').default,
+ resourceCategory: true,
+ },
+ computerScienceResource: {
+ icon: require('./precompiled-icons/le/computerScience.vue').default,
+ resourceCategory: true,
+ },
+ entrepreneurshipResource: {
+ icon: require('./precompiled-icons/le/entrepreneurship.vue').default,
+ resourceCategory: true,
+ },
+ financialLiteracyResource: {
+ icon: require('./precompiled-icons/le/financialLiteracy.vue').default,
+ resourceCategory: true,
+ },
+ currentEventsResource: {
+ icon: require('./precompiled-icons/le/currentEvents.vue').default,
+ resourceCategory: true,
+ },
+ environmentResource: {
+ icon: require('./precompiled-icons/le/environment.vue').default,
+ resourceCategory: true,
+ },
+ diversityResource: {
+ icon: require('./precompiled-icons/le/diversity.vue').default,
+ resourceCategory: true,
+ },
+ mentalHealthResource: {
+ icon: require('./precompiled-icons/le/mentalHealth.vue').default,
+ resourceCategory: true,
+ },
+ literacyResource: {
+ icon: require('./precompiled-icons/le/literacy.vue').default,
+ resourceCategory: true,
+ },
+ logicCriticalThinkingResource: {
+ icon: require('./precompiled-icons/le/logicCriticalThinking.vue').default,
+ resourceCategory: true,
+ },
+ learningSkillsResource: {
+ icon: require('./precompiled-icons/le/learningSkills.vue').default,
+ resourceCategory: true,
+ },
+ skillsResource: {
+ icon: require('./precompiled-icons/le/skills.vue').default,
+ resourceCategory: true,
+ },
// Learning Activity icons
allActivities: {
diff --git a/lib/KIcon/precompiled-icons/le/computerScience.vue b/lib/KIcon/precompiled-icons/le/computerScience.vue
new file mode 100644
index 000000000..717b7caef
--- /dev/null
+++ b/lib/KIcon/precompiled-icons/le/computerScience.vue
@@ -0,0 +1,12 @@
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/lib/KIcon/precompiled-icons/le/currentEvents.vue b/lib/KIcon/precompiled-icons/le/currentEvents.vue
new file mode 100644
index 000000000..0273038fe
--- /dev/null
+++ b/lib/KIcon/precompiled-icons/le/currentEvents.vue
@@ -0,0 +1,12 @@
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/lib/KIcon/precompiled-icons/le/diversity.vue b/lib/KIcon/precompiled-icons/le/diversity.vue
new file mode 100644
index 000000000..de28de0bd
--- /dev/null
+++ b/lib/KIcon/precompiled-icons/le/diversity.vue
@@ -0,0 +1,12 @@
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/lib/KIcon/precompiled-icons/le/entrepreneurship.vue b/lib/KIcon/precompiled-icons/le/entrepreneurship.vue
new file mode 100644
index 000000000..60287de32
--- /dev/null
+++ b/lib/KIcon/precompiled-icons/le/entrepreneurship.vue
@@ -0,0 +1,12 @@
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/lib/KIcon/precompiled-icons/le/environment.vue b/lib/KIcon/precompiled-icons/le/environment.vue
new file mode 100644
index 000000000..3622272f4
--- /dev/null
+++ b/lib/KIcon/precompiled-icons/le/environment.vue
@@ -0,0 +1,12 @@
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/lib/KIcon/precompiled-icons/le/financialLiteracy.vue b/lib/KIcon/precompiled-icons/le/financialLiteracy.vue
new file mode 100644
index 000000000..c6f836d95
--- /dev/null
+++ b/lib/KIcon/precompiled-icons/le/financialLiteracy.vue
@@ -0,0 +1,12 @@
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/lib/KIcon/precompiled-icons/le/history.vue b/lib/KIcon/precompiled-icons/le/history.vue
new file mode 100644
index 000000000..32ef0a64c
--- /dev/null
+++ b/lib/KIcon/precompiled-icons/le/history.vue
@@ -0,0 +1,12 @@
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/lib/KIcon/precompiled-icons/le/learningSkills.vue b/lib/KIcon/precompiled-icons/le/learningSkills.vue
new file mode 100644
index 000000000..f15f102f4
--- /dev/null
+++ b/lib/KIcon/precompiled-icons/le/learningSkills.vue
@@ -0,0 +1,12 @@
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/lib/KIcon/precompiled-icons/le/literacy.vue b/lib/KIcon/precompiled-icons/le/literacy.vue
new file mode 100644
index 000000000..ace468944
--- /dev/null
+++ b/lib/KIcon/precompiled-icons/le/literacy.vue
@@ -0,0 +1,12 @@
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/lib/KIcon/precompiled-icons/le/logicCriticalThinking.vue b/lib/KIcon/precompiled-icons/le/logicCriticalThinking.vue
new file mode 100644
index 000000000..0c0c5d33f
--- /dev/null
+++ b/lib/KIcon/precompiled-icons/le/logicCriticalThinking.vue
@@ -0,0 +1,12 @@
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/lib/KIcon/precompiled-icons/le/math.vue b/lib/KIcon/precompiled-icons/le/math.vue
new file mode 100644
index 000000000..1cf654933
--- /dev/null
+++ b/lib/KIcon/precompiled-icons/le/math.vue
@@ -0,0 +1,12 @@
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/lib/KIcon/precompiled-icons/le/mentalHealth.vue b/lib/KIcon/precompiled-icons/le/mentalHealth.vue
new file mode 100644
index 000000000..30183615c
--- /dev/null
+++ b/lib/KIcon/precompiled-icons/le/mentalHealth.vue
@@ -0,0 +1,12 @@
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/lib/KIcon/precompiled-icons/le/readingWriting.vue b/lib/KIcon/precompiled-icons/le/readingWriting.vue
new file mode 100644
index 000000000..892d04996
--- /dev/null
+++ b/lib/KIcon/precompiled-icons/le/readingWriting.vue
@@ -0,0 +1,12 @@
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/lib/KIcon/precompiled-icons/le/science.vue b/lib/KIcon/precompiled-icons/le/science.vue
new file mode 100644
index 000000000..3678b7a03
--- /dev/null
+++ b/lib/KIcon/precompiled-icons/le/science.vue
@@ -0,0 +1,12 @@
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/lib/KIcon/precompiled-icons/le/skills.vue b/lib/KIcon/precompiled-icons/le/skills.vue
new file mode 100644
index 000000000..afde6a51f
--- /dev/null
+++ b/lib/KIcon/precompiled-icons/le/skills.vue
@@ -0,0 +1,12 @@
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/package.json b/package.json
index 7624270bd..d836b0735 100644
--- a/package.json
+++ b/package.json
@@ -13,7 +13,8 @@
"lint-watch": "yarn lint -m",
"pregenerate": "node utils/pregenerate.js",
"_dev-only": "nuxt --port 4000",
- "precompile-svgs": "rm -rf lib/KIcon/precompiled-icons && node utils/precompileSvgs/index.js",
+ "precompile-svgs": "node utils/precompileSvgs/index.js",
+ "precompile-custom-svgs": "node utils/precompileSvgs/index.js --custom",
"_lint-watch-fix": "yarn lint -w -m",
"_test": "jest",
"_api-watch": "chokidar \"**/lib/**\" -c \"node utils/extractApi.js\""
diff --git a/utils/extractRstIcons.js b/utils/extractRstIcons.js
index b13c37040..38837b7d6 100644
--- a/utils/extractRstIcons.js
+++ b/utils/extractRstIcons.js
@@ -43,7 +43,7 @@ const ICON_DEFINITION_PATTERN = /\n {2}(\w+): {.*?\s+icon:\s+require\('(.+?)'\).
const ICON_DEFINITION_COLOR_PATTERN = /defaultColor:\s+themeTokens\(\)\.(\w+)/s;
// Within an icon file, match just the SVG tag
-const TEMPLATE_PATTERN = /<\/svg>/;
+const TEMPLATE_PATTERN = /<\/svg>/;
function writeRstIcons() {
// Load iconDefinitions.js as a simple text file
diff --git a/utils/precompileSvgs/index.js b/utils/precompileSvgs/index.js
index acd7c54c0..53bce0fce 100644
--- a/utils/precompileSvgs/index.js
+++ b/utils/precompileSvgs/index.js
@@ -4,8 +4,10 @@
*/
const fs = require('fs');
+const path = require('path');
const crypto = require('crypto');
const consola = require('consola');
+var rimraf = require('rimraf');
const SVGO = require('svgo');
@@ -26,31 +28,36 @@ const basePathForPrecompiledSvgs = './lib/KIcon/precompiled-icons';
* `iconLibPath` is where we find the original icon SVG files
* `namespace` is appended to basePathForPrecompiledSvgs to namespace the libraries
*/
+
const config = [
- // https://github.com/material-icons/material-icons
+ // Custom icons that we made here at LE
{
+ iconLibPath: './custom-icons',
+ namespace: 'le',
+ },
+];
+
+const customOnly = process.argv.includes('--custom');
+
+if (!customOnly) {
+ // https://github.com/material-icons/material-icons
+ config.push({
iconLibPath: './node_modules/@material-icons/svg/svg',
namespace: 'material-icons',
- },
+ });
// https://github.com/Templarian/MaterialDesign-SVG
- {
+ config.push({
iconLibPath: './node_modules/@mdi/svg/svg',
namespace: 'mdi',
- },
- // Icons that we made here at LE
- {
- iconLibPath: './custom-icons',
- namespace: 'le',
- },
-];
+ });
+}
-// Before we do anything we need to make the base svg directory. This directory ought not exist.
-try {
+// Clean up directories
+if (customOnly) {
+ rimraf.sync(path.join(basePathForPrecompiledSvgs, 'le'));
+} else {
+ rimraf.sync(basePathForPrecompiledSvgs);
fs.mkdirSync(basePathForPrecompiledSvgs);
-} catch (e) {
- consola.error(
- `Failed to create base SVG directory. You may need to remove the ${basePathForPrecompiledSvgs} directory.\nError message: ${e}`
- );
}
class LibPrecompiler {