From 477bf908462cd50c8177f50b84289265309c299d Mon Sep 17 00:00:00 2001 From: rofe Date: Tue, 12 Nov 2019 13:44:32 +0100 Subject: [PATCH] feat(icons): make class name and URL configurable (#523) --- src/schemas/secrets.schema.json | 17 ++++++++++++++++- src/utils/icon-handler.js | 6 +++--- 2 files changed, 19 insertions(+), 4 deletions(-) diff --git a/src/schemas/secrets.schema.json b/src/schemas/secrets.schema.json index 6d4cda53f..88bbbd194 100644 --- a/src/schemas/secrets.schema.json +++ b/src/schemas/secrets.schema.json @@ -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", @@ -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" } } } diff --git a/src/utils/icon-handler.js b/src/utils/icon-handler.js index dcd312b3d..a735c3786 100644 --- a/src/utils/icon-handler.js +++ b/src/utils/icon-handler.js @@ -15,14 +15,14 @@ * `` * @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}`, })])]; }; }