Something went wrong. Try again.
your personal website on atproto - mirror blento.app
Something went wrong. Try again.
1.2 kB · 44 lines
Svelte
123456789101112131415161718192021222324252627282930313233343536373839404142434445<script lang="ts"> import { Alert, Button, Input, Subheading } from '@foxui/core'; import Modal from '$lib/components/modal/Modal.svelte'; import type { CreationModalComponentProps } from '../../types';
let { item = $bindable(), oncreate, oncancel }: CreationModalComponentProps = $props();
let url = $state(''); let errorMessage = $state('');
function checkUrl() { errorMessage = ''; const match = url.match(/^https?:\/\/semble\.so\/profile\/([^/]+)\/collections\/([a-z0-9]+)$/); if (!match) { errorMessage = 'Please enter a valid Semble collection URL.'; return false; }
item.cardData.handle = match[1]; item.cardData.collectionRkey = match[2]; item.cardData.href = url; return true; }</script>
<Modal open={true} closeButton={false}> <Subheading>Enter a Semble collection URL</Subheading> <Input bind:value={url} placeholder="https://semble.so/profile/.../collections/..." />
{#if errorMessage} <Alert type="error" title="Invalid URL"><span>{errorMessage}</span></Alert> {/if}
<div class="mt-4 flex justify-end gap-2"> <Button onclick={oncancel} variant="ghost">Cancel</Button> <Button onclick={() => { if (checkUrl()) oncreate(); }} > Create </Button> </div></Modal>