2021-11-26 19:06:09 +00:00
|
|
|
import { DeesElement, html, property, customElement } from '@designestate/dees-element';
|
2020-09-17 10:35:33 +00:00
|
|
|
|
|
|
|
import * as domtools from '@designestate/dees-domtools';
|
|
|
|
|
2020-12-02 17:11:04 +00:00
|
|
|
import { icon, IconDefinition } from '@fortawesome/fontawesome-svg-core';
|
|
|
|
import {
|
|
|
|
faFacebook,
|
|
|
|
faGoogle,
|
|
|
|
faLinkedin,
|
|
|
|
faMedium,
|
2020-12-03 11:12:11 +00:00
|
|
|
faSlackHash,
|
2020-12-02 17:11:04 +00:00
|
|
|
faTwitter,
|
2022-07-14 21:29:25 +00:00
|
|
|
faInstagram,
|
|
|
|
faTiktok,
|
2020-12-02 17:11:04 +00:00
|
|
|
} from '@fortawesome/free-brands-svg-icons';
|
2020-12-01 22:24:54 +00:00
|
|
|
|
2020-12-02 17:11:04 +00:00
|
|
|
import {} from '@fortawesome/free-regular-svg-icons';
|
2020-12-02 17:30:41 +00:00
|
|
|
import { faDesktop, faRss, faUsers } from '@fortawesome/free-solid-svg-icons';
|
2020-12-02 17:11:04 +00:00
|
|
|
|
|
|
|
type TFontAwesomeIcon =
|
|
|
|
// normal
|
|
|
|
| 'desktop'
|
|
|
|
| 'rss'
|
|
|
|
// brands
|
|
|
|
| 'facebook'
|
|
|
|
| 'google'
|
|
|
|
| 'linkedin'
|
2022-07-14 21:29:25 +00:00
|
|
|
| 'instagram'
|
2020-12-02 17:11:04 +00:00
|
|
|
| 'medium'
|
2020-12-02 17:30:41 +00:00
|
|
|
| 'slack'
|
2022-07-14 21:29:25 +00:00
|
|
|
| 'tiktok'
|
|
|
|
| 'twitter'
|
2020-12-02 17:30:41 +00:00
|
|
|
| 'users';
|
2020-12-02 17:11:04 +00:00
|
|
|
const faIcons: { [key: string]: IconDefinition } = {
|
|
|
|
// normal
|
|
|
|
desktop: faDesktop,
|
|
|
|
rss: faRss,
|
|
|
|
// brands
|
2020-12-01 22:49:44 +00:00
|
|
|
facebook: faFacebook,
|
2020-12-02 17:11:04 +00:00
|
|
|
google: faGoogle,
|
2022-07-14 21:29:25 +00:00
|
|
|
instagram: faInstagram,
|
2020-12-01 22:49:44 +00:00
|
|
|
linkedin: faLinkedin,
|
2020-12-02 17:11:04 +00:00
|
|
|
medium: faMedium,
|
2020-12-03 11:12:11 +00:00
|
|
|
slack: faSlackHash,
|
2022-07-14 21:29:25 +00:00
|
|
|
tiktok: faTiktok,
|
2020-12-02 17:11:04 +00:00
|
|
|
twitter: faTwitter,
|
2020-12-02 17:30:41 +00:00
|
|
|
users: faUsers,
|
2020-12-01 22:24:54 +00:00
|
|
|
};
|
|
|
|
|
2021-03-06 15:48:02 +00:00
|
|
|
declare global {
|
|
|
|
interface HTMLElementTagNameMap {
|
|
|
|
'dees-icon': DeesIcon;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-09-17 10:35:33 +00:00
|
|
|
@customElement('dees-icon')
|
2021-11-26 19:06:09 +00:00
|
|
|
export class DeesIcon extends DeesElement {
|
2020-12-01 22:24:54 +00:00
|
|
|
public static demo = () => html`
|
2021-11-26 19:06:09 +00:00
|
|
|
<dees-icon iconName="visibility"></dees-icon>
|
2020-12-01 22:24:54 +00:00
|
|
|
<div style="background: #fff; padding: 10px;">
|
|
|
|
<dees-icon iconName="visibility"></dees-icon>
|
|
|
|
<dees-icon brandName="facebook"></dees-icon>
|
|
|
|
</div>
|
2020-12-02 17:11:04 +00:00
|
|
|
`;
|
2020-09-17 10:35:33 +00:00
|
|
|
|
|
|
|
@property()
|
|
|
|
public iconName: string;
|
|
|
|
|
2020-12-01 22:24:54 +00:00
|
|
|
@property()
|
2020-12-02 17:11:04 +00:00
|
|
|
public brandName: TFontAwesomeIcon;
|
2020-12-01 22:24:54 +00:00
|
|
|
|
|
|
|
@property()
|
|
|
|
public svgSize: number = 20;
|
|
|
|
|
2020-09-17 10:35:33 +00:00
|
|
|
constructor() {
|
|
|
|
super();
|
|
|
|
domtools.elementBasic.setup();
|
|
|
|
}
|
|
|
|
|
|
|
|
public render() {
|
|
|
|
return html`
|
|
|
|
${domtools.elementBasic.styles}
|
|
|
|
<style>
|
|
|
|
:host {
|
|
|
|
display: block;
|
|
|
|
line-height: inherit;
|
|
|
|
font-size: inherit;
|
2022-12-06 12:32:00 +00:00
|
|
|
margin: 0px;
|
|
|
|
padding: 0px;
|
|
|
|
white-space: nowrap;
|
2020-09-17 10:35:33 +00:00
|
|
|
}
|
2020-12-01 22:24:54 +00:00
|
|
|
#iconContainer svg {
|
|
|
|
display: inline-block;
|
|
|
|
height: ${this.svgSize}px;
|
|
|
|
}
|
2023-01-07 12:27:24 +00:00
|
|
|
.material-symbols-outlined {
|
|
|
|
font-family: 'Material Symbols Outlined';
|
2020-09-17 10:35:33 +00:00
|
|
|
font-weight: normal;
|
|
|
|
font-style: normal;
|
|
|
|
line-height: inherit;
|
2023-01-07 12:27:24 +00:00
|
|
|
font-size: inherit; /* Preferred icon size */
|
2020-09-17 10:35:33 +00:00
|
|
|
display: inline-block;
|
|
|
|
text-transform: none;
|
|
|
|
letter-spacing: normal;
|
|
|
|
word-wrap: normal;
|
|
|
|
white-space: nowrap;
|
|
|
|
direction: ltr;
|
|
|
|
}
|
|
|
|
</style>
|
2023-01-07 12:27:24 +00:00
|
|
|
${this.iconName
|
|
|
|
? html`
|
|
|
|
<i
|
|
|
|
class="material-symbols-outlined"
|
|
|
|
style="font-variation-settings: 'FILL' 1, 'wght' 700, 'GRAD' 0, 'opsz' 48;"
|
|
|
|
>
|
|
|
|
${this.iconName}
|
|
|
|
</i>`
|
|
|
|
: html``}
|
2020-12-01 22:24:54 +00:00
|
|
|
${this.brandName ? html`<div id="iconContainer"></div>` : html``}
|
2020-09-17 10:35:33 +00:00
|
|
|
`;
|
|
|
|
}
|
2020-12-01 22:24:54 +00:00
|
|
|
|
2023-01-07 12:41:24 +00:00
|
|
|
public async firstUpdated() {
|
2020-12-01 22:24:54 +00:00
|
|
|
if (this.brandName && !this.iconName) {
|
2020-12-02 17:11:04 +00:00
|
|
|
this.shadowRoot.querySelector('#iconContainer').innerHTML = icon(
|
|
|
|
faIcons[this.brandName]
|
|
|
|
).html[0];
|
2020-12-01 22:24:54 +00:00
|
|
|
}
|
|
|
|
}
|
2020-09-17 10:35:33 +00:00
|
|
|
}
|