-
Notifications
You must be signed in to change notification settings - Fork 143
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Created components/icons.js ↞ [auto-sync from https://github.com/Kudo…
- Loading branch information
1 parent
01627d6
commit 54aadd8
Showing
1 changed file
with
29 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
// Requires lib/dom.js | ||
|
||
const icons = { | ||
|
||
create({ name, size = 16, width, height, ...additionalAttrs }) { | ||
const iconData = icons[name], | ||
iconAttrs = { width: width || size, height: height || size, ...additionalAttrs } | ||
if (iconData.type == 'svg') { | ||
const svg = dom.create.svgElem('svg', { viewBox: iconData.viewBox, ...iconAttrs }) | ||
iconData.elems.forEach(([tag, attrs]) => svg.append(dom.create.svgElem(tag, attrs))) | ||
return svg | ||
} else // img w/ src | ||
return dom.create.elem('img', { src: iconData.src, ...iconAttrs }) | ||
}, | ||
|
||
plus: { | ||
type: 'svg', viewBox: '0 0 1024 1024', | ||
elems: [ | ||
[ 'path', { d: 'M899.901 600.38H600.728v299.173c0 74.383-179.503 74.383-179.503 0V600.38H122.051c-74.384 0-74.384-179.503 0-179.503h299.173V121.703c0-74.384 179.503-74.384 179.503 0v299.174H899.9c74.385 0 74.385 179.503.001 179.503z' }] | ||
] | ||
}, | ||
|
||
questionMark: { | ||
type: 'png', | ||
get src() { return `${icons.appProps.urls.assetHost}/images/icons/question-mark/icon16.png` } | ||
} | ||
} | ||
|
||
export { icons } |