PluralKit/src/lib/system/Body.svelte

77 lines
2.3 KiB
Svelte
Raw Normal View History

2021-12-11 15:57:20 +01:00
<script lang="ts">
import { Row, Col, Modal, Image, Button } from 'sveltestrap';
import moment from 'moment';
import { toHTML } from 'discord-markdown';
import type Sys from '../../api/system';
2021-12-11 15:57:20 +01:00
export let user: Sys;
2021-12-11 15:57:20 +01:00
export let editMode: boolean;
2021-12-12 10:31:08 +01:00
export let isPublic: boolean;
2021-12-11 15:57:20 +01:00
let htmlDescription: string;
if (user.description) {
htmlDescription = toHTML(user.description, {embed: true});
} else {
htmlDescription = "(no description)";
}
let created = moment(user.created).format("MMM D, YYYY");
2021-12-11 15:57:20 +01:00
let bannerOpen = false;
const toggleBannerModal = () => (bannerOpen = !bannerOpen);
let settings = JSON.parse(localStorage.getItem("pk-settings"));
2021-12-11 15:57:20 +01:00
</script>
<Row>
2021-12-12 10:31:08 +01:00
{#if user.id}
2021-12-11 15:57:20 +01:00
<Col xs={12} lg={4} class="mb-2">
<b>ID:</b> {user.id}
</Col>
2021-12-12 10:31:08 +01:00
{/if}
{#if user.name}
2021-12-11 15:57:20 +01:00
<Col xs={12} lg={4} class="mb-2">
<b>Name:</b> {user.name}
</Col>
2021-12-12 10:31:08 +01:00
{/if}
2021-12-11 15:57:20 +01:00
{#if user.tag}
<Col xs={12} lg={4} class="mb-2">
<b>Tag:</b> {user.tag}
</Col>
2021-12-12 10:31:08 +01:00
{/if}
{#if user.created}
<Col xs={12} lg={4} class="mb-2">
<b>Created:</b> {created}
</Col>
2021-12-11 15:57:20 +01:00
{/if}
2021-12-12 10:31:08 +01:00
{#if user.timezone}
2021-12-11 15:57:20 +01:00
<Col xs={12} lg={4} class="mb-2">
<b>Timezone:</b> {user.timezone}
</Col>
2021-12-12 10:31:08 +01:00
{/if}
2021-12-11 15:57:20 +01:00
{#if user.color}
<Col xs={12} lg={4} class="mb-2">
<b>Color:</b> {user.color}
</Col>
{/if}
{#if user.banner}
<Col xs={12} lg={3} class="mb-2">
<b>Banner:</b> <Button size="sm" color="light" on:click={toggleBannerModal}>View</Button>
<Modal isOpen={bannerOpen} toggle={toggleBannerModal}>
<div slot="external" on:click={toggleBannerModal} style="height: 100%; width: max-content; max-width: 100%; margin-left: auto; margin-right: auto; display: flex;">
<Image style="display: block; margin: auto;" src={user.banner} thumbnail alt="Your system banner" />
</div>
</Modal>
</Col>
{/if}
2021-12-11 16:02:42 +01:00
</Row>
<div class="my-2">
<b>Description:</b><br />
{@html htmlDescription}
</div>
{#if (user.banner && settings && settings.appearance.banner_bottom) || !settings}
2021-12-11 18:41:32 +01:00
<img src={user.banner} alt="your system banner" class="w-100 mb-3 rounded" style="max-height: 12em; object-fit: cover"/>
{/if}
2021-12-12 10:31:08 +01:00
{#if !isPublic}
<Button style="flex: 0" color="primary" on:click={() => editMode = true}>Edit</Button>
{/if}