feat: add cardDrop & ID dropdown

This commit is contained in:
Arman committed 2022-07-01 13:01:24 +02:00
1 parent 905f222414
commit 04a2ea6bca
5 files changed
+74 -24

No files matched your search

+26
View File
@@ -0,0 +1,26 @@
<script>
import { Card } from '$lib/components';
export let show = false;
</script>
{#if show}
<Card>
<header class="modal-header">
<h4 class="modal-title"><slot name="header" /></h4>
<button
type="button"
class="x-button"
aria-label="Close"
title="Close"
on:click={() => (show = false)}>
<span class="icon-x" aria-hidden="true" />
</button>
</header>
<div class="modal-content">
<slot />
</div>
<div class="modal-footer">
<slot name="footer" />
</div>
</Card>
{/if}
+1
View File
@@ -2,6 +2,7 @@ export { default as Modal } from './modal.svelte';
export { default as Pagination } from './pagination.svelte';
export { default as Card } from './card.svelte';
export { default as CardGrid } from './cardGrid.svelte';
export { default as CardDrop } from './cardDrop.svelte';
export { default as Tile } from './tile.svelte';
export { default as Tiles } from './tiles.svelte';
export { default as Back } from './back.svelte';
+6
View File
@@ -4,6 +4,7 @@
export let show = false;
export let size: 'small' | 'big' = null;
export let icon = false;
let browser = false;
//TODO: explore other solutions compatible with testing library
onMount(() => {
@@ -57,6 +58,11 @@
class="modal"
transition:fly={transitionFly}>
<header class="modal-header">
{#if icon}
<div class="avatar is-color-orange is-medium">
<span class="icon-exclamation" aria-hidden="true" />
</div>
{/if}
<h4 class="modal-title">
<slot name="header" />
</h4>
@@ -1,5 +1,6 @@
<script lang="ts">
import { Modal } from '$lib/components';
import { Modal, CardDrop } from '$lib/components';
import { Pill } from '$lib/elements';
import { InputText, Button, Form, FormList } from '$lib/elements/forms';
import { addNotification } from '$lib/stores/notifications';
import { sdkForProject } from '$lib/stores/sdk';
@@ -9,11 +10,12 @@
const dispatch = createEventDispatcher();
let name: string;
let name: string, id: string;
let showDropdown = false;
const create = async () => {
try {
const team = await sdkForProject.teams.create('unique()', name);
const team = await sdkForProject.teams.create(id ? id : 'unique()', name);
name = '';
showCreate = false;
dispatch('created', team);
@@ -36,6 +38,33 @@
placeholder="John Doe"
autofocus={true}
bind:value={name} />
{#if !showDropdown}
<div>
<Pill button on:click={() => (showDropdown = !showDropdown)}
>Team ID <i class="icon-pencil" /></Pill>
</div>
{:else}
<CardDrop bind:show={showDropdown}>
<svelte:fragment slot="header">Team ID</svelte:fragment>
<p>Enter a custom user ID. Leave blank for a randomly generated user ID.</p>
<svelte:fragment slot="footer">
<input
class="input-text "
type="text"
name="id"
id="id"
placeholder="Enter ID"
bind:value={id} />
<div class="u-flex u-gap-12">
<div class="icon-info u-block" />
<p class="u-small">
Allowed characters: alphanumeric, hyphen, non-leading underscore,
period
</p>
</div>
</svelte:fragment>
</CardDrop>
{/if}
</FormList>
<svelte:fragment slot="footer">
<Button secondary on:click={() => (showCreate = false)}>Cancel</Button>
@@ -1,5 +1,5 @@
<script lang="ts">
import { Modal, Card } from '$lib/components';
import { Modal, CardDrop } from '$lib/components';
import { Pill } from '$lib/elements/';
import {
Button,
@@ -64,24 +64,12 @@
>User ID <i class="icon-pencil" /></Pill>
</div>
{:else}
<Card>
<header class="modal-header">
<h4 class="modal-title">User ID</h4>
<button
type="button"
class="x-button"
aria-label="Close Modal"
title="Close Modal"
on:click={() => (showDropdown = false)}>
<span class="icon-x" aria-hidden="true" />
</button>
</header>
<div class="modal-content">
<p>Enter a custom user ID. Leave blank for a randomly generated user ID.</p>
</div>
<div class="modal-footer">
<CardDrop bind:show={showDropdown}>
<svelte:fragment slot="header">User ID</svelte:fragment>
<p>Enter a custom user ID. Leave blank for a randomly generated user ID.</p>
<svelte:fragment slot="footer">
<input
class="input-text"
class="input-text "
type="text"
name="id"
id="id"
@@ -89,13 +77,13 @@
bind:value={id} />
<div class="u-flex u-gap-12">
<div class="icon-info u-block" />
<p>
<p class="u-small">
Allowed characters: alphanumeric, hyphen, non-leading underscore,
period
</p>
</div>
</div>
</Card>
</svelte:fragment>
</CardDrop>
{/if}
</FormList>
<svelte:fragment slot="footer">