Skip to content

Commit

Permalink
fix(BaseList): render ul/ol and li tags
Browse files Browse the repository at this point in the history
  • Loading branch information
stafyniaksacha committed Sep 15, 2023
1 parent 712da3c commit 44c3876
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 14 deletions.
25 changes: 13 additions & 12 deletions components/base/BaseList.vue
Original file line number Diff line number Diff line change
@@ -1,12 +1,4 @@
<script lang="ts">
// const slots = useSlots()
// const hasMedia = computed(() => {
// return slots.default?.().some((vnode) => {
// console.log(vnode)
// return typeof vnode.type !== 'string'
// })
// })
export default defineComponent({
props: {
/**
Expand All @@ -16,17 +8,26 @@ export default defineComponent({
type: Boolean,
default: false,
},
/**
* Force the list to be media.
*/
media: {
type: Boolean,
default: undefined,
},
},
setup(props, { slots }) {
return () => {
const ordered = props.ordered ? 'nui-list-ol' : 'nui-list-ul'
const children = slots.default?.()
const hasMedia = children?.some((vnode) => {
return typeof vnode.type !== 'string'
})
const hasMedia =
props.media ??
children?.some((vnode) => {
return typeof vnode.type !== 'string'
})
return h(
'div',
props.ordered ? 'ol' : 'ul',
{
class: [
'nui-list',
Expand Down
4 changes: 2 additions & 2 deletions components/base/BaseListItem.vue
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ const hasSubtitle = computed(() => {
</script>

<template>
<div class="nui-list-item">
<li class="nui-list-item">
<slot />

<div v-if="hasTitle || hasSubtitle">
Expand All @@ -45,5 +45,5 @@ const hasSubtitle = computed(() => {
<div class="ms-auto">
<slot name="end" />
</div>
</div>
</li>
</template>

0 comments on commit 44c3876

Please sign in to comment.