Skip to content

Commit

Permalink
feat(component): lab component ChipSet
Browse files Browse the repository at this point in the history
  • Loading branch information
bre97-web committed Mar 9, 2024
1 parent 3707e86 commit 79e4c49
Showing 1 changed file with 32 additions and 0 deletions.
32 changes: 32 additions & 0 deletions packages/vue-components/components/labs/chip-set/ChipSet.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
<template>
<div data-am-chip-set v-bind="$attrs" ref="setRef" @keydown="handleKeydown">
<slot></slot>
</div>
</template>

<script setup lang="ts">
import { computed, ref } from 'vue';
const setRef = ref<HTMLElement | null>(null)
const chips = computed(() => {
if(setRef.value === null || setRef.value?.childElementCount === 0) return []
const children = [...setRef.value.children].filter(e => e.getAttribute('data-am-chip') || e.getAttribute('data-is-chip'))
return children
})
const handleKeydown = (e: KeyboardEvent) => {
const isLeft = e.key === 'ArrowLeft';
const isRight = e.key === 'ArrowRight';
const isHome = e.key === 'Home';
const isEnd = e.key === 'End';
if (!isLeft && !isRight && !isHome && !isEnd) {
return;
}
}
</script>

<style scoped>
</style>

0 comments on commit 79e4c49

Please sign in to comment.