@equinor/fusion-wc-icon
Advanced tools
Comparing version 2.1.0 to 2.2.0
# Change Log | ||
## 2.2.0 | ||
### Minor Changes | ||
- [#972](https://github.com/equinor/fusion-web-components/pull/972) [`68ecc45`](https://github.com/equinor/fusion-web-components/commit/68ecc45544fbb3de9db701831b50d669dce02133) Thanks [@odinr](https://github.com/odinr)! - allow slotting svg into fwc-icon | ||
- removed allowing setting svg as a property (don`t want content in memory) | ||
- added slot for adding svg content | ||
## 2.1.0 | ||
@@ -4,0 +13,0 @@ |
@@ -15,3 +15,3 @@ { | ||
}, | ||
"default": "css`\n :host {\n display: inline-flex;\n height: 1.5em;\n width: 1.5em;\n }\n svg {\n height: 100%;\n width: auto;\n fill: currentColor;\n }\n`" | ||
"default": "css`\n :host {\n display: inline-flex;\n height: 1.5em;\n width: 1.5em;\n }\n ::slotted(svg),\n svg {\n height: 100%;\n width: auto;\n fill: currentColor;\n }\n`" | ||
} | ||
@@ -263,3 +263,3 @@ ], | ||
"type": { | ||
"text": "SVGTemplateResult | null" | ||
"text": "SVGTemplateResult | void" | ||
} | ||
@@ -266,0 +266,0 @@ }, |
@@ -8,2 +8,3 @@ import { css } from 'lit'; | ||
} | ||
::slotted(svg), | ||
svg { | ||
@@ -10,0 +11,0 @@ height: 100%; |
import { IconName } from '@equinor/eds-icons'; | ||
import { LitElement, SVGTemplateResult } from 'lit'; | ||
import { HTMLTemplateResult, LitElement, SVGTemplateResult } from 'lit'; | ||
import { IconType } from './utils/create-icon'; | ||
@@ -12,3 +12,3 @@ export type IconElementProps = { | ||
type?: IconType; | ||
render(): SVGTemplateResult | null; | ||
render(): SVGTemplateResult | HTMLTemplateResult | void; | ||
} |
import { __decorate } from "tslib"; | ||
import { LitElement } from 'lit'; | ||
import { LitElement, html } from 'lit'; | ||
import { property } from 'lit/decorators.js'; | ||
@@ -8,3 +8,6 @@ import createIcon from './utils/create-icon'; | ||
render() { | ||
return this.icon ? createIcon(this.icon, this.type) : null; | ||
if (this.icon) { | ||
return createIcon(this.icon, this.type); | ||
} | ||
return html `<slot></slot>`; | ||
} | ||
@@ -11,0 +14,0 @@ } |
@@ -7,7 +7,6 @@ import { SVGTemplateResult } from 'lit'; | ||
export declare enum IconType { | ||
EDS = "eds", | ||
SVG = "svg" | ||
EDS = "eds" | ||
} | ||
export declare const createSvg: ({ height, width, svgPathData }: IconData) => SVGTemplateResult; | ||
export declare const createIcon: (nameOrSvgTemplate: IconName | string, type?: IconType) => SVGTemplateResult | null; | ||
export declare const createIcon: (nameOrSvgTemplate: IconName | string, type?: IconType) => SVGTemplateResult | void; | ||
export default createIcon; |
import { svg } from 'lit'; | ||
import { unsafeSVG } from 'lit/directives/unsafe-svg.js'; | ||
// import { unsafeSVG } from 'lit/directives/unsafe-svg.js'; | ||
import * as edsIcons from '@equinor/eds-icons'; | ||
@@ -8,3 +8,2 @@ export const iconNames = Object.keys(edsIcons); | ||
IconType["EDS"] = "eds"; | ||
IconType["SVG"] = "svg"; | ||
})(IconType || (IconType = {})); | ||
@@ -21,12 +20,6 @@ export const createSvg = ({ height, width, svgPathData }) => svg ` | ||
const icon = edsIcons[name]; | ||
if (!icon) { | ||
console.warn('could not find icon', name); | ||
return null; | ||
if (icon) { | ||
return createSvg(edsIcons[name]); | ||
} | ||
return createSvg(edsIcons[name]); | ||
} | ||
case IconType.SVG: { | ||
const svgString = nameOrSvgTemplate; | ||
return svg `${unsafeSVG(svgString)}`; | ||
} | ||
} | ||
@@ -33,0 +26,0 @@ }; |
{ | ||
"name": "@equinor/fusion-wc-icon", | ||
"version": "2.1.0", | ||
"version": "2.2.0", | ||
"description": "", | ||
@@ -35,3 +35,3 @@ "main": "lib/index.js", | ||
}, | ||
"gitHead": "5b1b245d9e0d04f931fd12634f11c621f52980f8" | ||
"gitHead": "7001d61663cbb2af8ba4e6fec90e1fe1673507f4" | ||
} |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
300688
1437