Skip to content

Commit

Permalink
fix: set attributes on icons (#43)
Browse files Browse the repository at this point in the history
  • Loading branch information
digitalsadhu authored Jan 23, 2023
1 parent 689fee2 commit dfd5f44
Showing 1 changed file with 2 additions and 10 deletions.
12 changes: 2 additions & 10 deletions scripts/output/elements.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,21 +9,13 @@ const basepath = joinPath(__dirname, '../../elements/')
mkdirSync(basepath, { recursive: true })

getSVGs().forEach(({ svg, name, size, filename, exportName }) => {
const attrs = Array.from(svg.attrs).map(attr => attr.name + `: ` + `'` + attr.value + `'`)
const attrs = Array.from(svg.attrs).map(attr => attr.name + `=` + `"` + attr.value + `"`)
const className = exportName
const output = [
`import { LitElement, html, svg } from 'lit';`,
``,
`export class ${className} extends LitElement {`,
` static _icon() {`,
` return svg\`${svg.html}\`;`,
` }`,
` get attrs() {`,
` const attrs = { ${attrs.join(', ')} };`,
` Array.from(this.attributes).forEach(({ nodeName, nodeValue }) => attrs[nodeName] = nodeValue);`,
` return Object.entries(attrs).map(([k, v]) => \`\${k}="\${v}"\`).join(' ');`,
` }`,
` render() { return html\`<svg \${this.attrs}>\${this.constructor._icon()}</svg>\`; }`,
` render() { return html\`<svg ${attrs.join(' ')}>${svg.html}</svg>\`; }`,
`}`,
`if (!customElements.get('f-icon-${name}${size}', ${className})) {`,
` customElements.define('f-icon-${name}${size}', ${className});`,
Expand Down

0 comments on commit dfd5f44

Please sign in to comment.