Skip to content

Commit 1679623

Browse files
committed
Document passing of custom components as icons
1 parent 97f5f01 commit 1679623

File tree

3 files changed

+49
-1
lines changed

3 files changed

+49
-1
lines changed

stories/4-utilities/Icons.stories.mdx

+28
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
import { Canvas, Meta, Story } from "@storybook/addon-docs";
2+
import * as iconStories from "../5-components/Brand/AuIcon.stories";
3+
4+
<Meta title="Utilities/Icons" />
5+
6+
# Icons
7+
8+
Appuniversum includes many SVG icons that can be used by passing the name of the icon into the component, e.g.
9+
10+
```
11+
<AuButton @icon="book">Button Text</AuButton>
12+
```
13+
14+
Alternatively, wherever you can pass an icon name you can instead pass an Ember component that will be rendered instead of the default SVG in the AuIcon component.
15+
This can be used, for example, to use inline SVGs or PNG icons.
16+
17+
Although the Ember component will not be passed any arguments, it's possible to pass them using the `component` helper.
18+
See [AuIcon docs](/docs/components-brand-auicon--with-custom-icon) for a live example.
19+
20+
```
21+
<AuButton @icon={{component 'custom-icon' iconName='some-name'}}>Button Text</AuButton>
22+
```
23+
24+
All the available icons are listed here:
25+
26+
<Canvas>
27+
<Story story={iconStories.Icons} />
28+
</Canvas>

stories/5-components/Brand/AuIcon.stories.js

+19
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,17 @@ const Template = (args) => ({
4242
context: args,
4343
});
4444

45+
const CustomIconTemplate = (args) => ({
46+
template: hbs`
47+
<AuIcon
48+
@icon={{component 'au-icon' icon=this.icon}}
49+
@size={{this.size}}
50+
@alignment={{this.alignment}}
51+
@ariaHidden={{this.ariaHidden}}
52+
/>`,
53+
context: args,
54+
});
55+
4556
const IconList = (args) => ({
4657
template: hbs`
4758
<AuIconList />
@@ -57,5 +68,13 @@ Component.args = {
5768
ariaHidden: true,
5869
};
5970

71+
export const WithCustomIcon = CustomIconTemplate.bind({});
72+
WithCustomIcon.args = {
73+
icon: 'info-circle',
74+
size: 'large',
75+
alignment: '',
76+
ariaHidden: true,
77+
};
78+
6079
export const Icons = IconList.bind({});
6180
IconList.args = {};

stories/5-components/Notifications/Toasts/Documentation.stories.mdx

+2-1
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,8 @@ All these methods have the same API. The only difference is the default icon and
3737
```ts
3838
interface ToastOptions {
3939
type?: "info" | "success" | "warning" | "error"; // Default depends on the used display method
40-
icon?: string; // Any valid Appuniversum icon name, default depends on the used display method
40+
icon?: string | Component<Record<string, never>>; // Any valid Appuniversum icon name, default
41+
// depends on the used display method, or an ember component requiring no arguments
4142
timeOut?: number; // delay in milliseconds after which the toast auto-closes
4243
closable?: boolean; // Can the toast be closed by users, defaults to `true`
4344
}

0 commit comments

Comments
 (0)