#50 [card] pronoun cards - support cake links, ui improvements

This commit is contained in:
Avris 2020-10-18 11:43:56 +02:00
parent 3bfad6ddc5
commit c7e9d0e788
3 changed files with 25 additions and 5 deletions

View File

@ -1,6 +1,7 @@
<template> <template>
<span> <span>
<Icon :v="icon" :set="iconSet"/> <img v-if="icon.startsWith('https://')" :src="icon" class="icon"/>
<Icon v-else :v="icon" :set="iconSet"/>
<a :href="link" target="_blank" rel="noopener"> <a :href="link" target="_blank" rel="noopener">
{{text}} {{text}}
</a> </a>
@ -11,6 +12,7 @@
import {clearUrl} from "../src/helpers"; import {clearUrl} from "../src/helpers";
const REGEX_TWITTER = '^https://twitter.com/([^/]+)'; const REGEX_TWITTER = '^https://twitter.com/([^/]+)';
const REGEX_CAKE = '^https://cake.avris.it/([bgoprc][A-E][0-6])$';
export default { export default {
props: { props: {
@ -22,11 +24,16 @@
return 'twitter'; return 'twitter';
} }
if (this.link.match(REGEX_CAKE)) {
return 'cake';
}
return 'other'; return 'other';
}, },
icon() { icon() {
return { return {
twitter: 'twitter', twitter: 'twitter',
cake: 'https://cake.avris.it/favicon.png',
other: 'globe-europe', other: 'globe-europe',
}[this.type]; }[this.type];
}, },
@ -40,8 +47,18 @@
return this.link.match(REGEX_TWITTER)[1]; return this.link.match(REGEX_TWITTER)[1];
} }
if (this.type === 'cake') {
return this.link.match(REGEX_CAKE)[1];
}
return clearUrl(this.link); return clearUrl(this.link);
}, },
} }
}; };
</script> </script>
<style lang="scss" scoped>
.icon {
height: 1em;
}
</style>

View File

@ -3,17 +3,20 @@
{{ locales[locale].name }} {{ locales[locale].name }}
<span v-if="profile"> <span v-if="profile">
<LocaleLink :locale="locale" :link="`/@${profile.username}`" class="badge badge-primary"> <LocaleLink :locale="locale" :link="`/@${profile.username}`" class="badge badge-primary">
<Icon v="id-card"/>
<T>profile.show</T> <T>profile.show</T>
</LocaleLink> </LocaleLink>
<LocaleLink :locale="locale" link="/TODO" class="badge badge-light border"> <LocaleLink :locale="locale" link="/TODO" class="badge badge-light border">
<Icon v="edit"/>
<T>profile.edit</T> <T>profile.edit</T>
</LocaleLink> </LocaleLink>
<LocaleLink :locale="locale" link="/TODOS" class="badge badge-light border border-danger"> <LocaleLink :locale="locale" link="/TODOS" class="badge badge-light">
<T>profile.delete</T> <Icon v="trash-alt"/>
</LocaleLink> </LocaleLink>
</span> </span>
<span v-else> <span v-else>
<LocaleLink :locale="locale" link="/TODO" class="badge badge-light border"> <LocaleLink :locale="locale" link="/TODO" class="badge badge-light border">
<Icon v="plus-circle"/>
<T>profile.init</T> <T>profile.init</T>
</LocaleLink> </LocaleLink>
</span> </span>

View File

@ -27,7 +27,7 @@
<Icon v="birthday-cake"/> <Icon v="birthday-cake"/>
{{ profile.age }} {{ profile.age }}
</li> </li>
<li v-for="link in profile.links" class="list-inline-item"> <li v-for="link in profile.links" class="list-inline-item pr-2">
<ProfileLink :link="link"/> <ProfileLink :link="link"/>
</li> </li>
</ul> </ul>
@ -35,7 +35,7 @@
<section v-if="Object.keys(profile.flags).length"> <section v-if="Object.keys(profile.flags).length">
<ul class="list-inline"> <ul class="list-inline">
<li v-for="(name, flag) in profile.flags" class="list-inline-item"> <li v-for="(name, flag) in profile.flags" class="list-inline-item pr-2">
<Flag :name="name" :src="`/flags/${flag}.png`"/> <Flag :name="name" :src="`/flags/${flag}.png`"/>
</li> </li>
</ul> </ul>