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

fix(#1294): Accordion heading not responding correctly on smaller scr… #1365

Merged
merged 1 commit into from
Sep 21, 2023
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
20 changes: 20 additions & 0 deletions libs/web-components/playground/src/pg-accordion.svelte
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
<svelte:options tag="pg-accordion" />

<script lang="ts">
</script>

<goa-accordion heading="A heading that's no longer and starts to wrap a second line">
<div style="display: flex; justify-content: flex-end" slot="headingcontent">
<goa-badge type="important" content="In progress"></goa-badge>
<goa-badge type="success" content="44"></goa-badge>
</div>
</goa-accordion>
<goa-accordion
heading="Heading"
>
<goa-badge type="success" content="22" slot="headingcontent"/>
</goa-accordion>
<goa-accordion heading="This is a heading" secondarytext="1 of 4 documents signed">
</goa-accordion>
<goa-accordion heading="Heading">
</goa-accordion>
29 changes: 25 additions & 4 deletions libs/web-components/src/components/accordion/Accordion.svelte
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<svelte:options tag="goa-accordion" />

Check warning on line 1 in libs/web-components/src/components/accordion/Accordion.svelte

View workflow job for this annotation

GitHub Actions / build

The 'tag' option is used when generating a custom element. Did you forget the 'customElement: true' compile option?

<!-- Script -->
<script lang="ts">
Expand Down Expand Up @@ -27,14 +27,26 @@
export let ml: Spacing = null;

let _hovering: boolean = false;
let _titleEl: HTMLElement = null;
let _headingContentSlotChildren: Element[] = [];

$: isOpen = toBoolean(open);

onMount(() => {
validateRequired("GoAAccordion", {heading})
validateHeadingSize(headingsize);
_headingContentSlotChildren = getChildren();
})

function getChildren(): Element[] {
if (_titleEl) {
const slot = _titleEl.querySelector("slot") as HTMLSlotElement;
if (slot) {
return [...slot.assignedElements()];
} else {
return [..._titleEl.children] as Element[]; // unit tests
}
}
return [];
}
</script>

<!-- HTML -->
Expand All @@ -56,10 +68,12 @@
<goa-icon type="chevron-forward"
fillcolor={_hovering?"var(--goa-color-interactive-hover)": "var(--goa-color-interactive-default)"}
></goa-icon>
<div class="title">
<div class="title" bind:this={_titleEl}>
<span class="heading heading-{headingsize}" data-testid={`${testid}-heading`}>{heading}</span>
<span class="secondary-text">{secondarytext}</span>
<div class="heading-content">
<div class="heading-content"
class:heading-content-top={_headingContentSlotChildren.length}
>
<slot name="headingcontent" />
</div>
</div>
Expand Down Expand Up @@ -202,6 +216,13 @@
summary .title {
flex-direction: column;
align-items: flex-start;
padding-bottom: 0.875rem;
}
summary .title span {
padding-bottom: 0;
}
summary .heading-content.heading-content-top {
margin-top: var(--goa-space-xs);
}
}

Expand Down
Loading