question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Collapse item with AList

See original GitHub issue

I want to build a collapsed items list. But item slot doesn’t work as expected. How to create a simple collapse with AList ? Here is the code :

<script lang="ts" setup>
import { ref } from 'vue'

const items = [{
  title: 'Apparence',
  subtitle: 'Apparence desc...',
},
{
  title: 'Network',
  subtitle: 'Network desc...',
}]
const selected = ref(new Set())
</script>

<template>
  <AList
    v-model="selected"
    :items="items"
    multi
    class="[--a-list-gap:0.25rem]"
  >
    <template #item="{ item, itemIndex }">
      <ATypography
        :title="[item.title, 'text-red']"
        :subtitle="item.subtitle"
      />
      <div v-if="selected.has(itemIndex)">I want to put collapsed content here, but this slot is not displayed ! Title isn't red.</div>
    </template>

    <template #append="{ itemIndex }">
      <div
        i-fa-chevron-right
        class="transition-transform text-gray hover:bg-opacity-0"
        :class="selected.has(itemIndex) && 'rotate-90'"
      />
    </template>
  </AList>
</template>

Issue Analytics

  • State:closed
  • Created 10 months ago
  • Comments:7 (7 by maintainers)

github_iconTop GitHub Comments

1reaction
ManUtopiKcommented, Dec 1, 2022

This ACollapse component has nothing to do with UI. You can use it multiple way. I’m not sure what you mean by decouple it from actual UI.

Here an example without UI.

<ACollapse>
  <template #trigger="{ value, toggle }">
    <div @click="toggle()">
      Toggle collapse
    </div>
  </template>

  <div>
    Collapsed content...
  </div>
</ACollapse>

Result : Peek 01-12-2022 00-15

With ABtn :

<ACollapse>
  <template #trigger="{ value, toggle }">
    <ABtn color="success" @click="toggle()">
      Toggle collapse
    </ABtn>
  </template>

  <div>
    Collapsed content...
  </div>
</ACollapse>

Peek 01-12-2022 00-54

With AAvatar :

<ACollapse>
  <template #trigger="{ value, toggle }">
    <AAvatar
      content="A"
      @click="toggle()"
    />
  </template>

  <div>
    Collapsed content...
  </div>
</ACollapse>

Peek 01-12-2022 00-57

And how I use it in my app :

Peek 01-12-2022 01-07

0reactions
ManUtopiKcommented, Dec 1, 2022

That’s it ! Ok, I close this issue even if in its current state it is not possible to do collapsing with AList

Read more comments on GitHub >

github_iconTop Results From Across the Web

How can I target each item in a list with collapsible items?
I have a list of div elements, each containing a header and a body section. Only the header of each item is initially...
Read more >
How to Create a Collapsible List of Items in ... - HTML Goodies
In this article, you will see how to use a little bit of standard JavaScript to hide and display items in a list....
Read more >
Bootstrap Collapse - W3Schools
The .collapse class indicates a collapsible element (a <div> in our example); this is the content that will be shown or hidden with...
Read more >
Expand & collapse groups of items in a list.
My ticket this week: Show documents with the same file name as a version stack. Tech used: Javascript, React, lodash. Some background.
Read more >
Nested list collapsing script - How To Create
This example has been collapsed using the script. It is set to auto collapse child branches when sibling branches are expanded. Like the...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found