Skip to content

Commit

Permalink
Add a default social icon
Browse files Browse the repository at this point in the history
Takes the ConnectionMetas and makes it uninstanced.

Related to Issue #39
  • Loading branch information
BobChao87 committed Oct 28, 2021
1 parent a4e2e91 commit cfd1ed4
Show file tree
Hide file tree
Showing 2 changed files with 50 additions and 52 deletions.
101 changes: 49 additions & 52 deletions components/user/social/Box.vue
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<template>
<Component :is="connectionMeta.link ? 'a' : 'div'" :href="connectionMeta.link" class="social-link-container">
<Component :is="connectionMeta.link ? 'a' : 'div'" :href="connectionMeta.link" target="_blank" class="social-link-container">
<p>{{ connectionMeta.header || connection.platform }}</p>
<FontAwesomeIcon :icon="connectionMeta.icon" class="icon fa-6x" />
<p>{{ connection.username }}</p>
Expand All @@ -19,62 +19,59 @@ export default Vue.extend({
},
computed: {
connectionMeta(): Partial<ConnectionMeta> {
const connectionMeta = this.connectionMetas[this.connection?.platform] ?? { };
if (connectionMeta.linkBase) {
connectionMeta.link = connectionMeta.linkBase(this.connection.username);
}
connectionMeta(): ConnectionMeta {
const connectionMeta = connectionMetas[this.connection?.platform] ?? connectionMetas._DEFAULT;
connectionMeta.link = connectionMeta.linkBase?.(this.connection.username);
return connectionMeta;
},
},
});
/* eslint-disable-next-line vue/order-in-components */ // Here, data is way less interesting than computed
data() {
return {
connectionMetas: {
DISCORD: {
icon: [ 'fab', 'discord' ],
},
EMAIL: {
linkBase: fragment => `mailto:${fragment}`,
icon: [ 'fas', 'envelope' ],
},
FACEBOOK: {
linkBase: fragment => `https://www.facebook.com/${fragment}`,
icon: [ 'fab', 'facebook-f' ],
},
INSTAGRAM: {
linkBase: fragment => `https://www.instagram.com/${fragment}`,
icon: [ 'fab', 'instagram' ],
},
PHONE: {
linkBase: fragment => `tel:${fragment}`,
icon: [ 'fas', 'phone' ],
},
NICO: {
linkBase: fragment => `https://com.nicovideo.jp/community/${fragment}`,
icon: [ 'fas', 'tv' ],
},
SNAPCHAT: {
linkBase: fragment => `https://www.snapchat.com/add/${fragment}`,
icon: [ 'fab', 'snapchat-ghost' ],
},
SPEEDRUNCOM: {
linkBase: fragment => `https://speedrun.com/user/${fragment}`,
icon: [ 'fas', 'trophy' ],
},
TWITCH: {
linkBase: fragment => `https://www.twitch.tv/${fragment}`,
icon: [ 'fab', 'twitch' ],
},
TWITTER: {
linkBase: fragment => `https://www.twitter.com/${fragment}`,
icon: [ 'fab', 'twitter' ],
},
} as ConnectionMetas,
};
const connectionMetas: ConnectionMetas&{ _DEFAULT: ConnectionMeta } = {
DISCORD: {
icon: [ 'fab', 'discord' ],
},
});
EMAIL: {
linkBase: fragment => `mailto:${fragment}`,
icon: [ 'fas', 'envelope' ],
},
FACEBOOK: {
linkBase: fragment => `https://www.facebook.com/${fragment}`,
icon: [ 'fab', 'facebook-f' ],
},
INSTAGRAM: {
linkBase: fragment => `https://www.instagram.com/${fragment}`,
icon: [ 'fab', 'instagram' ],
},
PHONE: {
linkBase: fragment => `tel:${fragment}`,
icon: [ 'fas', 'phone' ],
},
NICO: {
linkBase: fragment => `https://com.nicovideo.jp/community/${fragment}`,
icon: [ 'fas', 'tv' ],
},
SNAPCHAT: {
linkBase: fragment => `https://www.snapchat.com/add/${fragment}`,
icon: [ 'fab', 'snapchat-ghost' ],
},
SPEEDRUNCOM: {
linkBase: fragment => `https://speedrun.com/user/${fragment}`,
icon: [ 'fas', 'trophy' ],
},
TWITCH: {
linkBase: fragment => `https://www.twitch.tv/${fragment}`,
icon: [ 'fab', 'twitch' ],
},
TWITTER: {
linkBase: fragment => `https://www.twitter.com/${fragment}`,
icon: [ 'fab', 'twitter' ],
},
_DEFAULT: {
icon: [ 'fas', 'star' ],
},
};
</script>

<style lang="scss" scoped>
Expand Down
1 change: 1 addition & 0 deletions configs/font-awesome.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ const solid = [
'PaperPlane',
'Phone',
'Plus',
'Star',
'Trophy',
'Tv',
];
Expand Down

0 comments on commit cfd1ed4

Please sign in to comment.