-
-
Notifications
You must be signed in to change notification settings - Fork 18
/
BaseCard.vue
85 lines (77 loc) · 1.65 KB
/
BaseCard.vue
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
<script setup lang="ts">
const props = withDefaults(
defineProps<{
/**
* Adds a flat or a on hover shadow to the card.
*/
shadow?: 'flat' | 'hover'
/**
* The color of the card.
*
* @default 'default'
*/
color?:
| 'default'
| 'default-contrast'
| 'muted'
| 'muted-contrast'
| 'dark'
| 'black'
| 'primary'
| 'info'
| 'success'
| 'warning'
| 'danger'
| 'none'
/**
* The radius of the card.
*
* @since 2.0.0
* @default 'sm'
*/
rounded?: 'none' | 'sm' | 'md' | 'lg'
}>(),
{
rounded: undefined,
shadow: undefined,
color: undefined,
},
)
const color = useNuiDefaultProperty(props, 'BaseCard', 'color')
const rounded = useNuiDefaultProperty(props, 'BaseCard', 'rounded')
const radiuses = {
none: '',
sm: 'nui-card-rounded-sm',
md: 'nui-card-rounded-md',
lg: 'nui-card-rounded-lg',
}
const colors = {
default: 'nui-card-default',
'default-contrast': 'nui-card-default-contrast',
muted: 'nui-card-muted',
'muted-contrast': 'nui-card-muted-contrast',
dark: 'nui-card-dark',
black: 'nui-card-black',
primary: 'nui-card-primary',
info: 'nui-card-info',
success: 'nui-card-success',
warning: 'nui-card-warning',
danger: 'nui-card-danger',
none: '',
}
const shadows = {
flat: 'nui-card-shadow',
hover: 'nui-card-shadow-hover',
}
const classes = computed(() => [
'nui-card',
rounded.value && radiuses[rounded.value],
color.value && colors[color.value],
props.shadow && shadows[props.shadow],
])
</script>
<template>
<div :class="classes">
<slot></slot>
</div>
</template>