Skip to content

Commit

Permalink
feat(ld-icon): add parts
Browse files Browse the repository at this point in the history
  • Loading branch information
renet authored and borisdiakur committed Oct 27, 2021
1 parent c6da865 commit 91fa753
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/liquid/components/ld-icon/ld-icon.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import { fetchIcon } from './fetchIcon'
* @slot - (optional) Custom SVG icon (only valid without name prop).
* @virtualProp ref - reference to component
* @virtualProp {string | number} key - for tracking the node's identity when working with lists
* @part icon - Actual SVG element
*/
@Component({
assetsDirs: ['assets'],
Expand All @@ -29,8 +30,9 @@ export class LdIcon {
}

const div = document.createElement('div')
const iconString = await fetchIcon(this.name)

div.innerHTML = await fetchIcon(this.name)
div.innerHTML = iconString.replace('<svg', '<svg part="icon"')
this.element.shadowRoot.appendChild(div.firstChild)
}

Expand Down
7 changes: 7 additions & 0 deletions src/liquid/components/ld-icon/readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -258,6 +258,13 @@ Liquid's icons use the [`currentColor`](https://developer.mozilla.org/en-US/docs
| | (optional) Custom SVG icon (only valid without name prop). |


## Shadow Parts

| Part | Description |
| -------- | ------------------ |
| `"icon"` | Actual SVG element |


----------------------------------------------


0 comments on commit 91fa753

Please sign in to comment.