ano-ui
Version:
<p align="center"> <img src="https://github.com/ano-ui/ano-ui/raw/main/public/logo.svg" style="width:100px;" /> <h1 align="center">Ano-UI (WIP)</h1> <p align="center">An UniApp UI components with UnoCSS.</p> </p> <p align="center"> <a href="https://www.np
36 lines (28 loc) • 863 B
text/typescript
import type { SetupContext } from 'vue'
import { computed, inject } from 'vue'
import { cellGroupKey } from '../tokens'
import { CLICK_EVENT } from '../constants'
import type { CellEmits, CellProps } from './cell'
// @unocss-include
export function useCell(props: CellProps, emit: SetupContext<CellEmits>['emit']) {
const cellGroup = inject(cellGroupKey, undefined)
const arrow = computed(() => cellGroup?.arrow || props.arrow)
const clickable = computed(() => cellGroup?.clickable || props.clickable)
const classes = computed(() => {
const _classes: string[] = []
// #ifdef H5
if (arrow.value || clickable.value)
_classes.push('a-active-h5')
// #endif
return _classes
})
function clickHandler(evt: MouseEvent) {
emit(CLICK_EVENT, evt)
}
return {
arrow,
clickable,
classes,
clickHandler,
}
}