Coder Social home page Coder Social logo

Simple actions menu with AList about anu HOT 5 CLOSED

jd-solanki avatar jd-solanki commented on July 19, 2024
Simple actions menu with AList

from anu.

Comments (5)

ManUtopiK avatar ManUtopiK commented on July 19, 2024 1

Awesome ! You made a lot of works πŸš€
It simplify a lot the process.
So, I've been rewriting my simple menu with this :

<script lang="ts" setup>
function onSend() {
  console.log('Sended')
}
function onEdit() {
  console.log('Edited')
}
function onDelete() {
  console.log('Deleted')
}
</script>

<template>
  <ABtn>
    <AMenu>
      <AList>
        <AListItem title="Send" /><!-- No @click event : No pointer cursor and item highlight = good -->
        <AListItem title="Send" @click="onSend" /><!-- No pointer cursor and item highlight = bad -->
        <AListItem title="Edit" class="states:10 cursor-pointer" @click="onEdit" /><!-- Looks good :) -->
        <AListItem title="Delete" value="1" @click="onDelete" /><!-- Looks good :) -->
      </AList>
    </AMenu>

    Open Menu
  </ABtn>
</template>

I can get it worked, but we must add custom class or an arbitrary value attribute to display the list item with the cursor pointer and to be highlighted on hover. It's not very intuitive...

from anu.

jd-solanki avatar jd-solanki commented on July 19, 2024

With the latest changes in this commit you can now use below code snippet to achieve the desired result:

<script lang="ts" setup>
const items = [
  { title: 'Send' },
  { title: 'Edit' },
  { title: 'Delete' },
]

const triggerAction = (index: number) => {
  alert(`You Clicked: "${items[index].title}"`)
}
</script>

<template>
  <div class="cards-demo-container">
    <ABtn
      variant="text"
      class="!text-gray"
      icon="i-bx-home"
      icon-only
    >
      <AMenu
        trigger="hover"
        placement="bottom-end"
      >
        <AList
          :model-value="null"
          :items="items"
          class="[--a-list-gap:0.25rem]"
          @update:modelValue="triggerAction"
        />
      </AMenu>
    </ABtn>
  </div>
</template>

from anu.

jd-solanki avatar jd-solanki commented on July 19, 2024

@ManUtopiK I hope this is resolved now. Can we close this?

from anu.

jd-solanki avatar jd-solanki commented on July 19, 2024

Hey, we merged the changes. I hope this will resolve the issue now.

from anu.

ManUtopiK avatar ManUtopiK commented on July 19, 2024

Yes, everything seems good to me now !

This works as expected:

<AMenu>
  <AList>
    <AListItem title="Send" /><!-- No @click event : No pointer cursor and item highlight = good -->
    <AListItem title="Send" @click="onSend" /><!-- Good now :) -->
  </AList>
</AMenu>

from anu.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    πŸ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. πŸ“ŠπŸ“ˆπŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❀️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.