Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

formats, use basic accordion #1147

Merged
merged 1 commit into from
Nov 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 37 additions & 0 deletions src/resources/js/components/BasicAccordion.svelte
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
<script lang="ts">
export let header: string;
export let open: boolean = false;

function accordionToggle() {
open = !open;
}
</script>

<div class="mb-2 w-full rounded-md border border-gray-700 bg-gray-800">
<button
type="button"
aria-expanded={open}
aria-label="Toggle accordion"
class="flex w-full items-center justify-between rounded-md px-4 py-4 text-left text-sm font-semibold text-gray-300 hover:bg-gray-700 focus:outline-none"
on:click={accordionToggle}
on:keydown={(e) => (e.key === 'Enter' || e.key === ' ') && accordionToggle()}
>
<span class="w-full">{header}</span>

{#if open}
<svg class="h-3 w-3 text-gray-800 dark:text-white" aria-hidden="true" xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 10 6">
<path stroke="currentColor" stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M9 5 5 1 1 5" />
</svg>
{:else}
<svg class="h-3 w-3 text-gray-800 dark:text-white" aria-hidden="true" xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 10 6">
<path stroke="currentColor" stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="m1 1 4 4 4-4" />
</svg>
{/if}
</button>

<div class={open ? 'w-full bg-gray-800 px-4 py-2 text-gray-200' : 'hidden'}>
<slot />
</div>

<div class="w-full border-t border-gray-700" />
</div>
69 changes: 34 additions & 35 deletions src/resources/js/components/FormatForm.svelte
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
<script lang="ts">
import { validator } from '@felte/validator-yup';
import { createForm } from 'felte';
import { AccordionItem, Accordion, Button, Helper, Input, Label, Select } from 'flowbite-svelte';
import { Button, Helper, Input, Label, Select } from 'flowbite-svelte';
import BasicAccordion from './BasicAccordion.svelte';

import { createEventDispatcher } from 'svelte';
import * as yup from 'yup';

Expand Down Expand Up @@ -193,40 +195,37 @@
</div>
{/if}
<div class="md:col-span-2">
<Accordion multiple>
{#each allLanguages as lang}
<AccordionItem open={$translations.getLanguage() === lang}>
<span slot="header">{mappings[lang]}</span>
<div>
<Label for="{lang}_key" class="mb-2">{getLabel('keyTitle', lang)}</Label>
<Input type="text" id="{lang}_key" name="{lang}_key" disabled={isReservedKey(lang)} />
<Helper class="mb-2" color="red">
{#if $errors[lang + '_key']}
{$errors[lang + '_key']}
{/if}
</Helper>
</div>
<div>
<Label for="{lang}_name" class="mb-2">{getLabel('nameTitle', lang)}</Label>
<Input type="text" id="{lang}_name" name="{lang}_name" />
<Helper class="mb-2" color="red">
{#if $errors[lang + '_name']}
{$errors[lang + '_name']}
{/if}
</Helper>
</div>
<div>
<Label for="{lang}_description" class="mb-2">{getLabel('descriptionTitle', lang)}</Label>
<Input type="text" id="{lang}_description" name="{lang}_description" />
<Helper class="mb-2" color="red">
{#if $errors[lang + '_description']}
{$errors[lang + '_description']}
{/if}
</Helper>
</div>
</AccordionItem>
{/each}
</Accordion>
{#each allLanguages as lang}
<BasicAccordion header={mappings[lang]} open={$translations.getLanguage() === lang}>
<div>
<Label for="{lang}_key" class="mb-2">{getLabel('keyTitle', lang)}</Label>
<Input type="text" id="{lang}_key" name="{lang}_key" disabled={isReservedKey(lang)} />
<Helper class="mb-2" color="red">
{#if $errors[lang + '_key']}
{$errors[lang + '_key']}
{/if}
</Helper>
</div>
<div>
<Label for="{lang}_name" class="mb-2">{getLabel('nameTitle', lang)}</Label>
<Input type="text" id="{lang}_name" name="{lang}_name" />
<Helper class="mb-2" color="red">
{#if $errors[lang + '_name']}
{$errors[lang + '_name']}
{/if}
</Helper>
</div>
<div>
<Label for="{lang}_description" class="mb-2">{getLabel('descriptionTitle', lang)}</Label>
<Input type="text" id="{lang}_description" name="{lang}_description" />
<Helper class="mb-2" color="red">
{#if $errors[lang + '_description']}
{$errors[lang + '_description']}
{/if}
</Helper>
</div>
</BasicAccordion>
{/each}
</div>
{#if noFormatTranslations}
<div class="md:col-span-2">
Expand Down
12 changes: 5 additions & 7 deletions src/resources/js/routes/Account.svelte
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<script lang="ts">
import { AccordionItem, Accordion, Button, Helper, Input, Label } from 'flowbite-svelte';
import { Button, Helper, Input, Label } from 'flowbite-svelte';
import { createEventDispatcher } from 'svelte';
import { createForm } from 'felte';
import { validator } from '@felte/validator-yup';
Expand All @@ -13,6 +13,7 @@
import { spinner } from '../stores/spinner';
import { translations } from '../stores/localization';
import type { User } from 'bmlt-root-server-client';
import BasicAccordion from '../components/BasicAccordion.svelte';

const dispatch = createEventDispatcher<{ saved: { user: User } }>();
let userType = 'unknown';
Expand Down Expand Up @@ -198,12 +199,9 @@
</Button>
</div>
</div>
<Accordion>
<AccordionItem>
<span slot="header">{$translations.serviceBodiesWithEditableMeetings}</span>
<AccountServiceBodyList user={$authenticatedUser} />
</AccordionItem>
</Accordion>
<BasicAccordion header={$translations.serviceBodiesWithEditableMeetings}>
<AccountServiceBodyList user={$authenticatedUser} />
</BasicAccordion>
</div>
</form>
</div>