Skip to content

Commit

Permalink
formats, use basic accordion
Browse files Browse the repository at this point in the history
  • Loading branch information
pjaudiomv committed Nov 12, 2024
1 parent e8fae48 commit 48fad2c
Show file tree
Hide file tree
Showing 4 changed files with 73 additions and 107 deletions.
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>
55 changes: 0 additions & 55 deletions src/resources/js/components/BmltAccordion.svelte

This file was deleted.

78 changes: 32 additions & 46 deletions src/resources/js/components/FormatForm.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
import { validator } from '@felte/validator-yup';
import { createForm } from 'felte';
import { AccordionItem, Accordion, Button, Helper, Input, Label, Select } from 'flowbite-svelte';

Check failure on line 4 in src/resources/js/components/FormatForm.svelte

View workflow job for this annotation

GitHub Actions / test-js

'AccordionItem' is defined but never used

Check failure on line 4 in src/resources/js/components/FormatForm.svelte

View workflow job for this annotation

GitHub Actions / test-js

'Accordion' is defined but never used
import BmltAccordion from './BmltAccordion.svelte';
import BasicAccordion from './BasicAccordion.svelte';
import { createEventDispatcher } from 'svelte';
import * as yup from 'yup';
Expand Down Expand Up @@ -194,52 +194,38 @@
{selectedFormat?.id}
</div>
{/if}
<div id="properties-panel" class="overflow-auto hide-scrollbar">
<BmltAccordion ItemName="Deutsch">
Deutsch
</BmltAccordion>
<BmltAccordion ItemName="Dansk">
Dansk
</BmltAccordion>
<BmltAccordion ItemName="English">
English
</BmltAccordion>
</div>
<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
10 changes: 4 additions & 6 deletions src/resources/js/routes/Account.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -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>

0 comments on commit 48fad2c

Please sign in to comment.