mirror of
https://github.com/appwrite/console.git
synced 2026-11-18 20:47:21 +00:00
feat: update open on mobile modal
This commit is contained in:
1 parent
5df712b14d
commit
156105e360
4 files changed
+53
-21
No files matched your search
+49
-16
@@ -1,37 +1,70 @@
|
||||
<script lang="ts">
|
||||
import { Modal } from '$lib/components';
|
||||
import Card from '$lib/components/card.svelte';
|
||||
import { InputText } from '$lib/elements/forms';
|
||||
import { Button, InputSelect } from '$lib/elements/forms';
|
||||
import { copy } from '$lib/helpers/copy';
|
||||
import { sdk } from '$lib/stores/sdk';
|
||||
import { protocol } from '$routes/(console)/store';
|
||||
import type { Models } from '@appwrite.io/console';
|
||||
import { IconDuplicate } from '@appwrite.io/pink-icons-svelte';
|
||||
import { Image, Input, Layout } from '@appwrite.io/pink-svelte';
|
||||
import { onMount } from 'svelte';
|
||||
import { Icon, Image, Input, Layout, Tooltip } from '@appwrite.io/pink-svelte';
|
||||
|
||||
export let show = false;
|
||||
export let siteURL: string;
|
||||
let {
|
||||
show = $bindable(),
|
||||
proxyRuleList,
|
||||
selectedUrl = $bindable('')
|
||||
}: {
|
||||
show: boolean;
|
||||
proxyRuleList: Models.ProxyRuleList;
|
||||
selectedUrl?: string;
|
||||
} = $props();
|
||||
|
||||
let url = $protocol + siteURL;
|
||||
const options = proxyRuleList?.total
|
||||
? proxyRuleList.rules.map((rule) => {
|
||||
return {
|
||||
label: rule.domain,
|
||||
value: $protocol + rule.domain
|
||||
};
|
||||
})
|
||||
: [];
|
||||
|
||||
let image = '';
|
||||
onMount(() => {
|
||||
image = sdk.forProject.avatars.getQR(url, 352);
|
||||
});
|
||||
let url = $state(selectedUrl ? $protocol + selectedUrl : (options[0]?.value ?? ''));
|
||||
let tooltipMessage = $state('Copy');
|
||||
|
||||
function getImage(url: string) {
|
||||
return sdk.forProject.avatars.getQR(url, 352);
|
||||
}
|
||||
</script>
|
||||
|
||||
<Modal title="Open on mobile" bind:show hideFooter>
|
||||
<span slot="description">Open the preview of your site on any mobile or tablet device.</span>
|
||||
<Layout.Stack gap="l">
|
||||
<Layout.Stack gap="m" direction="row">
|
||||
<div style="width: 100%;max-width: 91.5%">
|
||||
<InputSelect id="copy" bind:value={url} {options}></InputSelect>
|
||||
</div>
|
||||
<Tooltip placement="bottom">
|
||||
<div>
|
||||
<Button
|
||||
secondary
|
||||
icon
|
||||
on:click={() => {
|
||||
copy(url);
|
||||
tooltipMessage = 'Copied';
|
||||
setTimeout(() => {
|
||||
tooltipMessage = 'Copy';
|
||||
}, 1000);
|
||||
}}>
|
||||
<Icon icon={IconDuplicate}></Icon>
|
||||
</Button>
|
||||
</div>
|
||||
<svelte:fragment slot="tooltip">{tooltipMessage}</svelte:fragment>
|
||||
</Tooltip>
|
||||
</Layout.Stack>
|
||||
<Card padding="l" radius="l">
|
||||
<Layout.Stack justifyContent="center" alignItems="center">
|
||||
<Image src={image} height={176} width={176} alt="QR code" radius="xxs" />
|
||||
<Image src={getImage(url)} height={176} width={176} alt="QR code" radius="xxs" />
|
||||
</Layout.Stack>
|
||||
</Card>
|
||||
<InputText id="copy" value={url} readonly>
|
||||
<svelte:fragment slot="end">
|
||||
<Input.Action icon={IconDuplicate} on:click={() => copy(url)} />
|
||||
</svelte:fragment>
|
||||
</InputText>
|
||||
</Layout.Stack>
|
||||
</Modal>
|
||||
@@ -186,8 +186,8 @@
|
||||
</Layout.Stack>
|
||||
</Card>
|
||||
|
||||
{#if show && siteUrl}
|
||||
<OpenOnMobileModal bind:show siteURL={siteUrl} />
|
||||
{#if show && proxyRuleList.total}
|
||||
<OpenOnMobileModal bind:show {proxyRuleList} />
|
||||
{/if}
|
||||
|
||||
<style lang="scss">
|
||||
|
||||
@@ -177,7 +177,7 @@
|
||||
callbackState={{ connectRepo: 'true' }} />
|
||||
{/if}
|
||||
{#if showOpenOnMobile}
|
||||
<OpenOnMobileModal bind:show={showOpenOnMobile} {siteURL} />
|
||||
<OpenOnMobileModal bind:show={showOpenOnMobile} proxyRuleList={data.proxyRuleList} />
|
||||
{/if}
|
||||
|
||||
{#if showInviteCollaborator}
|
||||
|
||||
@@ -96,7 +96,6 @@
|
||||
on:click={() => {
|
||||
showDomainQR = true;
|
||||
selectedDomainURL = rule.domain;
|
||||
console.log(rule.domain);
|
||||
}}>
|
||||
<Icon icon={IconQrcode} />
|
||||
</Button>
|
||||
@@ -110,5 +109,5 @@
|
||||
</Layout.Stack>
|
||||
|
||||
{#if showDomainQR && selectedDomainURL}
|
||||
<OpenOnMobileModal bind:show={showDomainQR} siteURL={selectedDomainURL} />
|
||||
<OpenOnMobileModal bind:show={showDomainQR} {proxyRuleList} selectedUrl={selectedDomainURL} />
|
||||
{/if}
|
||||
Reference in new issue
Block a user