fix popover

This commit is contained in:
Damodar Lohani committed 2024-09-22 15:09:17 +05:45
1 parent 3f115200c3
commit b6ec12b011
3 files changed
+48 -9

No files matched your search

+33 -1
View File
@@ -1,6 +1,7 @@
<script lang="ts">
import { FormItem, FormItemPart, Helper, Label } from '.';
import type { FormItemTag } from './formItem.svelte';
import { Drop } from '$lib/components';
export let id: string;
export let label: string | undefined = undefined;
@@ -19,10 +20,14 @@
}[];
export let isMultiple = false;
export let fullWidth = false;
export let popover: string[] | null = null;
export let popoverProps: Record<string, unknown> = {};
let element: HTMLSelectElement;
let error: string;
let show: boolean = false;
const handleInvalid = (event: Event) => {
event.preventDefault();
@@ -54,7 +59,34 @@
<svelte:component this={wrapper} {fullWidth} tag={wrapperTag}>
{#if label}
<Label {required} {hideRequired} {optionalText} hide={!showLabel} for={id}>
{label}
{label}{#if popover}
<Drop isPopover bind:show display="inline-block">
<!-- TODO: make unclicked icon greyed out and hover and clicked filled -->
&nbsp;<button
type="button"
on:click={() => (show = !show)}
class="tooltip"
aria-label="input tooltip">
<span
class="icon-info"
aria-hidden="true"
style:font-size="var(--icon-size-small)" />
</button>
<svelte:fragment slot="list">
<div
class="dropped card u-max-width-250"
style:--p-card-padding=".75rem"
style:--card-border-radius="var(--border-radius-small)"
style:box-shadow="var(--shadow-large)">
<div class="u-flex-vertical u-gap-16">
{#each popover as line}
<p>{@html line}</p>
{/each}
</div>
</div>
</svelte:fragment>
</Drop>
{/if}
</Label>
{/if}
@@ -84,7 +84,16 @@
label="Name (optional)"
placeholder="Enter name"
bind:value={name} />
<InputSelect id="role" label="Role" options={roles} bind:value={role} />
<InputSelect
popover={[
'<b>Roles</b>',
'Owner, Developer, Editor, Analyst, Billing.',
'<a href="https://appwrite.io/docs/roles">Learn more</a> about roles.'
]}
id="role"
label="Role"
options={roles}
bind:value={role} />
</FormList>
<svelte:fragment slot="footer">
<Button secondary on:click={() => (showCreate = false)}>Cancel</Button>
@@ -28,7 +28,6 @@
import { base } from '$app/paths';
import { isOwner } from '$lib/stores/roles';
import Edit from './edit.svelte';
import PopoverContent from '$routes/(console)/project-[project]/messaging/providers/popoverContent.svelte';
import { getRoleLabel } from '$lib/stores/billing';
export let data: PageData;
@@ -98,12 +97,11 @@
style:text-transform="none"
style:text-wrap="wrap"
style:box-shadow="var(--shadow-large)">
<PopoverContent
lines={[
'<b>Roles</b>',
'Owner, Developer, Editor, Analyst, Billing.',
'<a href="https://appwrite.io/docs/roles">Learn more</a> about roles.'
]} />
<div class="u-flex-vertical u-gap-16">
{#each ['<b>Roles</b>', 'Owner, Developer, Editor, Analyst, Billing.', '<a href="https://appwrite.io/docs/roles">Learn more</a> about roles.'] as line}
<p>{@html line}</p>
{/each}
</div>
</div>
</svelte:fragment>
</Drop>