Skip to content

Commit

Permalink
Add verified and moderator badge
Browse files Browse the repository at this point in the history
  • Loading branch information
ChrRubin committed Oct 25, 2021
1 parent aad1329 commit d42536a
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 4 deletions.
25 changes: 21 additions & 4 deletions src/components/Message.svelte
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
<script lang="ts">
import MessageRun from './MessageRuns.svelte';
import Icon from './common/Icon.svelte';
export let message: Ytc.ParsedMessage;
export let deleted: Chat.MessageDeletedObj | null = null;
Expand Down Expand Up @@ -27,9 +28,16 @@
}
};
$: member = message.author.types.includes('member');
$: moderator = message.author.types.includes('moderator');
$: owner = message.author.types.includes('owner');
let member = false;
let verified = false;
let moderator = false;
let owner = false;
$: message.author.types.forEach((type) => {
if (type === 'member') member = true;
else if (type === 'verified') verified = true;
else if (type === 'moderator') moderator = true;
else if (type === 'owner') owner = true;
});
$: nameColorClass = generateNameColorClass(member, moderator, owner, forceDark);
$: if (deleted != null) {
Expand All @@ -41,7 +49,16 @@
{#if !hideName}
<span on:click|stopPropagation class="{nameClass} {nameColorClass}">
<span class="align-middle">{message.author.name}</span>
{#if message.author.customBadge}
{#if moderator}
<Icon class="inline align-middle" small>build</Icon>
{:else if verified}
<Icon
class="inline align-middle text-gray-700 dark:text-gray-500"
small
>
verified
</Icon>
{:else if member && message.author.customBadge}
<img
on:click|stopPropagation
class="h-4 w-4 inline align-middle"
Expand Down
20 changes: 20 additions & 0 deletions src/components/common/Icon.svelte
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
<script lang="ts">
export let block = true;
export let small = false;
export let xs = false;
$: classes = 'material-icons icon select-none duration-200 ease-in ' +
($$props.class ?? '');
</script>

<i
aria-hidden="true"
class={classes}
on:click
class:block
class:text-base={small}
class:text-xs={xs}
style={$$props.style ?? ''}
>
<slot />
</i>

0 comments on commit d42536a

Please sign in to comment.