Skip to content

Commit

Permalink
PR feedback
Browse files Browse the repository at this point in the history
  • Loading branch information
mollykreis committed Feb 28, 2024
1 parent d8100c6 commit b6b2b0b
Showing 1 changed file with 16 additions and 10 deletions.
Original file line number Diff line number Diff line change
@@ -1,28 +1,34 @@
import { html, when, type ViewTemplate } from '@microsoft/fast-element';
import { html, type ViewTemplate } from '@microsoft/fast-element';
import type { IconSeverity } from '../../../icon-base/types';
import { MappingConfig } from './mapping-config';

export interface IconView {
severity: IconSeverity;
text?: string;
}

// Create an empty template containing only a space because creating a ViewTemplate
// with an empty string throws an exception at runtime.
const emptyTemplate = html<IconView>` `;

const createIconTemplate = (
icon: string | undefined
): ViewTemplate<IconView> => html`
${when(
() => icon,
html<IconView>`
<${icon!}
): ViewTemplate<IconView> => {
if (icon === undefined) {
return emptyTemplate;
}

return html`
<${icon}
title="${x => x.text}"
role="img"
aria-label="${x => x.text}"
severity="${x => x.severity}"
class="no-shrink"
>
</${icon!}>
`
)}
`;
</${icon}>
`;
};

/**
* Mapping configuration corresponding to a icon mapping
Expand Down

0 comments on commit b6b2b0b

Please sign in to comment.