From 0ab4e47f0bbf184b46d9529187d0cd81e32f36ed Mon Sep 17 00:00:00 2001 From: Mirco T Date: Sat, 9 Jan 2021 21:59:43 +0100 Subject: [PATCH] #515 switched to SVG icons, #525 added Ko-Fi platform (#528) * #515 switched to SVG icons, #525 added Ko-Fi platform * fixes #515, fixes #525 - added color to the SVGs directly * Removed `color` from config for socialHandles, not required anymore --- config/config.go | 1 + webroot/img/socialhandles/bandcamp.svg | 4 + webroot/img/socialhandles/default.svg | 93 ++++++++++++++++++++ webroot/img/socialhandles/discord.svg | 5 ++ webroot/img/socialhandles/facebook.svg | 5 ++ webroot/img/socialhandles/github.svg | 5 ++ webroot/img/socialhandles/gitlab.svg | 5 ++ webroot/img/socialhandles/google.svg | 5 ++ webroot/img/socialhandles/instagram.svg | 5 ++ webroot/img/socialhandles/ko-fi.svg | 5 ++ webroot/img/socialhandles/linkedin.svg | 5 ++ webroot/img/socialhandles/mastodon.svg | 5 ++ webroot/img/socialhandles/patreon.svg | 5 ++ webroot/img/socialhandles/paypal.svg | 5 ++ webroot/img/socialhandles/snapchat.svg | 5 ++ webroot/img/socialhandles/soundcloud.svg | 5 ++ webroot/img/socialhandles/spotify.svg | 5 ++ webroot/img/socialhandles/tiktok.svg | 1 + webroot/img/socialhandles/twitch.svg | 5 ++ webroot/img/socialhandles/twitter.svg | 5 ++ webroot/img/socialhandles/youtube.svg | 5 ++ webroot/js/components/platform-logos-list.js | 63 ++++++++++--- webroot/js/utils/platforms.js | 42 +++++---- webroot/styles/user-content.css | 6 +- 24 files changed, 265 insertions(+), 30 deletions(-) create mode 100644 webroot/img/socialhandles/bandcamp.svg create mode 100644 webroot/img/socialhandles/default.svg create mode 100644 webroot/img/socialhandles/discord.svg create mode 100644 webroot/img/socialhandles/facebook.svg create mode 100644 webroot/img/socialhandles/github.svg create mode 100644 webroot/img/socialhandles/gitlab.svg create mode 100644 webroot/img/socialhandles/google.svg create mode 100644 webroot/img/socialhandles/instagram.svg create mode 100644 webroot/img/socialhandles/ko-fi.svg create mode 100644 webroot/img/socialhandles/linkedin.svg create mode 100644 webroot/img/socialhandles/mastodon.svg create mode 100644 webroot/img/socialhandles/patreon.svg create mode 100644 webroot/img/socialhandles/paypal.svg create mode 100644 webroot/img/socialhandles/snapchat.svg create mode 100644 webroot/img/socialhandles/soundcloud.svg create mode 100644 webroot/img/socialhandles/spotify.svg create mode 100644 webroot/img/socialhandles/tiktok.svg create mode 100644 webroot/img/socialhandles/twitch.svg create mode 100644 webroot/img/socialhandles/twitter.svg create mode 100644 webroot/img/socialhandles/youtube.svg diff --git a/config/config.go b/config/config.go index 01f3f11f7..815c30dcf 100644 --- a/config/config.go +++ b/config/config.go @@ -53,6 +53,7 @@ type InstanceDetails struct { type socialHandle struct { Platform string `yaml:"platform" json:"platform"` URL string `yaml:"url" json:"url"` + Icon string `yaml:"icon" json:"icon"` } type videoSettings struct { diff --git a/webroot/img/socialhandles/bandcamp.svg b/webroot/img/socialhandles/bandcamp.svg new file mode 100644 index 000000000..e35788364 --- /dev/null +++ b/webroot/img/socialhandles/bandcamp.svg @@ -0,0 +1,4 @@ + + Bandcamp icon + + diff --git a/webroot/img/socialhandles/default.svg b/webroot/img/socialhandles/default.svg new file mode 100644 index 000000000..68ee444d2 --- /dev/null +++ b/webroot/img/socialhandles/default.svg @@ -0,0 +1,93 @@ + + + + + + + + + + + + + + + + diff --git a/webroot/img/socialhandles/discord.svg b/webroot/img/socialhandles/discord.svg new file mode 100644 index 000000000..27cc10ae7 --- /dev/null +++ b/webroot/img/socialhandles/discord.svg @@ -0,0 +1,5 @@ + + Discord icon + + diff --git a/webroot/img/socialhandles/facebook.svg b/webroot/img/socialhandles/facebook.svg new file mode 100644 index 000000000..81dc87400 --- /dev/null +++ b/webroot/img/socialhandles/facebook.svg @@ -0,0 +1,5 @@ + + Facebook icon + + diff --git a/webroot/img/socialhandles/github.svg b/webroot/img/socialhandles/github.svg new file mode 100644 index 000000000..162234a54 --- /dev/null +++ b/webroot/img/socialhandles/github.svg @@ -0,0 +1,5 @@ + + GitHub icon + + diff --git a/webroot/img/socialhandles/gitlab.svg b/webroot/img/socialhandles/gitlab.svg new file mode 100644 index 000000000..02aae0df9 --- /dev/null +++ b/webroot/img/socialhandles/gitlab.svg @@ -0,0 +1,5 @@ + + GitLab icon + + diff --git a/webroot/img/socialhandles/google.svg b/webroot/img/socialhandles/google.svg new file mode 100644 index 000000000..e07633930 --- /dev/null +++ b/webroot/img/socialhandles/google.svg @@ -0,0 +1,5 @@ + + Google icon + + diff --git a/webroot/img/socialhandles/instagram.svg b/webroot/img/socialhandles/instagram.svg new file mode 100644 index 000000000..a2063baa0 --- /dev/null +++ b/webroot/img/socialhandles/instagram.svg @@ -0,0 +1,5 @@ + + Instagram icon + + diff --git a/webroot/img/socialhandles/ko-fi.svg b/webroot/img/socialhandles/ko-fi.svg new file mode 100644 index 000000000..94d991602 --- /dev/null +++ b/webroot/img/socialhandles/ko-fi.svg @@ -0,0 +1,5 @@ + + Ko-fi icon + + diff --git a/webroot/img/socialhandles/linkedin.svg b/webroot/img/socialhandles/linkedin.svg new file mode 100644 index 000000000..4d6153288 --- /dev/null +++ b/webroot/img/socialhandles/linkedin.svg @@ -0,0 +1,5 @@ + + LinkedIn icon + + diff --git a/webroot/img/socialhandles/mastodon.svg b/webroot/img/socialhandles/mastodon.svg new file mode 100644 index 000000000..2cd0a634f --- /dev/null +++ b/webroot/img/socialhandles/mastodon.svg @@ -0,0 +1,5 @@ + + Mastodon icon + + diff --git a/webroot/img/socialhandles/patreon.svg b/webroot/img/socialhandles/patreon.svg new file mode 100644 index 000000000..1f2c1867e --- /dev/null +++ b/webroot/img/socialhandles/patreon.svg @@ -0,0 +1,5 @@ + + Patreon icon + + diff --git a/webroot/img/socialhandles/paypal.svg b/webroot/img/socialhandles/paypal.svg new file mode 100644 index 000000000..c7062a8b8 --- /dev/null +++ b/webroot/img/socialhandles/paypal.svg @@ -0,0 +1,5 @@ + + PayPal icon + + diff --git a/webroot/img/socialhandles/snapchat.svg b/webroot/img/socialhandles/snapchat.svg new file mode 100644 index 000000000..76bb111f4 --- /dev/null +++ b/webroot/img/socialhandles/snapchat.svg @@ -0,0 +1,5 @@ + + Snapchat icon + + diff --git a/webroot/img/socialhandles/soundcloud.svg b/webroot/img/socialhandles/soundcloud.svg new file mode 100644 index 000000000..86c768e6b --- /dev/null +++ b/webroot/img/socialhandles/soundcloud.svg @@ -0,0 +1,5 @@ + + SoundCloud icon + + diff --git a/webroot/img/socialhandles/spotify.svg b/webroot/img/socialhandles/spotify.svg new file mode 100644 index 000000000..63722973d --- /dev/null +++ b/webroot/img/socialhandles/spotify.svg @@ -0,0 +1,5 @@ + + Spotify icon + + diff --git a/webroot/img/socialhandles/tiktok.svg b/webroot/img/socialhandles/tiktok.svg new file mode 100644 index 000000000..31af892e4 --- /dev/null +++ b/webroot/img/socialhandles/tiktok.svg @@ -0,0 +1 @@ +TikTok icon \ No newline at end of file diff --git a/webroot/img/socialhandles/twitch.svg b/webroot/img/socialhandles/twitch.svg new file mode 100644 index 000000000..d422046e1 --- /dev/null +++ b/webroot/img/socialhandles/twitch.svg @@ -0,0 +1,5 @@ + + Twitch icon + + diff --git a/webroot/img/socialhandles/twitter.svg b/webroot/img/socialhandles/twitter.svg new file mode 100644 index 000000000..edcfb1a2f --- /dev/null +++ b/webroot/img/socialhandles/twitter.svg @@ -0,0 +1,5 @@ + + Twitter icon + + diff --git a/webroot/img/socialhandles/youtube.svg b/webroot/img/socialhandles/youtube.svg new file mode 100644 index 000000000..434b13f17 --- /dev/null +++ b/webroot/img/socialhandles/youtube.svg @@ -0,0 +1,5 @@ + + YouTube icon + + diff --git a/webroot/js/components/platform-logos-list.js b/webroot/js/components/platform-logos-list.js index efb41172a..880c4dac2 100644 --- a/webroot/js/components/platform-logos-list.js +++ b/webroot/js/components/platform-logos-list.js @@ -1,10 +1,50 @@ -import { h, Component } from '/js/web_modules/preact.js'; +import {h} from '/js/web_modules/preact.js'; import htm from '/js/web_modules/htm.js'; +import {SOCIAL_PLATFORMS} from '../utils/platforms.js'; +import {classNames} from '../utils/helpers.js'; + const html = htm.bind(h); -import { SOCIAL_PLATFORMS } from '../utils/platforms.js'; -import { classNames } from '../utils/helpers.js'; +function SocialIcon(props) { + const {platform, icon, url} = props; + const platformInfo = SOCIAL_PLATFORMS[platform.toLowerCase()]; + const inList = !!platformInfo; + const iconSupplied = !!icon + const name = inList ? platformInfo.name : platform; + + const finalIcon = iconSupplied ? icon : (inList ? platformInfo.icon : '/img/socialhandles/default.svg') + + const style = `background-image: url(${finalIcon});` + + const itemClass = classNames({ + "user-social-item": true, + "flex": true, + "justify-start": true, + "items-center": true, + "-mr-1": true, + "use-default": !inList, + }); + 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` + + + Find me on ${name} + + `); +} +/* function SocialIcon(props) { const { platform, url } = props; const platformInfo = SOCIAL_PLATFORMS[platform.toLowerCase()]; @@ -40,24 +80,27 @@ function SocialIcon(props) { Find me on ${name} `); -} +}*/ export default function (props) { - const { handles } = props; + const {handles} = props; if (handles == null) { return null; } const list = handles.map((item, index) => html`
  • - <${SocialIcon} platform=${item.platform} url=${item.url} /> + <${SocialIcon} platform=${item.platform} icon=${item.icon} + url=${item.url}/>
  • `); - return html``; + Follow me: + ${list} + `; } diff --git a/webroot/js/utils/platforms.js b/webroot/js/utils/platforms.js index 7bcf0be18..3f1fe549b 100644 --- a/webroot/js/utils/platforms.js +++ b/webroot/js/utils/platforms.js @@ -2,71 +2,79 @@ export const SOCIAL_PLATFORMS = { default: { name: "default", - imgPos: [0,0], // [row,col] + icon: '/img/socialhandles/default.svg', }, facebook: { name: "Facebook", - imgPos: [0,1], + icon: '/img/socialhandles/facebook.svg', }, twitter: { name: "Twitter", - imgPos: [0,2], + icon: '/img/socialhandles/twitter.svg', }, instagram: { name: "Instagram", - imgPos: [0,3], + icon: '/img/socialhandles/instagram.svg', }, snapchat: { name: "Snapchat", - imgPos: [0,4], + icon: '/img/socialhandles/snapchat.svg', }, tiktok: { name: "TikTok", - imgPos: [0,5], + icon: '/img/socialhandles/tiktok.svg', }, soundcloud: { name: "Soundcloud", - imgPos: [0,6], + icon: '/img/socialhandles/soundcloud.svg', }, bandcamp: { name: "Bandcamp", - imgPos: [0,7], + icon: '/img/socialhandles/bandcamp.svg', }, patreon: { name: "Patreon", - imgPos: [0,1], + icon: '/img/socialhandles/patreon.svg', }, youtube: { name: "YouTube", - imgPos: [0,9 ], + icon: '/img/socialhandles/youtube.svg', }, spotify: { name: "Spotify", - imgPos: [0,10], + icon: '/img/socialhandles/spotify.svg', }, twitch: { name: "Twitch", - imgPos: [0,11], + icon: '/img/socialhandles/twitch.svg', }, paypal: { name: "Paypal", - imgPos: [0,12], + icon: '/img/socialhandles/paypal.svg', }, github: { name: "Github", - imgPos: [0,13], + icon: '/img/socialhandles/github.svg', }, linkedin: { name: "LinkedIn", - imgPos: [0,14], + icon: '/img/socialhandles/linkedin.svg', }, discord: { name: "Discord", - imgPos: [0,15], + icon: '/img/socialhandles/discord.svg', }, mastodon: { name: "Mastodon", - imgPos: [0,16], + icon: '/img/socialhandles/mastodon.svg', + }, + gitlab: { + name: "Gitlab", + icon: '/img/socialhandles/gitlab.svg', + }, + kofi: { + name: "Ko-Fi", + icon: '/img/socialhandles/ko-fi.svg', }, }; diff --git a/webroot/styles/user-content.css b/webroot/styles/user-content.css index ff396d030..08ee172b4 100644 --- a/webroot/styles/user-content.css +++ b/webroot/styles/user-content.css @@ -11,9 +11,9 @@ --icon-width: 40px; height: var(--icon-width); width: var(--icon-width); - background-image: url(/img/platform-logos.gif); - background-position: calc(var(--imgCol) * var(--icon-width)) calc(var(--imgRow) * var(--icon-width)); - transform: scale(.65); + /*background-image: url(/img/platform-logos.gif); --> + background-position: calc(var(--imgCol) * var(--icon-width)) calc(var(--imgRow) * var(--icon-width));*/ + transform: scale(.70); }