Skip to content

Commit b73f038

Browse files
committed
custom icon registry story
1 parent b9a3e9a commit b73f038

File tree

1 file changed

+34
-1
lines changed

1 file changed

+34
-1
lines changed

packages/uui-icon-registry/lib/uui-icon-registry.story.ts

Lines changed: 34 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ CustomElement.parameters = {
4444
code: `
4545
import { UUIIconRegistryElement } from '@umbraco-ui/uui-icon-registry/lib/uui-icon-registry.element';
4646
47-
const icon = '<svg>..<svg>';
47+
const icon = '<svg>..</svg>';
4848
4949
class MyIconRegistryElement extends UUIIconRegistryElement {
5050
constructor () {
@@ -100,3 +100,36 @@ customElements.define('my-icon-registry', MyIconRegistryElement);
100100
},
101101
},
102102
};
103+
104+
export const AttachIconRegistryToACustomElement: Story = () =>
105+
html`
106+
Icon Registry is a element that provides a Icon Registry. The Element holds
107+
a empty icon registry pr. default. This registry can be access or replaced
108+
to provide icons of your interest. This example shows how to build a custom
109+
icon registry that provides an icon loaded externally: [see code]
110+
`;
111+
112+
AttachIconRegistryToACustomElement.parameters = {
113+
docs: {
114+
source: {
115+
code: `
116+
class MyCustomElement extends HTMLElement {
117+
118+
private _registry: UUIIconRegistry = new UUIIconRegistry();
119+
120+
constructor() {
121+
super();
122+
this._registry.defineIcon('myCustomIcon', '<svg>..</svg>');
123+
this._registry.attach(this);
124+
}
125+
126+
}
127+
customElements.define('my-custom-element', MyCustomElement);
128+
129+
<my-custom-element>
130+
<uui-icon name="myCustomIcon"></uui-icon>
131+
</my-icon-registry>
132+
`,
133+
},
134+
},
135+
};

0 commit comments

Comments
 (0)