-
-
Notifications
You must be signed in to change notification settings - Fork 7
/
template.ts
32 lines (29 loc) · 921 Bytes
/
template.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
import { toString } from "@carbon/icon-helpers";
import { PictogramOutput } from "@carbon/pictograms";
export function template({ descriptor }: PictogramOutput) {
return `<script>
/**
* Specify the pictogram title.
* @type {string}
*/
export let title = undefined;
$: labelled = $$props["aria-label"] || $$props["aria-labelledby"] || $$props["title"];
$: attributes = {
"aria-hidden": labelled ? undefined : true,
role: labelled ? "img" : undefined,
focusable: Number($$props["tabindex"]) === 0 ? true : undefined,
};
</script>
<svg
preserveAspectRatio="xMidYMid meet"
xmlns="${descriptor.attrs.xmlns}"
viewBox="${descriptor.attrs.viewBox}"
width="${descriptor.attrs.width}"
height="${descriptor.attrs.height}"
fill="${descriptor.attrs.fill}"
{title}
{...attributes}
{...$$restProps}>
${descriptor.content.map((element) => toString(element)).join("")}
</svg>`;
}