Skip to content
This repository has been archived by the owner on Feb 28, 2022. It is now read-only.

Commit

Permalink
feat(icons): make class name and URL configurable (#523)
Browse files Browse the repository at this point in the history
  • Loading branch information
rofe committed Nov 12, 2019
1 parent 5fe3fe4 commit 477bf90
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 4 deletions.
17 changes: 16 additions & 1 deletion src/schemas/secrets.schema.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"meta:license": [
"Copyright 2018 Adobe. All rights reserved.",
"Copyright 2019 Adobe. All rights reserved.",
"This file is licensed to you under the Apache License, Version 2.0 (the \"License\");",
"you may not use this file except in compliance with the License. You may obtain a copy",
"of the License at http://www.apache.org/licenses/LICENSE-2.0",
Expand Down Expand Up @@ -83,6 +83,21 @@
"type": "string",
"description": "GitHub access token to use while fetching markdown. See https://help.github.com/en/articles/creating-a-personal-access-token-for-the-command-line.",
"default": ""
},
"ICON_CLASS_PREFIX": {
"type": "string",
"description": "The prefix to use in the icon class attribute",
"default": "icon icon-"
},
"ICON_URL_PREFIX": {
"type": "string",
"description": "The prefix to use in the icon URL",
"default": "/icons/"
},
"ICON_URL_SUFFIX": {
"type": "string",
"description": "The suffix to use in the icon URL",
"default": ".svg"
}
}
}
6 changes: 3 additions & 3 deletions src/utils/icon-handler.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,14 @@
* `<svg xmlns="http://www.w3.org/2000/svg" class="icon icon-smile"><use href="/icons/smile.svg"></use></svg>`
* @param {string} id the identifier of the icon
*/
function icon() {
function icon(cfg) {
return function handler(h, node) {
const { value } = node;
return [h(node, 'svg', {
xmlns: 'http://www.w3.org/2000/svg',
className: `icon icon-${value}`,
className: `${cfg.ICON_CLASS_PREFIX}${value}`,
}, [h(node, 'use', {
href: `/icons/${value}.svg`,
href: `${cfg.ICON_URL_PREFIX}${value}${cfg.ICON_URL_SUFFIX}`,
})])];
};
}
Expand Down

0 comments on commit 477bf90

Please sign in to comment.