2021-01-09 23:59:43 +03:00
|
|
|
import {h} from '/js/web_modules/preact.js';
|
2020-10-07 09:42:46 +03:00
|
|
|
import htm from '/js/web_modules/htm.js';
|
2021-01-09 23:59:43 +03:00
|
|
|
import {classNames} from '../utils/helpers.js';
|
|
|
|
|
2020-08-24 07:41:02 +03:00
|
|
|
const html = htm.bind(h);
|
2020-10-04 21:36:05 +03:00
|
|
|
|
2021-01-09 23:59:43 +03:00
|
|
|
function SocialIcon(props) {
|
|
|
|
const {platform, icon, url} = props;
|
|
|
|
const iconSupplied = !!icon
|
2021-02-19 10:05:52 +03:00
|
|
|
const name = platform;
|
2021-01-09 23:59:43 +03:00
|
|
|
|
2021-02-19 10:05:52 +03:00
|
|
|
const finalIcon = iconSupplied ? icon : '/img/platformlogos/default.svg';
|
2021-01-09 23:59:43 +03:00
|
|
|
|
|
|
|
const style = `background-image: url(${finalIcon});`
|
|
|
|
|
|
|
|
const itemClass = classNames({
|
|
|
|
"user-social-item": true,
|
|
|
|
"flex": true,
|
|
|
|
"justify-start": true,
|
|
|
|
"items-center": true,
|
|
|
|
"-mr-1": true,
|
|
|
|
});
|
|
|
|
const labelClass = classNames({
|
|
|
|
"platform-label": true,
|
|
|
|
"visually-hidden": !!finalIcon,
|
|
|
|
"text-indigo-800": true,
|
|
|
|
"text-xs": true,
|
|
|
|
"uppercase": true,
|
|
|
|
"max-w-xs": true,
|
|
|
|
"inline-block": true,
|
|
|
|
});
|
|
|
|
|
|
|
|
return (
|
|
|
|
html`
|
2021-01-10 03:40:38 +03:00
|
|
|
<a class=${itemClass} target="_blank" rel="me" href=${url}>
|
2021-01-09 23:59:43 +03:00
|
|
|
<span class="platform-icon rounded-lg bg-no-repeat"
|
|
|
|
style=${style} title="Find me on ${name}"></span>
|
|
|
|
<span class=${labelClass}>Find me on ${name}</span>
|
|
|
|
</a>
|
|
|
|
`);
|
|
|
|
}
|
2020-06-21 10:07:57 +03:00
|
|
|
|
2020-10-04 21:36:05 +03:00
|
|
|
export default function (props) {
|
2021-01-09 23:59:43 +03:00
|
|
|
const {handles} = props;
|
2020-10-04 21:36:05 +03:00
|
|
|
if (handles == null) {
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
|
|
|
|
const list = handles.map((item, index) => html`
|
|
|
|
<li key="social${index}">
|
2021-01-09 23:59:43 +03:00
|
|
|
<${SocialIcon} platform=${item.platform} icon=${item.icon}
|
|
|
|
url=${item.url}/>
|
2020-10-04 21:36:05 +03:00
|
|
|
</li>
|
|
|
|
`);
|
|
|
|
|
2021-01-09 23:59:43 +03:00
|
|
|
return html`
|
|
|
|
<ul
|
2020-10-04 21:36:05 +03:00
|
|
|
id="social-list"
|
|
|
|
class="social-list flex flex-row items-center justify-start flex-wrap">
|
2021-01-09 23:59:43 +03:00
|
|
|
<span
|
|
|
|
class="follow-label text-xs font-bold mr-2 uppercase">Follow me:</span>
|
|
|
|
${list}
|
|
|
|
</ul>`;
|
2020-12-23 04:43:35 +03:00
|
|
|
}
|